@jungherz-de/glasskit-elements 0.9.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -16
- package/dist/glasskit-elements.esm.js +212 -18
- package/dist/glasskit-elements.js +213 -17
- package/dist/glasskit-elements.min.js +1 -1
- package/package.json +5 -5
- package/src/components/containers/glk-list-item.js +60 -4
- package/src/components/containers/glk-list.js +20 -1
- package/src/components/navigation/glk-tab-accessory.js +65 -0
- package/src/components/navigation/glk-tab-bar.js +9 -2
- package/src/components/navigation/glk-tab-dock.js +51 -0
- package/src/index.js +2 -0
|
@@ -2,10 +2,17 @@ import { GlkElement } from '../../base.js';
|
|
|
2
2
|
|
|
3
3
|
class GlkList extends GlkElement {
|
|
4
4
|
static get observedAttributes() {
|
|
5
|
-
return ['flush', 'bare'];
|
|
5
|
+
return ['flush', 'bare', 'header'];
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
render() {
|
|
9
|
+
// Optional section header — sits before the <ul>.
|
|
10
|
+
this._header = this.createElement('div', ['glass-list__section-header']);
|
|
11
|
+
const initialHeader = this.getAttribute('header') || '';
|
|
12
|
+
this._header.textContent = initialHeader;
|
|
13
|
+
this._header.hidden = !initialHeader;
|
|
14
|
+
this._wrapper.appendChild(this._header);
|
|
15
|
+
|
|
9
16
|
this._ul = this.createElement('ul', ['glass-list']);
|
|
10
17
|
if (this.getBoolAttr('flush')) this._ul.classList.add('glass-list--flush');
|
|
11
18
|
if (this.getBoolAttr('bare')) this._ul.classList.add('glass-list--bare');
|
|
@@ -41,6 +48,12 @@ class GlkList extends GlkElement {
|
|
|
41
48
|
case 'bare':
|
|
42
49
|
this._ul.classList.toggle('glass-list--bare', this.getBoolAttr('bare'));
|
|
43
50
|
break;
|
|
51
|
+
case 'header': {
|
|
52
|
+
const value = this.getAttribute('header') || '';
|
|
53
|
+
this._header.textContent = value;
|
|
54
|
+
this._header.hidden = !value;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
58
|
}
|
|
46
59
|
|
|
@@ -49,6 +62,12 @@ class GlkList extends GlkElement {
|
|
|
49
62
|
|
|
50
63
|
get bare() { return this.getBoolAttr('bare'); }
|
|
51
64
|
set bare(v) { this.setBoolAttr('bare', v); }
|
|
65
|
+
|
|
66
|
+
get header() { return this.getAttribute('header') || ''; }
|
|
67
|
+
set header(v) {
|
|
68
|
+
if (v) this.setAttribute('header', v);
|
|
69
|
+
else this.removeAttribute('header');
|
|
70
|
+
}
|
|
52
71
|
}
|
|
53
72
|
|
|
54
73
|
customElements.define('glk-list', GlkList);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { GlkElement } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
const VARIANTS = ['accent', 'success', 'error'];
|
|
4
|
+
|
|
5
|
+
class GlkTabAccessory extends GlkElement {
|
|
6
|
+
static get observedAttributes() {
|
|
7
|
+
return ['label', 'disabled', 'variant'];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
render() {
|
|
11
|
+
this._btn = this.createElement('button', ['glass-tab-bar__accessory']);
|
|
12
|
+
|
|
13
|
+
if (this.getBoolAttr('disabled')) this._btn.disabled = true;
|
|
14
|
+
|
|
15
|
+
const ariaLabel = this.getAttribute('label');
|
|
16
|
+
if (ariaLabel) this._btn.setAttribute('aria-label', ariaLabel);
|
|
17
|
+
|
|
18
|
+
this._applyVariant();
|
|
19
|
+
|
|
20
|
+
this._btn.appendChild(document.createElement('slot'));
|
|
21
|
+
this._wrapper.appendChild(this._btn);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_applyVariant() {
|
|
25
|
+
if (!this._btn) return;
|
|
26
|
+
for (const v of VARIANTS) {
|
|
27
|
+
this._btn.classList.remove(`glass-tab-bar__accessory--${v}`);
|
|
28
|
+
}
|
|
29
|
+
const variant = this.getAttribute('variant');
|
|
30
|
+
if (variant && VARIANTS.includes(variant)) {
|
|
31
|
+
this._btn.classList.add(`glass-tab-bar__accessory--${variant}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setupEvents() {
|
|
36
|
+
this._onClick = () => {
|
|
37
|
+
if (!this.getBoolAttr('disabled')) {
|
|
38
|
+
this.emit('glk-click');
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
this._btn.addEventListener('click', this._onClick);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
teardownEvents() {
|
|
45
|
+
this._btn?.removeEventListener('click', this._onClick);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
onAttributeChanged(name) {
|
|
49
|
+
if (!this._btn) return;
|
|
50
|
+
switch (name) {
|
|
51
|
+
case 'label':
|
|
52
|
+
this._btn.setAttribute('aria-label', this.getAttribute('label') || '');
|
|
53
|
+
break;
|
|
54
|
+
case 'disabled':
|
|
55
|
+
this._btn.disabled = this.getBoolAttr('disabled');
|
|
56
|
+
break;
|
|
57
|
+
case 'variant':
|
|
58
|
+
this._applyVariant();
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
customElements.define('glk-tab-accessory', GlkTabAccessory);
|
|
65
|
+
export { GlkTabAccessory };
|
|
@@ -2,7 +2,7 @@ import { GlkElement } from '../../base.js';
|
|
|
2
2
|
|
|
3
3
|
class GlkTabBar extends GlkElement {
|
|
4
4
|
static get observedAttributes() {
|
|
5
|
-
return ['static'];
|
|
5
|
+
return ['static', 'floating'];
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
render() {
|
|
@@ -11,14 +11,21 @@ class GlkTabBar extends GlkElement {
|
|
|
11
11
|
this._wrapper.appendChild(nav);
|
|
12
12
|
this._nav = nav;
|
|
13
13
|
|
|
14
|
+
if (this.getBoolAttr('floating')) {
|
|
15
|
+
nav.classList.add('glass-tab-bar--floating');
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
if (this.getBoolAttr('static')) {
|
|
15
19
|
this._applyStatic();
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
onAttributeChanged(name) {
|
|
20
|
-
if (
|
|
24
|
+
if (!this._nav) return;
|
|
25
|
+
if (name === 'static') {
|
|
21
26
|
this._applyStatic();
|
|
27
|
+
} else if (name === 'floating') {
|
|
28
|
+
this._nav.classList.toggle('glass-tab-bar--floating', this.getBoolAttr('floating'));
|
|
22
29
|
}
|
|
23
30
|
}
|
|
24
31
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { GlkElement } from '../../base.js';
|
|
2
|
+
|
|
3
|
+
class GlkTabDock extends GlkElement {
|
|
4
|
+
static get observedAttributes() {
|
|
5
|
+
return ['accessory-left', 'static'];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
render() {
|
|
9
|
+
this._dock = this.createElement('div', ['glass-tab-bar-dock']);
|
|
10
|
+
if (this.getBoolAttr('accessory-left')) {
|
|
11
|
+
this._dock.classList.add('glass-tab-bar-dock--accessory-left');
|
|
12
|
+
}
|
|
13
|
+
this._dock.appendChild(document.createElement('slot'));
|
|
14
|
+
this._wrapper.appendChild(this._dock);
|
|
15
|
+
|
|
16
|
+
if (this.getBoolAttr('static')) {
|
|
17
|
+
this._applyStatic();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
onAttributeChanged(name) {
|
|
22
|
+
if (!this._dock) return;
|
|
23
|
+
if (name === 'accessory-left') {
|
|
24
|
+
this._dock.classList.toggle(
|
|
25
|
+
'glass-tab-bar-dock--accessory-left',
|
|
26
|
+
this.getBoolAttr('accessory-left')
|
|
27
|
+
);
|
|
28
|
+
} else if (name === 'static') {
|
|
29
|
+
this._applyStatic();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_applyStatic() {
|
|
34
|
+
if (this.getBoolAttr('static')) {
|
|
35
|
+
this._dock.style.position = 'relative';
|
|
36
|
+
this._dock.style.left = 'auto';
|
|
37
|
+
this._dock.style.bottom = 'auto';
|
|
38
|
+
this._dock.style.transform = 'none';
|
|
39
|
+
this._dock.style.justifyContent = 'center';
|
|
40
|
+
} else {
|
|
41
|
+
this._dock.style.position = '';
|
|
42
|
+
this._dock.style.left = '';
|
|
43
|
+
this._dock.style.bottom = '';
|
|
44
|
+
this._dock.style.transform = '';
|
|
45
|
+
this._dock.style.justifyContent = '';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
customElements.define('glk-tab-dock', GlkTabDock);
|
|
51
|
+
export { GlkTabDock };
|
package/src/index.js
CHANGED
|
@@ -6,6 +6,8 @@ export { GlkNav } from './components/navigation/glk-nav.js';
|
|
|
6
6
|
export { GlkPill } from './components/navigation/glk-pill.js';
|
|
7
7
|
export { GlkTabBar } from './components/navigation/glk-tab-bar.js';
|
|
8
8
|
export { GlkTabItem } from './components/navigation/glk-tab-item.js';
|
|
9
|
+
export { GlkTabDock } from './components/navigation/glk-tab-dock.js';
|
|
10
|
+
export { GlkTabAccessory } from './components/navigation/glk-tab-accessory.js';
|
|
9
11
|
|
|
10
12
|
// Content
|
|
11
13
|
export { GlkCard } from './components/content/glk-card.js';
|