SlideShare a Scribd company logo
1 of 39
Download to read offline
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
Fail!

Fail!
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

What's hot

Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
Anthony Montalbano
 
Gordian Knot Presentation (Help Network)
Gordian Knot Presentation (Help Network)Gordian Knot Presentation (Help Network)
Gordian Knot Presentation (Help Network)
Jim Osowski
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
sblackman
 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic template
vathur
 

What's hot (20)

Progressive Prototyping w/HTML5, CSS3 and jQuery
Progressive Prototyping w/HTML5, CSS3 and jQueryProgressive Prototyping w/HTML5, CSS3 and jQuery
Progressive Prototyping w/HTML5, CSS3 and jQuery
 
Html5 ux london
Html5 ux londonHtml5 ux london
Html5 ux london
 
High-Quality JavaScript
High-Quality JavaScriptHigh-Quality JavaScript
High-Quality JavaScript
 
Html5 & CSS overview
Html5 & CSS overviewHtml5 & CSS overview
Html5 & CSS overview
 
iPhone Web Applications: HTML5, CSS3 & dev tips for iPhone development
iPhone Web Applications: HTML5, CSS3 & dev tips for iPhone developmentiPhone Web Applications: HTML5, CSS3 & dev tips for iPhone development
iPhone Web Applications: HTML5, CSS3 & dev tips for iPhone development
 
Introduction to web components
Introduction to web componentsIntroduction to web components
Introduction to web components
 
Html5 intro
Html5 introHtml5 intro
Html5 intro
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
 
Test upload
Test uploadTest upload
Test upload
 
Guia de-estudio-2
Guia de-estudio-2Guia de-estudio-2
Guia de-estudio-2
 
Gordian Knot Presentation (Help Network)
Gordian Knot Presentation (Help Network)Gordian Knot Presentation (Help Network)
Gordian Knot Presentation (Help Network)
 
The Thinking behind BEM
The Thinking behind BEMThe Thinking behind BEM
The Thinking behind BEM
 
Stole16
Stole16Stole16
Stole16
 
Page Caching Resurrected
Page Caching ResurrectedPage Caching Resurrected
Page Caching Resurrected
 
HTML & CSS Workshop Notes
HTML & CSS Workshop NotesHTML & CSS Workshop Notes
HTML & CSS Workshop Notes
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
 
关于 Html5 那点事
关于 Html5 那点事关于 Html5 那点事
关于 Html5 那点事
 
Html bangla
Html banglaHtml bangla
Html bangla
 
Bangla html
Bangla htmlBangla html
Bangla html
 
How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic template
 

Viewers also liked

Viewers also liked (7)

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

Similar to Try Web Components

Александр Кашеверов - Polymer
Александр Кашеверов - PolymerАлександр Кашеверов - Polymer
Александр Кашеверов - Polymer
DataArt
 
Polymer
Polymer Polymer
Polymer
jskvara
 

Similar to Try Web Components (20)

Polymer - Lego for the web!
Polymer - Lego for the web!Polymer - Lego for the web!
Polymer - Lego for the web!
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web Components
 
Polymer-Powered Design Systems - DevFest Florida
Polymer-Powered Design Systems - DevFest FloridaPolymer-Powered Design Systems - DevFest Florida
Polymer-Powered Design Systems - DevFest Florida
 
Web Components: Web back to future.
Web Components: Web back to future.Web Components: Web back to future.
Web Components: Web back to future.
 
Web Components mit Polymer und AngularJS 1.x
Web Components mit Polymer und AngularJS 1.xWeb Components mit Polymer und AngularJS 1.x
Web Components mit Polymer und AngularJS 1.x
 
Web Components mit Polymer und AngularJS 1.x
Web Components mit Polymer und AngularJS 1.xWeb Components mit Polymer und AngularJS 1.x
Web Components mit Polymer und AngularJS 1.x
 
X tag with web components - joe ssekono
X tag with web components - joe ssekonoX tag with web components - joe ssekono
X tag with web components - joe ssekono
 
Polytechnic 1.0 Granada
Polytechnic 1.0 GranadaPolytechnic 1.0 Granada
Polytechnic 1.0 Granada
 
Web Components: back to the future
Web Components: back to the futureWeb Components: back to the future
Web Components: back to the future
 
TOSSUG HTML5 讀書會 新標籤與表單
TOSSUG HTML5 讀書會 新標籤與表單TOSSUG HTML5 讀書會 新標籤與表單
TOSSUG HTML5 讀書會 新標籤與表單
 
Adobe & HTML5
Adobe & HTML5Adobe & HTML5
Adobe & HTML5
 
Александр Кашеверов - Polymer
Александр Кашеверов - PolymerАлександр Кашеверов - Polymer
Александр Кашеверов - Polymer
 
Developing web applications in 2010
Developing web applications in 2010Developing web applications in 2010
Developing web applications in 2010
 
Introduction to Webcomponents
Introduction to WebcomponentsIntroduction to Webcomponents
Introduction to Webcomponents
 
HTML & CSS - Le Wagon Bootcamp
HTML & CSS - Le Wagon BootcampHTML & CSS - Le Wagon Bootcamp
HTML & CSS - Le Wagon Bootcamp
 
Magento Fireside Chat: "Wiring Mageno Projects"
Magento Fireside Chat: "Wiring Mageno Projects"Magento Fireside Chat: "Wiring Mageno Projects"
Magento Fireside Chat: "Wiring Mageno Projects"
 
JQuery Mobile UI
JQuery Mobile UIJQuery Mobile UI
JQuery Mobile UI
 
Polymer
Polymer Polymer
Polymer
 
iWebkit
iWebkitiWebkit
iWebkit
 
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Try Web Components