futureproof styling in drupal 8
play

Futureproof styling in Drupal (8) by Tams Hajas more than 200 - PowerPoint PPT Presentation

Futureproof styling in Drupal (8) by Tams Hajas more than 200 .css files in Drupal 8 (currently) There is NO One Right Way! There is NO One Right Way! Tams Hajas Drupal Consultant Integral Vision Kft You always work in


  1. Futureproof styling 
 in Drupal (8) by Tamás Hajas

  2. more than 
 200 
 .css files in Drupal 8 (currently)

  3. There is NO One Right Way!

  4. There is NO One Right Way!

  5. Tamás Hajas Drupal Consultant Integral Vision Kft

  6. You always work 
 in a Team

  7. Team » Communication

  8. Coding Standards

  9. Drupal CSS Coding Standards https://www.drupal.org/ node/1886770

  10. Harry Roberts CSS Guidelines http://cssguidelin.es

  11. Hugo Giraudel Sass Guidelines http://sass-guidelin.es

  12. CSS formatting guidelines CSS architecture (for Drupal 8) CSS file organization (for Drupal 8)

  13. CSS formatting guidelines CSS architecture (for Drupal 8) CSS file organization (for Drupal 8)

  14. Comment 
 your code! https://www.flickr.com/photos/rushen/16071372313

  15. Team » Communication

  16. “code should be 
 self-documenting”

  17. /** * Grid container * Must only contain '.cell' children. */ .grid { height: 100%; font-size: 0; white-space: nowrap; }

  18. /** * Grid container * Must only contain '.cell' children. */ .grid { height: 100%; /* Remove inter-cell whitespace */ font-size: 0; /* Prevent inline-block cells wrapping */ white-space: nowrap; }

  19. /** * Grid container * Must only contain '.cell' children. * 1. Remove inter cell whitespace. * 2. Prevent inline-block cells wrapping */ .grid { height: 100%; font-size: 0; /* 1 */ white-space: nowrap; /* 2 */ }

  20. Source: Sevens’s button.css

  21. “Don’t make 
 me think!” https://www.flickr.com/photos/mugley/2594318333

  22. CSS formatting guidelines CSS architecture (for Drupal 8) CSS file organization (for Drupal 8)

  23. Keep specificity low! https://www.flickr.com/photos/freetheimage/14741164059

  24. Component

  25. Object OOCSS Module SMACSS Component Block BEM Atom, Molecule… Atomic Design

  26. BEM

  27. Block Element Modifier

  28. <div class="flower__bed"> <div class="flower"> <div class="flower__petals"> <div class="flower__face"></div> </div> <div class="flower__stem"> <div class="flower__leaves"></div> </div> </div> </div> Block John Albin: Managing complex projects with design components

  29. <div class="flower__bed"> <div class="flower"> <div class="flower__petals"> <div class="flower__face"></div> </div> <div class="flower__stem"> <div class="flower__leaves"></div> </div> </div> </div> Element John Albin: Managing complex projects with design components

  30. <div class="flower__bed"> <div class="flower flower--tulip"> <div class="flower__petals"> <div class="flower__face"></div> </div> <div class="flower__stem"> <div class="flower__leaves"></div> </div> </div> </div> Modifier John Albin: Managing complex projects with design components

  31. „Class names should communicate useful information to developers.” 
 – Nicolas Gallagher About HTML Semantics and Front-End Architecture

  32. Progress bar component Proposal: A Style Guide for Seven

  33. Progress bar component <div class="progress progress--small"> <label class="label label--small">Uploading sunset.jpg</label> <div class="progress__track"> <div class=“progress__bar js-progress-percent“ 
 style="width: 29%"></div> </div> <div class="progress__description"> <div class="layout-pull">Uploaded 221 of 762KB</div> <strong class="layout-push">29%</strong> </div> <a class="progress__cancel" href="#" title="cancel"> <span class="visually-hidden">cancel</span> </a> </div> CSS architecture (for Drupal 8)

  34. Progress bar component /** * Progress Bar component */ .progress {} .progress__track {} .progress__bar {} .progress__description {} .progress__cancel {} .progress__cancel:focus, .progress__cancel:hover {} /** * Progress Bar small variant */ .progress--small .progress__track {} .progress--small .progress__bar {} .progress--small .progress__cancel {} CSS architecture (for Drupal 8)

  35. Pager in Bartik Source: Bartik theme

  36. Pager in Bartik Source: Bartik’s pager.css

  37. CSS formatting guidelines CSS architecture (for Drupal 8) CSS file organization (for Drupal 8)

  38. SMACSS See purecss.io for kind of an implementation

  39. SMACSS structure • Base ul { list-style-type: none; padding: 0; margin: 0; }

  40. SMACSS structure • Base • Layout .layout-content {} .col-md-6 {}

  41. SMACSS structure • Base • Layout • Module

  42. SMACSS structure • Base • Layout • Module • State

  43. <div class="flower is-pollinating"> State John Albin: Managing complex projects with design components

  44. .flover:hover {} State John Albin: Managing complex projects with design components

  45. @media "print" { .flover {} } State John Albin: Managing complex projects with design components

  46. SMACSS structure • Base • Layout • Module • State .install-page { • Theme background-color: #1275b2; … }

  47. SMACSS-like structure • Base • Layout • Module • State • Theme

  48. SMACSS-like structure • Base • Layout • Component Module • State • Theme

  49. • Base • Layout • Component = Block • Element • Modifier • State • Theme John Albin: Managing complex projects with design components

  50. CSS files for Drupal 8 themes

  51. CSS files for Drupal 8 themes • base.css • layout.css • components.css 
 (components, -state, -theme)

  52. CSS files for Drupal 8 themes base components • elements.css • buttons.css • print.css • tabs.css • typography.css • … layout theme • layout.css • install-page.css • node-add.css • maintenance 
 -page.css Source: Drupal 8 Seven theme Bartik refactor meta issue: https://www.drupal.org/node/1342054

  53. CSS files for Drupal 8 modules

  54. CSS files for Drupal 8 modules • module_name.module.css 
 (layout, component, state) • module_name.theme.css • module_name.admin.css 
 (layout, component, state) • module_name.admin.theme.css • module_name.base.css Modules refactor issue: https://www.drupal.org/node/1995272

  55. mysubtheme.info.yml # Stylesheets override stylesheets-override: - system.theme.css # Remove not used stylesheets stylesheets-remove: - node.module.css Change record: https://drupal.org/node/1876600

  56. CSS formatting guidelines CSS file organization (for Drupal 8) CSS architecture (for Drupal 8) [META] Architect our CSS – http://drupal.org/node/1921610

  57. There is NO One Right Way!

  58. Tamás Hajas Drupal consultant Integral Vision Ltd integralvision.hu about.me/tamashajas

Recommend


More recommend