Assuming you have RVM and Bundler already installed, cd into the project directory and run:
$ bundle
$ middleman s
This runs a web server. Makes changes and then preview your project at http://localhost:4567.
- This framework uses 2 spaces for code indenting, no tabs
- It also uses HAML for templating
- JS libraries included are Modernizr, Tire JS, Underscore
- A basic Fontello font and styles are included
- Auto/live-reload is activated by default, so no page refreshing needed!
Custom settings added for this framework in config.rb are...
set :use_typekit, true
set :use_jquery, true
...to toggle use of Typekit and jQuery respectively. If you choose not to use jQuery, Tire JS is included for easy DOM selectors with minimum overhead.
======================================
To build your project, run
$ middleman build
Which compiles your templates into the build directory using the settings in config.rb. The build directory is ignored in .gitignore.
All assets minifed by default. For a different build config, please see the Middleman documentation.
======================================
- All site assets (css, javascript, images, fonts) lie within the
/assetsfolder - Use always use the BEM notation for CSS classes and module structure. Use classes generously and pragmatically
- You should be able to tell exactly what element you are affecting from CSS and front-end only, without looking at the source!
- Use the SMACSS notation for state e.g.
is-hidden,is-activeoris-current - Always prefix JS hooks or injected classes with
js-e.g.id="js-nav"orclass="js-added-class" - Only use IDs for JS identifiers, nothing else
- We are building modules, not pages
- All Sass configuration is located in
assets/css/config - Global variables are defined in
config/varsand separated into (major) breakpointsbreakpoints.sass, colourscolours.sass, typographytypography.sassand unitsunits.sass - Add custom mixins to
mixins.sass. Make use of existing and Compass mixins if possible - Add all
z-indexvalues discreetly inz-index.sassto easily see stacking context (avoids guessing e.g.z-index: 99999) - Place module-specific variables at the top of each object partial, to easily view them in context
- This project uses Jake Archibald's Sass-IE Framework framework.
- Always create media queries at module-level using the
respond-min,respond-maxorrespond-min-maxmixins - This means IE8 will recieve a perfect fallback stylesheet stripping out media queries and including styles up to the pixel value defined in
old-ie.css.sass - Define all major breakpoints in
breakpoints.sassusing unitless pixel values. These are then converted into em-based media queries using therespondmixins - Define minor breakpoints at module level, in the relevant object partial (again using unitless pixel values)
- Defined in
units.sass - Try to use the base unit
$unitinunits.sassas a reference for all arbitrary measurements - Pre-defined variables are given for the baseline unit
$unit--baseline, default gutters$unit--gutteras well as double and half units - Use the
em()function to convert units intoemse.g.margin-top: em($unit * 4) - Making all measures in
emsaround the base unit means we can easily change sizing/spacing globally
- All Sass partials in the
/base,/generic, and/objectsfolders are automatically imported using Sass globbing. This occurs in alphabetical order - Base elements (default selectors) are separated into category partials in
/base - Generic elements and helpers should be defined in
/generic - Objects (or modules) are defined in
/objectsusing the module name as the filename. Every selector within an object partial should be prefixed with the module name (as-per BEM) - Always check if you can re-use a module (and/or use a modifier) before creating a new one
- Use
helpers.sassfor all helper classes or generic@extendsand shared properties - Make use of helper classes to quickly prototype by adding classes to markup. Use discrection whether to keep these classes, or
@extenda selector
- Base grid configuration given in
grid.sass - Use
.gridas a wrapper and.grid__unitfor each grid cell - Then use a modier to define grid breakpoints and gutters (if needed)
- Always nest moodules inside grid units so you can move a module into a new grid without it breaking!
- Define grids on a per-module basis but consider abstraction and re-use first
- Read more about this
- Be default, all typographical elements are reset to avoid over-writing default text styling over and over
- Use the
.copyclass as a wrapper on a block of copy text which requires regular heading, list, paragraph etc. styling - Read more about this
- A double-stranded heading hierachy is also used. Make a
h4look like ah2using the.as-h2class
- Add all browser quirks / fixes in context to the element you're fixing, not in a separate stylesheet
- Always test for browser capability first using the Modernizr-added
<html>classes. Are we fixing IE8, or browsers that don't support RGBA? - Create all IE fixes using conditional
<html>classes and place them within the relavent object partial - Use the
old-iemixin to hide styles from all browsers that aren't IE8 and lower
- Make use of
TODO.mdto document all technical debt - Use
generic/shame.cssas a place to store sub-optimal CSS that was rushed, needs refactoring or requires further thought