Within the sass
directory, create a file called _init.scss.
In _init.scss
we will (in this order):
- Import Bourbon (the mixin library) and Neat Helpers (Neat’s settings and functions)
- Set some overrides
- Import Neat itself
- Import fonts
You can view an example of a full _init.scss
file here, but I’ll go through some of the highlights.
1. Import bourbon.scss
and neat-helpers.scss
First we import all of Bourbon and Neat’s settings and functions, which are included in neat-helpers.scss
.
// Import variables and mixins to be used (Bourbon).
@import "lib/bourbon/bourbon";
@import "lib/neat/neat-helpers";
2. Create overrides
Now we’ll override some of Neat’s settings and create our breakpoints.
// Turn on Neat's visual grid for development.
$visual-grid: true;
$visual-grid-color: #EEEEEE;
// Set to false if you'd like to remove the responsiveness.
$responsive: true;
// Set total number of columns in the grid.
$grid-columns: 12;
// Set the max width of the page using the px to em function in Bourbon.
// The first value is the pixel value of the width and the second is the base font size of your theme.
$font-size: 16px;
$max-width-px: 2000px;
$max-width: em($max-width-px, $font-size);
// Define breakpoints.
// The last argument is the number of columns the grid will have for that screen size.
// We've kept them all equal here.
$mobile: new-breakpoint(min-width em(320px, $font-size) $grid-columns);
$narrow: new-breakpoint(min-width em(560px, $font-size) $grid-columns);
$wide: new-breakpoint(min-width em(851px, $font-size) $grid-columns);
$horizontal-bar-mode: new-breakpoint(min-width em(950px, $font-size) $grid-columns);
3. Import Neat
Now that we’ve completed our settings, we’ll import the entire Neat library and our overrides will apply and cause the grid to function the way we want it to.
// Import grid to be used (Bourbon Neat) now that we've set our overrides.
@import "lib/neat/neat";
4. Import fonts
I like to include my fonts in this file to be consistent about how I’m importing my libraries (e.g. the Font Awesome library, which I’ve included in sass/lib
). Some people might move this into a _typography.scss
file or something similar, perhaps residing in the base
directory. Do what feels right!
// Fonts -----------------------------------------------------------------------
// Noto Serif (headings)
@import url(http://fonts.googleapis.com/css?family=Noto+Serif:400,700);
// Open Sans (copytext)
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,700,400);
// Font Awesome (icons)
@import 'lib/font-awesome/font-awesome';