In this presentation I share my best practices working with ZURB Foundation. Keep your projects clean and organized and make your code more maintainable and readable.
2. Amostlycssframework
· jQuery + JS: required by some components
· Sass: CSS Preprocessor
· Everything On by Default
2 — Copyright 2015-2016, James Stone, All Rights Reserved.
4. JavaScript
· Individual Imports Per Component
· Import jQuery First
· Activate FastClick.js for better mobile ux
· Use DEFER Attribute
4 — Copyright 2015-2016, James Stone, All Rights Reserved.
5. UseSass
· Allows you to quickly "theme"
· Easily upgradeable via Bower
· Extend ZURB Components with @mixins
5 — Copyright 2015-2016, James Stone, All Rights Reserved.
7. PresentationalClasses
· always use .small-12 instead of .medium-12
or .large-12
· always start with the medium grid (unless
mobile first)
· then refine small + large as needed
· if radically different use visibility classes
7 — Copyright 2015-2016, James Stone, All Rights Reserved.
9. wordorder
class=" small-8 medium-9 large-10 columns
small-centered "
grid, columns, grid modifiers
small to large
offset, centered, push/pull
9 — Copyright 2015-2016, James Stone, All Rights Reserved.
14. CSS
· Use OOCSS Principals when it makes sense
· Follow ZURB Foundation Naming Conventions
(BEM is out)
· Great Reference: SMACSS Book
If you want to go full BEM – just use the sass
mixins
14 — Copyright 2015-2016, James Stone, All Rights Reserved.
15. SassWorkflow
· Grunt
· Libsass (no Sass 3.3-3.4 features)
· Sourcemaps or Inline Comments
· Autoprefixer (config for sourcemaps)
· Development vs. Production
15 — Copyright 2015-2016, James Stone, All Rights Reserved.
16. SassOrganization-app.scss
1. Brand Variables
2. ZURB Foundation Overrides
3. Foundation Imports
4. Components
5. Modules (Views, Templates)
6. Sitewide
7. Etc.
8. Live Prototyping
16 — Copyright 2015-2016, James Stone, All Rights Reserved.
19. _settings.scss
· not to be confused with the foundation/
foundation/_settings.scss
· no dead sass vars
· these can change from time-to-time, easy
upgrade
· can be thought of as the theme, skin, look of site
· be careful, changes everything sitewide
19 — Copyright 2015-2016, James Stone, All Rights Reserved.
20. foundationimports
· just pull from bower_components/
_foundation.scss
· turn on / off what you need for performance
· to leave @mixins set:
$include-html-classes or include-html-n-classes
· in theory they all work
20 — Copyright 2015-2016, James Stone, All Rights Reserved.
21. quicktip
for rapid prototyping leave // @import
"foundation"; and or // $include-html-classes:
true; at the top and commented out.
Then just uncomment when prototyping.
Recomment and adjust when done.
21 — Copyright 2015-2016, James Stone, All Rights Reserved.
22. Components blocks of html + css used in more
than one page
Modules everything that is page sepcific
Sitewide single elements / selectors on more
than one page
Shame/Drupalisms/etc. stuff that doesn't fit
appropriately named
Prototype work fast in app.scss but find it a home
fast
22 — Copyright 2015-2016, James Stone, All Rights Reserved.
28. sassisprettysmart
ul.my-component { }
ul.my-component li { }
ul.my-component li a.button { }
ul.my-component li a.button.disabled { }
makesrefactoringclassnamesfastandeasy
28 — Copyright 2015-2016, James Stone, All Rights Reserved.
29. my-component, another-component a {
& small {
}
}
becomes
my-component small { }
another-component a small { }
watch out for
my-component {
& p, & a { /* each selector needs an & */ }
}
29 — Copyright 2015-2016, James Stone, All Rights Reserved.
30. modules
· same structure, same process, only the scope is
different
· based on project structure: views, templates,
pages, etc.
/* component */
.everything-else
ul.my-component>li>a
.everything-else
/* module, wrap entire page with a div */
.view-index-find>
.everything-else
30 — Copyright 2015-2016, James Stone, All Rights Reserved.
31. namingconventions
· make it easy to find, have a direct 1-to-1
correlation
· keep the list alphabetical
scss/view/index/_find.scss
scss/view/partial/auth/_header.scss
scss/page/about-us/_mission.scss
scss/template/blog/_article.scss
31 — Copyright 2015-2016, James Stone, All Rights Reserved.