-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClusterLayout.js
56 lines (52 loc) · 1.48 KB
/
ClusterLayout.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
54
55
56
customElements.define(
'cluster-layout',
class extends HTMLElement {
constructor() {
super()
this.attachShadow({ mode: 'open' })
}
render() {
// prettier-ignore
this.shadowRoot.innerHTML = `
<style>
:host {
display: flex;
flex-wrap: wrap;
justify-content: ${this.justify};
align-items: ${this.align};
gap: ${this.space};
}
</style>
<slot></slot>
`
// console.log('box:', this.shadowRoot.innerHTML)
}
connectedCallback() {
this.render()
}
attributeChangedCallback() {
this.render()
}
static get observedAttributes() {
return ['justify', 'align', 'space']
}
get justify() {
return this.getAttribute('justify') || 'flex-start'
}
set justify(val) {
return this.setAttribute('justify', val)
}
get align() {
return this.getAttribute('align') || 'flex-start'
}
set align(val) {
return this.setAttribute('align', val)
}
get space() {
return this.getAttribute('space') || 'var(--s1)'
}
set space(val) {
return this.setAttribute('space', val)
}
}
)