Slide 1

Slide 1 text

The Future is in Pieces

Slide 2

Slide 2 text

2003 CSS Takes Off

Slide 3

Slide 3 text

Wired Redesign

Slide 4

Slide 4 text

Blog Design

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Blog Designs #header h1, #header h2 { font-size:13px; font-weigh… } #header h1 { color: #680; float:right; padding-b…} #header h2 { float:left; padding:18px 20px; posi…} #header h2 img { position:absolute; left:0; top:0; } #header h2 a { text-decoration:none; color:#333; } #main h2 {text-transform:uppercase; font-weight:…} #main h2 a {text-decoration:none; color:#444;} #main h2 a:hover {color:#680;} #main .article.inside h1 { text-transform:uppercase;…} #comments .comment .meta .authorname { text-transfo… } #comments .comment .meta .commentnumber a { float: … }

Slide 8

Slide 8 text

Blog Designs #header h1, #header h2 { font-size:13px; font-weigh… } #header h1 { color: #680; float:right; padding-b…} #header h2 { float:left; padding:18px 20px; posi…} #header h2 img { position:absolute; left:0; top:0; } #header h2 a { text-decoration:none; color:#333; } #main h2 {text-transform:uppercase; font-weight:…} #main h2 a {text-decoration:none; color:#444;} #main h2 a:hover {color:#680;} #main .article.inside h1 { text-transform:uppercase;…} #comments .comment .meta .authorname { text-transfo… } #comments .comment .meta .commentnumber a { float: … }

Slide 9

Slide 9 text

Blog Designs #header h1, #header h2 { font-size:13px; font-weigh… } #header h1 { color: #680; float:right; padding-b…} #header h2 { float:left; padding:18px 20px; posi…} #header h2 img { position:absolute; left:0; top:0; } #header h2 a { text-decoration:none; color:#333; } #main h2 {text-transform:uppercase; font-weight:…} #main h2 a {text-decoration:none; color:#444;} #main h2 a:hover {color:#680;} #main .article.inside h1 { text-transform:uppercase;…} #comments .comment .meta .authorname { text-transfo… } #comments .comment .meta .commentnumber a { float: … }

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

SMACSS

Slide 17

Slide 17 text

Scalable and Modular Architecture for CSS

Slide 18

Slide 18 text

• Describes how to approach site design and development
 • No GitHub repo, not a library, not a framework, no tools
 • Techniques can be applied to static CSS, Sass, React, Web Components, etc.

Slide 19

Slide 19 text

What does it mean to be modular?

Slide 20

Slide 20 text

A module is “each of a set of standardized parts or independent units that can be used to construct a more complex structure.” –Dictionary

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

What hurdles are there to being truly independent?

Slide 26

Slide 26 text

• Inheritance
 • Cascade
 • Browser Default Styling
 • Putting modules/components together

Slide 27

Slide 27 text

Inheritance

Slide 28

Slide 28 text

• Typography
 e.g. color, font-size, font-family
 • List Styles
 e.g. list-style
 • Table Styles 
 e.g. border-collapse

Slide 29

Slide 29 text

Sorry, React. Inline styles won’t save you from inheritance.

Slide 30

Slide 30 text

• all: initial

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Cascade

Slide 34

Slide 34 text

The cascade is how the browser decides what properties to apply when you have multiple rules declared on the same element.

Slide 35

Slide 35 text

a:link { color: blue; } a:hover { color: cornflowerblue; } .sidebar a:link { color: grey; } .sidebar a:hover { color: crimson; } .nav a:link { color: cadetblue; } .nav a:hover { color: darkblue; }

Slide 36

Slide 36 text

• Don’t write multiple rules for the same element
 • Inline styles
 • Create a structured layering system to prevent conflicts

Slide 37

Slide 37 text

Browser Defaults

Slide 38

Slide 38 text

.button {
 border:1px solid purple;
 padding: 5px 10px;
 color: pink;
 } text-decoration: none;

Slide 39

Slide 39 text

• all: initial
 • Predictable HTML
 i.e. templates

Slide 40

Slide 40 text

Putting Modules Together

Slide 41

Slide 41 text

Send

Slide 42

Slide 42 text

Cancel Send

Slide 43

Slide 43 text

.button + .button { 
 margin-left: 10px; 
 }

Slide 44

Slide 44 text

Cancel Send

Slide 45

Slide 45 text

Send Email

Slide 46

Slide 46 text

.button + .button,
 .input + .button { 
 margin-left: 10px; 
 } * + * { 
 margin-left: 10px; 
 }

Slide 47

Slide 47 text

Send Subscribe Email

Slide 48

Slide 48 text

http://snk.ms/26

Slide 49

Slide 49 text

• Separate layout from module
 • Micro layout classes

Slide 50

Slide 50 text

Send Subscribe

Slide 51

Slide 51 text

Send Subscribe button>

Slide 52

Slide 52 text

BONUS PROBLEM! Media Queries

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

If Module A 
 in Module B 
 in Layout C 
 Then I’m screwed.

Slide 56

Slide 56 text

If Module A has room
 do this.

Slide 57

Slide 57 text

Element Queries

Slide 58

Slide 58 text

Element Queries

Slide 59

Slide 59 text

Oh, right. SMACSS.

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

Design has a cost.

Slide 68

Slide 68 text

Every piece of design ends up in code.

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

• Categorize
 • Naming Convention

Slide 72

Slide 72 text

Base Layout Module State Theme

Slide 73

Slide 73 text

• .btn • .btn--variation • .btn__component • .btn • &--variation • &__component • button.css • .variation • .component SMACSS-y BEM Sass CSS Modules/React • .btn • .btn-variation • .btn--component

Slide 74

Slide 74 text

HTML CSS JavaScript HTML CSS JavaScript HTML CSS JavaScript

Slide 75

Slide 75 text

The Future is React?

Slide 76

Slide 76 text

React.render( My Button! );

Slide 77

Slide 77 text

var XUIButton = React.createClass({ render: function() { return ( {this.props.children} ); } });

Slide 78

Slide 78 text

var myStyle = { color: '#FFF', backgroundColor: '#330000' } var XUIButton = React.createClass({ render: function() { return ( {this.props.children} ); }

Slide 79

Slide 79 text

HTML CSS JavaScript HTML CSS JavaScript HTML CSS JavaScript

Slide 80

Slide 80 text

The Future is Web Components?

Slide 81

Slide 81 text

• Templates
 • Shadow DOM
 • Custom Elements
 • HTML Imports

Slide 82

Slide 82 text

var p = document.createElement(‘p'); p.createShadowRoot(); p.shadowRoot.innerHTML = 'HTML Contents'; document.body.appendChild(p);

Slide 83

Slide 83 text

• The Cascade no longer applies
 • Inheritance still applies 
 (unless you use all:initial)

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

HTML CSS JavaScript

Slide 86

Slide 86 text

HTML CSS JavaScript component.html

Slide 87

Slide 87 text

Slide 88

Slide 88 text

Slide 89

Slide 89 text

// Creates a MediaObjectElement class // that extends HTMLElement. class MediaObjectElement extends HTMLElement { createdCallback() { var shadowRoot = this.createShadowRoot(); shadowRoot.innerHTML = 'Shadow DOM contents...'; } } // Registers the `` element for use. document.registerElement('custom-element', MediaObjectElement);

Slide 90

Slide 90 text

• Likely a year before all browsers support everything.
 • JavaScript Dependent
 • Phillip Walton’s Talk on Modular CSS with Web Components 
 http://snk.ms/27

Slide 91

Slide 91 text

• Think about standardized and modular design.
 • Frameworks like React can help.
 • Web Components are coming. (So is winter.)

Slide 92

Slide 92 text

Thank you.
 http://snook.ca/
 @snookca