Skip to content

Instantly share code, notes, and snippets.

:root {
/* Colors */
--color-100: --g-blue-100;
--color-200: --g-green-200;
/* text */
--text-color-500: --g-grey-800;
--text-color-300: --g-grey-400;
--body-font-500: --g-sans;
shadowRoot.innerHTML = `
<style>
:host {
--warning: var(--warning-color-100, red);
--default: var(--color-300, grey);
--primary: var(--color-100, green);
}
:host([status="warning"]) button{
--button-color: var(--warning)
}
class MyElement extends HTMLElement {
constructor(){
super();
const shadowRoot = elem.attachShadow({mode: `open`});
shadowRoot.innerHTML = `
<style>
:host {
--color: var(--text-color-100, blue);
display: block;
}
class MyElement extends HTMLElement {
constructor(){
super();
const shadowRoot = elem.attachShadow({mode: `open`});
shadowRoot.innerHTML = `
<style>
:host {
/* define a custom property here */
--text-color: blue;
display: block;
class MyElement extends HTMLElement {
constructor(){
super();
const shadowRoot = elem.attachShadow({mode: `open`});
shadowRoot.innerHTML = `
<style>
:host {
display: block;
}
span {
class MyElement extends HTMLElement {
constructor(){
super();
}
}
customElement.define(`my-element`, MyElement)
function Parent() {
this.prop = "prop";
this.anotherProp = "anotherProp";
}
// can I use arrow functions here?
Parent.prototype.someFunction = function() {
// ...
};
Parent.prototype.anotherFunction = function() {
function *exponents(start) {
yield start ** 1;
yield start ** 2;
yield start ** 3;
return 4;
}
for (let val of exponents(4)) {
console.log(val);
}
function *fibonacci(){
let first = 1;
let second = 1;
while (true){
let current = second;
second = first;
first = first + current;
yield current;
}
}
function *someFunction(a) {
const x = yield a*2;
const y = yield x*2;
const z = yield y*2;
console.log(`a:`,a,`x:`,x,` y:`,y,` z:`,z);
// a:5 x:20 y:4 z:8
return x+y+z;
}