This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
customElements.define('my-component', MyCustomComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<h1>Hello World!</h1> | |
<my-component></my-component> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a { | |
color: blue; | |
text-decoration: none; | |
border-bottom: 1px dotted blue; | |
} | |
a:visited { | |
border-bottom: 1px dotted purple; | |
} | |
a:hover { | |
border-bottom: 1px solid blue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async connectedCallback() { | |
var htmlFragment = await this.fetchTemplate(); | |
var styleElement = await this.fetchCSS(); | |
this.attachShadow({mode: 'open'}); | |
this.shadowRoot.appendChild(htmlFragment); | |
this.shadowRoot.appendChild(styleElement); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<script src='/my-component.js' type='module'></script> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my-component", | |
"version": "1.0.0", | |
"description": "a W3C standard web component", | |
"repository": { | |
"type": "git", | |
"url": "https://github.com/my-github-user-name/my-component.git" | |
}, | |
"files": [ | |
"my-component.html", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:host { | |
--color: white; | |
--background-color: black; | |
--width: 70vw; | |
--height: 50vh; | |
} | |
#component { | |
color: var(--color); | |
background-color: var(--background-color); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my-component { | |
--color: midnightblue; | |
--background-color: mintcreme; | |
--width: 700px; | |
--height: 500px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ContactTracing from './contact-tracing.class.js'; | |
// Instantiate with the mobile device's 32-byte private key | |
const ct = new ContactTracing('a1b2c3d411jj99kk55gg66hhz0y9x8w7'); | |
// Test data for Medium article "Contact Tracing with Android/iPhone" | |
const encounters = [ | |
{person: 'Uber driver', ts: 'May 15, 2020 16:21:00'}, | |
{person: 'Nearby shopper', ts: 'May 15, 2020 16:51:00'}, | |
{person: 'Stranger', ts: 'May 16, 2020 17:06:00'}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Gestures { | |
constructor(canvas) { | |
this.canvas = canvas; | |
this.fingerPointers = []; | |
} | |
// finger pointers appearing and disappearing | |
addFinger(event) { ... } | |
updateFinger(event) { ... } | |
removeFinger(event) { ... } |
OlderNewer