32. Web Components canoo
Web Components
C
ustom
E
lem
ents
H
TM
L
Im
ports
S
hadowâ¨
D
O
M
E
lem
ent
Tem
plate
33. Web Components canoo
Web Components
C
ustom
â¨
E
lem
ents
H
TM
L
Im
ports
S
hadow
D
O
M
E
lem
ent
Tem
plate
34. Web Components canoo
<div class="activity">
<a>Michael</a> had fun coding.
</div>
How do we store the icon source and time?
What is a <div> with the class âactivityâ anyway?
35. Web Components canoo
<activity-card iconSrc="img/michael.jpg" time="Seconds ago">
<a>Michael</a> had fun coding.
</activity-card>
<div class="activity">
<a>Michael</a> had fun coding.
</div>
38. document.registerElement("activity-card", options);
Web Components canoo
var activityCardPrototype = Object.create(HTMLElement.prototype);
var options = {prototype: activityPrototype}
<activity-card iconSrc="img/michael.jpg" time="Seconds ago">
<a>Michael</a> had fun coding.
</activity-card>
48. Web Components canoo
Web Components
C
ustom
E
lem
ents
H
TM
L
â¨
Im
ports
S
hadow
D
O
M
E
lem
ent
Tem
plate
49. Web Components canoo
Web Components
C
ustom
â¨
E
lem
ents
H
TM
L
â¨
Im
ports
S
hadowâ¨
D
O
M
E
lem
entâ¨
Tem
plateâ¨
50. webcomponent.js
Web Components canoo
⢠Today not all browsers support the new standards
⢠The community provides a pollyďŹlls to enable web
components in browser that have no native support
$ bower install --save webcomponentsjs
<script src="bower_components/webcomponentsjs/webcomponents.js"></script>
install it with bower
use it in your code
51. webcomponent.js
Web Components canoo
⢠The polyďŹlls are the junction of X-Tag and Polymer
basic libraries
⢠Mozilla created X-Tag as a polyďŹll to provide web
components
⢠Google created Polymer as a polyďŹll to provide web
components
52. webcomponent.js
Web Components canoo
⢠X-Tag and Polymer depends on webcomponents-js
⢠Both libraries provide additional features that are not
part of the speciďŹcation
webcomponents.org
53. X-Tag
Web Components canoo
<X>
⢠X-Tag is created & supported by Mozilla
⢠Future version will depend on webcomponents.js
(dependency added Jan 5, 2015)
⢠Adds some API sugar on top of webcomponents.js
x-tags.org
55. Polymer
Web Components canoo
⢠Polymer is created & supported by Google
⢠Adds some API sugar on top of webcomponents.js
⢠Provides elements for Material Design based
applications
www.polymer-project.org
58. Data Bindings
Web Components canoo
⢠two-way data binding is one of the additional features
of Polymer
<dom-module id="host-element">
<template>
<child-element name="{{myName}}"></child-element>
</template>
</dom-module>
59. The next steps
⢠Web Components can be reused
⢠Web Components can be styled
⢠A logical consequence is to provide toolkits
Web Components canoo
60. Google Web Components
Web Components canoo
<google-chart></google-chart>
<google-hangout-button></google-hangout-button>
⢠Google is building a lot of components (maps,
youtubeâŚ)
61. Google Polymer Paper
⢠provides custom web components
⢠provides layouts
⢠provides icon sets
Web Components canoo
62. Bootstrap
⢠Polymer is only released as developer preview
⢠Bootstrap is ďŹnal (Version 3.x)
⢠Polymer is based on modern web technology
⢠Bootstrap is based on CSS (and some JavaScript)
⢠Polymer provides custom web components
⢠Bootstrap provides CSS rules
Web Components canoo
Paper
63. Why does Google provide it?
⢠Polymer is the web part of âMaterial Designâ
⢠Provide the same user experience on any device
⢠Provide the same user experience over many
applications
Web Components canoo
âWe challenged ourselves to create a visual language for our users
that synthesizes the classic principles of good design with the
innovation and possibility of technology and science.â
64.
65.
66.
67.
68. Important features
⢠Responsive Design
⢠Customizable - Create your cooperative design
⢠Easy to use
⢠Extendable
Web Components canoo
74. ⢠Layout containers
⢠Components
⢠Animations
⢠Icons
Polymer Paper Elements
Web Components canoo
75. ⢠All components (layouts, controls, icons) are build as
web components
⢠A single component or a set can be added by using
bower
How to use Components
Web Components canoo
$ bower install --save PolymerElements/paper-elements
<link rel="import" href="bower_components/paper-slider/paper-slider.html">
import it in HTML
76. Bower
⢠A package manager for the web
⢠Search for dependencies and install them as packages
⢠Created by Twitter
⢠Open Source
Web Components canoo
www.bower.io
77. Bower
requires npm, node.js and git
Web Components canoo
$ npm install -g bower
$ bower init
$ bower install --save webcomponentsjs
in your project folder
download &
add module
add dependency to
bower file
78. ⢠The default Button
⢠shows ripple animation on click
Paper Button
Web Components canoo
<paper-button>flat button</paper-button>
<paper-button raised>raised button</paper-button>
<paper-button noink>No ripple effect</paper-button>
79. ⢠A styled CheckBox
⢠State can be deďŹned as attribute
Paper CheckBox
Web Components canoo
<paper-checkbox></paper-checkbox>
<paper-checkbox checked></paper-checkbox>
80. ⢠A dialog
⢠Supports title, modality, actions, âŚ
Paper Dialog
Web Components canoo
<paper-dialog>
<h2>Title</h2>
<paper-dialog-scrollable>
Lorem ipsum...
</paper-dialog-scrollable>
<div class="buttons">
...
</div>
</paper-dialog>
86. ⢠An application toolbar
⢠Toolbar content will be aligned
Toolbar
Web Components
<paper-toolbar>
<paper-icon-button icon="menu"></paper-icon-button>
<div title>Title</div>
<paper-icon-button icon="more"></paper-icon-button>
</paper-toolbar>
canoo
87. ⢠Wrapper around toolbar and
content
⢠Toolbar always on top
⢠Content scrollable
HeaderPanel
Web Components canoo
<paper-header-panel>
<paper-toolbar>Header</paper-toolbar>
<div>Content goes here...</div>
</paper-header-panel>
88. ⢠Adds a responsive
menu
⢠DeďŹnes attributes to
open and close the
menu
⢠Normally wraps 2
core-header-panel
DrawerPanel
Web Components canoo
89. ⢠You can create your own components
⢠API is more easy then the web components standard
Polymer Custom Elements
Web Components canoo
90. Polymer Element
Web Components
<dom-module id="hello-world">
<template>
Hello <span>{{name}}</span>
</template>
</dom-module>
<script>
Polymer({
is: 'hello-world',
properties: {
name: String
}
});
</script>
canoo
91. Polymer Element
Web Components canoo
bidirectional binding
tag attributes
custom tag name
<dom-module id="hello-world">
<template>
Hello <span>{{name}}</span>
</template>
</dom-module>
<script>
Polymer({
is: 'hello-world',
properties: {
name: String
}
});
</script>
93. ⢠Boilerplate for custom elements
Polymer Custom Elements
Web Components canoo
https://www.polymer-project.org/1.0/docs/start/reusableelements.html
https://goo.gl/nu9Rkx
94. Polymer Custom Elements
Web Components canoo
bower install
⢠seed-element.html
is the custom element
⢠Use it in index.html
⢠Tests can be deďŹned
by using Polymer
webcomponent-tester
(see test folder for
example)
95. Additional resources
Web Components canoo
⢠http://webcomponents.org
⢠http://component.kitchen
⢠http://customelements.io
most important entry point
custom web
components catalogs