Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Jonathan Snook – Falling to Pieces: The Componentization of the Web (Turing Fest 2017)

Jonathan Snook – Falling to Pieces: The Componentization of the Web (Turing Fest 2017)

Turing Fest

August 03, 2017
Tweet

More Decks by Turing Fest

Other Decks in Technology

Transcript

  1. #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 .article.inside h1 { text-transform:uppercase;…} #comments .comment .meta .authorname { text-transfo… } #comments .comment .meta .commentnumber a { float: … } #main .article.inside h1 { text-transform:uppercase;…} #sidebar h2 { text-transfo… } #comments .comment .meta .commentnumber a { float: … }
  2. A module is “each of a set of standardized parts

    or independent units that can be used to construct a more complex structure.” –Dictionary
  3. • Typography
 e.g. color, font-size, font-family
 • List Styles
 e.g.

    list-style
 • Table Styles 
 e.g. border-collapse
  4. The cascade is how the browser decides what properties to

    apply when you have multiple rules declared on the same element.
  5. • Don’t write multiple rules for the same element
 •

    Inline styles
 • Create a structured layering system to prevent conflicts
  6. <button class="button"> .button {
 border:1px solid purple;
 padding: 5px 10px;


    color: pink;
 } <a href="/" class="button"> text-decoration: none;
  7. .button + .button,
 .input + .button { 
 margin-left: 10px;

    
 } * + * { 
 margin-left: 10px; 
 }
  8. • Need to know rendered HTML to know what CSS

    will be applied
 • Need to be able to know how HTML will change via JavaScript
 • Need to be able to understand cascade
  9. var XUIButton = React.createClass({ render: function() { return ( <button

    className="{this.props.type}"> {this.props.children} </button> ); } });
  10. var myStyle = { color: '#FFF', backgroundColor: '#330000' } var

    XUIButton = React.createClass({ render: function() { return ( <button style="{myStyle}"> {this.props.children} </button> ); }
  11. • Tooling avoids namespacing and cascade issues
 • CSS embedded

    with JS allows easier visualization/ understanding of how the component and the styles for the component are linked
 • Bundling CSS and HTML with JS has potential for cohesive understanding and enable optimization
 • Automate what SMACSS/BEM does through convention Pros
  12. • Handling CSS’s state management at the JS level can

    cause performance issues or require workarounds
 • Like everything else, the solutions don’t understand the HTML and have no way to optimize 
 • Side effects when working outside of tooling ecosystem Cons
  13. • Web Components can be used across JavaScript frameworks
 GE

    did this: http://snk.ms/2a
 • Shadow DOM avoids cascade and namespacing issues Pros
  14. • No performance tooling (yet)
 • For now, cross-browser support

    is spotty and requires polyfills that don’t behave the same Cons
  15. • Think about standardized and modular design.
 • Frameworks like

    React can help.
 • Web Components are coming. (So is winter.)