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
The Future of Reusable CSS
Search
Glen Maddern
September 01, 2016
Technology
2
200
The Future of Reusable CSS
Presented at Coldfront Conf 2016 <3
Glen Maddern
September 01, 2016
Tweet
Share
More Decks by Glen Maddern
See All by Glen Maddern
The Road to Styled Components & the Road Ahead
geelen
2
230
The Road to Styled Components
geelen
2
1.2k
Styled Components and the Road to Unification
geelen
2
280
CSS Modules, CSS Variables and the Future of Reusable CSS
geelen
9
1.2k
Other Decks in Technology
See All in Technology
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
3
2.3k
Jetpack Composeで始めるServer Cache State
ogaclejapan
2
170
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
130
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
0
180
Wantedly での Datadog 活用事例
bgpat
1
440
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
540
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
8
6.9k
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
260
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
530
宇宙ベンチャーにおける最近の情シス取り組みについて
axelmizu
0
110
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
150
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
How to Ace a Technical Interview
jacobian
276
23k
Being A Developer After 40
akosma
87
590k
Embracing the Ebb and Flow
colly
84
4.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
The Cost Of JavaScript in 2023
addyosmani
45
7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Gamification - CAS2011
davidbonilla
80
5.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Thoughts on Productivity
jonyablonski
67
4.4k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Transcript
Reusable CSS THE FUTURE OF @glenmaddern
HELLO copeNhagen! ♥
@glenmaddern
@glenmaddern "
@glenmaddern
@glenmaddern front end C E N T E R https://frontend.center
@glenmaddern
@glenmaddern 2015 WHAT MAKES CSS SO HARD TO MAINTAIN?
@glenmaddern demonic CSS
None
@glenmaddern ✅ COMPLICATED SELECTORS CSS ✅ OVERRIDE-HEAVY ✅ NO ISOLATION
✅ !IMPORTANT ✅ END OF FILE ONLY
@glenmaddern
@glenmaddern https:/ /github.com/css-modules/css-modules
@glenmaddern IDEAS TECHNIQUES ✏ TECHNOLOGY
@glenmaddern .selector > header > span {} .foo.bar.baz {} p
{} ❌ .single-really-long-classnames {} ✅
@glenmaddern ✏ .Block {} .Block__Element {} .Block__Element--modifier https:/ /bem.info
@glenmaddern .block {} .element {} .modifier {} https:/ /github.com/css-modules/css-modules
@glenmaddern
@glenmaddern
@glenmaddern 2016 WHAT MAKES CSS SO HARD TO REUSE?
@glenmaddern import something from 'somewhere' something.leftPad()
@glenmaddern THE HUMAN BRAIN IS A (IN)CONSISTENCY-DETECTING MACHINE
@glenmaddern http://semantic-ui.com
@glenmaddern http://semantic-ui.com
@glenmaddern http://semantic-ui.com
@glenmaddern http://www.novolume.co.uk/blog/all-websites-look-the-same/
@glenmaddern SETTINGS.SCSS
@glenmaddern https://en.wikipedia.org/wiki/Margaret_Hamilton_(scientist)
@glenmaddern http://semantic-ui.com
@glenmaddern IDEAS TECHNIQUES ✏ TECHNOLOGY
@glenmaddern css v ari able s
@glenmaddern CSS CUSTOM PROPERTIES CSS VARIABLES =
@glenmaddern http://caniuse.com/#feat=css-variables
@glenmaddern
@glenmaddern re sponsive component s
@glenmaddern DEATH TO PIXEL PERFECTION
@glenmaddern YOUR COMPONENTS SHOULD DEMAND LESS & RESPOND MORE
@glenmaddern A COMPONENT SHOULD RESPOND TO ITS ENVIRONMENT • •
RATHER THAN THE ENVIRONMENT OVERRIDING THE COMPONENT
@glenmaddern LAYOUT COMPONENTS ✏
@glenmaddern PADDING MARGIN SIZE
@glenmaddern .component { width: 50%; margin-top: 2rem; flex-grow: 1; }
❌
@glenmaddern .parent { display: flex; padding: 1rem; } .parent >
* { flex-grow: 1; } ONE ONE TWO ONE TWO THREE
@glenmaddern .parent { display: flex; padding: 1rem; } .parent >
* { flex-grow: 1; } .parent > * + * { margin-left: 1rem; } ONE ONE TWO ONE TWO THREE
@glenmaddern .parent { display: flex; padding: 1rem; } .parent >
* { flex-grow: 1; } .parent > * + * { margin-left: 1rem; } .parent > :first-child { flex: 0 0 50%; } ONE TWO ONE TWO THREE ONE TWO THREE FOUR
@glenmaddern CONTEXTUAL COMPONENTS ✏
@glenmaddern DEMO: CURRENTCOLOR
@glenmaddern https://www.youtube.com/watch?v=jPOBVaomzLE
@glenmaddern .component { --size: 2rem; width: calc(2 * var(--size)); height:
var(--size); } .component
@glenmaddern .component { --size: var(--spacing, 2rem); width: calc(2 * var(--size));
height: var(--size); } .component .container .component .container { --spacing: 1rem; }
@glenmaddern .component { --size: var(--spacing, 2rem); width: calc(2 * var(--size));
height: var(--size); } .component .component.large .large { --spacing: 4rem; /* or */ --size: 4rem; }
@glenmaddern .component { background: var(--bg, black); color: var(--fg, white); }
@glenmaddern .component { background: var(--bg, black); color: var(--fg, white); }
(bg, fg) => <Component style.../>
@glenmaddern DEMO: INVERTED BUTTON
@glenmaddern INHERITANCE THE CASCADE vs
@glenmaddern NAMING MISMATCHES?
@glenmaddern .container .container { --grid-size: 1rem; } .component .component .component
{ --size: var(--spacing, 2rem); width: calc(2 * var(--size)); height: var(--size); }
@glenmaddern .component .container .component.fix .container { --grid-size: 1rem; } .fix
{ --spacing: var(--grid-size); } .component { --size: var(--spacing, 2rem); width: calc(2 * var(--size)); height: var(--size); }
@glenmaddern EXPLICIT COMPONENTS ✏
@glenmaddern http://semantic-ui.com/elements/button.html
@glenmaddern http://jxnblk.com/rebass/#Button
@glenmaddern DEMO: DOCUMENTATION
@glenmaddern OPEN COMPONENTS ✏
@glenmaddern import styles from './MediaObject.css' const MediaObject = ({ title,
image, text }) => ( <div className={styles.outer}> <img className={styles.img} src={ image }/> <div className={styles.inner}> <h1 className={styles.h1}>{ title }</h1> <p className={styles.p}>{ text }</p> </div> </div> )
@glenmaddern import styles from './MediaObject.css' const MediaObject = ({ title,
image, text, theme=styles })=>( <div className={theme.outer}> <img className={theme.img} src={ image }/> <div className={theme.inner}> <h1 className={theme.h1}>{ title }</h1> <p className={theme.p}>{ text }</p> </div> </div> ) https://github.com/css-modules/css-modules/issues/147
@glenmaddern DEMO: INTERNAL STRUCTURE DOCS
@glenmaddern re sponsive component s
@glenmaddern ✏ KEEP LAYOUT SEPARATE ✏ RESPOND TO CONTEXT ✏
DOCUMENT ASSUMPTIONS ✏ OPEN FOR MODIFICATION
@glenmaddern t hank you! @glenmaddern