-
Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathmy-element.ts
44 lines (41 loc) · 1.21 KB
/
my-element.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import {LitElement, html, css, PropertyDeclaration} from 'lit';
import {customElement, property} from 'lit/decorators.js';
@customElement('my-element')
class MyElement extends LitElement {
/* playground-fold */
static styles = css`
:host {
display: inline-block;
padding: 4px;
}
:host([active]) {
font-weight: 800;
}
:host([variant]) {
outline: 4px solid green;
}
:host([variant="special"]) {
border-radius: 8px; border: 4px solid red;
}`;
/* playground-fold-end */
@property({type: Boolean, reflect: true})
active: boolean = false;
@property({reflect: true, useDefault: true} as PropertyDeclaration)
variant = 'normal';
render() {
return html`
<div><label>active: <input type="checkbox"
.value="${this.active}"
@change="${(e: {target: HTMLInputElement}) =>
this.active = e.target.checked}">
${this.active}
</label></div>
<div><label>variant: <input type="checkbox"
.value="${this.variant === 'special'}"
@change="${(e: {target: HTMLInputElement}) =>
this.variant = e.target.checked ? 'special' : 'normal'}">
${this.variant}
</label></div>
`;
}
}