Top Banner
USING COMPONENTS TO BUILD Native-Quality HTML5 Apps Gray Norton, Enyo http://enyojs.com @enyojs @graynorton Presentation originally authored by Kevin Schaaf (@kevinpschaaf)
39
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Using Components to Build Native-Quality HTML5 Apps

USING COMPONENTS TO BUILD

Native-Quality HTML5 Apps

Gray Norton, Enyohttp://enyojs.com

@enyojs

@graynorton

Presentation originally authored by Kevin Schaaf (@kevinpschaaf)

Page 2: Using Components to Build Native-Quality HTML5 Apps

HI.

Page 3: Using Components to Build Native-Quality HTML5 Apps

KNOCKING ON DOORS

Page 4: Using Components to Build Native-Quality HTML5 Apps

CSS

JS

Webpages

Page 5: Using Components to Build Native-Quality HTML5 Apps

Native-Quality

Apps

?CSS

JS

Page 6: Using Components to Build Native-Quality HTML5 Apps
Page 7: Using Components to Build Native-Quality HTML5 Apps
Page 8: Using Components to Build Native-Quality HTML5 Apps
Page 9: Using Components to Build Native-Quality HTML5 Apps

CONSISTENT LOOK & FEEL

HIGH PERFORMANCE

TOUCH-FRIENDLINESS

ADAPTABILITY

Page 10: Using Components to Build Native-Quality HTML5 Apps

MAINTAINABILITY

REUSABILITY

…AND NO WHEEL-REINVENTION

Page 11: Using Components to Build Native-Quality HTML5 Apps

TEMPLATES: NOT ENOUGH

?

Content-based Views Templates

Rich, Interactive Controls

Page 12: Using Components to Build Native-Quality HTML5 Apps

UI PLUGINS: NOT ENOUGH

Page 13: Using Components to Build Native-Quality HTML5 Apps

UI PLUGINS: NOT ENOUGH

Page 14: Using Components to Build Native-Quality HTML5 Apps

A NEW WAY OF THINKING

Page 15: Using Components to Build Native-Quality HTML5 Apps

COMPONENTS

THE SOLUTION:

Page 16: Using Components to Build Native-Quality HTML5 Apps

Functions

Properties

EventsA

PI

Markup:

Event handling:

Logic / state:

ENCAPSULATE

Lifecycle management:

Page 17: Using Components to Build Native-Quality HTML5 Apps

SLIDER

EXAMPLE:

Page 18: Using Components to Build Native-Quality HTML5 Apps

Markup Lifecycle Event Handling Logic/API

Lifecycle management:Event handling:State / Logic:Markup:Markup:

Page 19: Using Components to Build Native-Quality HTML5 Apps

new Slider({value:20});

new Slider({value:20});

new Slider({value:20});

new Slider({value:20});

new Slider({value:20});

Page 20: Using Components to Build Native-Quality HTML5 Apps
Page 21: Using Components to Build Native-Quality HTML5 Apps

APPLICATION VIEWS

EXAMPLE:

Page 22: Using Components to Build Native-Quality HTML5 Apps

+Label

Label

API: setContent()

IntegerLabel

API: setValue()

Label: 20

ValueLabel

API: setContent()

setValue()

Label: 20

ValueLabel

API: setContent()

setValue()

Slider

API: setValue()

+

+

LabeledSlider

API: setLabel()

setValue()

LabeledSlider

API: setLabel()

setValue()

Groupbox

AttributeView

API: setAttributes()

Page 23: Using Components to Build Native-Quality HTML5 Apps

AttributeView

API: setAttributes()

+

ContactDetailView

API: setContactModel()

Page 24: Using Components to Build Native-Quality HTML5 Apps

new ContactDetailView({contactModel:m});

new ContactDetailView({contactModel:m});

new ContactDetailView({contactModel:m});

new ContactDetailView({contactModel:m});

new ContactDetailView({contactModel:m});

Page 25: Using Components to Build Native-Quality HTML5 Apps

ContactDetail:AttributeView:LabeledSlider:Slider:

Page 26: Using Components to Build Native-Quality HTML5 Apps

LIST

EXAMPLE:

Page 27: Using Components to Build Native-Quality HTML5 Apps

List

Viewport

Page 0

Page 1

Render page

0

Render page

1

JavaScript: DOM:

Render page

0

Page 28: Using Components to Build Native-Quality HTML5 Apps
Page 29: Using Components to Build Native-Quality HTML5 Apps

SPOTLIGHT (FOCUS

MANAGER)

EXAMPLE:

Page 30: Using Components to Build Native-Quality HTML5 Apps

WEB COMPONENTS

TOWARD STANDARDIZATION:

Page 31: Using Components to Build Native-Quality HTML5 Apps

HTML TEMPLATES

CUSTOM ELEMENTS

SHADOW DOM

COMPONENT LOADER

Page 32: Using Components to Build Native-Quality HTML5 Apps

HTML TEMPLATES

Page 33: Using Components to Build Native-Quality HTML5 Apps

<template id="commentTemplate"><div>

<img src=""><div class="comment"></div>…

</div></template>

var t = document.querySelector("#commentTemplate");

someElement.appendChild(t.content.cloneNode());

Page 34: Using Components to Build Native-Quality HTML5 Apps

CUSTOM ELEMENTS

& SHADOW DOM

Page 35: Using Components to Build Native-Quality HTML5 Apps

<element extends="button" name="x-fancybutton” constructor=“FancyButton”><template>

<style scoped>@host { display: contents; }div.fancy {

…}

</style><div class="fancy">

<content></content></div><script>

FancyButton.prototype.fancify = function() { … };

this.lifecycle({ inserted: this.doSomething(); });</script>

</template></element>

<button is=“x-fancybutton”>Click Me!</button>

Page 36: Using Components to Build Native-Quality HTML5 Apps

COMPONENT LOADER

Page 37: Using Components to Build Native-Quality HTML5 Apps

<link rel="components" href=”my-components.html">

Page 38: Using Components to Build Native-Quality HTML5 Apps

SO…WHY AGAIN?

Page 39: Using Components to Build Native-Quality HTML5 Apps

USING COMPONENTS TO BUILD

Native-Quality HTML5 Apps

Gray Norton, Enyohttp://enyojs.com

@enyojs

@graynorton