SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Drupal 8 Themes with
SASS and SMACSS
(and kittens)
Who am I?
Liisa, The CSS Nazi
Senior Software Developer, Super-
hyper Drupal Girl @Tieto
d.org: lduerig
Twitter: @LisKit7
About Tieto
Tieto is the largest Nordic IT services provider, offering full
life-cycle services, mainly focusing in:
● Financial services
● Manufacturing, Retail and Logistics
● Public, Healthcare and Welfare
● Telecom, Media and Energy
Not part of the scope of this presentation, but
ask if you want to know more. May be good for
a later presentation.
=
Old school.
● media queries /
breakpoints
● sprites
● fixed gutter width
● fixed sprite width
Unmaintainable, manual
labour and prone to
inconsistencies.
SASS - CSS with Superpowers
$variable + @mixin + @extend ==
less copy/paste ==
consistant ==
AWESOME!
(Be careful with @extends.
And nesting fever. (Later))
What about Drupal?
● Can’t modules handle this?
o Yes, but if you know enough code to be writing
SCSS, you probably shouldn’t need a module for it.
● How does this work with Drupal dev?
o Perfectly. Separately.
Setup
● Ruby
● Sass
● Compass
● Breakpoint
● Bundler, for version management
Ruby
config.rb
● Environment (minification)
● Firesass
● Resources
● Compass plugins
● Import external stuff
● SASS options
Bundler Gemfile
Useful if you are working on a pre-existing
setup, and need specific versions of things.
Variables? Awesome!
Use for:
● breakpoints
● measurements
● font-sizes
● font-families
● … anything that you use often or should have a default.
Benefits:
● Consistent CSS.
● Easy to make site-wide changes.
● No need to sift through code if a breakpoint or font-size
should be changed.
● No need to remember what these default values are.
Best practices
● Keep most site-wide variables in a partial _variables.scss, within your
SMACSS “base” directory.
● Use these variables in other partials, don’t mix up static styles with
variables!
o Every time I find font-size: 10px an SCSS partial, God kills a kitten and
I have nightmares.
● Vertical measurement variables and font-sizes should be ems and
calculated with Compass vertical-rhythm library.
● Horizontal measurement variables can be set however you want, perhaps
using multiples of a $base-unit-pixels. Be consistent.
SASS @mixins
Use mixins for bits of code
that you use frequently in
your SCSS.
This little mixin makes it very
easy to whip up media
queries on-the-fly.
And then the mixin grew up and realized life
wasn’t
so
simple.
Don’t re-invent the wheel.
SASS libraries have a lot of awesome functions
and mixins to do this stuff for you.
Breakpoint
http://breakpoint-sass.com
Compiles
to
Breakpoint
http://breakpoint-sass.com
Really Simple, Organized,
Media Queries with Sass
How about that obnoxious
sprite?
Compass - Sprites
Files:
images/my-icons/new.png
images/my-icons/edit.png
images/my-icons/save.png
images/my-icons/delete.png
SCSS:
@import "compass/utilities/sprites";
@import "my-icons/*.png";
@include all-my-icons-sprites;
Generated CSS:
.my-icons-sprite,
.my-icons-delete,
.my-icons-edit,
.my-icons-new,
.my-icons-save { background: url('/images/my-icons-
s34fe0604ab.png') no-repeat; }
.my-icons-delete { background-position: 0 0; }
.my-icons-edit { background-position: 0 -32px; }
.my-icons-new { background-position: 0 -64px; }
.my-icons-save { background-position: 0 -96px; }
Compass - Sprites
● Configuration options per sprite or sprite-map
● Magic selectors
● Magic imports
● Sprite layouts
● Sass functions
tutorial: http://compass-style.org/help/tutorials/spriting/
Compass - Sprites
We need:
● toggle menu icon for mobile
● fixed width and height
● list-items in the menu should
be of equal height
● More control, no extra classes
SCSS Generated CSS
Compass - Sprites
That’s extra lines of code, what’s the point?
● I am not wasting my time fiddling around with a sprite.
● I don’t care how many pixels a particular image is offset
in the sprite.
● I don’t care what size the image is.
● My designers don’t have to care about creating sprites
or listen to me whine, either.
What else can we do with
Compass?
Compass - CSS3
Which of these would you rather write?
HINT!
Compass - Links
● Hover Link – Underline a link when you hover over it.
● Link Colors – Easy assignment of colors to link states.
● Unstyled Link – Make a link appear like regular text.
Compass - Lists
● Bullets – Mixins for managing list bullets.
● Horizontal List – Float a list so it appears horizontally.
● Inline-Block List – set list-elements to inline-block so they appear
horizontally while retaining their structure.
● Inline List – Style a list as inline text.
Compass - Text
● Ellipsis – Text truncation with ellipsis.
● Force Wrap – Wrap URLs and long lines of text.
● No Wrap – Remembering whether or not there's a hyphen in white-
space is too hard.
● Text Replacement – Replace text with images.
Compass - Typography
Vertical Rhythm
A massive pile of variables, constants, functions and mixins
to help create and manage vertical rhythm on your site.
This stuff is AWESOME, check it out.
Compass also has it’s own
layout import, and there are
many other Sass layout
libraries out there, Susy,
Bootstrap, Zen grids...
Compass can be
overkill
But usually is a timesaver.
● Calculates ems for you with Vertical Rhythm.
● Generates sprites and all kinds of sprite-related
goodies.
● Allows you to do all kinds of things that would normally
require many lines of CSS to be cross-browser
compatible.
● All kinds of fun stuff that is tedious to do by hand.
Nesting
is the best thing
ever, right?
.block {
h2.title {
color: MediumSeaGreen;
}
}
Only logged in users
actually wanted to see
this colour and only in
the content region...
.logged-in {
#content {
.block {
h2.title {
color: MediumSeaGreen;
}
}
}
}
Wait, the
sidebar should
be different!
.logged-in {
#content {
.block {
h2.title {
color: MediumSeaGreen;
}
}
.sidebar-second {
.block {
h2.title {
color: LightGoldenRodYellow;
}
}
}
}
}
Communications
department has a
special announcement,
they want a special
block style to highlight
it.
.logged-in {
#content {
.block {
h2.title {
color: MediumSeaGreen;
}
}
.sidebar-second {
.block {
h2.title {
color: LightGoldenRodYellow;
}
&#my-special-block {
h2.title {
color: YouGottaBeKiddingMe;
}
}
}
}
}
}
Poor kitty. :’(
.logged-in {
#content {
.block h2.title {
color: MediumSeaGreen;
}
.sidebar-second {
.block {
h2.title {
color: LightGoldenRodYellow;
}
&#my-special-block {
h2.title {
color: YouGottaBeKiddingMe;
}}}}}} /* This is called saving space */
.logged-in #content .block h2.title { color: MediumSeaGreen; }
.logged-in #content .sidebar-second .block h2.title { color: LightGoldenRod
.logged-in #content .sidebar-second .block#my-special-block h2.title { colo
Override this, I dare you.
.node-type-key-topics #main #content .panel-pane.pane-key-topics-portfolio-panel-
pane-2 .view-key-topics-portfolio > .view-content li.views-row > div {
}
Real life example. Love the ability to nest selectors in SASS/LESS, but remember that nesting isn’t
always necessary. If you don’t need to nest to achieve a certain level of specificity, don’t do it.
Rule of thumb: Nest no more than 3-4 levels deep!
http://www.creativebloq.com/css3/avoid-css-mistakes-10135080 - For all the insights on everything
everyone is doing wrong.
padding: 0;padding: 0 $base_unit
!important;
There, I did it. Neener, neener.
Other Pitfalls
● !important
● Over-specificity
● #id selectors - Not cool! Practically
impossible to override and slower
performance.
Please keep your module CSS non-
specific. Overspecify, and I would rather
write my own module than use yours.
SMACSS
● Scalable and
● Modular
● Architecture for
● Cascading
● Style
● Sheets
https://smacss.com/
Why?
● Organization
● Working with individual, repeatable
components, rather than whole-page
mentality
● Less nesting
● Fewer unnecessary overrides
● BEM - Easier to tell what a component is doing from
name alone
● Styleguide-driven development
Sass structure
● Base - Resets, defaults, variables, mixins, no classes or ids!
● Layout - Set it and forget it. No styles!
● Module (Component) - Individual and repeatable separate pieces of your
site (e.g. .button)
o Block
o Element
o Modifier
● State - hover and other contextual issues
● Theme (Skin) - Things specific to your theme, independant of
components, etc.
BEM Naming
Conventions
.cat { // Block: A cat. }
.cat__fur { // Element: Fur is an element “in” the cat. }
.cat__box { // Element: Box is a wrapper around the cat. }
.cat--fetish { // Modifier: Fetish is a specific cat. }
.cat--fetish.is-purring { // State: Fetish the cat is purring. }
.living-room .cat { // Theme: A cat in the living room. }
Styleguide driven development
New to front-end development?
“Here’s a secret: No one
else really knows what
they’re doing either.”
Nicholas Gallagher, 2013
(stolen from John Albin)
Further reading/watching/tools
● http://styleguides.io/
● Styleguide driven
development -
https://www.youtube.com/wat
ch?v=0ulC_UiObS0
● http://bourbon.io
Drupal 8 themes with SASS, SMACSS and kittens

Weitere ähnliche Inhalte

Kürzlich hochgeladen

VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceEscorts Call Girls
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdfMatthew Sinclair
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查ydyuyu
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdfMatthew Sinclair
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...nilamkumrai
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...Escorts Call Girls
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...SUHANI PANDEY
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceDelhi Call girls
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)Delhi Call girls
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...SUHANI PANDEY
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.soniya singh
 

Kürzlich hochgeladen (20)

VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
 

Empfohlen

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Empfohlen (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Drupal 8 themes with SASS, SMACSS and kittens

  • 1. Drupal 8 Themes with SASS and SMACSS (and kittens)
  • 2.
  • 4.
  • 5. Liisa, The CSS Nazi Senior Software Developer, Super- hyper Drupal Girl @Tieto d.org: lduerig Twitter: @LisKit7
  • 6. About Tieto Tieto is the largest Nordic IT services provider, offering full life-cycle services, mainly focusing in: ● Financial services ● Manufacturing, Retail and Logistics ● Public, Healthcare and Welfare ● Telecom, Media and Energy
  • 7. Not part of the scope of this presentation, but ask if you want to know more. May be good for a later presentation. =
  • 8. Old school. ● media queries / breakpoints ● sprites ● fixed gutter width ● fixed sprite width Unmaintainable, manual labour and prone to inconsistencies.
  • 9. SASS - CSS with Superpowers $variable + @mixin + @extend == less copy/paste == consistant == AWESOME! (Be careful with @extends. And nesting fever. (Later))
  • 10. What about Drupal? ● Can’t modules handle this? o Yes, but if you know enough code to be writing SCSS, you probably shouldn’t need a module for it. ● How does this work with Drupal dev? o Perfectly. Separately.
  • 11. Setup ● Ruby ● Sass ● Compass ● Breakpoint ● Bundler, for version management
  • 12. Ruby config.rb ● Environment (minification) ● Firesass ● Resources ● Compass plugins ● Import external stuff ● SASS options
  • 13. Bundler Gemfile Useful if you are working on a pre-existing setup, and need specific versions of things.
  • 14. Variables? Awesome! Use for: ● breakpoints ● measurements ● font-sizes ● font-families ● … anything that you use often or should have a default. Benefits: ● Consistent CSS. ● Easy to make site-wide changes. ● No need to sift through code if a breakpoint or font-size should be changed. ● No need to remember what these default values are.
  • 15. Best practices ● Keep most site-wide variables in a partial _variables.scss, within your SMACSS “base” directory. ● Use these variables in other partials, don’t mix up static styles with variables! o Every time I find font-size: 10px an SCSS partial, God kills a kitten and I have nightmares. ● Vertical measurement variables and font-sizes should be ems and calculated with Compass vertical-rhythm library. ● Horizontal measurement variables can be set however you want, perhaps using multiples of a $base-unit-pixels. Be consistent.
  • 16. SASS @mixins Use mixins for bits of code that you use frequently in your SCSS. This little mixin makes it very easy to whip up media queries on-the-fly.
  • 17. And then the mixin grew up and realized life wasn’t so simple.
  • 18. Don’t re-invent the wheel. SASS libraries have a lot of awesome functions and mixins to do this stuff for you.
  • 21. How about that obnoxious sprite?
  • 22. Compass - Sprites Files: images/my-icons/new.png images/my-icons/edit.png images/my-icons/save.png images/my-icons/delete.png SCSS: @import "compass/utilities/sprites"; @import "my-icons/*.png"; @include all-my-icons-sprites; Generated CSS: .my-icons-sprite, .my-icons-delete, .my-icons-edit, .my-icons-new, .my-icons-save { background: url('/images/my-icons- s34fe0604ab.png') no-repeat; } .my-icons-delete { background-position: 0 0; } .my-icons-edit { background-position: 0 -32px; } .my-icons-new { background-position: 0 -64px; } .my-icons-save { background-position: 0 -96px; }
  • 23. Compass - Sprites ● Configuration options per sprite or sprite-map ● Magic selectors ● Magic imports ● Sprite layouts ● Sass functions tutorial: http://compass-style.org/help/tutorials/spriting/
  • 24. Compass - Sprites We need: ● toggle menu icon for mobile ● fixed width and height ● list-items in the menu should be of equal height ● More control, no extra classes SCSS Generated CSS
  • 25. Compass - Sprites That’s extra lines of code, what’s the point? ● I am not wasting my time fiddling around with a sprite. ● I don’t care how many pixels a particular image is offset in the sprite. ● I don’t care what size the image is. ● My designers don’t have to care about creating sprites or listen to me whine, either.
  • 26. What else can we do with Compass?
  • 27. Compass - CSS3 Which of these would you rather write? HINT!
  • 28. Compass - Links ● Hover Link – Underline a link when you hover over it. ● Link Colors – Easy assignment of colors to link states. ● Unstyled Link – Make a link appear like regular text.
  • 29. Compass - Lists ● Bullets – Mixins for managing list bullets. ● Horizontal List – Float a list so it appears horizontally. ● Inline-Block List – set list-elements to inline-block so they appear horizontally while retaining their structure. ● Inline List – Style a list as inline text.
  • 30. Compass - Text ● Ellipsis – Text truncation with ellipsis. ● Force Wrap – Wrap URLs and long lines of text. ● No Wrap – Remembering whether or not there's a hyphen in white- space is too hard. ● Text Replacement – Replace text with images.
  • 31. Compass - Typography Vertical Rhythm A massive pile of variables, constants, functions and mixins to help create and manage vertical rhythm on your site. This stuff is AWESOME, check it out.
  • 32. Compass also has it’s own layout import, and there are many other Sass layout libraries out there, Susy, Bootstrap, Zen grids...
  • 34.
  • 35. But usually is a timesaver. ● Calculates ems for you with Vertical Rhythm. ● Generates sprites and all kinds of sprite-related goodies. ● Allows you to do all kinds of things that would normally require many lines of CSS to be cross-browser compatible. ● All kinds of fun stuff that is tedious to do by hand.
  • 36. Nesting is the best thing ever, right? .block { h2.title { color: MediumSeaGreen; } }
  • 37. Only logged in users actually wanted to see this colour and only in the content region... .logged-in { #content { .block { h2.title { color: MediumSeaGreen; } } } }
  • 38. Wait, the sidebar should be different! .logged-in { #content { .block { h2.title { color: MediumSeaGreen; } } .sidebar-second { .block { h2.title { color: LightGoldenRodYellow; } } } } }
  • 39. Communications department has a special announcement, they want a special block style to highlight it. .logged-in { #content { .block { h2.title { color: MediumSeaGreen; } } .sidebar-second { .block { h2.title { color: LightGoldenRodYellow; } &#my-special-block { h2.title { color: YouGottaBeKiddingMe; } } } } } }
  • 40. Poor kitty. :’( .logged-in { #content { .block h2.title { color: MediumSeaGreen; } .sidebar-second { .block { h2.title { color: LightGoldenRodYellow; } &#my-special-block { h2.title { color: YouGottaBeKiddingMe; }}}}}} /* This is called saving space */ .logged-in #content .block h2.title { color: MediumSeaGreen; } .logged-in #content .sidebar-second .block h2.title { color: LightGoldenRod .logged-in #content .sidebar-second .block#my-special-block h2.title { colo
  • 41. Override this, I dare you. .node-type-key-topics #main #content .panel-pane.pane-key-topics-portfolio-panel- pane-2 .view-key-topics-portfolio > .view-content li.views-row > div { } Real life example. Love the ability to nest selectors in SASS/LESS, but remember that nesting isn’t always necessary. If you don’t need to nest to achieve a certain level of specificity, don’t do it. Rule of thumb: Nest no more than 3-4 levels deep! http://www.creativebloq.com/css3/avoid-css-mistakes-10135080 - For all the insights on everything everyone is doing wrong. padding: 0;padding: 0 $base_unit !important; There, I did it. Neener, neener.
  • 42. Other Pitfalls ● !important ● Over-specificity ● #id selectors - Not cool! Practically impossible to override and slower performance. Please keep your module CSS non- specific. Overspecify, and I would rather write my own module than use yours.
  • 43. SMACSS ● Scalable and ● Modular ● Architecture for ● Cascading ● Style ● Sheets https://smacss.com/
  • 44. Why? ● Organization ● Working with individual, repeatable components, rather than whole-page mentality ● Less nesting ● Fewer unnecessary overrides ● BEM - Easier to tell what a component is doing from name alone ● Styleguide-driven development
  • 45. Sass structure ● Base - Resets, defaults, variables, mixins, no classes or ids! ● Layout - Set it and forget it. No styles! ● Module (Component) - Individual and repeatable separate pieces of your site (e.g. .button) o Block o Element o Modifier ● State - hover and other contextual issues ● Theme (Skin) - Things specific to your theme, independant of components, etc.
  • 46. BEM Naming Conventions .cat { // Block: A cat. } .cat__fur { // Element: Fur is an element “in” the cat. } .cat__box { // Element: Box is a wrapper around the cat. } .cat--fetish { // Modifier: Fetish is a specific cat. } .cat--fetish.is-purring { // State: Fetish the cat is purring. } .living-room .cat { // Theme: A cat in the living room. }
  • 48. New to front-end development? “Here’s a secret: No one else really knows what they’re doing either.” Nicholas Gallagher, 2013 (stolen from John Albin)
  • 49. Further reading/watching/tools ● http://styleguides.io/ ● Styleguide driven development - https://www.youtube.com/wat ch?v=0ulC_UiObS0 ● http://bourbon.io