Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Adaptation and Components
Search
Nicolas Gallagher
April 09, 2014
Programming
6
1.3k
Adaptation and Components
About adaptable systems and the benefits of the component abstraction when building web UI's.
Nicolas Gallagher
April 09, 2014
Tweet
Share
More Decks by Nicolas Gallagher
See All by Nicolas Gallagher
React Native for web and beyond
necolas
5
970
Thinking beyond "Scalable CSS"
necolas
14
6.9k
Making Twitter UI Infrastructure
necolas
14
4k
CSS Application Architecture
necolas
15
560
HTML5 Boilerplate: past, present, and future
necolas
4
250
The purification of web development
necolas
5
430
Other Decks in Programming
See All in Programming
HTTP compression in PHP and Symfony apps
dunglas
2
1.1k
TypeScript でバックもやるって実際どう? 実運用で困ったこと3選
yuichiro_serita
17
7.5k
cmp.Or に感動した
otakakot
3
340
Reckoner における Datadog Browser Test の活用事例 / Datadog Browser Test at Reckoner
nomadblacky
0
190
MoQとか勉強会#2 発表資料
yuki_uchida
2
140
Cursorでアプリケーションの追加開発や保守をどこまでできるか試したら得るものが多かった話
drumnistnakano
0
260
事業成長を爆速で進めてきたプロダクトエンジニアたちの成功談・失敗談
nealle
3
1.1k
React CompilerとFine Grained Reactivityと宣言的UIのこれから / The next chapter of declarative UI
ssssota
7
3.2k
新卒研修で作ったアプリのご紹介
mkryo
0
230
14 Years of iOS: Lessons and Key Points
seyfoyun
0
460
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
150
[FlutterKaigi2024] Effective Form 〜Flutterによる複雑なフォーム開発の実践〜
chocoyama
1
3.9k
Featured
See All Featured
The Invisible Side of Design
smashingmag
298
50k
Fireside Chat
paigeccino
34
3.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
A better future with KSS
kneath
238
17k
Bash Introduction
62gerente
608
210k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
240
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Transcript
Adaptation and Components @necolas
“Adaption” vs “Change”
“Adaptable” vs “Adaptive”
Adaptable systems
2013 App 2014 App 2012 App
The ability to adapt-in-time is business-critical
Complexity affects the ability to adapt
Technology type as an organising principle
HTML A B C D ... CSS A B C
D ... JS A B C D ... UNIT A B C D ... ... A B C D ...
HTML A B C D ... CSS A B C
D ... JS A B C D ... UNIT A B C D ... ... A B C D ...
HTML AD B CD D ... CSS A AB C
D ... JS A B C D ... UNIT A B C D ... ... A B AC D ...
Leaky abstractions increase complexity
<article class="user"> <div class="avatar"> <img class="avatar-img" ...> <div class="tooltip hidden">...</div>
</div> <button class="btn btn-follow"> <span class="btn-icon"> <span class="icn icn-follow"></span> </span> <span class= "btn-text">...</span> </button> </article>
<article class="user"> <button class="btn btn-follow"> <span class="btn-icon"> <span class="icn icn-follow"></span>
</span> <span class= "btn-text">...</span> </button> </article> <div class="avatar"> <img class="avatar-img" ...> <div class="tooltip hidden">...</div> </div>
<article class="user"> <button class="btn btn-follow"> <span class="btn-icon"> <span class="icn icn-follow"></span>
</span> <span class= "btn-text">...</span> </button> </article> <div class="avatar"> <img class="user-img avatar-img" ...> <div class="tooltip hidden">...</div> </div>
/* avatar */ .avatar { } /* tweet */ .tweet
{ } .tweet .avatar { } .tweet .text {} /* user card */ .user { } .user .avatar { }
Modularity is not enough
Components as the primary unit of scale
A HTML CSS JS UNIT ...
A HTML CSS JS UNIT ... B HTML CSS JS
UNIT ...
A HTML CSS JS UNIT ... B HTML CSS JS
UNIT ... C HTML CSS JS UNIT ...
A HTML CSS JS UNIT ... B HTML CSS JS
UNIT ... C HTML CSS JS UNIT ... D HTML CSS JS UNIT ...
A HTML CSS JS UNIT ... B HTML CSS JS
UNIT ... C HTML CSS JS UNIT ... D HTML CSS JS UNIT ... ... HTML CSS JS UNIT ...
Components are simple
Components are composable & configurable
Reduces emergent complexity
Adaptable over reusable
facebook.github.io/react Defining components with React
/** @jsx React.DOM */ var Photo = React.createClass({ render: function
() { return ( <img src={this.props.src} /> ); } });
<Photo src="photo.jpg"> </Photo>
<figure className={'photo' + this.props.size}> <span className={'crop' + this.props.crop}> <img className="img"
src={this.props.src} alt= "" /> </span> <figcaption className="caption"> {this.props.children} </figcaption> </figure>
<Photo src="photo.jpg" size="large" crop="circle"> Half-Dome in Yosemite National Park <Attribution
owner="necolas" /> </Photo>
suitcss.github.io Styling components with SUIT CSS
<figure className={'photo' + this.props.size}> <span className={'crop' + this.props.crop}> <img className="img"
src={this.props.src} alt= "" /> </span> <figcaption className="caption"> {this.props.children} </figcaption> </figure>
<figure className={'photo' + this.props.size}> <span className={'crop' + this.props.crop}> <img className="img"
src={this.props.src} alt="" /> </span> <figcaption className="caption"> {this.props.children} </figcaption> </figure>
<figure className={'Photo Photo--' + this.props.size}> <span className={'Photo-crop Photo-crop--' + this.props.crop}>
<img className="Photo-img" src={this.props.src} alt="" /> </span> <figcaption className="Photo-caption u-textBreak"> {this.props.children} </figcaption> </figure>
/** @define Photo */ .Photo {} /* Component */ .Photo--large
{} /* Component modifier */ .Photo-crop {} /* Component descendent */ .Photo-crop--circle {} /* Descendent modifier */ .Photo-img {} .Photo-caption {}
<figure className={'Photo Photo--' + this.props.size}> <span className={'Photo-crop Photo-crop--' + this.props.crop}>
<img className="Photo-img" src={this.props.src} alt="" /> </span> <figcaption className="Photo-caption u-textBreak"> {this.props.children} </figcaption> </figure>
<figure className={'Photo Photo--' + this.props.size}> <span className={'Photo-crop Photo-crop--' + this.props.crop}>
<img className="Photo-img" src={this.props.src} alt="" /> </span> <figcaption className="Photo-caption u-textBreak"> {this.props.children} </figcaption> <Attribution owner={this.props.owner} /> </figure>
github.com/component/component Managing components with Component
A HTML CSS JS UNIT ... B HTML CSS JS
UNIT ... C HTML CSS JS UNIT ... D HTML CSS JS UNIT ... ... HTML CSS JS UNIT ...
A HTML CSS JS UNIT ...
A HTML CSS JS UNIT ... component.json
A HTML CSS JS UNIT ... component.json B
A HTML CSS JS UNIT ... component.json B C D
E F
{ "name": "tweet", "styles": [ "tweet.css" ], "scripts": [ "tweet.js"
], "dependencies": { "suitcss/utils": "0.8.0" }, "locals": [ "avatar", "inline-tweetbox", "tweet-actions" ] }
Building web UI is more than a CSS problem
The end @necolas