the future is modular, jonathan snook

91
The Future is Modular

Upload: future-insights

Post on 16-Apr-2017

641 views

Category:

Design


1 download

TRANSCRIPT

Page 1: The Future is Modular, Jonathan Snook

The Future is Modular

Page 2: The Future is Modular, Jonathan Snook

2003 CSS Takes Off

Page 3: The Future is Modular, Jonathan Snook

Wired Redesign

Page 4: The Future is Modular, Jonathan Snook

Blog Design

Page 5: The Future is Modular, Jonathan Snook
Page 6: The Future is Modular, Jonathan Snook
Page 7: The Future is Modular, Jonathan Snook

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: … }

Page 8: The Future is Modular, Jonathan Snook

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: … }

Page 9: The Future is Modular, Jonathan Snook

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: … }

Page 10: The Future is Modular, Jonathan Snook
Page 11: The Future is Modular, Jonathan Snook
Page 12: The Future is Modular, Jonathan Snook
Page 13: The Future is Modular, Jonathan Snook
Page 14: The Future is Modular, Jonathan Snook
Page 15: The Future is Modular, Jonathan Snook
Page 16: The Future is Modular, Jonathan Snook

SMACSS

Page 17: The Future is Modular, Jonathan Snook

Scalable and Modular Architecture for CSS

Page 18: The Future is Modular, Jonathan Snook

• 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.

Page 19: The Future is Modular, Jonathan Snook

What does it mean to be modular?

Page 20: The Future is Modular, Jonathan Snook

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

Page 21: The Future is Modular, Jonathan Snook
Page 22: The Future is Modular, Jonathan Snook
Page 23: The Future is Modular, Jonathan Snook
Page 24: The Future is Modular, Jonathan Snook
Page 25: The Future is Modular, Jonathan Snook

What hurdles are there to being truly independent?

Page 26: The Future is Modular, Jonathan Snook

• Inheritance

• Cascade

• Browser Default Styling

• Putting modules/components together

Page 27: The Future is Modular, Jonathan Snook

Inheritance

Page 28: The Future is Modular, Jonathan Snook

• Typographye.g. color, font-size, font-family

• List Stylese.g. list-style

• Table Styles e.g. border-collapse

Page 29: The Future is Modular, Jonathan Snook

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

Page 30: The Future is Modular, Jonathan Snook

• all: initial

Page 31: The Future is Modular, Jonathan Snook
Page 32: The Future is Modular, Jonathan Snook
Page 33: The Future is Modular, Jonathan Snook

Cascade

Page 34: The Future is Modular, Jonathan Snook

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

Page 35: The Future is Modular, Jonathan Snook

• Don’t write multiple rules for the same element

• Inline styles

• Create a structured layering system to prevent conflicts

Page 36: The Future is Modular, Jonathan Snook

Browser Defaults

Page 37: The Future is Modular, Jonathan Snook

<button class="button">

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

<a href="/" class="button">

text-decoration: none;

Page 38: The Future is Modular, Jonathan Snook

• all: initial

• Predictable HTMLi.e. templates

Page 39: The Future is Modular, Jonathan Snook

Putting Modules Together

Page 40: The Future is Modular, Jonathan Snook

Send

Page 41: The Future is Modular, Jonathan Snook

Cancel Send

Page 42: The Future is Modular, Jonathan Snook

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

Page 43: The Future is Modular, Jonathan Snook

Cancel Send

Page 44: The Future is Modular, Jonathan Snook

SendEmail

Page 45: The Future is Modular, Jonathan Snook

.button + .button,

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

* + * { margin-left: 10px; }

Page 46: The Future is Modular, Jonathan Snook

Send SubscribeEmail

Page 47: The Future is Modular, Jonathan Snook

http://snk.ms/26

Page 48: The Future is Modular, Jonathan Snook

• Separate layout from module

• Micro layout classes

Page 49: The Future is Modular, Jonathan Snook

<span class=“layout-inline”> <input><button>Send</button></span>

<span class=“layout-inline”> <button>Subscribe</button></span>

Page 50: The Future is Modular, Jonathan Snook

<input><button>Send</button>

<button class=“ML-S”>Subscribe</button>

Page 51: The Future is Modular, Jonathan Snook

BONUS PROBLEM!Media Queries

Page 52: The Future is Modular, Jonathan Snook
Page 53: The Future is Modular, Jonathan Snook
Page 54: The Future is Modular, Jonathan Snook

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

Page 55: The Future is Modular, Jonathan Snook

If Module A has roomdo this.

Page 56: The Future is Modular, Jonathan Snook

Element Queries

Page 57: The Future is Modular, Jonathan Snook

Element Queries

Page 58: The Future is Modular, Jonathan Snook

Oh, right. SMACSS.

Page 59: The Future is Modular, Jonathan Snook
Page 60: The Future is Modular, Jonathan Snook
Page 61: The Future is Modular, Jonathan Snook
Page 62: The Future is Modular, Jonathan Snook
Page 63: The Future is Modular, Jonathan Snook
Page 64: The Future is Modular, Jonathan Snook
Page 65: The Future is Modular, Jonathan Snook
Page 66: The Future is Modular, Jonathan Snook

Design has a cost.

Page 67: The Future is Modular, Jonathan Snook

Every piece of design ends up in code.

Page 68: The Future is Modular, Jonathan Snook
Page 69: The Future is Modular, Jonathan Snook
Page 70: The Future is Modular, Jonathan Snook

• Categorize

• Naming Convention

Page 71: The Future is Modular, Jonathan Snook

Base

Layout

Module

State

Theme

Page 72: The Future is Modular, Jonathan Snook

• .btn • .btn--variation • .btn__component

• .btn • &--variation • &__component

• button.css • .variation • .component

SMACSS-yBEM

Sass

CSS Modu

les/Rea

ct

• .btn • .btn-variation • .btn--component

Page 73: The Future is Modular, Jonathan Snook

HTML

CSS

JavaScript

HTML

CSS

JavaScript

HTML

CSS

JavaScript

Page 74: The Future is Modular, Jonathan Snook

React and Inline Styles

Page 75: The Future is Modular, Jonathan Snook

React.render( <XUIButton type={type}> My Button! </XUIButton> );

Page 76: The Future is Modular, Jonathan Snook

var XUIButton = React.createClass({ render: function() { return ( <button className="{this.props.type}"> {this.props.children} </button> ); }});

Page 77: The Future is Modular, Jonathan Snook

var myStyle = { color: '#FFF', backgroundColor: '#330000'}

var XUIButton = React.createClass({ render: function() { return ( <button style="{myStyle}"> {this.props.children} </button> ); }});

Page 78: The Future is Modular, Jonathan Snook

HTML

CSS

JavaScript

HTML

CSS

JavaScript

HTML

CSS

JavaScript

Page 79: The Future is Modular, Jonathan Snook

The Future: Web Components

Page 80: The Future is Modular, Jonathan Snook

• Templates

• Shadow DOM

• Custom Elements

• HTML Imports

Page 81: The Future is Modular, Jonathan Snook

var p = document.createElement(‘p');

p.createShadowRoot();

p.shadowRoot.innerHTML = 'HTML Contents';

document.body.appendChild(p);

Page 82: The Future is Modular, Jonathan Snook

• The Cascade no longer applies

• Inheritance still applies (unless you use all:initial)

Page 83: The Future is Modular, Jonathan Snook
Page 84: The Future is Modular, Jonathan Snook

HTML

CSS

JavaScript

Page 85: The Future is Modular, Jonathan Snook

HTML

CSS

JavaScript

component.html <link rel="import" href="component.html">

Page 86: The Future is Modular, Jonathan Snook

<template><figure> <content select="img"></content></figure><div> <content></content></div></template>

Page 87: The Future is Modular, Jonathan Snook

<custom-element> <img src="…"></custom-element>

Page 88: The Future is Modular, Jonathan Snook

// Creates a MediaObjectElement class // that extends HTMLElement.class MediaObjectElement extends HTMLElement { createdCallback() { var shadowRoot = this.createShadowRoot(); shadowRoot.innerHTML = 'Shadow DOM contents...'; }}

// Registers the `<custom-element>` element for use.document.registerElement('custom-element', MediaObjectElement);

Page 89: The Future is Modular, Jonathan Snook

• Likely a year before all browsers support everything.

• JavaScript Dependent

• Phillip Walton’s Talk on Modular CSS with Web Components http://snk.ms/27

Page 90: The Future is Modular, Jonathan Snook

• Think about standardized and modular design.

• Frameworks like React can help.

• Web Components are coming. (So is winter.)

Page 91: The Future is Modular, Jonathan Snook

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