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
my-component { | |
--color: midnightblue; | |
--background-color: mintcreme; | |
--width: 700px; | |
--height: 500px; | |
} |
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
:host { | |
--color: white; | |
--background-color: black; | |
--width: 70vw; | |
--height: 50vh; | |
} | |
#component { | |
color: var(--color); | |
background-color: var(--background-color); |
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
{ | |
"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", |
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
<head> | |
<script src='/my-component.js' type='module'></script> | |
</head> |
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
async connectedCallback() { | |
var htmlFragment = await this.fetchTemplate(); | |
var styleElement = await this.fetchCSS(); | |
this.attachShadow({mode: 'open'}); | |
this.shadowRoot.appendChild(htmlFragment); | |
this.shadowRoot.appendChild(styleElement); | |
} |
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
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; |
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
<body> | |
<h1>Hello World!</h1> | |
<my-component></my-component> | |
</body> |
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
customElements.define('my-component', MyCustomComponent); |
NewerOlder