(WEB?) COMPONENTS IN
PRODUCTION
AMAZON WEB SERVICES
 
SERVICE TEAMS
Small
Strong ownership
Independence
NO GOLDEN HAMMER
Pick what works best for your team.
This includes processes, languages, and tools.
There is no single answer.
DEVELOPERS ❤ JS FRAMEWORKS
200X: jQuery, MooTools, Prototype & script.aculo.us
2010: Ext JS
2011: Google Web Toolkit
2012: Backbone.js
2013: Ember.js
2014: AngularJS
2015: React
2016: Angular 2?
... to be continued
SO HOW CAN WE
HELP OUR TEAMS?
CHOCOLATE
FACTORY
INCREASE DEVELOPER
HAPPINESS AND PRODUCTIVITY!
OPTION 1
DESIGN GUIDE
Rather low initial cost
Derive patterns from what you already have
One time cost to implement per JS framework
N-time cost of continuous changes to style guide
Very high cost to enforce compliance
Hard to make sure it doesn't contradict itself
OPTION 2
CSS FRAMEWORK
Much better!
Render example pages and use cases
But CSS de nes Markup
No clear boundary of ownership / CSS overwrites
Can't incorporate a11y and functionality
Hard to maintain and update
OPTION 3
SOMETHING IN CODE THAT ...
Supports all frontend frameworks
Supports currently used browsers
Decouples style and markup
Is performant
Is accessible
Has tests and a deployment strategy
And last but not least a contribution model
WEB COMPONENTS
TO THE RESCUE!
Chrome Firefox Internet
Explorer
Edge Safari
Templates
HTML Imports
Custom Elements
Shadow DOM
POLYFILLS ARE ASYNC BY NATURE
MISSING FRAMEWORK INTEGRATION
WEB COMPONENTS
TO THE RESCUE!
IDEAS WE KEPT
Custom elements
Style encapsulation
De ned API
ARCHITECTURE
Components
Framework Wrapper
Runtime
Browser Environment
RUNTIME
Custom element declaration and lifecycle
Custom events, property and region handling
Render engine (mithril)
Validation of property types
Metrics
FRAMEWORK WRAPPER
GWT
AngularJS
React
Angular 2 (prototype)
Web Components (hack day)
FRAMEWORK WRAPPER
FOR ANGULARJS
The AngularJS wrapper is a script that declares
an Angular directive for each component at runtime.
FRAMEWORK WRAPPER
FOR REACT
We have a wrapper around the React.createClass function that
converts our component speci cations to the native React components.
FRAMEWORK WRAPPER
FOR GWT
A library that provides a GWT Widget API class for each component.
These classes are generated at build-time.
OKAY, ...
SHOW ME A COMPONENT
DEMO
CodeFest
2010
<awsui-conference>
<div class="awsui-conference">
<div class="awsui logo red"></div>
CodeFest 2010
</div>
</awsui-conference>
COMPONENT'S CODE
AwsUi.__addComponent('awsui-conference', {
properties: {
title: { type: 'string' },
counter: { type: 'integer', defaultValue: 2010 }
},
render(m, h) {
const component = this;
const color = this.counter % 2 === 0 ? 'red' : 'purple';
const logo = m('div',
h.copyDefined({ className: `awsui logo ${color}` }));
return m('div', h.copyDefined({
className: 'awsui-conference',
onclick: () => component.counter++
}), [logo, `${component.title} ${this.counter}`]);
}
});
VANILLA JAVASCRIPT
<script src="js/awsui.min.js"></script>
<script src="js/awsui-conference.js"></script>
const node = AwsUi.createComponent('awsui-conference');
node.component.title = 'CodeFest';
document.body.appendChild(node);
REACT
<script src="js/awsui.min.js"></script>
<script src="js/awsui-react.min.js"></script>
<script src="js/awsui-conference.js"></script>
import React, { Component } from 'react';
export default class FancyPage extends Component {
render() {
return (<Conference title="CodeFest"/>);
}
}
ANGULAR
<script src="js/awsui.min.js"></script>
<script src="js/awsui-angular.min.js"></script>
<script src="js/awsui-conference.js"></script>
<div ng-controller="Data">
<awsui-conference title="{{name}}"></awsui-conference>
</div>
AND EVEN GWT
import com.amazonaws.ui.gwt.js.client.AwsUiInjector;
<ui:UiBinder
xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:awsui="urn:import:com.amazonaws.ui.gwt.widget.components">
<awsui:Conference title="CodeFest"/>
</ui:UiBinder>
IT WORKS!
BENEFITS WE SAW
On-boarding new teams is less than one day of work
Teams are compliant out of the box
Zero or low e ort for teams after design changes
Sparked community engagement and contribution
LESSONS LEARNED
It was a hard decision to re-invent some things, but it payed o
SLA is key to build trust
Our teams liked having form elements most
Even implementing a tooltip component can be a challenge
CODIFY YOUR STYLE GUIDES!
USAGE OF OUR COMPONENTS
FUTURE
Grow our team in Berlin and Seattle
Build more tools that help frontend developers and designers
Open source what we have done
THANK YOU
CODEFEST.RU
Thomas
Denis
@tlobinger
@pragmadash

Thomas Lobinger