More Related Content Similar to React & Radium (Colin Megill) (20) More from Future Insights (20) React & Radium (Colin Megill) 2. I love D3.
var circle = svg.selectAll(‘circle’)
circle
.style({"padding", function (d) {
return d.foo === bar ? 5 : 10;
}})
3. Why is this possible?
padding: function(d) {
return d.foo === bar ? 5 : 10;
}
5. Why is this significant?
The UI is always a reflection of the data.
The styles are recomputed every time the
data changes.
6. Back to the beginning
<p style="padding: 10px">
who’s a kitty
</p>
7. Why did we stop doing this?
<p style=“padding: 10px”>
who’s a kitty
</p>
<p style="padding: 10px">
who’s a kitty
</p>
8. CSS to the rescue
If we wanted to change the look and feel of
the site, we would need to change it in all of
the .html files one at a time.
10. We like saying CSS is declarative
<p class="kitty">
who’s a kitty
</p>
.kitty {
padding: 10px;
}
<p class="kitty">
who’s a kitty
</p>
.kitty {
padding: 10px;
}
13. Backbone & jQuery to the rescue?
this.model.on('change', function()
{
if (this.model.foo === bar) {
$('#kitty').addClass('meow');
}
}
23. Wait, isn’t that why we started down this
path in the first place, shared code?
(globals aren’t good)
25. (variables, functions, etc.)
We even use Sass for static websites!
@import "normalize"; → require("normalize")
h1 { color: $light-blue; }; →
Think: Sass on the client
27. We still have modularization. It’s just going to
look different:
var buttonStyles = {
padding: 5,
margin: 10
}
Modularizing with objects
28. var button = require
("buttonStyles");
The end of globals
39. ❖ Diffing // Perf
❖ Composability
❖ Better mental model
❖ Server side rendering
❖ React native
❖ Stability
❖ Community
❖ Radium
Advantages