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
: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; |
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
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) | |
} |
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 MyElement extends HTMLElement { | |
constructor(){ | |
super(); | |
const shadowRoot = elem.attachShadow({mode: `open`}); | |
shadowRoot.innerHTML = ` | |
<style> | |
:host { | |
--color: var(--text-color-100, blue); | |
display: block; | |
} |
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 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; |
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 MyElement extends HTMLElement { | |
constructor(){ | |
super(); | |
const shadowRoot = elem.attachShadow({mode: `open`}); | |
shadowRoot.innerHTML = ` | |
<style> | |
:host { | |
display: block; | |
} | |
span { |
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 MyElement extends HTMLElement { | |
constructor(){ | |
super(); | |
} | |
} | |
customElement.define(`my-element`, MyElement) |
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
function Parent() { | |
this.prop = "prop"; | |
this.anotherProp = "anotherProp"; | |
} | |
// can I use arrow functions here? | |
Parent.prototype.someFunction = function() { | |
// ... | |
}; | |
Parent.prototype.anotherFunction = function() { |
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
function *exponents(start) { | |
yield start ** 1; | |
yield start ** 2; | |
yield start ** 3; | |
return 4; | |
} | |
for (let val of exponents(4)) { | |
console.log(val); | |
} |
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
function *fibonacci(){ | |
let first = 1; | |
let second = 1; | |
while (true){ | |
let current = second; | |
second = first; | |
first = first + current; | |
yield current; | |
} | |
} |
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
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; | |
} |