WebComponents or shadow side of the Doom

15
WebComponents or shadow side of the Doom Grzegorz Wilczyński @wilq_ Wrocław, 17.11.2014

description

WebComponents or shadow side of the Doom

Transcript of WebComponents or shadow side of the Doom

Page 1: WebComponents or shadow side of the Doom

WebComponents or shadow side of the Doom

Grzegorz Wilczyński @wilq_

Wrocław, 17.11.2014

Page 2: WebComponents or shadow side of the Doom

But Why?

Page 3: WebComponents or shadow side of the Doom

Four Horsemen

Custom Elements

HTML Imports

Templates

Shadow DOM

Page 4: WebComponents or shadow side of the Doom

Custom Elements

<polymer-element name="post-list" extends="post-list-base" attributes="type posts"> <template> </template> </polymer-element>

Page 5: WebComponents or shadow side of the Doom

Custom Elements

<post-list> post list </post-list> !

<post-list posts="{foo: 'bar'}" type="pretty"> post list with attributes </post-list>

Page 6: WebComponents or shadow side of the Doom

Templates

<template repeat="{{post in posts}}"> <post-card> <img src="{{post.avatar}}"> <h2>{{post.username}}</h2> <p>{{post.text}}</p> </post-card> </template>

Page 7: WebComponents or shadow side of the Doom

Templates

<template> <div class="card-header" layout horizontal center> <content select="img"></content> <content select="h2"></content> </div> <content></content> <template>

Page 8: WebComponents or shadow side of the Doom

Shadow DOM

Page 9: WebComponents or shadow side of the Doom
Page 10: WebComponents or shadow side of the Doom

Shadow DOM

Shadow DOM gives us DOM tree encapsulation and style boundaries, but please don't: !

:host([data-post-status="warning"]) /deep/ #postState /deep/ #submitButton /deep/ core-icon { color: #259b24; }

Page 11: WebComponents or shadow side of the Doom

HTML Imports

<link rel="import" href="foo/bar.html">

Page 12: WebComponents or shadow side of the Doom

Are We Componentized Yet?

X-Tags by Mozilla

Polymer by Google

Bosonic

Page 13: WebComponents or shadow side of the Doom

Warehouse

Search Bower Packages

Component Kitchen

Custom Elements

Page 14: WebComponents or shadow side of the Doom

Sources

http://webcomponents.org

https://www.polymer-project.org

http://pascalprecht.github.io/dont-stop-thinking-about-tomorrow/

http://jonrimmer.github.io/are-we-componentized-yet/

Page 15: WebComponents or shadow side of the Doom

Thank YOU