chore: formatting; add sample
This commit is contained in:
parent
ee80a55649
commit
1287b42186
4 changed files with 40 additions and 12 deletions
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"editor.formatOnSave": true
|
||||
}
|
|
@ -20,7 +20,7 @@ export class WebComponent extends HTMLElement {
|
|||
this.render();
|
||||
}
|
||||
|
||||
this.onChanges({previousValue, currentValue});
|
||||
this.onChanges({ previousValue, currentValue });
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
16
demo/SimpleText.mjs
Normal file
16
demo/SimpleText.mjs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// @ts-check
|
||||
import WebComponent from "../index.mjs";
|
||||
|
||||
class SimpleText extends WebComponent {
|
||||
greeting = "Hello";
|
||||
|
||||
static get observedAttributes() {
|
||||
return ["greeting"];
|
||||
}
|
||||
|
||||
get template() {
|
||||
return `<p>Simple text ${this.greeting}</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("simple-text", SimpleText);
|
|
@ -1,12 +1,21 @@
|
|||
<head>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>WC demo</title>
|
||||
<script type="module" src="HelloWorld.mjs"></script>
|
||||
</head>
|
||||
<body>
|
||||
<hello-world name="Ayo" emotion="sad">
|
||||
<script>
|
||||
const helloWorld = document.querySelector('hello-world');
|
||||
<script type="module" src="SimpleText.mjs"></script>
|
||||
</head>
|
||||
<body>
|
||||
<hello-world name="Ayo" emotion="sad"></hello-world>
|
||||
<simple-text greeting="hey"></simple-text>
|
||||
|
||||
<script type="module">
|
||||
const helloWorld = document.querySelector("hello-world");
|
||||
setTimeout(() => {
|
||||
helloWorld.setAttribute('emotion', 'excited');
|
||||
}, 2500)
|
||||
helloWorld.setAttribute("emotion", "excited");
|
||||
}, 2500);
|
||||
</script>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue