-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExampleVanilla.js
53 lines (45 loc) · 941 Bytes
/
ExampleVanilla.js
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
45
46
47
48
49
50
51
52
53
import { html, render } from 'lit-html';
export default class ExampleVanilla extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.header = 'My Example';
}
connectedCallback() {
this.update();
}
update() {
render(this.renderShadowDom(), this.shadowRoot);
}
renderShadowDom() {
return html`
<style>
:host {
background: grey;
display: block;
padding: 25px;
}
h1 {
color: white;
font-size: 25px;
margin: 0;
}
:host(.right) {
background: green;
text-align: right;
}
:host(.right) h1 {
color: orange;
text-align: right;
}
:host(.right) div {
text-align: right;
}
</style>
<h1>${this.header}</h1>
<div>
<slot></slot>
</div>
`;
}
}