2016-08-22 10:30:46 -04:00
Locomotive's Front-end Boilerplate
==================================
2014-03-01 09:33:24 -08:00
2016-08-22 10:30:46 -04:00
Front-end boilerplate for projects by [Locomotive][locomtl].
2015-02-15 15:44:11 -05:00
2015-12-07 10:35:27 -05:00
## Requirements
2016-08-22 10:30:46 -04:00
| Prerequisite | How to check | How to install |
| --------------- | ------------- | -------------------------------- |
| Node.js 4.1.1 | `node -v` | [nodejs.org ](https://nodejs.org ) |
| Grunt >= 0.1.13 | `grunt -v` | `npm install -g grunt-cli` |
2015-03-05 14:57:47 -05:00
2015-12-07 10:35:27 -05:00
## Getting started
2015-03-13 12:47:44 -04:00
2016-08-22 10:30:46 -04:00
1. **Get the latest node modules **
1. `npm install -g npm-check-updates`
2. `npm-check-updates -u`
3. `npm install`
2015-03-13 12:47:44 -04:00
2016-08-22 10:30:46 -04:00
2. **Run grunt and start coding **
- `grunt`
2015-03-05 14:57:47 -05:00
2015-12-07 10:35:27 -05:00
### Grunt
2016-08-22 10:30:46 -04:00
2015-04-20 09:53:11 -04:00
Each Grunt task has it's own file in the `grunt_tasks` folder.
2015-12-07 10:35:27 -05:00
### BrowserSync
2016-08-22 10:30:46 -04:00
2015-04-20 09:53:11 -04:00
BrowserSync will automatically inject, refresh and sync all your browsers.
Run `grunt sync`
2015-12-07 10:35:27 -05:00
## CSS
2015-02-15 15:44:11 -05:00
2016-08-22 10:30:46 -04:00
- We use [Sass ](http://sass-lang.com ) for our CSS Preprocessor
- [itcss ](http://itcss.io ) CSS architecture
- More Minimal BEM like CSS Syntax: `.block_element -modifier`
- [More Transparent UI Code with Namespaces ](http://csswizardry.com/2015/03/more-transparent-ui-code-with-namespaces )
2015-12-07 10:35:27 -05:00
### Sass import order
2015-02-15 15:44:11 -05:00
2016-08-22 10:30:46 -04:00
* **Settings: ** Global variables, site-wide settings, config switches, etc.
* **Tools: ** Site-wide mixins and functions.
* **Generic: ** Low-specificity, far-reaching rulesets (e.g. resets).
* **Base: ** Unclassed HTML elements (e.g. `a {}` , `blockquote {}` , `address {}` ).
* **Objects: ** Objects, abstractions, and design patterns (e.g. `.o-media {}` ).
* **Components: ** Discrete, complete chunks of UI (e.g. `.c-carousel {}` ).
* **Trumps: ** High-specificity, very explicit selectors. Overrides and helper
2015-12-07 10:35:27 -05:00
classes (e.g. `.u-hidden {}` ).
2015-03-06 10:15:49 -05:00
### Grid
We are using a simple inline-block grid system.
2015-03-06 11:08:43 -05:00
**Usage**
2015-03-06 10:15:49 -05:00
2015-12-07 10:35:27 -05:00
Insert a `o-grid` block and add `o-grid_item` elements inside it.
2015-03-23 12:56:15 -04:00
No rows that contain floats, no twelve columns system; just the number of items you want, with the classes names you want, inside a single block.
2015-03-06 10:15:49 -05:00
2016-08-22 10:30:46 -04:00
- Include the grid mixins in your components classes.
- Create custom width grid items by including the `grid_item` mixin and adding the widths you need or just include the helpers mixins with fractions like names.
- Add media queries, on the helpers mixins or on your custom components to change the grid items widths, for your content, on different screen sizes.
2015-03-06 10:15:49 -05:00
2016-08-22 10:30:46 -04:00
*[Demo][demo-grid]*
2015-03-24 13:05:05 -04:00
### Form
We included some basic CSS styles and resets to the form elements so we can easily have custom style form elements that work on every browsers.
2016-08-22 10:30:46 -04:00
*[Demo][demo-form]*
2015-12-07 10:35:27 -05:00
## JavaScript
2016-08-22 10:30:46 -04:00
- We use HTML data attributes to init our JavaScript modules: `data-module`
- All DOM related JavaScript is hooked to `js-` prefixed HTML classes
- [jQuery ](https://jquery.com ) is globally included
[locomtl]: https://locomotive.ca
[demo-grid]: https://codepen.io/AntoineBoulanger/pen/EaLNxe
[demo-form]: https://codepen.io/AntoineBoulanger/pen/uBJmi