Advertisement
Advertisement

More Related Content

Advertisement

SMACSS Your Sass Up

  1. smacss your up
  2. @minamarkham
  3. “I need two demo sites” “And I need them in two days”
  4. CSS is easy.
  5. hard CSS is easy.
  6. CSS is bullshit.
  7. Modular CSS
  8. Focusing on creating healthy front-end modules instead of complete pages can help break complex page layouts into reusable solutions.” “ - Dave Rupert
  9. small pieces independent portable
  10. Navigation, Tabs, Tables, Accordions, Lists, Dropdowns Pagination, Buttons, Labels, Inputs, Breadcrumbs, etc.
  11. “Tiny Bootstraps”
  12. Module, Pattern, Component, etc.
  13. MVCSS, BEM, OOCSS, Suit, intuit.css
  14. SMACSS
  15. Scalable & Modular Architecture for CSS
  16. Framework
  17. categorization naming conventions depth of applicability
  18. Categorization
  19. base layout modules states themes
  20. Base CSS resets, default styles (ex. html, body, h1, ul, etc)
  21. Layout grid, major components ex. header, sidebar, nav
  22. header content footer
  23. sidebar header main content
  24. Modules content patterns (ex. search-box, navigation, content-box)
  25. navigation hero promo promo promo promo footer-text link-list
  26. States module in various states
  27. Themes module in various contexts
  28. jessicahische.is
  29. Naming Conventions
  30. Base h1, h2, p, a, etc.
  31. Layout .layout-*, .l-*
  32. Module .<name>
  33. Module .button
  34. Sub-module .<name>-<state>
  35. Sub-module .button-secondary
  36. State .is-*
  37. Theme .theme-*
  38. Theme .theme-*
  39. Depth of Applicability
  40. header#top-menu > nav > ul > li a + div > ul > li > ul li:hover > a {…}
  41. 10 generations!
  42. http://specificity.keegan.st/ , , , Specificity = 0,1,1,11
  43. header#top-menu > nav > ul > li a + div > ul > li > ul li:hover > a {…}
  44. header#top-menu > nav > ul > li a + div > ul > li > ul li:hover > a {…}
  45. .nav-subitem
  46. http://specificity.keegan.st/ , , , Specificity = 0,0,1,0
  47. .nav-subitem > a
  48. http://specificity.keegan.st/ , , , Specificity = 0,0,1,1
  49. child selectors class selectors naming conventions
  50. Recap
  51. categorize css rules meaningful names shallow selectors
  52. add some
  53. not SASS
  54. Namespacing
  55. the almighty ampersand
  56. .btn { &:hover {…} }
  57. .btn:hover {…}
  58. .btn { form & {…} }
  59. form .btn {…}
  60. &- or &_
  61. .btn { &-secondary {…} &_secondary {…} }
  62. .btn-secondary {…} .btn_secondary {…}
  63. nesting
  64. inception rule
  65. < 3 levels deep
  66. .btn { &-secondary { &-icon {…} } }
  67. .btn-secondary {…} .btn-secondary-icon {…}
  68. .btn {…} .btn-large {…} ! <div class=“btn btn-large”>
  69. @extend all the things!
  70. .btn {…} .btn-large {@extend .btn;} ! <div class=“btn-large”>
  71. %btn {…} .btn-large {@extend %btn;} ! <div class=“btn-large”>
  72. don’t @extend between modules
  73. File Structure
  74. @import
  75. 01. Utilities utilities/_index.scss @import 'global'; @import 'functions'; @import 'mixins'; @import 'helpers'; Variables, mixins, functions, etc. Basically anything that doesn’t output CSS by itself.
  76. utilities/_lib.scss @import "lib/susy"; @import "lib/font-­‐awesome"; @import "lib/pesticide"; Third-party libraries such as Susy, Font Awesome, Pesticide, and other plugins. 01. Utilities 02. Libraries
  77. base/_index.scss @import ‘normalize'; @import 'base'; CSS resets, Normalize, element styles 01. Utilities 02. Libraries 03. Base
  78. layout/_index.scss @import 'global'; @import 'functions'; @import 'mixins'; @import 'helpers'; Grid styles, major layout components (e.g. header, footer, sidebar, etc) 01. Utilities 02. Libraries 03. Base 04. Layout
  79. modules/_index.scss @import 'btn'; @import 'table'; @import 'nav'; Individual modules, such as buttons, navigation, menus, etc. 01. Utilities 02. Libraries 03. Base 04. Layout 05. Modules
  80. states/_index.scss @import 'states'; @import 'touch'; Describe states of being, ex: active, collapsed or hidden 01. Utilities 02. Libraries 03. Base 04. Layout 05. Modules 06. States
  81. 01. Utilities 02. Libraries 03. Base 04. Layout 05. Modules 06. States 07. @font-­‐face utilities/_fonts.scss Web fonts imports & declarations
  82. 01. Utilities 02. Libraries 03. Base 04. Layout 05. Modules 06. States 07. @font-­‐face 08. Print states/_print.scss Print styles
  83. !important
  84. shame.css
  85. _shame.scss
  86. 01. Utilities 02. Libraries 03. Base 04. Layout 05. Modules 06. States 07. @font-­‐face 08. Print 09. Shame _shame.scss because hacks happen
  87. small and readable
  88. mina.so/sassyStarter
  89. Theming
  90. @mixin theme($name) { @if $theme == $name { @content; } }
  91. $theme: rebeccapurple
  92. @include theme($rebeccapurple)
  93. refactor all the things!
  94. refactor all the things?
  95. Baby steps
  96. extract components create variables apply naming conventions nest and @extend
  97. mina.so/smacss-menu
  98. Before: 161 lines After: 97 lines
  99. Recap
  100. namespace with ampersands & @extends break modules into partials refactor in chunks
  101. Resources
  102. smacss.com
  103. sass-lang.com
  104. sassmeister.com
  105. mina.so/smacss thanks! @minamarkham
Advertisement