Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Sass Basics #2
Search
jina
April 22, 2014
Design
1
180
Sass Basics #2
A beginner-level presentation I gave internally at work to teach the basics of Sass.
jina
April 22, 2014
Tweet
Share
More Decks by jina
See All by jina
Design Systems are for People
jina
1
940
Design Tokens in Design Systems
jina
9
28k
Designing a Design System
jina
34
7.4k
Living Design Systems
jina
42
2.4M
Lightning Design System
jina
6
650
Sass & Style Guides
jina
11
480
Designing for Enterprise
jina
4
200
Refactoring Web Interfaces
jina
20
990
In Search of the Single Source of Truth
jina
1
380
Other Decks in Design
See All in Design
AIの実践とコミュニケーションデザインの意義 / AI practice and the significance of communication design
bebe
0
680
アクセシビリティに取り組むメリット
magi1125
1
210
“ブロック”で作る、WordPress制作フロー変革のすすめ
koots2021
4
1.9k
ブランドパーソナリティ言語化における生成AI活用の実際
h0sa
0
190
UXデザインはなぜ定着しないのか?
designstudiopartners
0
780
minpaku-community-scrum-patterns
norinity1103
1
170
Light My Fire/ハートに火をつけるコミュニティ
kgsi
1
140
無自覚なランクとその影響を紐解くワークショップ / Unpacking Unconscious Privilege Workshop
spring_aki
4
320
UXとUIの違いを自分の言葉で表現する: UX DAYS TOKYO
mizunashi_mana
0
200
AI時代に淘汰されないデザインのしごと
akinen
1
150
Marpで推しCSSスライドを作ろう! / marp-with-favorite-css
fujiemon
0
380
Storyboard Honey
rocioparronrubio
0
290
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
246
12k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.6k
Code Reviewing Like a Champion
maltzj
524
40k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.5k
Music & Morning Musume
bryan
46
6.7k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Typedesign – Prime Four
hannesfritz
42
2.7k
Producing Creativity
orderedlist
PRO
346
40k
Transcript
JINA BOLTON SENIOR PRODUCT DESIGNER SALESFORCE UX Sass Basics #2
…PREVIOUSLY IN Sass Basics #1 INTRODUCTION TO SASS COMMENTING NESTING
VARIABLES
Sass Basics #2 INTRODUCTION TO MIXINS PASSING ARGUMENTS CONTENT BLOCKS
MIXIN LIBRARIES
SASSMEISTER.COM
CSS Output SCSS .thingy { background: #eee; color: #444; }
@mixin module { background: #eee; color: #444; } .thingy { @include module; }
Sass SCSS =module background: #eee color: #444 @mixin module {
background: #eee; color: #444; }
You can nest selectors in a mixin.
CSS Output SCSS .thingy { background: #eee; } .thingy .this
{ color: #444; } @mixin module { background: #eee; .this { color: #444; } } .thingy { @include module; }
You can include mixins outside of rules…
CSS Output SCSS .this { color: #444; } .that {
color: #444; } @mixin module { .this { color: #444; } .that { color: #ccc; } } @include module;
…unless you directly define properties or parent selectors.
CSS Output SCSS Invalid CSS after "...lor: #ccc; }} ":
expected "{", was "@include module;" @mixin module { color: #444; &.that { color: #ccc; } } @include module;
You can include other mixins in mixins.
CSS Output SCSS .thingy { background: #222; color: #ccc; }
.thingy a { color: #fff; } @mixin dark-theme { background: #222; color: #ccc; } @mixin module { @include dark-theme; a { color: #fff; } } .thingy { @include module; }
You can pass in arguments.
CSS Output SCSS .thingy1 { background: #eee; color: #444; }
.thingy2 { background: #eee; color: purple; } .thingy3 { background: green; color: red; } .thingy4 { background: blue; color: #444; } @mixin module($text: #444, $background: #eee) { background: $background; color: $text; } .thingy1 { @include module; } .thingy2 { @include module(purple); } .thingy3 { @include module(red, green); } .thingy4 { @include module($background: blue); }
You can pass in content blocks.
CSS Output SCSS * html .thingy1 { display: inline; }
@mixin ie6-only { * html { @content; } } @include ie6-only { .thingy1 { display: inline; } }
With great power, comes great responsibility ;-)
Every time you use a Mixin, you output that code
again.
SASS-LANG.COM
USE SASSMEISTER TO EXPERIMENT WITH MIXINS. BUILD A BASIC MIXIN
LIBRARY NEXT WEEK: EXTENDING & PLACEHOLDER SELECTORS your homework