chore: better example with explanations
This commit is contained in:
parent
859260f578
commit
d3573ec5b2
2 changed files with 8 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
|||
import WebComponent from "../src/index.js";
|
||||
|
||||
export class HelloWorld extends WebComponent {
|
||||
name = "World";
|
||||
dataName = "World";
|
||||
emotion = "excited";
|
||||
|
||||
static properties = ["data-name", "emotion"];
|
||||
|
|
|
@ -8,11 +8,17 @@
|
|||
* import WebComponent from "https://unpkg.com/web-component-base/index.js";
|
||||
*
|
||||
* class HelloWorld extends WebComponent {
|
||||
* // initialize prop
|
||||
* dataName = 'World';
|
||||
*
|
||||
* // tell the browser which attributes to cause a render
|
||||
* static properties = ["data-name", "emotion"];
|
||||
*
|
||||
* // give the component a readonly template
|
||||
* // note: props have kebab-case & camelCase counterparts
|
||||
* get template() {
|
||||
* return `
|
||||
* <h1>Hello ${this.dataName || 'World'}${this.emotion === "sad" ? ". 😭" : "! 🙌"}</h1>`;
|
||||
* <h1>Hello ${this.dataName}${this.emotion === "sad" ? ". 😭" : "! 🙌"}</h1>`;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue