Skip to content

Instantly share code, notes, and snippets.

View smpnjn's full-sized avatar
🥶

Johnny smpnjn

🥶
View GitHub Profile
npx react-create-app my-app
<status-bar></status-bar>
<div class="status-bar">
<div class="size">
<div class="small">-</div>
<div class="big">+</div>
</div>
<div class="status-bar-progress">
<div class="progress">
<div class="progress-percentage"></div>
</div>
</div>
<alpha-paragraph color="blue">
<p slot="paragraph-text">
Custom Text
</p>
</alpha-paragraph>
class Paragraph extends HTMLElement {
constructor() {
super()
// Attach shadow DOM
let shadow = this.attachShadow({mode: 'open'});
// Append our Paragraph
shadow.innerHTML = `
<slot name="paragraph-text"><p>Default Text</p></slot>
<p>Another, unchangeable paragraph</p>
<alpha-paragraph color="blue">
<p slot="paragraph-text">
Custom Text
</p>
</alpha-paragraph>
class Paragraph extends HTMLElement {
constructor() {
super()
// Attach shadow DOM
let shadow = this.attachShadow({mode: 'open'});
// Append our Paragraph
shadow.innerHTML = `
<slot name="paragraph-text"><p>Default Text</p></slot>
<p>Another, unchangeable paragraph</p>
<template id="alphaParagraph">
<slot name="paragraph-text"><p>Default Text</p></slot>
<p>Another, unchangeable paragraph</p>
</template>
class Paragraph extends HTMLElement {
constructor() {
super()
// Attach shadow DOM
let shadow = this.attachShadow({mode: 'open'});
// Append our Paragraph
shadow.innerHTML = '<p>Hello</p>'
// Add in our CSS
class Paragraph extends HTMLElement {
constructor() {
super()
this.innerHTML = '<p>Hello</p>'
}
connectedCallback() {
// ...
}
attributeChangedCallback() {
// ...