actually, he’s always trying his best
Past Jack
Present Jack
Future Jack
Slide 94
Past Jack
Slide 95
remember, there is no such thing as a bad decision, only a decision made with less data then you have now. Past Jack
Slide 96
remember, there is no such thing as a bad decision, only a decision made with less data then you have now. Past Jack
so great job, past Jack!
Slide 97
Past Jack
Present Jack
Future Jack
Slide 98
“
Past Jack
what can I learn from Past Jack?
Present Jack
Future Jack
Slide 99
“
what can I learn from Past Jack?
Present Jack
Past Jack
“
that will make Future Jack’s life easier?
Future Jack
Slide 100
this does not work well!
<thread-item product-id=”1234” include-brandname show-old-pricesale no-sentiment ></thread-item>
Slide 101
e h t
u s p e e r c w a s e e s
u o y n o p
Slide 102
You will constantly trade off maintainability and configurability This is one of the hardest things to get right consistently
Slide 103
“Feed”
“Full”
m o C ”
” t c a p
Slide 104
“Feed”
“Full”
m o C ”
” t c a p
Slide 105
“Full”
“
e m “Feed” a s e h t y l r a e n m o C ”
” t c a p
Slide 106
allowing components to differ slightly when required
Slide 107
variants
Slide 108
Encode an allowed set of variants rather than individual options that can be toggled on or off.
export const variants = { FULL, COMPACT, FEED }
Slide 109
Users can explicitly pass in the variant they want.
<ItemCard variant={variants.COMPACT} />
Slide 110
always prefer explicit configuration over implicit options
Slide 111
breaking components down
Slide 112
components are cheap, but not free
Slide 113
Slide 114
£
maintaining the component
Slide 115
£
maintaining the component
£
complexity in the system
Slide 116
£
maintaining the component
£
complexity in the system
£
communication between components
Slide 117
£
maintaining the component
£
complexity in the system
£
communication between components
£
documentation
Slide 118
components should be small and you should have lots of them
Slide 119
and complexity
component size
When is a component ready to be split up?
time
Slide 120
and complexity
component size
When is a component ready to be split up?
time
Slide 121
and complexity
component size
When is a component ready to be split up?
time
Slide 122
and complexity
component size
When is a component ready to be split up?
time
Slide 123
?
Slide 124
?
How many lines of code is it?
Slide 125
?
How many lines of code is it? How many different HTML elements does this component render?
Slide 126
?
How many lines of code is it? How many different HTML elements does this component render? How “hard” is this component to understand?
Slide 127
?
How many lines of code is it? How many different HTML elements does this component render? How “hard” is this component to understand? Is the component hard to name? Do I naturally want to put “and” in the name?
Slide 128
?
How many lines of code is it? How many different HTML elements does this component render? How “hard” is this component to understand?
c i r
Is the component hard to name? Do IdP n A ename? naturally want to put “and” in the m a N m e t I ♂
e
Slide 129
there are no hard rules here find a set of guidelines that you’re comfortable with
Slide 130
breaking the black box abstraction
Slide 131
could you pick up a component and drop it into a new project with no additional work or setup?
Slide 132
not all of your components can or should be black boxes
Slide 133
Slide 134
“
an yo hel ne lo th …is er e?
Slide 135
Your app’s data
Your app’s components
Slide 136
Your app’s data
Your app’s components
Slide 137
Your app’s data
Your app’s components
Slide 138
Your app’s data
Your app’s components
Slide 139
how do we give a component data?
Slide 140
1 fetching from an API 2 via attributes passed in HTML 3 via data in script tags
Slide 141
1 fetching from an API 1. Component renders loading spinner 2. Make request to /api to fetch JSON 3. Parse response 4. Render data onto page
Slide 142
1 fetching from an API ✅1.Component the most up to date data Componentalways rendershas loading spinner 2.Easy Maketorequest tothe /apidata to fetch ✅ re-fetch later.JSON 3. Parse response ❌Have to handle error state 4. Render data onto page ❌JS dependency on showing the user anything
Slide 143
2
via attributes passed in HTML
Slide 144
2
via attributes passed in HTML
✅ no API required to fetch data ✅ no error state ❌long strings in HTML ❌data might be out of date by the time it’s rendered
Slide 145
3 via data in script tags
Slide 146
3 via data in script tags ✅ useful for data that’s global across your system ❌can get outdated ❌user could change this data - so be careful what you use it for!
Slide 147
1 fetching from an API 2 via attributes passed in HTML 3 via data in script tags
Slide 148
the path to components in your application
Slide 149
2 years ago jQuery, jQuery and more jQuery Server side templates with Django No true component system in place
Today ~100 components across the site Reusable components make it easier for others to contribute Starting to form a Thread design system to improve consistency We’ve never stopped shipping features.
Slide 150
Slide 151
software migrations
Slide 152
value added
ground up rewrite
time to reach feature parity
time
ew n g n i d uil b nd a d e p p shi
es r u t fea
Slide 153
value added
ground up incremental rewrite rebuild with new features time
Slide 154
value added
ground up incremental rewrite rebuild with new features time
Slide 155
value added
ground up incremental rewrite rebuild with new features
slower at first as you build tools to bridge the legacy gap, but quickly you’re shipping and adding value
time
Slide 156
incremental rebuilds let you test assumptions
Slide 157
Slide 158
Slide 159
?
Slide 160
how we adopted CSS Modules at Thread
Slide 161
hey, I think we should try CSS Modules at Thread because…
Slide 162
sounds great to me, let’s give it a go on the next component we build!
Slide 163
Slide 164
Regular CSS, global styles, trying to name things uniquely
Slide 165
Regular CSS, global styles, trying to name things uniquely
Slide 166
Regular CSS, global styles, trying to name things uniquely
CSS Modules
Slide 167
WE DISLIKE IT Replace the CSS Modules component with our usual solution. We learned a bunch and reversed out easily.
Slide 168
WE DISLIKE IT
WE LIKE IT!
Replace the CSS Modules component with our usual solution. We learned a bunch and reversed out easily.
Decide on next step: enforce that every component uses CSS Modules from now on decide to experiment or figure out how to answer any more concerns that we have.
Slide 169
Yes, all your components should be built using the same technology. But don’t let ideals get in the way of experimenting and trying something new. A failed experiment is a great chance to learn.
Slide 170
It’s easy to get bogged down comparing and debating different frameworks, libraries, and approaches It’s quicker to just try it.
Slide 171
Thank You
javascriptplayground.com
fishandscripts.com @fishandscripts
@Jack_Franklin
Slide 172
Slide 173
<div>Icons made by <a href=”https://www.flaticon.com/authors/freepik ” title=”Freepik”>Freepik</a> from <a href=”https://www.flaticon.com/” title=”Flaticon”>www.flaticon.com</a></div>