Skip to content

Instantly share code, notes, and snippets.

View joehonton's full-sized avatar
💭
Writing clean code one line at a time

Joe Honton joehonton

💭
Writing clean code one line at a time
View GitHub Profile
customElements.define('my-component', MyCustomComponent);
<body>
<h1>Hello World!</h1>
<my-component></my-component>
</body>
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;
async connectedCallback() {
var htmlFragment = await this.fetchTemplate();
var styleElement = await this.fetchCSS();
this.attachShadow({mode: 'open'});
this.shadowRoot.appendChild(htmlFragment);
this.shadowRoot.appendChild(styleElement);
}
<head>
<script src='/my-component.js' type='module'></script>
</head>
{
"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",
:host {
--color: white;
--background-color: black;
--width: 70vw;
--height: 50vh;
}
#component {
color: var(--color);
background-color: var(--background-color);
my-component {
--color: midnightblue;
--background-color: mintcreme;
--width: 700px;
--height: 500px;
}
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'},
class Gestures {
constructor(canvas) {
this.canvas = canvas;
this.fingerPointers = [];
}
// finger pointers appearing and disappearing
addFinger(event) { ... }
updateFinger(event) { ... }
removeFinger(event) { ... }