-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1087 lines (1020 loc) · 28.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Predictablity--or Why JSX & Inline Styles Win</title>
<meta name="description" content="A presentation on the benefits of using JSX & Inline Styles with React.">
<meta name="author" content="Jacob Gibbons">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>Predictability</h1>
<h3>or Why JSX & Inline Styles Win Over 'Seperation of Concerns' Dogma</h3>
<p>
<small>Presented by <a href="https://www.linkedin.com/in/jayseeg">Jake Gibbons</a> / <a href="https://twitter.com/jayseeg">@jayseeg</a></small>
</p>
<aside class="notes">
<ul>
<li>
Who here shouted that at twitter when they first saw JSX?
</li>
<li>
Perfect audience?
</li>
<li>
Seperation of concerns is why we put js in one folder,
</li>
<li>
styles in another,
</li>
<li>
and markup in another.
</li>
<li>
I think the main point of that was to get us to stop writing repetitive scripts & styles.
</li>
<li>
Instead we started reusing the scripts & styles.
</li>
<li>
That made our sites more DRY.
</li>
<li>
Now that we write modular components, we don't have to use the different folders & files abstraction.
</li>
<li>
Because reusable components are dry by nature.
</li>
<li>
Let me tell you why I say that.
</li>
</ul>
</aside>
</section>
<section>
<h2>Problem</h2>
<p>
It's difficult to predictably modify or style components in a <span class="fragment">React</span> web app.
</p>
<ul>
<li class="fragment">
Globals
</li>
<li class="fragment">
Sharing Values Across 'Concerns'
</li>
<li class="fragment">
The Cascade
</li>
<li class="fragment">
Dependencies
</li>
<li class="fragment">
Findability
</li>
<li class="fragment">
Readability
</li>
</ul>
<aside class="notes">
It's difficult to predictably modify or style components in a web app
Specifically a React app for the purposes of this presentation.
There are challenges surrounding: globals, sharing values across 'concerns', the cascade, dependencies, findability, and readability.
I'll go into each more indepth now.
</aside>
</section>
<section>
<section>
<h2>Globals</h2>
<p>
CSS Stylesheets Encourage Piles of Globals
</p>
<aside class="notes">
We all know that littering our app with globals in JS is a dangerous thing, but for some reason we think it's ok with CSS.
</aside>
</section>
<section>
<h2>Bootstrap, for Instance, Introduces 600 Globals</h2>
<br>
<p>
<small>Shamelessly stolen from <a href="http://blog.vjeux.com/2014/javascript/react-css-in-js-nationjs.html">Christopher Chedeau's presentation on inline styles</a>.</small>
</p>
<aside class="notes">
Each declaration is essentially a global variable being placed in the browser waiting for an element to grab it.
How many of you used to write JS this way?
How many still do?
</aside>
</section>
</section>
<section>
<section>
<h2>Sharing Values</h2>
<p>
Comment breadcrumbs are a pretty shoddy way of telling your future self where shared values are.
</p>
<p class="fragment">
What if filenames change?
</p>
<p class="fragment">
Or if some jerk doesn't update the comment when they move the shared code.
</p>
<aside class="notes">
There are times when you need to derive a value in js that will also be used in css.
If you're strategy here is to assign the value in each and leave a comment saying where it needs to be kept in sync, you've created an unpredictable brittle link for future you, or the next dev to hopefully respect.
</aside>
</section>
</section>
<section>
<section>
<h2>The Cascade</h2>
<p>
It's essentially a giant extend.
</p>
<aside class="notes">
Extends are great. We use them all the time in js. But if you have to mentally keep track of several extendedrules in your head, you'll probably fail.
</aside>
</section>
<section>
<p>
Extend is great in moderation,...
</p>
<p class="fragment">
But when you've got hundreds of rules overriding each each other you need to introduce complex naming conventions <span class="fragment">(BEM)</span> to manage them.
</p>
<aside class="notes">
Order of declaration is a pretty simple rule to follow, but when you're looking at thousands of lines, it's impossible to keep it in order in your head.
Standards like BEM are pretty great for combating this problem, but it feels like a pretty sloppy solution.
</aside>
</section>
</section>
<section>
<section>
<h2>Dependencies</h2>
<p>Serving async CSS is a potential nightmare.</p>
<aside class="notes">
You may want to only serve styles for what's on a page in a large Single Page App.
You could produce real performance gains this way.
</aside>
</section>
<section>
<h2>Async + The Cascade === Race Conditions</h2>
<p class="fragment">
That can span entire site visits.
</p>
</section>
<section>
<p>
If someone get's to your app from a page other than home, then goes home, what order do the CSS files from each visit get processed in?
</p>
<p class="fragment">
How do you debug/QA test for that?
</p>
<aside class="notes">
I don't know of a great solution for this, but I also haven't encountered this problem.
</aside>
</section>
</section>
<section>
<section>
<h2>Findability</h2>
<p>
It's simple to find things in your app, and you already have your own methods to handle it.
</p>
<aside class="notes">
This probably seems dumb because you've been dealing with this issue for so long you don't even notice it.
</aside>
</section>
<section>
<h2>One way</h2>
<p class="fragment">(of many)</p>
<ol>
<li class="fragment">
You look at a component in your browser to find identifiable text.
</li>
<li class="fragment">
Then you grep for that phrase in your templates.
</li>
<li class="fragment">
Then you grep in your view folder for a call for that previously found template file.
</li>
<li class="fragment">
And you can grep your style folder for all uses of any relevant classes from the template file.
</li>
<li class="fragment">
Then you look at each declaration to determine if it's specificity score qualifies for an override.
</li>
</ol>
<p class="fragment">
Simple!
</p>
<aside class="notes">
(read the slides)
</aside>
</section>
</section>
<section>
<section>
<h2>Readability</h2>
<p>JSX in JS looks like the apocalypse to most seperation of concerns dogmatists.</p>
<pre><code data-trim class="jsx">
const {
reportName,
filters,
} = state
if (!props.isOpen) return (<span></span>)
return (
<Modal
title='Reporting Chart Configuration'
backdrop={true}
animation={true}
container={props.container}
onRequestHide={props.hideHandler}
ref='reportSelectModal'
>
<div className='modal-body'>
<div className='control-group'>
<label>Source</label>
</div>
</div>
</Modal>
)
</code></pre>
<aside class="notes">
Most of us probably scoffed pretty hard when we first saw JSX.
I know I did.
</aside>
</section>
<section>
<h2>XML in JS?</h2>
<p>Wat? Why???</p>
<aside class="notes">
This goes against everything we've ever be taught,... right?
</aside>
</section>
<section>
<h2>Nested Function Calls</h2>
<p>
A series of nested function calls describing the DOM end up looking like a JS pyramid.
</p>
<pre><code data-trim class="es6">
function render() {
return React.createElement(
MyComponent,
null,
React.createElement(
"h1",
null,
"Hello World"
)
)
}
</code></pre>
<aside class="notes">
The alternative isn't terribly readable though.
</aside>
</section>
</section>
<section>
<h2>We've Gotten Pretty Good at All of That</h2>
<p class="fragment">
But there's a better way.
</p>
</section>
<section>
<section>
<h2>JSX</h2>
<p>
JSX is actually an XML like veneer that get's preprocessed into the function calls we're trying to avoid.
</p>
<aside class="notes">
JSX is the part of a react component that looks like someone just dumped XML in the middle of our beatiful work.
</aside>
</section>
<section>
<pre><code data-trim class="jsx">
render () {
return (
<MyComponent>
<h1>Hello World</h1>
</MyComponent>
)
}
</code></pre>
<div class="fragment">
<p>is sugar for</p>
<pre><code data-trim class="es6">
function render() {
return React.createElement(
MyComponent,
null,
React.createElement(
"h1",
null,
"Hello World"
)
)
}
</code></pre>
</div>
<aside class="notes">
We'll touch on this more in a second.
</aside>
</section>
</section>
<section>
<section>
<h2>Inline Styles</h2>
<p>
We all know how to write inline styles. You just add a style attribute to an HTML element.
</p>
<p class="fragment">
That declaration automatically takes precedence.
</p>
<aside class="notes">
This is an old, and frowned upon concept.
</aside>
</section>
<section>
<h2>Inline Styles in React</h2>
<p>
React encourages the use of inline styles by providing a parser which reads JS objects that have a very similar syntax to CSS.
</p>
<p class="fragment">
The differences are:
<ul>
<li class="fragment">
Keys are camelCased instead of dashed
<pre><code data-trim class="es6">
{ font-weight: 700; } => { fontWeight: 700 }
</code></pre>
</li>
<li class="fragment">
Values are quoted
<pre><code data-trim class="es6">
{ color: #F00; } => { color: '#F00' }
</code></pre>
</li>
<li class="fragment">
And single pixel values are numbers without the PX
<pre><code data-trim class="es6">
{ height: 175px; } => { height: 175 }
</code></pre>
</li>
</ul>
</p>
<aside class="notes">
React has cleaned up this concept and brought it back to life.
There are subtle differences between React's Styles and CSS's.
Keys are camelCased instead of dashed
Values are quoted
And single pixel values are numbers without the PX
</aside>
</section>
</section>
<section>
<section>
<h2>Globals</h2>
</section>
<section>
<h2>Use Existing Tools</h2>
<p>
Require/import are great ways to isolate & decouple in JS.
</p>
<p class="fragment">
They can be used for styles too.
</p>
<aside class="notes">
I'm assuming everyone here is familiar with the CommonJS pattern of requiring in modules.
Well, styles written in JS can freely be pulled in in the same way.
</aside>
</section>
<section>
<pre><code data-trim class="es6">
import MyComponentStyles from './MyComponentStyles.js'
import {
TypographyStyles,
LayoutStyles,
} from '../styles/BaseStyles.js'
</code></pre>
<aside class="notes">
There's no ambiguity here, the styles you are using can be quickly isolated down to a few SHORT files.
</aside>
</section>
</section>
<section>
<section>
<h2>Sharing Values</h2>
</section>
<section>
<h2>Sharing Values in JS is<br/>Dead Simple</h2>
<p class="fragment">
You declare a var (let, or const) and use it.
</p>
</section>
<section>
<pre><code data-trim>
let currentHeight = parseInt(window.innerHeight / 13, 10)
styles = extend(styles, {height: currentHeight})
</code></pre>
<aside class="notes">
I think this slide says it all.
</aside>
</section>
</section>
<section>
<section>
<h2>The Cascade</h2>
</section>
<section>
<h2>Declaritive Extends Make Overrides Obvious</h2>
<p class="fragment">
You simply look at order in a short list.
</p>
</section>
<section>
<pre><code data-trim class="es6">
const styles = extend(importedStyles, {
moreStyles: {
fontWeight: 100
}
}, {
moreStyles: {
fontWeight: 700
}
})
</code></pre>
<p class="fragment">
Font weight for styles.moreStyles will be 700.
</p>
<aside class="notes">
You can quickly tell which styles will take precedence based on the order you declared them.
</aside>
</section>
</section>
<section>
<section>
<h2>Dependencies</h2>
</section>
<section>
<h2>Inline Styles are Delivered with HTML</h2>
<p class="fragment">
And they have obvious specicifity—no calculations necessary.
</p>
<aside class="notes">
With inline styles, you just eliminate the problem by not relying on a seperate file.
</aside>
</section>
<section>
<pre><code data-trim class="html">
<div style="display: inline-block; width: 8px; height: 8px; bottom: 0px; margin-left: 0px; margin-right: 5px; border-radius: 99px; position: relative; transition: background-color 0.111s ease-in-out; background-color: rgb(132, 154, 61);" data-reactid=".0.$=11:0.$=10=21:0.$=11:0.1.1.$0.0.0.0"></div>
</code></pre>
</section>
</section>
<section>
<section>
<h2>Findability</h2>
</section>
<section>
<h2>Component Folders Contain Their Dependencies</h2>
<p class="fragment">
Want to find the styles for a component?
</p>
<ol>
<li class="fragment">
Open the ______Styles.js file in that component folder.
</li>
<li class="fragment">
Done.
</li>
<li class="fragment">
Go drink a beer.
</li>
</ol>
</section>
<section>
<img src="./img/folder.png" height="204" width="364" alt="">
<aside class="notes">
It doesn't get much easier than that to find files relevant to a component.
</aside>
</section>
</section>
<section>
<section>
<h2>Readability</h2>
</section>
<section>
<h2>JSX</h2>
<p class="fragment">
Even a designer could quickly tell what JSX's XML will translate too.
</p>
<pre><code data-trim class="jsx">
render () {
return (
<MyComponent>
<h1>Hello World</h1>
</MyComponent>
)
}
</code></pre>
<aside class="notes">
Maybe it's just me, but this maps really well to my mental models of html elements which is what we're emulating with the virtual dom.
</aside>
</section>
</section>
<section>
<h2>Complications</h2>
<aside class="notes">
<ul>
<li>
It's not all peaches n' cream
</li>
<li>
This approach eliminates the problems we went through
</li>
<li>
But it introduces some complications & tradeoffs
</li>
</ul>
</aside>
</section>
<section>
<section>
<h2>Clutter</h2>
<p class="fragment">
Components don't stay simple.
</p>
<p class="fragment">
Complexity can lead to cluttered component code.
</p>
<aside class="notes">
<ul>
<li>
</li>
</ul>
</aside>
</section>
<section>
<h2>Inline Styles Reduce Readability</h2>
<pre><code data-trim class="jsx fragment">
return (
<MyComponent
style={{
minHeight: 350,
color: 'red',
backgroundColor: 'black',
width: '36em',
position: 'relative',
}}
>
<div
style={{
position: 'absolute',
top: 16,
left: 16,
}}
>
Some stuffs.
</div>
</MyComponent>
)
</code></pre>
<aside class="notes">
</aside>
</section>
<section>
<h2>Treat Styles Like Objects</h2>
<p class="fragment">
(because they are)
</p>
<pre><code data-trim class="jsx fragment">
const styles = {
MyComponentStyles: {
minHeight: 350,
width: '36em',
position: 'relative',
},
divStyles: {
position: 'absolute',
top: 16,
left: 16,
}
}
return (
<MyComponent style={styles.MyComponentStyles}>
<div style={styles.divStyles}>
Some stuffs.
</div>
</MyComponent>
)
</code></pre>
<aside class='notes'>
now it looks like html again
</aside>
</section>
<section>
<h2>Complex Property Lists Also Reduce Readability</h2>
<pre><code data-trim class="jsx fragment">
return (
<MyComponent
changeHandler={this.changeHandler.bind(this)}
key={props.id}
yOrient='left'
align='right'
legend={props.data.length > 1 ? true : false}
>
<div
isReactCSSTransitionGroup={true}
ref='someStuffs'
className='yoyo yo'
>
Some stuffs.
</div>
</MyComponent>
)
</code></pre>
<aside class='notes'>
this only loosely resembles html
</aside>
</section>
<section>
<h2>Treat Properties Like Objects</h2>
<p class="fragment">
(because they are)
</p>
<pre><code data-trim class="jsx fragment">
const MyComponentProps = {
changeHandler: this.changeHandler.bind(this),
key: props.id,
yOrient: 'left',
align: 'right',
legend: props.data.length > 1 ? true : false,
style: styles.MyComponentStyles,
}
const divProps = {
isReactCSSTransitionGroup: true,
ref: 'someStuffs',
className: 'yoyo yo',
style: styles.divStyles,
}
return (
<MyComponent {...MyComponentProps}>
<div {...divProps}>
Some stuffs.
</div>
</MyComponent>
)
</code></pre>
<aside class='notes'>
<ul>
<li>
again
</li>
<li>
we're really dealing with objects
</li>
<li>
now it looks like html
</li>
</ul>
</aside>
</section>
</section>
<section>
<section>
<h2>Pseudo Selectors</h2>
<p class="fragment">Don't work inline.</p>
<p class="fragment">:\</p>
</section>
<section>
<h2>But We still need hover?!</h2>
<p class="fragment">
Libraries to the rescue!
</p>
</section>
<section>
<h2>Radium.js</h2>
<p class="fragment">
Is a decoration on React classes.
</p>
<p class="fragment">
It's kind of shimming inline style's shortcomings.
</p>
<pre><code data-trim class="jsx fragment">
const styles = {
linkStyle: {
backgroundColor: '#FFF'
':hover': {
backgroundColor: '#0088FF'
}
}
},
</code></pre>
</section>
</section>
<section>
<section>
<h2>Media Queries</h2>
<p class="fragment">Also,...</p>
<p class="fragment">Don't work inline.</p>
<p class="fragment">:\</p>
<aside class="notes">
</aside>
</section>
<section>
<h2>Radium.js</h2>
<p class="fragment">To the rescue again!</p>
<pre><code data-trim class="jsx fragment">
const styles = {
linkStyle: {
backgroundColor: '#FFF',
':hover': {
backgroundColor: '#0088FF',
},
'@media(min-width:769px)': {
fontSize: 16,
},
},
},
</code></pre>
<aside class="notes">
</aside>
</section>
</section>
<section>
<section>
<h2>Publishing Your Own Components</h2>
<p class="fragment">
Inline styles will not be overridden.
</p>
<p class="fragment">
Your consumers need an API, or,...
</p>
<p class="fragment">
you can simply use stylesheets.
</p>
<p class="fragment">
:\
</p>
<aside class="notes">
</aside>
</section>
<section>
<h2>Public API</h2>
<p class="fragment">
Add props for each stylable child element.
</p>
</section>
<section>
<p>
The top level component gets setup by the consumer:
</p>
<pre><code data-trim class="jsx fragment">
import { MyComponent } from 'my-published-component'
...
return (
<MyComponent
divStyle={styles.customDivStyles}
linkStyle={styles.customLinkStyles}
/>
)
</code></pre>
<aside class="notes">
</aside>
</section>
<section>
<p>
Within the published component we apply those props as styles:
</p>
<pre><code data-trim class="jsx fragment">
const styles = {
divStyle: {
...
},
linkStyle: {
...
},
}
const {
divStyle,
linkStyle,
} = this.props
const _divStyle = extend({}, styles.divStyle, divStyle)
const _linkStyle = extend({}, styles.linkStyle, linkStyle)
return (
<div
style={_divStyle}
>
<a
href='javascript:void(1)'
style={_linkStyle}
>
Click me!
</a>
</div>
)
</code></pre>
<p class="fragment">
This is a use case where classic CSS makes the code more portable, so it may be better to just use classes and CSS.
</p>
<aside class="notes">
</aside>
</section>
</section>
<section>
<section>
<h2>CSS Animations</h2>
<p>
Easier than you think.
</p>
<aside class="notes">
</aside>
</section>
<section>
<h2>Radium.js</h2>
<p>
Radium provides an API for keyframe animations:
</p>
<pre><code data-trim class="jsx fragment">
const pulseKeyframes = Radium.keyframes({
'0%': {width: '10%'},
'50%': {width: '50%'},
'100%': {width: '10%'},
});
const styles = {
inner: {
animation: `${pulseKeyframes} 3s ease 0s infinite`,
background: 'blue',
height: '4px',
margin: '0 auto',
}
};
</code></pre>
<p class="fragment">
Radium takes care of the vendor prefixing as well.
</p>
<aside class="notes">
</aside>
</section>
</section>
<section>
<section>
<h2>CSS Transitions</h2>
<p class="fragment">
Not as easy as you think.
</p>
<p class="fragment">
:\
</p>
<aside class="notes">
</aside>
</section>
<section>
<h2>CSSTransitionGroup</h2>
<p>
React has an addon called CSSTransitionGroup.
</p>
<p class="fragment">
It manages the application of custom classes through component lifecycle hooks.
</p>
<p class="fragment">
But that means we need a seperate style sheet <span class="fragment">,... right?</span>
</p>
<aside class="notes">
</aside>
</section>
<section>
<h2>Radium Style Component</h2>
<p>
Adds a style element to the DOM.
</p>
<p class="fragment">
Warning: use sparingly!
</p>
<pre><code data-trim class="jsx fragment">
import Radium, { Style } from 'radium'
import { ReactCSSTransitionGroup } from ('react/addons/CSSTransitionGroup')
...
return (
<div>
<Style rules={{
'.yo-appear': {
opacity: 0.01,
transition: 'opacity 1.666s linear',
},
'.yo-appear.yo-appear-active': {
opacity: 1
}
}}
>
</Style>
<ReactCSSTransitionGroup
transitionName='yo'
transitionAppear={true}
>
{props.children}
</ReactCSSTransitionGroup>
</div>
)
</code></pre>
</section>
</section>
<section>
<section>