Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Futureproof styling in Drupal

Tamás Hajas
September 05, 2015

Futureproof styling in Drupal

Slides of my Drupal Dev Days Montpellier 2015 session.
http://montpellier2015.drupaldays.org/sessions/futureproof-styling-drupal

Tamás Hajas

September 05, 2015
Tweet

More Decks by Tamás Hajas

Other Decks in Technology

Transcript

  1. /** * Grid container * Must only contain '.cell' children.

    */ .grid { height: 100%; font-size: 0; white-space: nowrap; }
  2. /** * 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; }
  3. /** * 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 */ }
  4. BEM

  5. <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> John Albin: Managing complex projects with design components Block
  6. <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> John Albin: Managing complex projects with design components Element
  7. <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> John Albin: Managing complex projects with design components Modifier
  8. „Class names should communicate useful information to developers.” 
 –

    Nicolas Gallagher About HTML Semantics and Front-End Architecture
  9. CSS architecture (for Drupal 8) 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>
  10. CSS architecture (for Drupal 8) 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 {}
  11. @media "print" { .flover {} } John Albin: Managing complex

    projects with design components State
  12. SMACSS structure • Base • Layout • Module • State

    • Theme .install-page { background-color: #1275b2; … }
  13. • Base • Layout • Component = Block • Element

    • Modifier • State • Theme John Albin: Managing complex projects with design components
  14. base • elements.css • print.css • typography.css layout • layout.css

    • node-add.css components • buttons.css • tabs.css • … theme • install-page.css • maintenance
 -page.css CSS files for Drupal 8 themes Source: Drupal 8 Seven theme Bartik refactor meta issue: https://www.drupal.org/node/1342054
  15. • 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 CSS files for Drupal 8 modules Modules refactor issue: https://www.drupal.org/node/1995272
  16. # Stylesheets override # Remove not used stylesheets Change record:

    https://drupal.org/node/1876600 stylesheets-override: - system.theme.css stylesheets-remove: - node.module.css mysubtheme.info.yml
  17. CSS formatting guidelines CSS file organization (for Drupal 8) CSS

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