SlideShare a Scribd company logo
ONE DIVTO RULE THEM ALL! CONTROLLING DRUPAL DIV’S AND IMPLEMENTING A MODULAR CSS PHILOSOPHYby Leah Wagner // from The Jibe // @leahmarsh@thejibeOne Div To Rule Them All! // @leahmarsh
THE AGENDAWhat is Modular CSS and how it can be helpful? How you are probably already using this philosophy. (whether you know it or not.) How a set file structure and naming conventions makes thisphilosophy work best. How preprocessors like SASS and adding on tools like SASS- globbing and Compass can improve your workflow. One Div To Rule Them All! // @leahmarsh
THE AGENDAHow do we apply this to Drupal when so much of our HTML ispre-rendered for us? Using theme tpl filesUsing contributed modulesUsing contributed themesOne Div To Rule Them All! // @leahmarsh
WHAT IS MODULAR CSS? TRUST ME, YOU HAVE SEEN THIS BEFORE... One Div To Rule Them All! // @leahmarsh
BASE RULESThe most basic elements that will exist on the page. Usually neveroverridden. rests fall into this category. a { color: #666; } a:hover { color: #333; text-decoration: underline; } input[type=text], input[type=password] { border: 1px solid #CCC; } One Div To Rule Them All! // @leahmarsh
LAYOUT RULESThere are layout rules for major page regions and smallercomponents on the page. #header, #footer { width: 100%; background: #333; } #main { width: 100%; background: #FFF; } #content { width: 75%; display: inline; float: left; } #sidebar { width: 25%; display: inline; float: right; } .l-grid-4 li { width: 25%; display: inline; float: left;} .l-inline { display: inline; } One Div To Rule Them All! // @leahmarsh
COMPONENT RULES (OR MODULES) How many times to we style something like this? <div id="block-view-1" class="view"> <h1>My views listing title</h1> <ul> <li> <h3><a href="/node/1">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/2">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/3">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> </ul> </div> One Div To Rule Them All! // @leahmarsh
COMPONENT RULES (OR MODULES) And we might start styling with something like this: To reuse this code, we do something like this: #block-view-1 li { border-bottom: 1px solid #CCC; padding: 20px 0; } #block-view-1 h3 a { color: #333; } #block-view-1 p { font-style: italic; } #block-view-1 li, #block-view-2 li { border-bottom: 1px solid #CCC; padding: 20px 0; } #block-view-1 h3 a, #block-view-2 h3 a { color: #333; } #block-view-1 p, #block-view-2 p { font-style: italic; } One Div To Rule Them All! // @leahmarsh
COMPONENT RULES (OR MODULES) Instead we define a reusable class: <div id="block-view-1" class="list-title-body"> <h1>My views listing title</h1> <ul> <li> <h3><a href="/node/1">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/2">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/3">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> </ul> </div> One Div To Rule Them All! // @leahmarsh
COMPONENT RULES (OR MODULES) This is what we have in place: We are NOT going to: We going to define a subcomponent with the overrides: .list-title-body li { border-bottom: 1px solid #CCC; padding: 20px 0; } .list-title-body h3 a { color: #333; } .list-title-body p { font-style: italic; } #block-view-2 li:nth-child(2n) { background: #DDD; } ul.striped li:nth-child(2n) { background: #DDD; } .list-title-body ul.striped li:nth-child(2n) { background: #DDD; } .list-title-body--striped li:nth-child(2n) { background: #DDD; } One Div To Rule Them All! // @leahmarsh
COMPONENT RULES (OR MODULES) Then we add our subcomponent class: <div id="block-view-2" class="list-title-body list-title-body--striped"> <h1>My views listing title</h1> <ul> <li> <h3><a href="/node/1">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/2">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/3">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> </ul> </div> One Div To Rule Them All! // @leahmarsh
COMPONENT RULES (OR MODULES) With a preprocessor, we can extend our class: We only need one class because our SASS looks like this: <div id="block-view-2" class="list-title-body--striped"> <h1>My views listing title</h1> <ul><li>...</li></ul> </div> .list-title-body li border-bottom: 1px solid #CCC padding: 20px 0 .list-title-body--striped @extend .list-title-body li:nth-child(2n) background: #DDDOne Div To Rule Them All! // @leahmarsh
STATE RULESState rules are used for styles that have a JS dependency and thisis indicated with the 'is-' prefix. Our classes might look like: <header id="header"> <nav class="is-collapsed"> <ul> <li><a href="/home">Home</a></li> <li><a href="/about">About</a></li> </ul> </nav> </header> nav { height: auto; } nav.is-collapsed { height: 0px; } One Div To Rule Them All! // @leahmarsh
THEME RULESStyle your components for different themes or colour pallets // As defined by the component .button { background: #CCC; border: #000; border-radius: 5px; } // As defined in red.css .button { background: #FF0000; } One Div To Rule Them All! // @leahmarsh
ORGANIZATIONFile structure and naming conventionsOne Div To Rule Them All! // @leahmarsh
WHAT IS MODULAR CSS? To get us started, an example we see everyday in Drupal. .views-row { border-bottom: 1px solid #CCC; padding: 20px 0; } .views-row-last { border-bottom: none; } <div id="block-view-1" class="view"> <div class="views-row views-row-first"></div> <div class="views-row"></div> <div class="views-row views-row-last"></div> </div> One Div To Rule Them All! // @leahmarsh
WHAT IS MODULAR CSS? This is not something you download, but a philosophy you usewhen you style your projectObject Oriented CSS (OOCSS) Block, Element, Modifier (BEM) Don’t Repeat Yourself CSS (DRY CSS) Atomic CSS Scalable and Modular Architecture for CSS (SMACSS) Read more... Read more... Read more... Read more... Read more... One Div To Rule Them All! // @leahmarsh
WHY (OR WHY NOT) SMACSS? This is the wrong questionD8 has adopted this philosophy for core dev WHY USE A MODULAR CSS PHILOSOPHY? Your CSS with have a high level of specificity while remaininghighly reusable. You (should) never have to rewrite code. Potentially, share codeacross different projects. Avoid CSS conflicts and changes breaking other elements. Read more... One Div To Rule Them All! // @leahmarsh
GETTING TO KNOWSMACSSOne Div To Rule Them All! // @leahmarsh
CATEGORIZATION5 different categories of codeBaseLayoutComponents (or Modules) StateThemeOne Div To Rule Them All! // @leahmarsh
ORGANIZATIONSample folder structure <base> - normalize.css - base.sass <components> - <bourbon> - _icon.sass - _button.sass - _list-title-body.sass - _list-title-body-image.sass - style.sass <layout> - <bourbon neat> - layout.sass <states> - state.sass <themes> - red.sassOne Div To Rule Them All! // @leahmarsh
ORGANIZATIONNaming conventions // Layout .l-grid-4 // State .is-collapsed // Components .list-title-body // Subcomponents .list-title-body--stripedOne Div To Rule Them All! // @leahmarsh
CONTROLLINGDRUPAL MARKUPBringing us back to One Div To Rule Them All! TPL filesModulesThemesOne Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPTPL Files // field.tpl.php <div class="<?php print $classes; ?>"<?php print $attributes; ?>> <?php if (!$label_hidden): ?> <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?> <?php endif; ?> <div class="field-items"<?php print $content_attributes; ?>> <?php foreach ($items as $delta => $item): ?> <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<? <?php endforeach; ?> </div> </div> One Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPTPL Files // field--field-node-link.tpl.php <button class="btn-read-more"> <?php print render($item); ?> </button> One Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPModule: FencesEnable class overridesSelect HTML5 element on a per field basisOne Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPModule: Display Suite ExtrasEnable Display Suite Extras and activate fieldOne Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPModule: Display Suite ExtrasSelect HTML5 element on a per field basisOne Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPModule: ViewsCreate a custom classOne Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPModule: ViewsCleanup your row markupOne Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPModule: ViewsCustomize your field markupOne Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPModule: Clean MarkupCreate a custom block classOne Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPModule: Clean MarkupCreate a custom panel pane or panel region classOne Div To Rule Them All! // @leahmarsh
CONTROLLING DRUPAL MARKUPThemeFor when you find yourself repeating yourself... Much of this can be configured on the theme level with TPLCreate your own starter theme or a collection of TPL filesCapture settings you are implementing on every projectLook to other themes for inspirationOne Div To Rule Them All! // @leahmarsh
WORKING WITHBEST PRACTICESModular CSS helps us... Reinforce clean markupWhile you are thinking about classes, you think about using thecorrect HTML5 markupThis concept lends itself to online style tiles or style guidesOne Div To Rule Them All! // @leahmarsh
THE ENDLET'S CHAT! by Leah Wagner // from The Jibe // @leahmarsh@thejibeOne Div To Rule Them All! // @leahmarsh
Ad

More Related Content

What's hot (20)

Drupal Camp Manila 2014 - Theming with Zen
Drupal Camp Manila 2014 - Theming with ZenDrupal Camp Manila 2014 - Theming with Zen
Drupal Camp Manila 2014 - Theming with Zen
Japo Domingo
 
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
Jer Clarke
 
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax ...
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective,  Ajax ...The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective,  Ajax ...
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax ...
Nicole Sullivan
 
How to use CSS3 in WordPress
How to use CSS3 in WordPressHow to use CSS3 in WordPress
How to use CSS3 in WordPress
Suzette Franck
 
Developing Your Ultimate Package
Developing Your Ultimate PackageDeveloping Your Ultimate Package
Developing Your Ultimate Package
Simon Collison
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) Theming
PINGV
 
Functional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal ThemingFunctional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal Theming
Emma Jane Hogbin Westby
 
Battle of the Front-End Frameworks: Bootstrap vs. Foundation
Battle of the Front-End Frameworks: Bootstrap vs. FoundationBattle of the Front-End Frameworks: Bootstrap vs. Foundation
Battle of the Front-End Frameworks: Bootstrap vs. Foundation
Rachel Cherry
 
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Laura Scott
 
Bootstrap [part 2]
Bootstrap [part 2]Bootstrap [part 2]
Bootstrap [part 2]
Ghanshyam Patel
 
SMACSS Workshop
SMACSS WorkshopSMACSS Workshop
SMACSS Workshop
Tim Hettler
 
Slicing the web
Slicing the webSlicing the web
Slicing the web
Mohamad Hemmat
 
Responsive Websites
Responsive WebsitesResponsive Websites
Responsive Websites
Joe Seifi
 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic template
vathur
 
Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013
Andrea Tarr
 
CSS Systems
CSS SystemsCSS Systems
CSS Systems
Natalie Downe
 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to life
Derek Christensen
 
Bootstrap Framework and Drupal
Bootstrap Framework and DrupalBootstrap Framework and Drupal
Bootstrap Framework and Drupal
Jim Birch
 
Scalable and Modular CSS FTW!
Scalable and Modular CSS FTW!Scalable and Modular CSS FTW!
Scalable and Modular CSS FTW!
FITC
 
DrupalCon Austin - Absolute Beginner's Guide to Drupal
DrupalCon Austin - Absolute Beginner's Guide to DrupalDrupalCon Austin - Absolute Beginner's Guide to Drupal
DrupalCon Austin - Absolute Beginner's Guide to Drupal
Rod Martin
 
Drupal Camp Manila 2014 - Theming with Zen
Drupal Camp Manila 2014 - Theming with ZenDrupal Camp Manila 2014 - Theming with Zen
Drupal Camp Manila 2014 - Theming with Zen
Japo Domingo
 
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
Jer Clarke
 
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax ...
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective,  Ajax ...The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective,  Ajax ...
The Cascade, Grids, Headings, and Selectors from an OOCSS Perspective, Ajax ...
Nicole Sullivan
 
How to use CSS3 in WordPress
How to use CSS3 in WordPressHow to use CSS3 in WordPress
How to use CSS3 in WordPress
Suzette Franck
 
Developing Your Ultimate Package
Developing Your Ultimate PackageDeveloping Your Ultimate Package
Developing Your Ultimate Package
Simon Collison
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) Theming
PINGV
 
Functional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal ThemingFunctional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal Theming
Emma Jane Hogbin Westby
 
Battle of the Front-End Frameworks: Bootstrap vs. Foundation
Battle of the Front-End Frameworks: Bootstrap vs. FoundationBattle of the Front-End Frameworks: Bootstrap vs. Foundation
Battle of the Front-End Frameworks: Bootstrap vs. Foundation
Rachel Cherry
 
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Laura Scott
 
Responsive Websites
Responsive WebsitesResponsive Websites
Responsive Websites
Joe Seifi
 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic template
vathur
 
Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013
Andrea Tarr
 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to life
Derek Christensen
 
Bootstrap Framework and Drupal
Bootstrap Framework and DrupalBootstrap Framework and Drupal
Bootstrap Framework and Drupal
Jim Birch
 
Scalable and Modular CSS FTW!
Scalable and Modular CSS FTW!Scalable and Modular CSS FTW!
Scalable and Modular CSS FTW!
FITC
 
DrupalCon Austin - Absolute Beginner's Guide to Drupal
DrupalCon Austin - Absolute Beginner's Guide to DrupalDrupalCon Austin - Absolute Beginner's Guide to Drupal
DrupalCon Austin - Absolute Beginner's Guide to Drupal
Rod Martin
 

Similar to One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular CSS Philosophy (20)

Diazo: Bridging Designers and Programmers
Diazo: Bridging Designers and ProgrammersDiazo: Bridging Designers and Programmers
Diazo: Bridging Designers and Programmers
TsungWei Hu
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
William Myers
 
ViA Bootstrap 4
ViA Bootstrap 4ViA Bootstrap 4
ViA Bootstrap 4
imdurgesh
 
css.ppt
css.pptcss.ppt
css.ppt
DakshPratapSingh1
 
css.ppt
css.pptcss.ppt
css.ppt
Sana903754
 
HTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.pptHTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.ppt
raghavanp4
 
Display Suite: A Themers Perspective
Display Suite: A Themers PerspectiveDisplay Suite: A Themers Perspective
Display Suite: A Themers Perspective
Mediacurrent
 
HTML 5 Drupalcamp Ireland Dublin 2010
HTML 5 Drupalcamp Ireland Dublin 2010HTML 5 Drupalcamp Ireland Dublin 2010
HTML 5 Drupalcamp Ireland Dublin 2010
alanburke
 
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
Eric Carlisle
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Erin M. Kidwell
 
Slow kinda sucks
Slow kinda sucksSlow kinda sucks
Slow kinda sucks
Tim Wright
 
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style GuidesAdvanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Aidan Foster
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
Heather Rock
 
Create a landing page
Create a landing pageCreate a landing page
Create a landing page
Fabien Vauchelles
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSS
Sanjoy Kr. Paul
 
Fewd week2 slides
Fewd week2 slidesFewd week2 slides
Fewd week2 slides
William Myers
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
Marco Pinheiro
 
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
Roni Banerjee
 
HTML5 & CSS3 Flag
HTML5 & CSS3 FlagHTML5 & CSS3 Flag
HTML5 & CSS3 Flag
Christopher Schmitt
 
Prototyping interactions
Prototyping interactionsPrototyping interactions
Prototyping interactions
selwynjacob90
 
Diazo: Bridging Designers and Programmers
Diazo: Bridging Designers and ProgrammersDiazo: Bridging Designers and Programmers
Diazo: Bridging Designers and Programmers
TsungWei Hu
 
ViA Bootstrap 4
ViA Bootstrap 4ViA Bootstrap 4
ViA Bootstrap 4
imdurgesh
 
HTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.pptHTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.ppt
raghavanp4
 
Display Suite: A Themers Perspective
Display Suite: A Themers PerspectiveDisplay Suite: A Themers Perspective
Display Suite: A Themers Perspective
Mediacurrent
 
HTML 5 Drupalcamp Ireland Dublin 2010
HTML 5 Drupalcamp Ireland Dublin 2010HTML 5 Drupalcamp Ireland Dublin 2010
HTML 5 Drupalcamp Ireland Dublin 2010
alanburke
 
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}
Eric Carlisle
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Erin M. Kidwell
 
Slow kinda sucks
Slow kinda sucksSlow kinda sucks
Slow kinda sucks
Tim Wright
 
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style GuidesAdvanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Aidan Foster
 
GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1GDI Seattle Intermediate HTML and CSS Class 1
GDI Seattle Intermediate HTML and CSS Class 1
Heather Rock
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSS
Sanjoy Kr. Paul
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
Marco Pinheiro
 
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
Roni Banerjee
 
Prototyping interactions
Prototyping interactionsPrototyping interactions
Prototyping interactions
selwynjacob90
 
Ad

Recently uploaded (20)

AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Ad

One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular CSS Philosophy

  • 1. ONE DIVTO RULE THEM ALL! CONTROLLING DRUPAL DIV’S AND IMPLEMENTING A MODULAR CSS PHILOSOPHYby Leah Wagner // from The Jibe // @leahmarsh@thejibeOne Div To Rule Them All! // @leahmarsh
  • 2. THE AGENDAWhat is Modular CSS and how it can be helpful? How you are probably already using this philosophy. (whether you know it or not.) How a set file structure and naming conventions makes thisphilosophy work best. How preprocessors like SASS and adding on tools like SASS- globbing and Compass can improve your workflow. One Div To Rule Them All! // @leahmarsh
  • 3. THE AGENDAHow do we apply this to Drupal when so much of our HTML ispre-rendered for us? Using theme tpl filesUsing contributed modulesUsing contributed themesOne Div To Rule Them All! // @leahmarsh
  • 4. WHAT IS MODULAR CSS? TRUST ME, YOU HAVE SEEN THIS BEFORE... One Div To Rule Them All! // @leahmarsh
  • 5. BASE RULESThe most basic elements that will exist on the page. Usually neveroverridden. rests fall into this category. a { color: #666; } a:hover { color: #333; text-decoration: underline; } input[type=text], input[type=password] { border: 1px solid #CCC; } One Div To Rule Them All! // @leahmarsh
  • 6. LAYOUT RULESThere are layout rules for major page regions and smallercomponents on the page. #header, #footer { width: 100%; background: #333; } #main { width: 100%; background: #FFF; } #content { width: 75%; display: inline; float: left; } #sidebar { width: 25%; display: inline; float: right; } .l-grid-4 li { width: 25%; display: inline; float: left;} .l-inline { display: inline; } One Div To Rule Them All! // @leahmarsh
  • 7. COMPONENT RULES (OR MODULES) How many times to we style something like this? <div id="block-view-1" class="view"> <h1>My views listing title</h1> <ul> <li> <h3><a href="/node/1">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/2">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/3">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> </ul> </div> One Div To Rule Them All! // @leahmarsh
  • 8. COMPONENT RULES (OR MODULES) And we might start styling with something like this: To reuse this code, we do something like this: #block-view-1 li { border-bottom: 1px solid #CCC; padding: 20px 0; } #block-view-1 h3 a { color: #333; } #block-view-1 p { font-style: italic; } #block-view-1 li, #block-view-2 li { border-bottom: 1px solid #CCC; padding: 20px 0; } #block-view-1 h3 a, #block-view-2 h3 a { color: #333; } #block-view-1 p, #block-view-2 p { font-style: italic; } One Div To Rule Them All! // @leahmarsh
  • 9. COMPONENT RULES (OR MODULES) Instead we define a reusable class: <div id="block-view-1" class="list-title-body"> <h1>My views listing title</h1> <ul> <li> <h3><a href="/node/1">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/2">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/3">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> </ul> </div> One Div To Rule Them All! // @leahmarsh
  • 10. COMPONENT RULES (OR MODULES) This is what we have in place: We are NOT going to: We going to define a subcomponent with the overrides: .list-title-body li { border-bottom: 1px solid #CCC; padding: 20px 0; } .list-title-body h3 a { color: #333; } .list-title-body p { font-style: italic; } #block-view-2 li:nth-child(2n) { background: #DDD; } ul.striped li:nth-child(2n) { background: #DDD; } .list-title-body ul.striped li:nth-child(2n) { background: #DDD; } .list-title-body--striped li:nth-child(2n) { background: #DDD; } One Div To Rule Them All! // @leahmarsh
  • 11. COMPONENT RULES (OR MODULES) Then we add our subcomponent class: <div id="block-view-2" class="list-title-body list-title-body--striped"> <h1>My views listing title</h1> <ul> <li> <h3><a href="/node/1">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/2">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> <li> <h3><a href="/node/3">Lorem Ipsum Dolor</a></h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing.</p> </li> </ul> </div> One Div To Rule Them All! // @leahmarsh
  • 12. COMPONENT RULES (OR MODULES) With a preprocessor, we can extend our class: We only need one class because our SASS looks like this: <div id="block-view-2" class="list-title-body--striped"> <h1>My views listing title</h1> <ul><li>...</li></ul> </div> .list-title-body li border-bottom: 1px solid #CCC padding: 20px 0 .list-title-body--striped @extend .list-title-body li:nth-child(2n) background: #DDDOne Div To Rule Them All! // @leahmarsh
  • 13. STATE RULESState rules are used for styles that have a JS dependency and thisis indicated with the 'is-' prefix. Our classes might look like: <header id="header"> <nav class="is-collapsed"> <ul> <li><a href="/home">Home</a></li> <li><a href="/about">About</a></li> </ul> </nav> </header> nav { height: auto; } nav.is-collapsed { height: 0px; } One Div To Rule Them All! // @leahmarsh
  • 14. THEME RULESStyle your components for different themes or colour pallets // As defined by the component .button { background: #CCC; border: #000; border-radius: 5px; } // As defined in red.css .button { background: #FF0000; } One Div To Rule Them All! // @leahmarsh
  • 15. ORGANIZATIONFile structure and naming conventionsOne Div To Rule Them All! // @leahmarsh
  • 16. WHAT IS MODULAR CSS? To get us started, an example we see everyday in Drupal. .views-row { border-bottom: 1px solid #CCC; padding: 20px 0; } .views-row-last { border-bottom: none; } <div id="block-view-1" class="view"> <div class="views-row views-row-first"></div> <div class="views-row"></div> <div class="views-row views-row-last"></div> </div> One Div To Rule Them All! // @leahmarsh
  • 17. WHAT IS MODULAR CSS? This is not something you download, but a philosophy you usewhen you style your projectObject Oriented CSS (OOCSS) Block, Element, Modifier (BEM) Don’t Repeat Yourself CSS (DRY CSS) Atomic CSS Scalable and Modular Architecture for CSS (SMACSS) Read more... Read more... Read more... Read more... Read more... One Div To Rule Them All! // @leahmarsh
  • 18. WHY (OR WHY NOT) SMACSS? This is the wrong questionD8 has adopted this philosophy for core dev WHY USE A MODULAR CSS PHILOSOPHY? Your CSS with have a high level of specificity while remaininghighly reusable. You (should) never have to rewrite code. Potentially, share codeacross different projects. Avoid CSS conflicts and changes breaking other elements. Read more... One Div To Rule Them All! // @leahmarsh
  • 19. GETTING TO KNOWSMACSSOne Div To Rule Them All! // @leahmarsh
  • 20. CATEGORIZATION5 different categories of codeBaseLayoutComponents (or Modules) StateThemeOne Div To Rule Them All! // @leahmarsh
  • 21. ORGANIZATIONSample folder structure <base> - normalize.css - base.sass <components> - <bourbon> - _icon.sass - _button.sass - _list-title-body.sass - _list-title-body-image.sass - style.sass <layout> - <bourbon neat> - layout.sass <states> - state.sass <themes> - red.sassOne Div To Rule Them All! // @leahmarsh
  • 22. ORGANIZATIONNaming conventions // Layout .l-grid-4 // State .is-collapsed // Components .list-title-body // Subcomponents .list-title-body--stripedOne Div To Rule Them All! // @leahmarsh
  • 23. CONTROLLINGDRUPAL MARKUPBringing us back to One Div To Rule Them All! TPL filesModulesThemesOne Div To Rule Them All! // @leahmarsh
  • 24. CONTROLLING DRUPAL MARKUPTPL Files // field.tpl.php <div class="<?php print $classes; ?>"<?php print $attributes; ?>> <?php if (!$label_hidden): ?> <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?> <?php endif; ?> <div class="field-items"<?php print $content_attributes; ?>> <?php foreach ($items as $delta => $item): ?> <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<? <?php endforeach; ?> </div> </div> One Div To Rule Them All! // @leahmarsh
  • 25. CONTROLLING DRUPAL MARKUPTPL Files // field--field-node-link.tpl.php <button class="btn-read-more"> <?php print render($item); ?> </button> One Div To Rule Them All! // @leahmarsh
  • 26. CONTROLLING DRUPAL MARKUPModule: FencesEnable class overridesSelect HTML5 element on a per field basisOne Div To Rule Them All! // @leahmarsh
  • 27. CONTROLLING DRUPAL MARKUPModule: Display Suite ExtrasEnable Display Suite Extras and activate fieldOne Div To Rule Them All! // @leahmarsh
  • 28. CONTROLLING DRUPAL MARKUPModule: Display Suite ExtrasSelect HTML5 element on a per field basisOne Div To Rule Them All! // @leahmarsh
  • 29. CONTROLLING DRUPAL MARKUPModule: ViewsCreate a custom classOne Div To Rule Them All! // @leahmarsh
  • 30. CONTROLLING DRUPAL MARKUPModule: ViewsCleanup your row markupOne Div To Rule Them All! // @leahmarsh
  • 31. CONTROLLING DRUPAL MARKUPModule: ViewsCustomize your field markupOne Div To Rule Them All! // @leahmarsh
  • 32. CONTROLLING DRUPAL MARKUPModule: Clean MarkupCreate a custom block classOne Div To Rule Them All! // @leahmarsh
  • 33. CONTROLLING DRUPAL MARKUPModule: Clean MarkupCreate a custom panel pane or panel region classOne Div To Rule Them All! // @leahmarsh
  • 34. CONTROLLING DRUPAL MARKUPThemeFor when you find yourself repeating yourself... Much of this can be configured on the theme level with TPLCreate your own starter theme or a collection of TPL filesCapture settings you are implementing on every projectLook to other themes for inspirationOne Div To Rule Them All! // @leahmarsh
  • 35. WORKING WITHBEST PRACTICESModular CSS helps us... Reinforce clean markupWhile you are thinking about classes, you think about using thecorrect HTML5 markupThis concept lends itself to online style tiles or style guidesOne Div To Rule Them All! // @leahmarsh
  • 36. THE ENDLET'S CHAT! by Leah Wagner // from The Jibe // @leahmarsh@thejibeOne Div To Rule Them All! // @leahmarsh