Skip to content

dl988/nikita-kickstarter

 
 

Repository files navigation

nikita.kickstarter

This is our toolbelt how to start a new project from scratch.

Latest Release: GitHub version

If you're interested in HTML patterns, code snippets and best practices, try nikita.html. If you want to write efficient and scalable (S)CSS-code for big websites, try nikita.css.

Project-Setup

Grunt depends on node.js, SCSS-Lint depends on Ruby. Some of the Grunt plugins depend on command line tools to be installed on your (build) system.

Requirements

These are the minimum requirements for the project setup:

If you want to use the browser-auto-refresh-feature, get LiveReload.js and install it to the root-folder of localhost.

Getting started

Open your preferred command line tool and choose your project directory.

Either use ./setup-dev-env.sh. This will start a shell script to check requirements, then runs npm install and bower install automatically to install Grunt and Grunt plugins required for the build script plus Bower and Bower packages.

Or use npm install and bower install if your are on Windows (you have to check the requirements manually). This will install Grunt and Grunt plugins required for the build script plus Bower and Bower packages.

  1. grunt or grunt build – start build script
  2. http://localhost:9002/ or http://0.0.0.0:9002/ – watch your build-directory in the browser (livereload is running on port 9002)
  3. grunt dist – start distribution build script

If you want to specify a different port, you can start the script with the --port option: grunt --port=9010 will launch the webserver on http://0.0.0.0:9010/

Grunt-Devtools

If you dont't like the command line you can use an alternative called grunt-devtools for the Chrome browser to start the grunt tasks.

  1. Download the Grunt Devtools extension for Chrome Developer Tools from the Chrome Web Store.
  2. Global install via npm install -g grunt-devtools.
  3. Run grunt-devtools in a directory with a Gruntfile.
  4. Open Chrome Devtools and find the Grunt tab. Your grunt tasks should now be accessible from within Chrome.

Grunt-Notifications

You don't like to stare permanently on your console? So wouldn’t it be great if your system could notify you when your fresh build is ready to consume or when anything bad happened? Meet grunt-notify, an automatic desktop notification service for Grunt using Growl for OS X or Windows, Mountain Lion and Mavericks Notification Center and Notify-Send. Just install this plugin via npm and load it in your Gruntfile.

Grunt-Plugins used

Bower-Packages used

Project structure

The kickstart-setup provides the three main folders source/, build/ and dist/. All source-files will be put to the source-folder like templates, fonts, images, js- and sass-files. These files will be processed by several grunt tasks – e.g. grunt-sass: sass -> css – and then stored in the build-folder. From there you can view the generated html-files in the browser. The dist-folder is built up like the build-folder. The main difference between build/ and dist/ is, that dist/ has combined and minified css/js files, no unnecessary files or code-comments. The build-folder is for debugging your files, the dist-folder should be used for production.

$ tree -d -I node_modules
.
├── bower_components
├── build
│   ├── ajax-content
│   ├── bower_components
│   ├── css
│   ├── fonts
│   ├── img
│   │   ├── appicons
│   │   └── bgs
│   └── js
│       └── modernizr
├── dist
│   ├── ajax-content
│   ├── bower_components
│   ├── css
│   ├── fonts
│   ├── img
│   │   ├── appicons
│   │   └── bgs
│   └── js
│       └── modernizr
├── source
│   ├── ajax-content
│   ├── assemble
│   │   ├── data
│   │   ├── helpers
│   │   ├── layouts
│   │   ├── pages
│   │   └── partials
│   ├── fonts
│   ├── img
│   │   ├── appicons
│   │   ├── bgs
│   │   ├── dev
│   │   ├── icons
│   │   └── temp
│   ├── js
│   │   └── modernizr
│   └── sass
│       ├── blocks
│       ├── extends
│       ├── mixins
│       └── variables
└── tmp
    ├── svgcss
    ├── svg-bg-extends
    └── svgmin
        └── bgs

HTML

For the HTML structure, please have a look at nikita.html. This sub project describes the HTML coding standards and conventions.

CSS

For the CSS structure, please have a look at nikita.css. This sub project describes the CSS coding standards and conventions.

Javascript

For the JS structure, please have a look at nikita.js. This sub project describes the JS coding standards and conventions.

The page will contain two parts of javascript.

The first part is in assemble/layouts/lyt-default.hbs at the beginning:

<script src="js/modernizr.js"></script>

It ensures that the html5shiv is loaded and modernizr is ready. The modernizr file is generated automagically with all modernizr features, which are used in your sass/**/*.sass and js/**/*.js files. The js/modernizr folder contains custom tests for modernizr. Those will be added to the modernizr.js, too.

The second part is at the end of the file (before the closing </body> tag:

<script data-main="app" src="js/main.js"></script>

The data-main attribute ensures, that the app.js will be loaded (as soon as main.js is ready). The js/main.js file is generated by using the project specific js/_requireconfig.js and the generic requirejs.js from bower components. For dist mode the main.js file contains everything, which is required or included in the js/_requireconfig.js.

Icon-Workflow

There're two possible ways to use icons.

SVG-Sprite

You'd like to edit your icons with CSS, e.g. to change the fill-color or you have one and the same icon in different colors? Then this is your choice.

  1. Just put your SVG-icons into source/img/icons.
  2. All icons will be processed with the svgmin-task and put into the tmp/svgmin/icons folder.
  3. Afterwards the svgstore-task uses these icons to put together an icon-sprite.svg which will be copied to the img/icons folder. It must be injected with ajax directly after the opening <body> element at the top of the document (have a look at the file lyt-default.hbs in the layouts folder).
  4. To include a SVG-icon use <svg class="your-class-name"><use xlink:href="#filename" /></svg> in your .hbs-files. Make sure you use a class name on the SVG to size it.
  5. Now you can use .your-class-name { fill: #f30; } to color your icon.

For further infos read the article Icon System with SVG sprites by Chris Coyier.

Data-URIs

If you have to include your icon as a background-image, e.g. because you can't simply add a svg element, then you should use this method.

  1. Just put your SVG-icons into source/img/bgs.
  2. All icons will be processed with the svgmin-task and put into the tmp/svgmin/bgs folder.
  3. Afterwards the svgcss-task uses these icons to produce SCSS-files (all icons are included as data-URIs in the form of SASS-placeholders), which will be put into tmp/svgcss folder.
  4. These SCSS-files will now be processed by the string-replace-task to get different placeholder-extends. They are saved into tmp/svg-bg-extends folder.
  5. Now you can include your icons by using the _svg-background.scss mixin. Just type @include svg-background(name-of-your-icon);.

Questions?

If you're asking yourself »Why not …?« have a look at my WHYNOT.md file. There we might answer some common questions. :)

License

nikita.kickstarter is licensed under CC0: Public Domain Dedication, please see NIKITA-LICENSE.md for further information.

About

The Project-Setup for nikita.kit

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Handlebars 34.5%
  • CSS 33.1%
  • JavaScript 31.5%
  • Other 0.9%