👇🏼
👇🏼
Vincent Ogloblinsky
Frontend software architect
import {
LitElement,
html,
property,
customElement
} from 'lit-element';
@customElement('simple-greeting')
export class SimpleGreeting extends LitElement {
@property() name = 'World';
render() {
return html`<p>Hello, ${this.name}!</p>`;
}
}
<simple-greeting name="Everyone"></simple-greeting>
import {Slim} from 'slim-js'
import {
tag,
template,
attribute
} from 'slim-js/Decorators'
@tag('simple-greeting')
@template('<p>Hello, {{name}}!</p>')
class MyTag extends Slim {
@attribute
name
}
<simple-greeting name="Everyone"></simple-greeting>
import
Element, { html }
from '@skatejs/element-lit-html';
export default class extends Element {
static get props() {
return {
name: String
};
}
render() {
return html`
<p>Hello, ${this.name}!</p>
`;
}
}
<simple-greeting name="Everyone"></simple-greeting>
import { html, define } from 'hybrids';
export const HelloWorld = {
name: '',
render: ({ name }) => html`
<p>Hello, ${name}</p>
`,
};
define('simple-greeting', HelloWorld);
<simple-greeting name="Everyone"></simple-greeting>
import { define, WeElement, html, render } from 'omi'
define('simple-greeting', class extends WeElement {
render(props) {
return html`<p>{props.text}</p>`
}
});
<simple-greeting name="Everyone"></simple-greeting>
<!-- simple-greeting.riot -->
<p>{ props.message }</p>
import { register, mount, component } from 'riot';
import simpleGreeting from './simple-greeting.riot';
// register the my-component as global component
register('simple-greeting', simpleGreeting);
// find all the DOM nodes called `<simple-greeting>` and
// mount them with the component previously registered
mount('simple-greeting');
<simple-greeting name="Everyone"></simple-greeting>
<p>{name}</p>
<script>
export default {
tag: 'simple-greeting',
props: ['name']
}
</script>
/**
* -> Compile it with Svelte CLI
*/
<simple-greeting name="Everyone"></simple-greeting>
import { h, Component, Prop } from '@stencil/core';
@Component({
tag: 'simple-greeting'
})
export class SimpleGreeting {
@Prop() name: string;
render() {
return <p>{this.name}</p>;
}
}
<simple-greeting name="Everyone"></simple-greeting>
import { Component, Input } from '@angular/core';
@Component({
selector: 'simple-greeting',
template: `
<p>{{ name }}</p>
`
})
export class SimpleGreeting {
@Input() name: string;
}
<simple-greeting name="Everyone"></simple-greeting>
import { ɵrenderComponent } from '@angular/core';
import { SimpleGreeting } from './simple-greeting.component';
export class SimpleGreetingElement extends HTMLElement {
private comp: SimpleGreeting;
constructor() {
super();
this.comp = ɵrenderComponent(SimpleGreeting, { host: this });
}
}
<template>
<p>{name}</p>
</template>
<script>
export default {
name: 'SimpleGreeting',
props: ['name']
}
</script>
/**
* -> Compile it with Vue CLI
*/
<simple-greeting name="Everyone"></simple-greeting>
import { WidgetBase } from '@dojo/framework/widget-core/WidgetBase';
import customElement from '@dojo/framework/widget-core/decorators/customElement';
import { v } from '@dojo/framework/widget-core/d';
import { ThemedMixin } from '@dojo/framework/widget-core/mixins/Themed';
@customElement({
tag: 'simple-greeting',
events: [],
attributes: ['name'],
properties: []
})
export default class SimpleGreeting extends ThemedMixin(WidgetBase) {
protected render() {
const { name } = this.properties;
return v('s', {}, [name]);
}
}
/**
* -> Compile it with Dojo CLI
*/
<simple-greeting name="Everyone"></simple-greeting>
Centralized library of components that can be shared across teams and projects to simplify design and development while ensuring consistent brand experiences, at scale.
The idea behind Micro Frontends is to think about a website or web app as a composition of features which are owned by independent teams. Each team has a distinct area of business or mission it cares about and specialises in. A team is cross functional and develops its features end-to-end, from database to user interface. (micro-fontend.org)
<template id="person">
<section>
<h1>{{name}}</h1>
Email: <a href="mailto:{{email}}">{{email}}</a>
</section>
</template>
let template = document.querySelector('#person');
let instance = template.createInstance({
name: "Ryosuke Niwa",
email: "rniwa@webkit.org"
});
<x-foo>
#shadow-root
<div part="some-box"><span>...</span></div>
<input part="some-input">
<div>...</div> /_ not styleable _/
</x-foo>
x-foo::part(some-box) { ... }
Chrome 74
const myElementSheet = new CSSStyleSheet();
class MyElement extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: "open" });
shadowRoot.adoptedStyleSheets = [myElementSheet];
}
connectedCallback() {
if (myElementSheet.cssRules.length == 0) {
myElementSheet.replaceSync(styleText);
}
}
}
<script type="module">
import {content} from "import.html"
document.body.appendChild(content);
</script>
<div id="blogPost">
<p>Content...</p>
</div>
<script type="module">
let blogPost = import.meta.document.querySelector("#blogPost");
export {blogPost}
</script>
import {content} from "import.html"
import styles from './styles.css';
class MyElement extends HTMLElement {
constructor() {
this.attachShadow({mode: open});
// push() doesn't actually exist yet
this.shadowRoot.moreStyleSheets.push(styles);
this.shadowRoot.appendChild(content);
}
}
Chrome 73
// Create a new registry that inherits from the global registry
const myRegistry = new CustomElementRegistry(window.customElements);
// Use the local registry when creating the ShadowRoot
element.attachShadow({mode: 'open', customElements: myRegistry});
// Define a trivial subclass of XFoo so that we can register it ourselves
class MyFoo extends XFoo {}
// Register it as `my-foo` locally.
myRegistry.define('my-foo', MyFoo);
// the definiton of my-foo will be resolved from the custom registry
const myFoo = this.shadowRoot.createElement('my-foo');
element.shadowRoot.appendChild(myFoo);
https://blog.bitsrc.io/9-web-component-ui-libraries-you-should-know-in-2019-9d4476c3f103
https://developers.google.com/web/updates/2019/02/constructable-stylesheets
https://hackernoon.com/design-systems-should-be-javascript-framework-agnostic-2a0c47129ec8
Slides : bit.ly/wc-can-do-that