Created
May 5, 2021 12:22
-
-
Save smpnjn/a3b214aefc42e1125d3976f0c6340165 to your computer and use it in GitHub Desktop.
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 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 | |
let style = document.createElement('style'); | |
let elCss = style.textContent = ` | |
p { | |
color: red; | |
font-size: 1.25rem; | |
} | |
`; | |
// Append our CSS | |
shadow.appendChild(style); | |
} | |
} | |
customElements.define('alpha-paragraph', Paragraph); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment