Guillermo Rodas
Google Developer Expert in Web Technologies, Community Organizer, and Online Teacher.
@garethderioth
Medellin, December 9, 2015
https://mmmelon.com/es
<div id="tabs">
<ul>
<li><a href="#tabs-1">Nunc tincidunt</a></li>
<li><a href="#tabs-2">Proin dolor</a></li>
<li><a href="#tabs-3">Aenean lacinia</a></li>
</ul>
<div id="tabs-1">
<p>Proin elit arcu.</p>
</div>
<div id="tabs-2">
<p>Morbi tincidunt.</p>
</div>
<div id="tabs-3">
<p>Mauris eleifend.</p>
</div>
</div>
<script>
$( "#tabs" ).tabs();
</script>
https://jqueryui.com/tabs/
<div id="tabstrip">
<ul>
<li>Tab 1</li>
<li>Tab 2</li>
</ul>
<div>Content 1</div>
<div>Content 2</div>
</div>
<script>
$("#tabstrip").kendoTabStrip({
animation: {
// fade-out current tab over 1000 milliseconds
close: {
duration: 1000,
effects: "fadeOut"
},
// fade-in new tab over 500 milliseconds
open: {
duration: 500,
effects: "fadeIn"
}
}
});
</script>
http://docs.telerik.com/kendo-ui/api/javascript/ui/tabstrip
<div id="demo"></div>
<script>
YUI().use('tabview', function(Y) {
var tabview = new Y.TabView({
children: [{
label: 'foo',
content: '<p>foo content</p>'
}, {
label: 'bar',
content: '<p>bar content</p>'
}, {
label: 'baz',
content: '<p>baz content</p>'
}]
});
tabview.render('#demo');
});
</script>
http://yuilibrary.com/yui/docs/tabview/
@Component({
selector: 'tabs',
template: `
<ul>
<li *ng-for="#tab of tabs" (click)="selectTab(tab)">
{{tab.tabTitle}}
</li>
</ul>
<content></content>
`,
directives: [NgFor]
})
export class Tabs {
constructor() {
this.tabs = [];
}
selectTab(tab) {
this.tabs.forEach((tab) => {
tab.active = false;
});
tab.active = true;
}
addTab(tab: Tab) {
if (this.tabs.length === 0) {
tab.active = true;
}
this.tabs.push(tab);
}
}
@Component({
selector: 'tab',
inputs: ['tabTitle: tab-title'],
template: `
<div [hidden]="!active">
<content></content>
</div>
`
})
export class Tab {
constructor(tabs:Tabs) {
tabs.addTab(this);
}
}
http://blog.thoughtram.io/angular/2015/04/09/developing-a-tabs-component-in-angular-2.html
https://github.com/pedronauck/react-simpletabs
var Tabs = require('react-simpletabs');
var App = React.createClass({
render: function() {
return (
<Tabs>
<Tabs.Panel title='Tab #1'>
<h2>Content #1 here</h2>
</Tabs.Panel>
<Tabs.Panel title='Tab #2'>
<h2>Content #2 here</h2>
</Tabs.Panel>
<Tabs.Panel title='Tab #3'>
<h2>Content #3 here</h2>
</Tabs.Panel>
</Tabs>
);
}
});
React.renderComponent(<App />, mountNode);
<paper-tabs>
<paper-tab>KNOWLEDGE</paper-tab>
<paper-tab>HISTORY</paper-tab>
<paper-tab>FOOD</paper-tab>
</paper-tabs>
https://elements.polymer-project.org/elements/paper-tabs
Just keep it simple!
noun
"an assembly plant for imported components"
https://en.wikipedia.org/wiki/Component-based_software_engineering
It is a reuse-based approach to defining, implementing and composing loosely coupled independent components into systems.
Web Components are a set of standards for the creation of reusable widgets or components in web documents and web applications.
Define new HTML/DOM elements
Define new HTML
<paper-tabs selected=“1”>
<paper-tab>Tab 1</paper-tab>
<paper-tab>Tab 2</paper-tab>
<paper-tab>Tab 3</paper-tab>
</paper-tabs>
const tabs = document.querySelector('paper-tabs');
tabs.addEventListener('iron-activate', function() {
console.log(this.selected);
});
Native client-side templating
Native client-side templating
Use DOM to scaffold DOM → no XSS
Parsed, not rendered
Content is inert until cloned/used
Doc fragment → not part of the page
<template>
<div class=“comment”>
<img src=“image.png”>
</div>
<script>...</script>
</template>
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template
DOM/CSS scoping
<video src=“foo.webm” controls></video>
<video src=“foo.webm” controls></video>
Actually Shadow DOM
Loading web components
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link href="bootstrap.html" rel="import">
vulcanize target.html > build.html
grunt-vulcanize
gulp-vulcanize
vulcanize-loader
Create new HTML elements and extend existing ones
Native templating in the browser
Scoped CSS with encapsulated markup
Load custom element definitions and resources
http://jonrimmer.github.io/are-we-componentized-yet/
https://blogs.windows.com/msedgedev/2015/07/14/bringing-componentization-to-the-web-an-overview-of-web-components/
https://blogs.windows.com/msedgedev/2015/07/15/microsoft-edge-and-web-components/
"Web components have a lot to offer the community. We’re excited about the potential for the technology to dramatically simplify large-scale web development while simultaneously reinforcing good declarative patterns that are already familiar in HTML."
https://hacks.mozilla.org/2015/11/an-update-on-web-components-and-firefox/
https://developer.mozilla.org/en-US/docs/Web/Web_Components/Status_in_Firefox
https://webkit.org/blog/4096/introducing-shadow-dom-api/
"To complement shadow DOM, we’re also interested in custom elements. The custom elements API allows authors to associate a JavaScript class with a particular element name in HTML documents, and it’s a great way to attach shadow DOM and other custom behaviors idiomatically."
"To conclude, we’re really excited about bringing a major feature of Web Components to WebKit, and we’ll keep you posted about more features coming your way."
https://mozilla.github.io/platatus/#html-templates
https://webkit.org/status/#feature-template-element
https://dev.windows.com/en-us/microsoft-edge/platform/status/templateelement
https://www.chromestatus.com/features/5207287069147136
https://mozilla.github.io/platatus/#shadow-dom
https://webkit.org/status/#feature-shadow-dom
https://dev.windows.com/en-us/microsoft-edge/platform/status/shadowdom
https://www.chromestatus.com/features/4507242028072960
https://mozilla.github.io/platatus/#custom-elements
https://webkit.org/status/#feature-custom-elements
https://dev.windows.com/en-us/microsoft-edge/platform/status/customelements
https://www.chromestatus.com/features/4642138092470272
https://mozilla.github.io/platatus/#html-imports
https://webkit.org/status/#feature-html-imports
https://dev.windows.com/en-us/microsoft-edge/platform/status/htmlimports
https://www.chromestatus.com/features/5144752345317376
By Guillermo Rodas
Web Components Support today for a series of FE talks
Google Developer Expert in Web Technologies, Community Organizer, and Online Teacher.