Slide 1

Slide 1 text

context based PROGRESSIVE ENHANCEMENT

Slide 2

Slide 2 text

Freelance Front-end Developer Rik Schennink @rikschennink

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Origins Initialisation logic drama

Slide 5

Slide 5 text

Writing maintainable JavaScript for big web platforms is though.

Slide 7

Slide 7 text

ui/GoogleMap.js var GoogleMap = (function() {
 
 var exports = function GoogleMap(element) {
 
 };
 
 return exports;
 
 }());

Slide 8

Slide 8 text

// init start var elements = Array.from( document.getElementsByClassName(‘google-map’) ); elements.forEach(function(element) { new GoogleMap(element); }); // more init logic here index.html

Slide 9

Slide 9 text

// init start if (window.innerWidth > 600) { var elements = Array.from( document.getElementsByClassName(‘google-map’) ); elements.forEach(function(element) { new GoogleMap(element); }); } // more init logic here index.html

Slide 10

Slide 10 text

Our init logic was starting to show cracks.

Slide 11

Slide 11 text

1024px

Slide 12

Slide 12 text

1024px 320px 768px

Slide 13

Slide 13 text

no pixels lot’s of pixels

Slide 14

Slide 14 text

no pixels lot’s of pixels touch mouse gesture remote keyboard game controller

Slide 15

Slide 15 text

no pixels lot’s of pixels touch mouse pen gesture remote voice keyboard virtual game controller

Slide 16

Slide 16 text

The web is quite an intense environment.

Slide 17

Slide 17 text

HTML works everywhere. “CSS and JavaScript are the changing factors.”

Slide 18

Slide 18 text

Not device types but features are of interest. “User moves his mouse… and the viewport is pretty wide…”

Slide 19

Slide 19 text

Functionality might not stay relevant during the entire session. “A rotation of the device can invalidate a Google Map”

Slide 20

Slide 20 text

touch mouse pen gesture remote voice keyboard virtual game controller no pixels lot’s of pixels LIGHT LEVEL SESSION duration SCROLL POSITION battery level LOCATION velocity TIME CONNECTION STABILITY HISTORICAL BEHAVIOR MOTION

Slide 21

Slide 21 text

We have to be aware of other context parameters. “Can’t treat every user as if they’re sitting at a desk.”

Slide 22

Slide 22 text

on context And how it relates to features

Slide 23

Slide 23 text

Features are stable, context is always changing

Slide 24

Slide 24 text

Detect features render view Done

Slide 25

Slide 25 text

Detect features render view update Start monitoring context “allows cookies” “rotates viewport” update “button tapped” update “has scrolled down” update

Slide 26

Slide 26 text

“The framework should measure the users’ context and fine-tune the interface so it fits perfectly.”

Slide 27

Slide 27 text

let’s do a demo

Slide 28

Slide 28 text

HOW Does it work Three principles

Slide 29

Slide 29 text

1. modules are isolated A strict separation between modules

Slide 30

Slide 30 text

ui/GoogleMap.js define(function() {
 
 var exports = function GoogleMap(element) {
 
 };
 
 return exports;
 
 });

Slide 31

Slide 31 text

ui/GoogleMap.js export default class GoogleMap { constructor(element) { } };

Slide 32

Slide 32 text

Modules are bound to the DOM using data attributes instead of classes.

Slide 33

Slide 33 text

Slide 34

Slide 34 text

var elements = Array.from( document.querySelectorAll(‘[data-module]’); ); elements.forEach(function(element) { var name = element.getAttribute(‘data-module’); require(name, function(Module) { new Module(element); }); }); init.js

Slide 35

Slide 35 text

Making modules environment agnostic 2. focus on functionality

Slide 36

Slide 36 text

Setup functionality that monitors context.

Slide 37

Slide 37 text

window element media pointer width, height visible, width, height query, supported near, fine

Slide 38

Slide 38 text

Supply context parameters to Conditioner using data attributes.

Slide 39

Slide 39 text

Slide 40

Slide 40 text

media:{(min-width:40em)} :{}

Slide 41

Slide 41 text

Extend with your own monitors.

Slide 42

Slide 42 text

monitor/light.js // some boilerplate here {
 trigger:{
 'devicelight':window
 },
 test:{
 ‘max-level’:function(data, event) {
 return event.level < data.expected;
 }
 }
 }

Slide 43

Slide 43 text

Slide 44

Slide 44 text

media:{(min-width:40em)} and not session:{first}

Slide 45

Slide 45 text

3. configuration standard Uniform configuration of module properties

Slide 46

Slide 46 text

Configuration is done through so called options.

Slide 47

Slide 47 text

ui/GoogleMap.js define(function(){
 
 var exports = function GoogleMap(element, options) {
 
 }; 
 exports.options = { zoom:10, type:'map', key:null }; 
 return exports;
 
 });

Slide 48

Slide 48 text

main.js conditioner.init({ modules:{ 'ui/GoogleMap':{ options:{ key:'123ABC' } } } }

Slide 49

Slide 49 text

Slide 50

Slide 50 text

Conditioner automatically merges these option objects.

Slide 51

Slide 51 text

{ zoom: 10, type: ‘map’, key: null }

Slide 52

Slide 52 text

{ zoom: 10, type: ‘map’, key: ’123ABC’ }

Slide 53

Slide 53 text

{ zoom: 10, type: ‘terrain’, key: ’123ABC’ }

Slide 54

Slide 54 text

require(‘ui/GoogleMap', function(Module) { new Module(element, { zoom: 10, type: 'terrain', key: '123ABC' }); }); init.js

Slide 55

Slide 55 text

what does this give me Closing statements

Slide 56

Slide 56 text

development advantages

Slide 57

Slide 57 text

voice keyboard virtua game controller LIGHT LEVEL SESSION duration LOCATION velocity TIME CO S Sounds of the Ocean

Slide 58

Slide 58 text

Project B Project A Project C Without Conditioner

Slide 59

Slide 59 text

Available Enhancements

Slide 60

Slide 60 text

context super powers

Slide 61

Slide 61 text

GET 30% OFF On your purchase available only 30 minutes. Enter your email address here GET MY FREE COUPON

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Favorites Favorites 0 x 5 x 20 x interactions:

Slide 64

Slide 64 text

“Conditioner helps you embrace all these different contexts instead of fight against them”

Slide 65

Slide 65 text

Thanks!