-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
887 lines (805 loc) · 30.5 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>CSS Architecture</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/glint.css">
<!-- Theme used for syntax highlighting of code -->
<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>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>CSS Architecture</h1>
<p>Strategies for writing meaningful, robust, flexible and scalable CSS</p>
<h3 style="margin-top: 2em;">by Nathan Rambeck</h3>
<img src="assets/Sparkbox.svg" alt="Sparkbox" style="min-width: 400px;">
<p>
<img src="assets/Twitter.svg" alt="Twitter" style="vertical-align: -60%; margin-right: 0.3em;">
<a href="http://twitter.com/nrambeck">@nrambeck</a>
</p>
</section>
<section>
<section>
<img src="assets/family.jpg" alt="Rambeck Family">
</section>
<section>
<img src="assets/sparkbox-lunch.jpg" alt="Sparkbox Lunch">
</section>
<section>
<img src="assets/better-web-tshirt.jpg" alt="Better Web Shirt">
</section>
</section>
<section>
<section>
<h2>Why CSS Architecture?</h2>
</section>
<section>
<h2>Can't we just style our pages?</h2>
<figure class="fragment fade-up">
<img src="assets/shack.jpg" alt="Shack">
<figcaption><a href="https://unsplash.com/photos/2-KEVc5JRSw">Bradley Swenson</a></figcaption>
</figure>
</section>
<section>
<blockquote class="u-txt-xxl">We’re not designing pages, we’re designing systems of components. —<a href="http://bradfrost.com/blog/mobile/bdconf-stephen-hay-presents-responsive-design-workflow/">Stephen Hay</a></blockquote>
</section>
<section>
<h2>Complexity requires planning and organization</h2>
<figure class="fragment fade-up">
<img src="assets/complex-architecture.jpg" alt="Complex Architecture">
<figcaption><a href="https://unsplash.com/photos/zCevd81eJDU">Alexandre Perotto</a></figcaption>
</figure>
</section>
<section>
<h2>Scalability Issues</h2>
<ul class="u-txt-larger">
<li class="fragment fade-up">Scaling number of pages/templates</li>
<li class="fragment fade-up">Scaling complexity (responsive)</li>
<li class="fragment fade-up">Scaling dev team</li>
</ul>
</section>
</section>
<section>
<section>
<h1>Building Design <em>Systems</em></h1>
</section>
<section>
<blockquote class="u-txt-xxl">Tiny Bootstraps for every client —<a href="http://daverupert.com/2013/04/responsive-deliverables/">Dave Rupert</a></blockquote>
</section>
<section>
<h2>Thinking in terms of modules and components</h2>
<figure class="fragment fade-up">
<img src="assets/modules-components.jpg" alt="Modules and Components">
</figure>
</section>
<section>
<h2>Pattern Libraries</h2>
<ul class="u-txt-larger">
<li class="fragment fade-up"><a href="https://github.com/cloudfour/drizzle">Drizzle</a></li>
<li class="fragment fade-up"><a href="http://fbrctr.github.io/">Fabricator</a></li>
<li class="fragment fade-up"><a href="http://patternlab.io/">PatternLab</a></li>
</ul>
</section>
</section>
<section>
<h2>Where these ideas came from</h2>
<ul class="u-txt-larger">
<li class="fragment fade-up"><a href="https://www.smashingmagazine.com/2011/12/an-introduction-to-object-oriented-css-oocss/">Object-Oriented CSS</a> (re-usability) - Nicole Sullivan</li>
<li class="fragment fade-up"><a href="https://smacss.com">SMACSS</a> (seperation of concerns) - Jonathan Snook</li>
<li class="fragment fade-up"><a href="http://www.creativebloq.com/web-design/manage-large-scale-web-projects-new-css-architecture-itcss-41514731">ITCSS</a> (style ordering) - Harry Roberts</li>
</ul>
</section>
<section>
<h1>Types of CSS Rules</h1>
<ul class="u-txt-larger">
<li class="fragment fade-up">Base</li>
<li class="fragment fade-up">Objects</li>
<li class="fragment fade-up">Components</li>
<li class="fragment fade-up">State</li>
<li class="fragment fade-up">Javascript</li>
<li class="fragment fade-up">Themes</li>
<li class="fragment fade-up">Utilities</li>
</ul>
</section>
<section>
<section>
<ul class="c-overview-list">
<li class="is-active">Base</li>
<li>Objects</li>
<li>Components</li>
<li>State</li>
<li>Javascript</li>
<li>Themes</li>
<li>Utilities</li>
</ul>
</section>
<section>
<h1>Base CSS</h1>
<p>Styles applied globally to bare elements</p>
</section>
<section>
<pre><code class="css" data-noescape>
body {
margin: 0;
padding: 0;
}
a {
color: Orange;
}
img {
max-width: 100%;
}
</code></pre>
</section>
<section>
<h2>Base CSS Considerations</h2>
<ul class="u-txt-larger">
<li class="fragment fade-up">Use a project like <a href="https://necolas.github.io/normalize.css/">normalize.css</a></li>
<li class="fragment fade-up">These are global defaults</li>
<li class="fragment fade-up">Don't be too heavy-handed</li>
</ul>
</section>
</section>
<section>
<section>
<ul class="c-overview-list">
<li>Base</li>
<li class="is-active">Objects</li>
<li>Components</li>
<li>State</li>
<li>Javascript</li>
<li>Themes</li>
<li>Utilities</li>
</ul>
</section>
<section>
<h1>What are objects?</h1>
<p class="fragment fade-in">Re-usable CSS classes for layout and structure</p>
</section>
<section>
<h2>Recognize layout and structure patterns</h2>
<figure class="fragment fade-up">
<img src="assets/recognizing-patterns.jpg" alt="Recognizing Patterns">
</figure>
</section>
<section data-transition="fade-out">
<pre><code class="css" data-noescape>
.promo {
max-width: 1000px;
height: 300px;
padding: 20px;
margin: 0 auto;
position: relative;
overflow: hidden;
}
</code></pre>
</section>
<section data-transition="fade-in">
<pre><code class="css" data-noescape>
.o-container-wide {
max-width: 1000px;
margin: 0 auto;
overflow: hidden;
}
.promo {
height: 300px;
padding: 20px;
}
</code></pre>
<pre class="fragment"><code class="html" data-noescape>
<div class="promo o-container-wide"></div>
</code></pre>
</section>
<section>
<h2>Examples</h2>
<ul class="u-txt-larger">
<li class="fragment fade-up">Grid systems</li>
<li class="fragment fade-up">Layout containers</li>
<li class="fragment fade-up">Structural patterns</li>
</ul>
</section>
</section>
<section>
<section>
<ul class="c-overview-list">
<li>Base</li>
<li>Objects</li>
<li class="is-active">Components</li>
<li>State</li>
<li>Javascript</li>
<li>Themes</li>
<li>Utilities</li>
</ul>
</section>
<section>
<p>Components are discrete, self-contained pieces of UI</p>
</section>
<section>
<h2>Examples</h2>
<ul class="u-txt-larger">
<li class="fragment fade-up">Buttons</li>
<li class="fragment fade-up">Carousels</li>
<li class="fragment fade-up">Pullquotes</li>
<li class="fragment fade-up">Header</li>
<li class="fragment fade-up">Navigation</li>
</ul>
</section>
<section>
<h2>Components make up the bulk of your CSS rules</h2>
</section>
<section>
<h2>Independent and self-contained</h2>
<p class="fragment fade-in">You should be able to drop a component anywhere on any page and it will maintain it's structure and design.</p>
</section>
<section>
<h2>Components can be small</h2>
</section>
<section>
<pre><code class="html" data-noescape>
<button class="btn">My Button</button>
</code></pre>
</section>
<section>
<h2>Components can be big</h2>
</section>
<section data-transition="fade-out">
<pre><code class="html" data-noescape>
<footer class="c-footer">
<div class="o-container-wide">
<a class="c-footer__logo icon-a-assist" href="/">The Assist</a>
<div class="c-social c-social--follow">
<div class="c-social__label">Join the conversation</div>
<ul class="c-social__list">
<li class="c-social__item"></li>
<li class="c-social__item"></li>
<li class="c-social__item"></li>
</ul>
</div>
<p class="c-footer__credit"></p>
</div>
</footer>
</code></pre>
</section>
<section data-transition="fade-in">
<pre><code class="html" data-noescape>
<footer class="<mark>c-footer</mark>">
<div class="o-container-wide">
<a class="<mark>c-footer__logo</mark> icon-a-assist" href="/">The Assist</a>
<div class="c-social c-social--follow">
<div class="c-social__label">Join the conversation</div>
<ul class="c-social__list">
<li class="c-social__item"></li>
<li class="c-social__item"></li>
<li class="c-social__item"></li>
</ul>
</div>
<p class="<mark>c-footer__credit</mark>"></p>
</div>
</footer>
</code></pre>
</section>
</section>
<section>
<section>
<h1>Naming Components</h1>
</section>
<section>
<h2>BEM</h2>
<h3>(Block, Element, Modifier)</h3>
<p><a href="http://getbem.com/introduction/">http://getbem.com/</a></p>
</section>
<section>
<h2>[block]__[element]--[modifier]</h2>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<div class="alert alert--warning">
<h1 class="alert__title">
<span class="alert__icon"></span>
Alert Title
</h1>
<p class="alert__description">The password you entered is invalid.</p>
</div>
</code></pre>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<div class="<mark>alert</mark> <mark>alert</mark>--warning">
<h1 class="<mark>alert</mark>__title">
<span class="<mark>alert</mark>__icon icon-warning"></span>
Alert Title
</h1>
<p class="<mark>alert</mark>__description">The password you entered is invalid.</p>
</div>
</code></pre>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<div class="alert alert--warning">
<h1 class="alert__<mark>title</mark>">
<span class="alert__<mark>icon</mark> icon-warning"></span>
Alert Title
</h1>
<p class="alert__<mark>description</mark>">The password you entered is invalid.</p>
</div>
</code></pre>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<div class="alert alert--<mark>warning</mark>">
<h1 class="alert__title">
<span class="alert__icon icon-warning"></span>
Alert Title
</h1>
<p class="alert__description">The password you entered is invalid.</p>
</div>
</code></pre>
</section>
<section>
<h2>Why?</h2>
<ul class="u-txt-larger">
<li class="fragment fade-up">Readability</li>
<li class="fragment fade-up">Self-descriptive</li>
<li class="fragment fade-up">Specificity</li>
</ul>
</section>
<section data-transition="fade-in fade-out">
<h2>Specificity Problems</h2>
<pre><code class="html" data-noescape>
<div class="alert warning">
<h1>
<span class="icon-warning"></span>
Alert Title
</h1>
<p>The password you entered is invalid.</p>
</div>
</code></pre>
<pre><code class="css" data-noescape>
.alert { }
.alert.warning { }
.alert h1 { }
.alert span { }
.alert p { }
</code></pre>
</section>
</section>
<section>
<section>
<ul class="c-overview-list">
<li>Base</li>
<li>Objects</li>
<li>Components</li>
<li class="is-active">State</li>
<li>Javascript</li>
<li>Themes</li>
<li>Utilities</li>
</ul>
</section>
<section>
<p>State classes are helpers that modify the state of a component.</p>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<ul class="nav">
<li class="nav__item">Home</li>
<li class="nav__item">About</li>
<li class="nav__item">Contact</li>
</ul>
</code></pre>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<ul class="nav">
<li class="nav__item">Home</li>
<li class="nav__item <mark>is-active</mark>">About</li>
<li class="nav__item">Contact</li>
</ul>
</code></pre>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="css" data-noescape>
.nav__item {
display: inline-block;
padding: .5em;
}
.nav__item.is-active {
font-weight: bold;
}
</code></pre>
</section>
<section>
<p>It's common to add remove state classes with Javascript.</p>
</section>
<section>
<p>State classes begin with "is" or "has"</p>
<ul class="u-txt-larger">
<li class="fragment fade-up">.is-active</li>
<li class="fragment fade-up">.is-hidden</li>
<li class="fragment fade-up">.is-selected</li>
<li class="fragment fade-up">.has-focus</li>
</ul>
</section>
</section>
<section>
<section>
<ul class="c-overview-list">
<li>Base</li>
<li>Objects</li>
<li>Components</li>
<li>State</li>
<li>Javascript</li>
<li class="is-active">Themes</li>
<li>Utilities</li>
</ul>
</section>
<section>
<p>Theme classes alter components with unique colors, fonts or other decorations</p>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<blockquote class="c-pullquote <mark>t-light</mark>">
<p>A great quote from someone special.</p>
</blockquote>
</code></pre>
<pre class="fragment"><code class="css" data-noescape>
.c-pullquote {
font-size: 2em;
font-style: italic;
}
.t-light {
background-color: Cream;
color: Magenta;
}
.t-dark {
background-color: Magenta;
color: Cream;
}
</code></pre>
</section>
</section>
<section>
<section>
<ul class="c-overview-list">
<li>Base</li>
<li>Objects</li>
<li>Components</li>
<li>State</li>
<li>Javascript</li>
<li>Themes</li>
<li class="is-active">Utilities</li>
</ul>
</section>
<section>
<p>Utility classes are single purpose helpers that apply one specific styling rule.</p>
</section>
<section>
<h2>Examples of Utilities</h2>
<pre class="fragment"><code class="css" data-noescape>
.u-sp {
margin-bottom: 1em !important;
}
.u-clearfix:after {
content: " ";
display: block; clear: both; visibility: hidden;
height: 0; font-size: 0;
}
.u-txt-center {
text-align: center !important;
}
.u-txt-larger {
font-size: 130% !important;
}
</code></pre>
<pre class="fragment"><code class="html" data-noescape>
<div class="promo <mark>u-sp</mark>"></div>
<div class="promo <mark>u-sp</mark>"></div>
<div class="promo"></div>
</code></pre>
</section>
<section>
<div class="u-txt-larger">
<p>Tweak your layout</p>
<p>or</p>
<p>slightly modify a component...</p>
<p>without creating another variant</p>
</div>
</section>
<section>
<h2>Don't Overdo It!</h2>
<pre class="fragment"><code class="html" data-noescape>
<div class="
border-top-width-1-dot-04em
border-top-style-dotted
border-top-color-lightgrey
border-bottom-width-12px
border-bottom-style-solid
border-bottom-color-cornflowerblue
border-top-right-radius-1-dot-60em
padding-5px
margin-left-10px
background-color-fuchsia
">
</div>
</code></pre>
<p class="fragment">from <a href="https://github.com/marmelab/universal.css">universal.css</a> a parody of
<a href="http://acss.io/">Atomic CSS</a></p>
</section>
</section>
<section>
<section>
<h1>Naming Your Classes</h1>
</section>
<section>
<h2>Naming Things is Hard</h2>
<p>see <a href="https://seesparkbox.com/foundry/naming_css_stuff_is_really_hard">Sparkbox Foundry post</a></p>
<ul class="u-txt-larger">
<li class="fragment fade-up">All lowercase</li>
<li class="fragment fade-up">Use dashes or underscores</li>
<li class="fragment fade-up">Long enough to discern (.pullquote not .pq)</li>
<li class="fragment fade-up">No longer than needs to be (.btn not .button)</li>
</ul>
</section>
<section>
<h2>Naming Methodologies</h2>
<ul class="u-txt-larger">
<li class="fragment fade-up">By Presentation</li>
<li class="fragment fade-up">By Content</li>
<li class="fragment fade-up">By Function</li>
</ul>
</section>
<section>
<h3>By Presentation</h3>
<pre><code class="css" data-noescape>
.button--green { }
.rounded-image { }
.large-heading { }
</code></pre>
<h3>By Content</h3>
<pre><code class="css" data-noescape>
.button--submit { }
.profile-image { }
.article-heading { }
</code></pre>
<h3>By Function</h3>
<pre><code class="css" data-noescape>
.button--primary { }
.decorative-image { }
.content-heading { }
</code></pre>
</section>
<section>
<h2>Namespacing</h2>
<p>Add prefixes to all of your classes to recognize the purpose of each one.</p>
<ul class="u-txt-larger">
<li class="fragment fade-up">Objects: .o-</li>
<li class="fragment fade-up">Components: .c-</li>
<li class="fragment fade-up">State: .is- or .has-</li>
<li class="fragment fade-up">Theme: .t-</li>
<li class="fragment fade-up">Utility: .u-</li>
</ul>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<footer class="c-footer">
<div class="o-container-wide">
<a class="c-footer__logo" href="/">The Assist</a>
<div class="c-social c-social--follow">
<div class="c-social__label u-txt-center">Join the conversation</div>
<ul class="c-social__list">
<li class="c-social__item"></li>
<li class="c-social__item is-active"></li>
<li class="c-social__item"></li>
</ul>
</div>
<p class="c-footer__credit"></p>
</div>
</footer>
</code></pre>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<footer class="c-footer">
<div class="<mark>o-container-wide</mark>">
<a class="c-footer__logo" href="/">The Assist</a>
<div class="c-social c-social--follow">
<div class="c-social__label u-txt-center">Join the conversation</div>
<ul class="c-social__list">
<li class="c-social__item"></li>
<li class="c-social__item is-active"></li>
<li class="c-social__item"></li>
</ul>
</div>
<p class="c-footer__credit"></p>
</div>
</footer>
</code></pre>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<footer class="<mark>c-footer</mark>">
<div class="o-container-wide">
<a class="c-footer__logo" href="/">The Assist</a>
<div class="<mark>c-social</mark> c-social--follow">
<div class="c-social__label u-txt-center">Join the conversation</div>
<ul class="c-social__list">
<li class="c-social__item"></li>
<li class="c-social__item is-active"></li>
<li class="c-social__item"></li>
</ul>
</div>
<p class="c-footer__credit"></p>
</div>
</footer>
</code></pre>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<footer class="c-footer">
<div class="o-container-wide">
<a class="c-footer__logo" href="/">The Assist</a>
<div class="c-social c-social--follow">
<div class="c-social__label u-txt-center">Join the conversation</div>
<ul class="c-social__list">
<li class="c-social__item"></li>
<li class="c-social__item <mark>is-active</mark>"></li>
<li class="c-social__item"></li>
</ul>
</div>
<p class="c-footer__credit"></p>
</div>
</footer>
</code></pre>
</section>
<section data-transition="fade-in fade-out">
<pre><code class="html" data-noescape>
<footer class="c-footer">
<div class="o-container-wide">
<a class="c-footer__logo" href="/">The Assist</a>
<div class="c-social c-social--follow">
<div class="c-social__label <mark>u-txt-center</mark>">Join the conversation</div>
<ul class="c-social__list">
<li class="c-social__item"></li>
<li class="c-social__item is-active"></li>
<li class="c-social__item"></li>
</ul>
</div>
<p class="c-footer__credit"></p>
</div>
</footer>
</code></pre>
</section>
</section>
<section>
<section>
<h1>Code Organization</h1>
</section>
<section>
<h2>Use a preprocessor (Sass, Less, Stylus) to take advantage of:</h2>
<ul class="u-txt-larger">
<li class="fragment fade-up">Imports</li>
<li class="fragment fade-up">Variables</li>
<li class="fragment fade-up">Functions</li>
<li class="fragment fade-up">Mixins</li>
<li class="fragment fade-up">Nesting</li>
</ul>
</section>
<section>
<h2>Divide styles into meaningful files</h2>
<pre><code class="css" data-noescape>
@import "variables";
@import "mixins";
@import "normalize";
@import "typography";
@import "headings";
@import "buttons";
@import "layout";
@import "carousel";
</code></pre>
</section>
<section>
<h2>Prefix your variable names</h2>
<pre><code class="scss" data-noescape>
// Colors
$c-warning: Red;
$c-primary: Blue;
$c-background: White;
</code></pre>
<figure class="fragment fade-up">
<img src="assets/color-autocompletion.jpg" alt="Variable Autocompletion">
</figure>
</section>
<section>
<h2>Scope your variables</h2>
<pre><code class="scss" data-noescape>
.alert {
$background-color: Red;
$foreground-color: Cream;
background-color: $background-color;
color: $foreground-color;
}
</code></pre>
</section>
</section>
<section>
<section>
<h1>Source Ordering</h1>
<h3>The Inverted Triangle Method</h3>
</section>
<section>
<p>ITCSS is a method of ordering your CSS settings and rules to prevent
namespace collisions, specificity wrestling, leaky styles and inadvertent
regressions.</p>
</section>
<section>
<figure>
<img src="assets/itcss1.jpg" alt="ITCSS Illustration 1">
</figure>
</section>
<section>
<figure>
<img src="assets/itcss2.jpg" alt="ITCSS Illustration 2">
</figure>
</section>
<section>
<pre><code class="scss" data-noescape>
@import "settings.global";
@import "settings.colors";
@import "tools.functions";
@import "tools.mixins";
@import "generic.box-sizing";
@import "generic.normalize";
@import "elements.headings";
@import "elements.links";
@import "objects.wrappers";
@import "objects.grid";
@import "components.nav";
@import "components.buttons";
@import "components.promos";
@import "trumps.utilities";
@import "trumps.ie8";
</code></pre>
</section>
</section>
<section>
<h1>Questions?</h1>
<p>
<img src="assets/Twitter.svg" alt="Twitter" style="vertical-align: -60%; margin-right: 0.3em;">
<a href="http://twitter.com/nrambeck">@nrambeck</a>
</p>
<img src="assets/Sparkbox.svg" alt="Sparkbox" style="min-width: 400px;">
<p><a href="https://nrambeck.github.io/css-architecture/">https://nrambeck.github.io/css-architecture/</a></p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
history: true,
width: 960,
height: 800,
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>