Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Reducing complexity with a Component API
Search
Ianfeather
April 25, 2014
0
200
Reducing complexity with a Component API
Ianfeather
April 25, 2014
Tweet
Share
More Decks by Ianfeather
See All by Ianfeather
Building Resilient Front End Systems (Smashingconf)
ianfeather
0
120
Building Resilient Frontend Systems (All Day Hey)
ianfeather
1
530
Building Resilient Frontend Systems (@frontendne)
ianfeather
1
200
Testing Without Assertions
ianfeather
0
140
Building Resilient Frontend Systems - NationJS
ianfeather
0
210
Establishing Performance Contexts
ianfeather
0
130
Web Fonts and Performance
ianfeather
0
230
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Documentation Writing (for coders)
carmenintech
76
5.2k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Speed Design
sergeychernyshev
33
1.4k
The World Runs on Bad Software
bkeepers
PRO
72
12k
How GitHub (no longer) Works
holman
316
140k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.1k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Transcript
Reducing Complexity with a Component API Ian Feather
Complexity
High risk, high fear
Intertwined
Low reuse
Technical debt
! Complexity at " ";
None
This time we’ll nail it
HTML CSS JS SHARED SPECIFIC HOTELS The rebuild
HTML CSS JS SHARED SPECIFIC High Reuse Low Reuse HOTELS
The rebuild
HTML CSS JS SHARED SPECIFIC High Reuse Strong Caching Low
Reuse Weak Caching HOTELS The rebuild
HTML CSS JS SHARED SPECIFIC High Reuse Strong Caching High
Risk Low Reuse Weak Caching Low Risk HOTELS The rebuild
HTML CSS JS SHARED SPECIFIC HOTELS PLACES SEARCH THEME High
Reuse Strong Caching
 High Risk Low Reuse Weak Caching
 Low Risk The rebuild
HTML CSS JS SHARED SPECIFIC HOTELS PLACES SEARCH THEME High
Reuse Strong Caching
 High Risk Low Reuse Weak Caching
 Low Risk The rebuild
HTML CSS JS SHARED SPECIFIC HOTELS PLACES SEARCH THEME High
Reuse Strong Caching
 High Risk Low Reuse Weak Caching
 Low Risk The rebuild
This model doesn’t favour
 the front end
We need a different
 solution
None
It should feel as easy as
 working on a small
site
A Style Guide would
 help, right?
/* Styleguide [Buttons] ! <button class=“btn-primary”>Button</button> <button class=“btn-secondary”>Button</button> ! */
! .btn—primary { background: blue; } ! .btn—secondary { background: red; }
None
A Style Guide isn’t
 the mechanism
We need to decouple our
 UI Layer from the application
Component Layer & API
What is a component?
Create an API to standardise
 fetching these components
None
= component(“form/search”, {
 label: search
 })

<form action="/search"> <label class="accessibility" for="search-q">Search</label> <input id="search-q" name="q" tabindex="1" type=“search"/>
<button name="search-q-submit" type="submit">Search</button> </form> = component(“form/search”, {
 label: search
 })

None
component(“input/search”, {
 label: search, autocomplete: true
 })
<form action="/search"> <label class="accessibility" for="search-q">Search</label> <input class="js-autocomplete" id="search-q" name=“q" />
<button name="search-q-submit" type="submit">Search</button>
 <div class="js-autocomplete-container"></div> </form> component(“input/search”, {
 label: search, autocomplete: true
 })
None
component("cards/collection_card", { 
 
 double?: true, slug: "/top-things-to-do—in-paris", title: "Top
things to do in Paris", image_url: "/assets/paris.jpg"
 })
None
None
SPECIFIC Low Risk
 Low Reuse HOTELS PLACES SEARCH THEME HTML
CSS JS SHARED High Risk High Reuse
SPECIFIC Low Risk
 Low Reuse HOTELS PLACES SEARCH THEME HTML
CSS JS SHARED High Risk High Reuse Low Risk
 High Reuse Component Layer & API
Rizzo ! Component Layer, API 
 & Style Guide
Our Style Guide can be just
 another data-driven application
A ready-made visual 
 regression test suite
Enables Style Guide 
 driven development
None
None
Why would you
 want to use a
 Component API?
You’ll have
 happier developers
You’ll have
 visual consistency
You’ll be able to
 refactor easily
You won’t have to
 tweak padding values
 (as much)
It can feel like working
 on a small site
Thank you @ianfeather
 
 http://rizzo.lonelyplanet.com