SlideShare a Scribd company logo
1 of 41
Download to read offline
1
About me
      Jan-yves Vanhaverbeke

      Wunderkraut Belgium (Ghent)
      Frontend Developer
      jan-yves.vanhaverbeke@wunderkraut.com

      Drupal.org: jyve
      Twitter: janyves




                                              2
Maintainable
Drupal Theming


                 3
Why
Client: the white-space on the news
overview page is wrong!


body #page .view-news .views-row
div.node .node-section.clear-block {
  margin-top: 0 !important;
}


                                       4
Agenda
‣   Drupal is special
‣   Optimize your design input
‣   Optimize your Drupal HTML
‣   Write maintainable CSS
‣   Build a maintainable theme



                                 5
Drupal is
 special

            6
Drupal is a CMS

‣   Highly customizable
‣   What if content is added?
‣   What if a block is moved?




                                7
Content-first approach

‣   First content types, taxonomy, users,
    comments
‣   Pages assembled from different
    sources
‣   Theming should support this



                                            8
Optimize your
 design input

                9
Problems with designs

‣   A design is static
‣   Not all pages will be designed
‣   Designs are rarely consistent
‣   A design reflects the ideal situation




                                           10
Solutions

‣   Ask for a Style Guide
‣   Analyze the design
‣   Keep designers involved




                              11
Style Guide


‣   All recurring design elements and
    interactions
‣   Leading in case of inconsistencies.




                                          12
Style Guide
‣   Site elements:
    ‣   Navigations: including mouse-over and active
        states
    ‣   One or more block templates
    ‣   A pager
    ‣   Message boxes: warning, confirmation and error
    ‣   A form. Typically useful for the contact form
    ‣   A list of the most important colors


                                                        13
Style Guide
‣   Typography:
    ‣   Headings: H1, H2, H3 and H4
    ‣   Links: color and (optional) underline. Also define
        a mouse-over state
    ‣   Paragraph: for default text the line-height and
        space between text should be defined
    ‣   (Un)ordered list: How does it look in content?




                                                            14
Analyze the design
‣   Print all designs
‣   Look for patterns:
    ‣   Block styles
    ‣   Image styles
    ‣   View Modes
    ‣   Regions...
‣   Convert patterns to HTML tags/classes/styles



                                                   15
Optimize
your HTML

            16
“ The Views output contains a
  rich set of div tags allowing
fine-grained CSS control over
          the output. ”




                                  17
Remove HTML

‣   Clean up template files
‣   Examples: Panels, Views, Field
‣   Use Display Suite (Field Templates)
‣   One-time effort




                                          18
Before cleanup




                 19
After cleanup




                20
Module unaware HTML

‣   .panel-pane .pane-title {}
      vs
    .block > h2 {}
‣   page.tpl.php vs Panels Layout
‣   Views specific classes



                                    21
Add own classes

‣   Block class: http://drupal.org/
    project/block_class
‣   Views
‣   Display Suite
‣   Panels



                                      22
Write
maintainable CSS


                   23
Functional selectors
‣   Theme a functional element, not a
    Drupal module:
‣   Bad:
    ‣   .views-articles .views-row {}
    ‣   .views-row {}
‣   Good:
    ‣   .article-teaser {}
    ‣   .item-list li {}

                                        24
As generic as possible


.field
  vs
.page-article #content div.node
div.field-title



                                  25
Avoid overwrites

‣   Remove Drupal and module CSS
‣   function theme_css_alter(&$css) {
      unset($css['modules/system/system.menus.css']);
    }

‣   Dare to rework existing CSS as
    features are added.



                                                        26
Drupal CSS standards

‣   http://drupal.org/node/1887862


‣   .quote {
      margin-left: 15px;
      font-style: italic;
    }



                                     27
Build a
maintainable theme


                     28
Theming is...

‣   Basic design
‣   Features
‣   Reusable styles




                        29
Basic design
‣   All generic elements: header, footer,
    layout
‣   Style Guide: navigation, typography,
    colors, links etc
‣   Simple content page with mixed
    typographical content.



                                            30
Features

‣   Examples: news, blog, slideshow
‣   Separate CSS files
‣   Clear separation between reuse of
    styles and custom CSS




                                        31
Styles

‣   Examples: list of teasers, block styles
‣   Power of Sass
‣   Add as you go




                                              32
Power of Sass

‣   Mixins and extendables
‣   Variables
‣   Selector nesting




                             33
Power of Sass
.node-news {
  .view-mode-teaser {
    @extend %teaser;
    color: $grey;
    @include border-radius(3px);
    margin-top: 0;
  }
}


                                   34
Wundertheme

‣   Custom starter theme
‣   Beta
‣   https://github.com/Krimson/
    wundertheme.git




                                  35
In Summary

             36
In Summary
Client: the white-space on the news
overview page is wrong!


body #page .view-news .views-row
div.node .node-section.clear-block {
  margin-top: 0 !important;
}


                                       37
Power of Sass
.node-news {
  .view-mode-teaser {
    @extend %teaser;
    color: $grey;
    @include border-radius(3px);
    margin-top: 0;
  }
}


                                   38
In Summary
‣   Drupal is special
‣   Optimize your design input
‣   Optimize your Drupal HTML
‣   Write maintainable CSS
‣   Build a maintainable theme



                                 39
Questions?


             40
41

More Related Content

Similar to Maintainable theming

PrintCSS workshop XMLPrague 2020
PrintCSS workshop XMLPrague 2020PrintCSS workshop XMLPrague 2020
PrintCSS workshop XMLPrague 2020Andreas Jung
 
PrintCSS W3C workshop at XMLPrague 2020
PrintCSS W3C workshop at XMLPrague 2020PrintCSS W3C workshop at XMLPrague 2020
PrintCSS W3C workshop at XMLPrague 2020Andreas Jung
 
The Future of CSS Layout
The Future of CSS LayoutThe Future of CSS Layout
The Future of CSS LayoutZoe Gillenwater
 
WordPress Beginners Workshop
WordPress Beginners WorkshopWordPress Beginners Workshop
WordPress Beginners WorkshopThe Toolbox, Inc.
 
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)Four Kitchens
 
Face/Off: APEX Templates & Themes
Face/Off: APEX Templates & ThemesFace/Off: APEX Templates & Themes
Face/Off: APEX Templates & Themescrokitta
 
Accelerated grid theming using NineSixty (Dallas Drupal Days 2011)
Accelerated grid theming using NineSixty (Dallas Drupal Days 2011)Accelerated grid theming using NineSixty (Dallas Drupal Days 2011)
Accelerated grid theming using NineSixty (Dallas Drupal Days 2011)Four Kitchens
 
Beginner & Intermediate Guide to HTML5/CSS3 In Drupal
Beginner & Intermediate Guide to HTML5/CSS3 In DrupalBeginner & Intermediate Guide to HTML5/CSS3 In Drupal
Beginner & Intermediate Guide to HTML5/CSS3 In DrupalMediacurrent
 
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)Four Kitchens
 
Drupal theming using the 960.gs grid system
Drupal theming using the 960.gs grid systemDrupal theming using the 960.gs grid system
Drupal theming using the 960.gs grid systemFour Kitchens
 
Accelerated grid theming using NineSixty (DrupalCamp LA 2011)
Accelerated grid theming using NineSixty (DrupalCamp LA 2011)Accelerated grid theming using NineSixty (DrupalCamp LA 2011)
Accelerated grid theming using NineSixty (DrupalCamp LA 2011)Four Kitchens
 
The ABC of Coded Style Guides
The ABC of Coded Style GuidesThe ABC of Coded Style Guides
The ABC of Coded Style GuidesHenning Muszynski
 
Unic - frontend development-in-complex-projects
Unic - frontend development-in-complex-projectsUnic - frontend development-in-complex-projects
Unic - frontend development-in-complex-projectsUnic
 
Surviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studySurviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studypeter_ibuildings
 
Drupal Overview For Techies
Drupal Overview For TechiesDrupal Overview For Techies
Drupal Overview For TechiesRobert Carr
 
How to Build an Accessible WordPress Theme
How to Build an Accessible WordPress ThemeHow to Build an Accessible WordPress Theme
How to Build an Accessible WordPress ThemeGraham Armfield
 

Similar to Maintainable theming (20)

PrintCSS workshop XMLPrague 2020
PrintCSS workshop XMLPrague 2020PrintCSS workshop XMLPrague 2020
PrintCSS workshop XMLPrague 2020
 
PrintCSS W3C workshop at XMLPrague 2020
PrintCSS W3C workshop at XMLPrague 2020PrintCSS W3C workshop at XMLPrague 2020
PrintCSS W3C workshop at XMLPrague 2020
 
The Future of CSS Layout
The Future of CSS LayoutThe Future of CSS Layout
The Future of CSS Layout
 
WordPress Beginners Workshop
WordPress Beginners WorkshopWordPress Beginners Workshop
WordPress Beginners Workshop
 
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
 
Face/Off: APEX Templates & Themes
Face/Off: APEX Templates & ThemesFace/Off: APEX Templates & Themes
Face/Off: APEX Templates & Themes
 
Accelerated grid theming using NineSixty (Dallas Drupal Days 2011)
Accelerated grid theming using NineSixty (Dallas Drupal Days 2011)Accelerated grid theming using NineSixty (Dallas Drupal Days 2011)
Accelerated grid theming using NineSixty (Dallas Drupal Days 2011)
 
Efficient theming in Drupal
Efficient theming in DrupalEfficient theming in Drupal
Efficient theming in Drupal
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
 
Beginner & Intermediate Guide to HTML5/CSS3 In Drupal
Beginner & Intermediate Guide to HTML5/CSS3 In DrupalBeginner & Intermediate Guide to HTML5/CSS3 In Drupal
Beginner & Intermediate Guide to HTML5/CSS3 In Drupal
 
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
 
Drupal theming using the 960.gs grid system
Drupal theming using the 960.gs grid systemDrupal theming using the 960.gs grid system
Drupal theming using the 960.gs grid system
 
Accelerated grid theming using NineSixty (DrupalCamp LA 2011)
Accelerated grid theming using NineSixty (DrupalCamp LA 2011)Accelerated grid theming using NineSixty (DrupalCamp LA 2011)
Accelerated grid theming using NineSixty (DrupalCamp LA 2011)
 
The ABC of Coded Style Guides
The ABC of Coded Style GuidesThe ABC of Coded Style Guides
The ABC of Coded Style Guides
 
RWD
RWDRWD
RWD
 
Unic - frontend development-in-complex-projects
Unic - frontend development-in-complex-projectsUnic - frontend development-in-complex-projects
Unic - frontend development-in-complex-projects
 
Surviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studySurviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-study
 
Slice and Dice
Slice and DiceSlice and Dice
Slice and Dice
 
Drupal Overview For Techies
Drupal Overview For TechiesDrupal Overview For Techies
Drupal Overview For Techies
 
How to Build an Accessible WordPress Theme
How to Build an Accessible WordPress ThemeHow to Build an Accessible WordPress Theme
How to Build an Accessible WordPress Theme
 

Maintainable theming

  • 1. 1
  • 2. About me Jan-yves Vanhaverbeke Wunderkraut Belgium (Ghent) Frontend Developer jan-yves.vanhaverbeke@wunderkraut.com Drupal.org: jyve Twitter: janyves 2
  • 4. Why Client: the white-space on the news overview page is wrong! body #page .view-news .views-row div.node .node-section.clear-block { margin-top: 0 !important; } 4
  • 5. Agenda ‣ Drupal is special ‣ Optimize your design input ‣ Optimize your Drupal HTML ‣ Write maintainable CSS ‣ Build a maintainable theme 5
  • 7. Drupal is a CMS ‣ Highly customizable ‣ What if content is added? ‣ What if a block is moved? 7
  • 8. Content-first approach ‣ First content types, taxonomy, users, comments ‣ Pages assembled from different sources ‣ Theming should support this 8
  • 10. Problems with designs ‣ A design is static ‣ Not all pages will be designed ‣ Designs are rarely consistent ‣ A design reflects the ideal situation 10
  • 11. Solutions ‣ Ask for a Style Guide ‣ Analyze the design ‣ Keep designers involved 11
  • 12. Style Guide ‣ All recurring design elements and interactions ‣ Leading in case of inconsistencies. 12
  • 13. Style Guide ‣ Site elements: ‣ Navigations: including mouse-over and active states ‣ One or more block templates ‣ A pager ‣ Message boxes: warning, confirmation and error ‣ A form. Typically useful for the contact form ‣ A list of the most important colors 13
  • 14. Style Guide ‣ Typography: ‣ Headings: H1, H2, H3 and H4 ‣ Links: color and (optional) underline. Also define a mouse-over state ‣ Paragraph: for default text the line-height and space between text should be defined ‣ (Un)ordered list: How does it look in content? 14
  • 15. Analyze the design ‣ Print all designs ‣ Look for patterns: ‣ Block styles ‣ Image styles ‣ View Modes ‣ Regions... ‣ Convert patterns to HTML tags/classes/styles 15
  • 17. “ The Views output contains a rich set of div tags allowing fine-grained CSS control over the output. ” 17
  • 18. Remove HTML ‣ Clean up template files ‣ Examples: Panels, Views, Field ‣ Use Display Suite (Field Templates) ‣ One-time effort 18
  • 21. Module unaware HTML ‣ .panel-pane .pane-title {} vs .block > h2 {} ‣ page.tpl.php vs Panels Layout ‣ Views specific classes 21
  • 22. Add own classes ‣ Block class: http://drupal.org/ project/block_class ‣ Views ‣ Display Suite ‣ Panels 22
  • 24. Functional selectors ‣ Theme a functional element, not a Drupal module: ‣ Bad: ‣ .views-articles .views-row {} ‣ .views-row {} ‣ Good: ‣ .article-teaser {} ‣ .item-list li {} 24
  • 25. As generic as possible .field vs .page-article #content div.node div.field-title 25
  • 26. Avoid overwrites ‣ Remove Drupal and module CSS ‣ function theme_css_alter(&$css) { unset($css['modules/system/system.menus.css']); } ‣ Dare to rework existing CSS as features are added. 26
  • 27. Drupal CSS standards ‣ http://drupal.org/node/1887862 ‣ .quote { margin-left: 15px; font-style: italic; } 27
  • 29. Theming is... ‣ Basic design ‣ Features ‣ Reusable styles 29
  • 30. Basic design ‣ All generic elements: header, footer, layout ‣ Style Guide: navigation, typography, colors, links etc ‣ Simple content page with mixed typographical content. 30
  • 31. Features ‣ Examples: news, blog, slideshow ‣ Separate CSS files ‣ Clear separation between reuse of styles and custom CSS 31
  • 32. Styles ‣ Examples: list of teasers, block styles ‣ Power of Sass ‣ Add as you go 32
  • 33. Power of Sass ‣ Mixins and extendables ‣ Variables ‣ Selector nesting 33
  • 34. Power of Sass .node-news { .view-mode-teaser { @extend %teaser; color: $grey; @include border-radius(3px); margin-top: 0; } } 34
  • 35. Wundertheme ‣ Custom starter theme ‣ Beta ‣ https://github.com/Krimson/ wundertheme.git 35
  • 37. In Summary Client: the white-space on the news overview page is wrong! body #page .view-news .views-row div.node .node-section.clear-block { margin-top: 0 !important; } 37
  • 38. Power of Sass .node-news { .view-mode-teaser { @extend %teaser; color: $grey; @include border-radius(3px); margin-top: 0; } } 38
  • 39. In Summary ‣ Drupal is special ‣ Optimize your design input ‣ Optimize your Drupal HTML ‣ Write maintainable CSS ‣ Build a maintainable theme 39
  • 41. 41