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
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
3
220
Flutterによる 効率的なAndroid・iOS・Webアプリケーション開発の事例
recruitengineers
PRO
0
100
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
13k
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
Platform Engineering for Software Developers and Architects
syntasso
1
520
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.1k
The Role of Developer Relations in AI Product Success.
giftojabu1
0
130
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.6k
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.4k
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Code Review Best Practice
trishagee
64
17k
It's Worth the Effort
3n
183
27k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
We Have a Design System, Now What?
morganepeng
50
7.2k
RailsConf 2023
tenderlove
29
900
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Typedesign – Prime Four
hannesfritz
40
2.4k
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