-
Notifications
You must be signed in to change notification settings - Fork 0
/
GridLayout.js
72 lines (59 loc) · 1.68 KB
/
GridLayout.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
customElements.define(
'grid-layout',
class extends HTMLElement {
constructor() {
super()
this.attachShadow({ mode: 'open' })
}
render() {
// prettier-ignore
this.shadowRoot.innerHTML = `
<style>
:host {
display: grid;
align-content: start;
grid-gap: ${this.space};
grid-template-columns: repeat(auto-fill, minmax(min(${this.min}, 100%), 1fr));
}
</style>
<slot></slot>
`
// console.log('grid:', this.shadowRoot.innerHTML)
}
connectedCallback() {
this.render()
}
attributeChangedCallback() {
this.render()
}
static get observedAttributes() {
return ['min', 'space']
}
get min() {
return this.getAttribute('min') || '250px'
}
set min(val) {
return this.setAttribute('min', val)
}
get space() {
return this.getAttribute('space') || 'var(--s1)'
}
set space(val) {
return this.setAttribute('space', val)
}
}
)
/*
grid-l {
display: grid;
grid-gap: var(--s1);
align-content: start;
grid-template-columns: 100%;
}
grid-template-columns: 100%;
@supports (width: min(${this.min}, 100%)) {
:host {
grid-template-columns: repeat(auto-fill, minmax(min(${this.min}, 100%), 1fr));
}
}
*/