SlideShare a Scribd company logo
Try Web Components!
Hiroki Tani

Front-end Developer
2013-11-30(SAT.)
Goal
Goal
$ yo polymer
Web Components?
Shadow DOM Encapsulation
HTML Templates Scaffolding
Custom Elements Extensions
HTML Imports Packaging
<x-calendar></x-calendar>

http://mozilla.github.io/brick/demos/x-tag-calendar/index.html
<x-calendar view="2013-06-09" controls></x-calendar>

http://mozilla.github.io/brick/demos/x-tag-calendar/index.html
<x-flipbox>
<div>I'm the front face.</div>
<div>And I'm the back face.</div>
</x-flipbox>

http://mozilla.github.io/brick/demos/x-tag-flipbox/index.html
<button is="mega-button">Mega button</button>

http://www.webcomponentsshift.com/#10
<gangnam-style></gangnam-style>

http://www.webcomponentsshift.com/#9
<gangnam-style></gangnam-style>

http://www.webcomponentsshift.com/#9
Try Web Components
Fail!

Fail!
Try Web Components
Fail!

Fail!
Try Web Components!
Try Web Components!
w/ Polymer
http://www.polymer-project.org/
http://www.html5rocks.com/en/tutorials/webcomponents/yeoman/
http://www.html5rocks.com/en/tutorials/webcomponents/yeoman/
$
$
$
$
$

npm install -g yo
npm install generator-polymer -g
mkdir YOUR_PROJECT && cd $_
yo polymer
yo polymer:element YOUR_ELEMENT

http://www.html5rocks.com/en/tutorials/webcomponents/yeoman/
<polymer-element name="YOUR_ELEMENT-element" attributes="">
<template>
<style>
@host { :scope {display: block;} }
</style>
<span>I'm <b>YOURELEMENT-element</b>. This is my Shadow
DOM.</span>
</template>
<script>
Polymer('YOUR_ELEMENT-element', {
//applyAuthorStyles: true,
//resetStyleInheritance: true,
created: function() { },
enteredView: function() { },
leftView: function() { },
attributeChanged: function(attrName, oldVal, newVal) { }
});
</script>
</polymer-element>
<polymer-element name="YOUR_ELEMENT-element" attributes="">
<template>
<style>
@host { :scope {display: block;} }
</style>
<span>I'm <b>YOURELEMENT-element</b>. This is my Shadow
DOM.</span>
</template>
<script>
Polymer('YOUR_ELEMENT-element', {
//applyAuthorStyles: true,
//resetStyleInheritance: true,
created: function() { },
enteredView: function() { },
leftView: function() { },
attributeChanged: function(attrName, oldVal, newVal) { }
});
</script>
</polymer-element>
<polymer-element name="YOUR_ELEMENT-element" attributes="">
<template>
<style>
@host { :scope {display: block;} }
</style>
<span>I'm <b>YOURELEMENT-element</b>. This is my Shadow
DOM.</span>
</template>
<script>
Polymer('YOUR_ELEMENT-element', {
//applyAuthorStyles: true,
//resetStyleInheritance: true,
created: function() { },
enteredView: function() { },
leftView: function() { },
attributeChanged: function(attrName, oldVal, newVal) { }
});
</script>
</polymer-element>

Please...
<x-switch></x-switch>

https://github.com/hiloki/demo/tree/master/frontrend_chrome/switch.html
<polymer-element name="x-switch" attributes="status">
<template>
<style>
...
input[type=checkbox] {
-webkit-appearance: none;
box-shadow: inset 0px 0px 0px 1px #e6e6e6;
...
}
input[type=checkbox]:checked {
box-shadow: inset 0px 0px 0px 20px #53d76a;
}
...
</style>
<input type="checkbox" />
</template>
<script>
...
</script>
</polymer-element>
<x-switch></x-switch>
https://github.com/hiloki/demo/tree/master/frontrend_chrome
<x-appbar heading="Feed" class="the-header">
	 <a href="./home" class="appbar-left">
	 	 <x-icon type="fa-list" attr="fa-lg"></x-icon>
	 </a>
	 <a href="./gear" class="appbar-right">
	 	 <x-icon type="fa-gear" attr="fa-lg"></x-icon>
	 </a>
</x-appbar>
<x-tabs class="the-tabs">
	 <div>
	 	 <x-icon type="fa-pencil" attr="fa-lg"></x-icon> Status
	 </div>
	 <div>
	 	 <x-icon type="fa-camera" attr="fa-lg"></x-icon> Photo
	 </div>
	 <div>
	 	 <x-icon type="fa-map-marker" attr="fa-lg"></x-icon> Check-in
	 </div>
</x-tabs>
<x-media src="/images/hiloki.jpg" width="50" height="50"
class="author">
	 	 <p class="author-name">Hiroki Tani</p>
	 	 <p><x-icon type="fa-map-marker" attr="fa-lg"></x-icon>
Nagiso, Nagano</p>
</x-media>
<x-like class="the-article-feedback-like"></x-like>

index.html
<x-like class="the-article-feedback-like"></x-like>
class="the-article-feedback-like">
<x-icon type="fa-thumbs-o-up" attr="fa-lg" on-click="">
<i class="fa fa-thumbs-o-up fa-lg"></i>
</x-icon>
<span></span>
</x-like>

index.html + Show Shadow DOM
<polymer-element name="x-like" attributes="type count">
<template>
<x-icon type="{{type}}" attr="fa-lg" on-click="{{countup}}"></xicon> <span>{{count}}</span>
</template>
<script>
Polymer('x-like', {
type: "fa-thumbs-o-up",
count: "",
countup: function() {
this.count++;
this.type = "fa-thumbs-up";
}
});
</script>
</polymer-element>

elements/x-like.html
<x-like class="the-article-feedback-like" type="fa-thumbs-up"
count="3">
<x-icon type="fa-thumbs-up" attr="fa-lg" on-click="">
<i class="fa fa-thumbs-up fa-lg"></i>
</x-icon>
<span>3</span>
</x-like>

index.html + Show Shadow DOM
Web Components
makes
Web development
more fun!
Thanks!
Hiroki Tani

@hiloki,@hiloki_en
inkdesign.jp
html5experts.jp/hiloki/

More Related Content

PDF
Beyond CSS Architecture
PDF
モダンなCSS設計パターンを考える
PDF
CSSプリプロセッサの取扱説明書
PDF
モダンなCSS設計パターンを考える
KEY
Slow kinda sucks
PDF
Prototyping w/HTML5 and CSS3
PPTX
Rapid and Responsive - UX to Prototype with Bootstrap
DOC
I pv6+at+caribbean+sector
Beyond CSS Architecture
モダンなCSS設計パターンを考える
CSSプリプロセッサの取扱説明書
モダンなCSS設計パターンを考える
Slow kinda sucks
Prototyping w/HTML5 and CSS3
Rapid and Responsive - UX to Prototype with Bootstrap
I pv6+at+caribbean+sector

What's hot (20)

PDF
Progressive Prototyping w/HTML5, CSS3 and jQuery
PDF
Html5 ux london
PDF
High-Quality JavaScript
PDF
Html5 & CSS overview
PPTX
iPhone Web Applications: HTML5, CSS3 & dev tips for iPhone development
PDF
Introduction to web components
KEY
Html5 intro
PDF
Your Custom WordPress Admin Pages Suck
TXT
Test upload
TXT
Guia de-estudio-2
TXT
Gordian Knot Presentation (Help Network)
PDF
The Thinking behind BEM
PDF
Stole16
KEY
Page Caching Resurrected
PPT
HTML & CSS Workshop Notes
TXT
Private slideshow
KEY
关于 Html5 那点事
PDF
Html bangla
PDF
Bangla html
PDF
How to create a basic template
Progressive Prototyping w/HTML5, CSS3 and jQuery
Html5 ux london
High-Quality JavaScript
Html5 & CSS overview
iPhone Web Applications: HTML5, CSS3 & dev tips for iPhone development
Introduction to web components
Html5 intro
Your Custom WordPress Admin Pages Suck
Test upload
Guia de-estudio-2
Gordian Knot Presentation (Help Network)
The Thinking behind BEM
Stole16
Page Caching Resurrected
HTML & CSS Workshop Notes
Private slideshow
关于 Html5 那点事
Html bangla
Bangla html
How to create a basic template
Ad

Viewers also liked (7)

PDF
Thinking about CSS Architecture
PDF
Hello jQuery - 速習jQuery +綺麗なコードを書くためのヒント -
PDF
High Performance Webdesign
PDF
日米における商品としてのアニメーションの動向
PDF
CSS設計の理想と現実
PDF
10 Revealing Statistics About Compensation & Benefits You should Know
PDF
Build Features, Not Apps
Thinking about CSS Architecture
Hello jQuery - 速習jQuery +綺麗なコードを書くためのヒント -
High Performance Webdesign
日米における商品としてのアニメーションの動向
CSS設計の理想と現実
10 Revealing Statistics About Compensation & Benefits You should Know
Build Features, Not Apps
Ad

Similar to Try Web Components (20)

PDF
Introduction to Web Components & Polymer Workshop - JS Interactive
PDF
Custom Elements with Polymer Web Components #econfpsu16
PPTX
Introduction to Web Components & Polymer Workshop - U of I WebCon
PPTX
Web Components: The Future of Web Development is Here
PDF
PPTX
Web Components
PDF
2014 03-25 - GDG Nantes - Web Components avec Polymer
PDF
Web components are the future of the web - Take advantage of new web technolo...
PPTX
Віталій Бобров — Web components, Polymer and Drupal
PDF
Александр Кашеверов - Polymer
PDF
Client side apps from the future
PDF
Web components the future is here
PDF
Web Components with Polymer (extra Polymer 2.0)
PDF
Polymer & the web components revolution 6:25:14
PDF
Polytechnic 1.0 Granada
PPTX
Web Components: The Future of Web Development is Here
PDF
Introduction to Polymer and Firebase - Simon Gauvin
PDF
Devoxx France - Web Components, Polymer et Material Design
PDF
Levent-Gurses' Introduction to Web Components & Polymer
PDF
Tech talk polymer
Introduction to Web Components & Polymer Workshop - JS Interactive
Custom Elements with Polymer Web Components #econfpsu16
Introduction to Web Components & Polymer Workshop - U of I WebCon
Web Components: The Future of Web Development is Here
Web Components
2014 03-25 - GDG Nantes - Web Components avec Polymer
Web components are the future of the web - Take advantage of new web technolo...
Віталій Бобров — Web components, Polymer and Drupal
Александр Кашеверов - Polymer
Client side apps from the future
Web components the future is here
Web Components with Polymer (extra Polymer 2.0)
Polymer & the web components revolution 6:25:14
Polytechnic 1.0 Granada
Web Components: The Future of Web Development is Here
Introduction to Polymer and Firebase - Simon Gauvin
Devoxx France - Web Components, Polymer et Material Design
Levent-Gurses' Introduction to Web Components & Polymer
Tech talk polymer

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Empathic Computing: Creating Shared Understanding
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Big Data Technologies - Introduction.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
“AI and Expert System Decision Support & Business Intelligence Systems”
Empathic Computing: Creating Shared Understanding
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectral efficient network and resource selection model in 5G networks
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Network Security Unit 5.pdf for BCA BBA.
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Dropbox Q2 2025 Financial Results & Investor Presentation
MIND Revenue Release Quarter 2 2025 Press Release
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Teaching material agriculture food technology

Try Web Components