@gecko-ui-kit/vue 0.1.0 → 0.3.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 +69 -33
- package/package.json +7 -7
- package/src/actions.d.ts +1 -1
- package/src/actions.js +28 -28
- package/src/basics.d.ts +1 -1
- package/src/basics.js +55 -55
- package/src/controls.d.ts +3 -3
- package/src/controls.js +31 -31
- package/src/core.d.ts +1 -1
- package/src/core.js +3 -3
- package/src/data.js +15 -15
- package/src/effects.d.ts +5 -5
- package/src/effects.js +34 -34
- package/src/forms.js +10 -10
- package/src/motion.d.ts +4 -4
- package/src/motion.js +10 -10
- package/src/overlays.d.ts +6 -2
- package/src/overlays.js +20 -17
- package/src/shell.js +77 -77
- package/src/text.js +10 -10
package/src/overlays.js
CHANGED
|
@@ -42,10 +42,11 @@ const pick = (props, keys) => { const o = {}; for (const k of keys) { const v =
|
|
|
42
42
|
* Opens when `open` turns true (zooms out of `anchor` if given; bottom sheet on phones) and closes, animated,
|
|
43
43
|
* when it turns false. Closing from inside (✕, scrim, Esc) sets v-model:open to false and calls @close.
|
|
44
44
|
* title / sub: text props, or #title / #sub slots for richer content; they may change while it is open.
|
|
45
|
+
* words: { close } — the ✕ button's label (default 'Close'), e.g. :words="{ close: 'ปิด' }".
|
|
45
46
|
*/
|
|
46
47
|
export const Modal = defineComponent({
|
|
47
48
|
name: 'Modal',
|
|
48
|
-
props: { open: B, title: ANY, sub: ANY, size: { type: String, default: '' }, anchor: ANY, onClose: Function, 'onUpdate:open': Function },
|
|
49
|
+
props: { open: B, title: ANY, sub: ANY, size: { type: String, default: '' }, anchor: ANY, words: Object, onClose: Function, 'onUpdate:open': Function },
|
|
49
50
|
setup(props, { slots }) {
|
|
50
51
|
const client = useClient();
|
|
51
52
|
let box = null, hasFoot = false;
|
|
@@ -58,12 +59,12 @@ export const Modal = defineComponent({
|
|
|
58
59
|
O.bindEscape();
|
|
59
60
|
alive.value = true;
|
|
60
61
|
const l = O.modal({
|
|
61
|
-
title: '', size: props.size, anchor: deref(props.anchor), body: '', foot: ' ',
|
|
62
|
+
title: '', size: props.size, anchor: deref(props.anchor), body: '', foot: ' ', words: props.words ?? {},
|
|
62
63
|
onMount: (el) => {
|
|
63
|
-
const h3 = el.querySelector('.modal__head h3'); h3.id = titleId; h3.append(b.title);
|
|
64
|
+
const h3 = el.querySelector('.gk-modal__head h3'); h3.id = titleId; h3.append(b.title);
|
|
64
65
|
const p = document.createElement('p'); p.append(b.sub); h3.after(p);
|
|
65
|
-
el.querySelector('.modal__body').append(b.body);
|
|
66
|
-
const foot = el.querySelector('.modal__foot'); foot.textContent = ''; foot.append(b.foot);
|
|
66
|
+
el.querySelector('.gk-modal__body').append(b.body);
|
|
67
|
+
const foot = el.querySelector('.gk-modal__foot'); foot.textContent = ''; foot.append(b.foot);
|
|
67
68
|
b.body.querySelector(FOCUSABLE)?.focus({ preventScroll: true });
|
|
68
69
|
},
|
|
69
70
|
onClose: () => {
|
|
@@ -78,7 +79,8 @@ export const Modal = defineComponent({
|
|
|
78
79
|
// things that may change while it is open
|
|
79
80
|
const refresh = () => {
|
|
80
81
|
const el = layer.current?.el; if (!el || !box) return;
|
|
81
|
-
el.className = `modal ${props.size ? 'modal--' + props.size : ''}`;
|
|
82
|
+
el.className = `gk-modal ${props.size ? 'gk-modal--' + props.size : ''}`;
|
|
83
|
+
el.querySelector('.gk-modal__head [data-close]')?.setAttribute('aria-label', props.words?.close ?? 'Close');
|
|
82
84
|
if (!slots.title && props.title != null) { el.setAttribute('aria-label', String(props.title)); el.removeAttribute('aria-labelledby'); }
|
|
83
85
|
else { el.removeAttribute('aria-label'); el.setAttribute('aria-labelledby', titleId); }
|
|
84
86
|
const p = box.sub.parentElement; if (p) p.hidden = !slots.sub && (props.sub == null || props.sub === '' || props.sub === false);
|
|
@@ -114,11 +116,11 @@ export const Modal = defineComponent({
|
|
|
114
116
|
* </Drawer>
|
|
115
117
|
* Slides in from the side (a bottom sheet on phones); its content drifts up as it lands. Opening a drawer
|
|
116
118
|
* closes any other drawer. Closing from inside (✕, scrim, Esc, another drawer) sets v-model:open to false and
|
|
117
|
-
* calls @close. title / sub / head: text props or slots of the same name.
|
|
119
|
+
* calls @close. title / sub / head: text props or slots of the same name. words: { close } — the ✕ button's label.
|
|
118
120
|
*/
|
|
119
121
|
export const Drawer = defineComponent({
|
|
120
122
|
name: 'Drawer',
|
|
121
|
-
props: { open: B, title: ANY, sub: ANY, head: ANY, side: { type: String, default: 'right' }, onClose: Function, 'onUpdate:open': Function },
|
|
123
|
+
props: { open: B, title: ANY, sub: ANY, head: ANY, side: { type: String, default: 'right' }, words: Object, onClose: Function, 'onUpdate:open': Function },
|
|
122
124
|
setup(props, { slots }) {
|
|
123
125
|
const client = useClient();
|
|
124
126
|
let box = null, hasFoot = false;
|
|
@@ -131,13 +133,13 @@ export const Drawer = defineComponent({
|
|
|
131
133
|
O.bindEscape();
|
|
132
134
|
alive.value = true;
|
|
133
135
|
const l = O.drawer({
|
|
134
|
-
title: '', side: props.side, body: '', foot: ' ',
|
|
136
|
+
title: '', side: props.side, body: '', foot: ' ', words: props.words ?? {},
|
|
135
137
|
onMount: (el) => {
|
|
136
|
-
el.querySelector('.drawer__title').prepend(b.head);
|
|
137
|
-
const h3 = el.querySelector('.drawer__head h3'); h3.id = titleId; h3.append(b.title);
|
|
138
|
+
el.querySelector('.gk-drawer__title').prepend(b.head);
|
|
139
|
+
const h3 = el.querySelector('.gk-drawer__head h3'); h3.id = titleId; h3.append(b.title);
|
|
138
140
|
const p = document.createElement('p'); p.append(b.sub); h3.after(p);
|
|
139
|
-
el.querySelector('.drawer__body').append(b.body);
|
|
140
|
-
const foot = el.querySelector('.drawer__foot'); foot.textContent = ''; foot.append(b.foot);
|
|
141
|
+
el.querySelector('.gk-drawer__body').append(b.body);
|
|
142
|
+
const foot = el.querySelector('.gk-drawer__foot'); foot.textContent = ''; foot.append(b.foot);
|
|
141
143
|
if (!RM() && b.body.children.length) g.fromTo(b.body.children, { opacity: 0, y: 14 }, { opacity: 1, y: 0, duration: 0.5, delay: 0.12, stagger: 0.04, ease: 'power3.out', clearProps: 'transform,opacity' });
|
|
142
144
|
},
|
|
143
145
|
onClose: () => {
|
|
@@ -151,6 +153,7 @@ export const Drawer = defineComponent({
|
|
|
151
153
|
const close = () => { const l = layer.current; if (l) { layer.current = null; l.close(); } };
|
|
152
154
|
const refresh = () => {
|
|
153
155
|
const el = layer.current?.el; if (!el || !box) return;
|
|
156
|
+
el.querySelector('.gk-drawer__head [data-close]')?.setAttribute('aria-label', props.words?.close ?? 'Close');
|
|
154
157
|
if (!slots.title && props.title != null) { el.setAttribute('aria-label', String(props.title)); el.removeAttribute('aria-labelledby'); }
|
|
155
158
|
else { el.removeAttribute('aria-label'); el.setAttribute('aria-labelledby', titleId); }
|
|
156
159
|
const p = box.sub.parentElement; if (p) p.hidden = !slots.sub && (props.sub == null || props.sub === '' || props.sub === false);
|
|
@@ -183,8 +186,8 @@ function openConfirm({ title = 'Are you sure?', body = '', ok = 'Confirm', cance
|
|
|
183
186
|
O.bindEscape();
|
|
184
187
|
const promise = new Promise((res) => {
|
|
185
188
|
layer = O.modal({
|
|
186
|
-
title: esc(title), size: 'sm', anchor: deref(anchor), body: body ? `<p class="muted">${esc(body)}</p>` : '',
|
|
187
|
-
foot: `<button type="button" class="btn" data-close>${esc(cancel)}</button><button type="button" class="btn ${danger ? 'btn--danger' : 'btn--primary'}" data-ok>${esc(ok)}</button>`,
|
|
189
|
+
title: esc(title), size: 'sm', anchor: deref(anchor), body: body ? `<p class="gk-muted">${esc(body)}</p>` : '',
|
|
190
|
+
foot: `<button type="button" class="gk-btn" data-close>${esc(cancel)}</button><button type="button" class="gk-btn ${danger ? 'gk-btn--danger' : 'gk-btn--primary'}" data-ok>${esc(ok)}</button>`,
|
|
188
191
|
onMount: (el, close) => {
|
|
189
192
|
el.setAttribute('aria-label', String(title));
|
|
190
193
|
el.querySelector('[data-ok]').addEventListener('click', () => { answered = true; res(true); close(); });
|
|
@@ -414,7 +417,7 @@ export const Tooltip = defineComponent({
|
|
|
414
417
|
return () => {
|
|
415
418
|
const s = tip.value;
|
|
416
419
|
const node = s ? h(Teleport, { to: 'body' }, [h('div', {
|
|
417
|
-
ref: tipEl, id, role: 'tooltip', class: cx('tip', s.right && 'is-side'),
|
|
420
|
+
ref: tipEl, id, role: 'tooltip', class: cx('gk-tip', s.right && 'gk-is-side'),
|
|
418
421
|
style: { display: 'block', left: s.left + 'px', top: s.top + 'px' },
|
|
419
422
|
}, slots.text ? slots.text() : props.text)]) : null;
|
|
420
423
|
return trigger(wrap, 'Tooltip', undefined, [...(slots.default?.() ?? []), node]);
|
|
@@ -467,7 +470,7 @@ export const CookieBanner = defineComponent({
|
|
|
467
470
|
|
|
468
471
|
/* ---------------- loading bar ---------------- */
|
|
469
472
|
/**
|
|
470
|
-
* const bar = useLoadingBar({ color: 'var(--good)' }); (in setup) … bar.start(); await save(); bar.done()
|
|
473
|
+
* const bar = useLoadingBar({ color: 'var(--gk-good)' }); (in setup) … bar.start(); await save(); bar.done()
|
|
471
474
|
* The thin loading line along the top of the page (or along the top of `mount`: an element, template ref or
|
|
472
475
|
* selector). options: an object, a ref or a getter; when they change the bar is made again. Returns a handle that
|
|
473
476
|
* stays the same for the component's life: start() · done() · done(true) · fail() · set(0..1) · inc(n) · value ·
|
package/src/shell.js
CHANGED
|
@@ -82,12 +82,12 @@ function navLink({ onNavigate, link }, { href, onClick, ...rest }, kids) {
|
|
|
82
82
|
: h('a', { href, ...rest, onClick: click }, kids);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
/* html.is-sideopen: the sidebar shown as a drawer on phones. Every part hears about it through one event. */
|
|
85
|
+
/* html.gk-is-sideopen: the sidebar shown as a drawer on phones. Every part hears about it through one event. */
|
|
86
86
|
const SIDE_EVENT = 'gecko:sideopen';
|
|
87
87
|
const setSideOpen = (open) => {
|
|
88
88
|
const root = document.documentElement;
|
|
89
|
-
if (root.classList.contains('is-sideopen') === !!open) return;
|
|
90
|
-
root.classList.toggle('is-sideopen', !!open);
|
|
89
|
+
if (root.classList.contains('gk-is-sideopen') === !!open) return;
|
|
90
|
+
root.classList.toggle('gk-is-sideopen', !!open);
|
|
91
91
|
window.dispatchEvent(new CustomEvent(SIDE_EVENT, { detail: !!open }));
|
|
92
92
|
};
|
|
93
93
|
|
|
@@ -111,13 +111,13 @@ export const useShell = () => inject(SHELL, null)?.api ?? null;
|
|
|
111
111
|
/* Sidebar */
|
|
112
112
|
/* ======================================================================= */
|
|
113
113
|
/* FLIP targets and the parts that fade while the sidebar collapses / expands (same as the vanilla shell) */
|
|
114
|
-
const FLIP = [['.side__head .brand', '.mark'], ['.side__head .collapse', ''], ['.snav__item', '.ico'], ['.side__me', ':scope > .av']];
|
|
115
|
-
const FADE = '.brand__text, .side__group, .snav__label, .snav__chev, .snav__count, .snav__subs, .side__me .cell__text, .side__me > .ico';
|
|
116
|
-
const RISE = ':scope > .card, :scope > .grid > .card, :scope > .kpis > .kpi, :scope > .stack > .card, [data-rise]';
|
|
114
|
+
const FLIP = [['.gk-side__head .gk-brand', '.gk-mark'], ['.gk-side__head .gk-collapse', ''], ['.gk-snav__item', '.gk-ico'], ['.gk-side__me', ':scope > .gk-av']];
|
|
115
|
+
const FADE = '.gk-brand__text, .gk-side__group, .gk-snav__label, .gk-snav__chev, .gk-snav__count, .gk-snav__subs, .gk-side__me .gk-cell__text, .gk-side__me > .gk-ico';
|
|
116
|
+
const RISE = ':scope > .gk-card, :scope > .gk-grid > .gk-card, :scope > .gk-kpis > .gk-kpi, :scope > .gk-stack > .gk-card, [data-rise]';
|
|
117
117
|
|
|
118
118
|
const initials = (name = '') => String(name).split(/\s+/).filter(Boolean).slice(0, 2).map((w) => w[0]).join('').toUpperCase();
|
|
119
119
|
/* the same markup as av(person, '', online) */
|
|
120
|
-
const avatar = (person, online) => h('span', { class: `av av--${person.tone || 'indigo'}`, title: person.name }, [person.ini ?? initials(person.name), online ? h('i', { class: 'av__on' }) : null]);
|
|
120
|
+
const avatar = (person, online) => h('span', { class: `gk-av gk-av--${person.tone || 'indigo'}`, title: person.name }, [person.ini ?? initials(person.name), online ? h('i', { class: 'gk-av__on' }) : null]);
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* <Sidebar :brand="{ name: 'MotoRent', sub: 'Chiang Mai', icon: 'logo' }" :nav="nav" :end="end" :user="me"
|
|
@@ -152,9 +152,9 @@ export const Sidebar = defineComponent({
|
|
|
152
152
|
railTl?.progress(1);
|
|
153
153
|
if (rail.value === r) return;
|
|
154
154
|
closeFly(true);
|
|
155
|
-
const root = document.documentElement, sideEl = side.value, main = document.querySelector('.t-main');
|
|
155
|
+
const root = document.documentElement, sideEl = side.value, main = document.querySelector('.gk-t-main');
|
|
156
156
|
const apply = () => {
|
|
157
|
-
root.classList.toggle('is-rail', r);
|
|
157
|
+
root.classList.toggle('gk-is-rail', r);
|
|
158
158
|
try { if (innerWidth >= props.railBreakpoint) localStorage.setItem(`${props.storageKey}:pinned`, r ? '0' : '1'); } catch {}
|
|
159
159
|
rail.value = r;
|
|
160
160
|
};
|
|
@@ -162,7 +162,7 @@ export const Sidebar = defineComponent({
|
|
|
162
162
|
const collect = () => FLIP.flatMap(([s, rf]) => $$(s, sideEl).map((el) => ({ el, ref: (rf ? el.querySelector(rf) : el) ?? el, key: s + (el.dataset?.id ?? '') })));
|
|
163
163
|
const els = collect();
|
|
164
164
|
const w0 = sideEl.offsetWidth, m0 = main?.getBoundingClientRect().left ?? 0;
|
|
165
|
-
root.classList.toggle('is-rail', r); const w1 = sideEl.offsetWidth, m1 = main?.getBoundingClientRect().left ?? 0; root.classList.toggle('is-rail', !r);
|
|
165
|
+
root.classList.toggle('gk-is-rail', r); const w1 = sideEl.offsetWidth, m1 = main?.getBoundingClientRect().left ?? 0; root.classList.toggle('gk-is-rail', !r);
|
|
166
166
|
const clip = (x) => `inset(0 ${x}px 0 0 round 22px)`;
|
|
167
167
|
// measure, switch, then (once Vue has drawn the new state, before the next paint) slide every icon from where
|
|
168
168
|
// it was: those tweens go into the rail timeline at `at` (room is kept for them there, so it does not end first)
|
|
@@ -178,14 +178,14 @@ export const Sidebar = defineComponent({
|
|
|
178
178
|
const a = x.ref.getBoundingClientRect(), dx = b.left - a.left, dy = b.top - a.top;
|
|
179
179
|
if (Math.abs(dx) + Math.abs(dy) < 0.5) return;
|
|
180
180
|
sub.fromTo(x.el, { x: dx, y: dy }, { x: 0, y: 0, duration: dur, ease }, 0);
|
|
181
|
-
if (x.el.matches('.snav__item[aria-current="page"]')) sub.fromTo(pill.value, { x: dx, y: dy }, { x: 0, y: 0, duration: dur, ease }, 0);
|
|
181
|
+
if (x.el.matches('.gk-snav__item[aria-current="page"]')) sub.fromTo(pill.value, { x: dx, y: dy }, { x: 0, y: 0, duration: dur, ease }, 0);
|
|
182
182
|
});
|
|
183
183
|
tl.add(sub, at);
|
|
184
184
|
});
|
|
185
185
|
};
|
|
186
186
|
const cleanup = () => {
|
|
187
187
|
g.set(sideEl, { clearProps: 'clipPath' }); if (main) g.set(main, { clearProps: 'marginLeft' });
|
|
188
|
-
g.set([...$$(FADE, sideEl), ...$$('.snav__item, .brand, .collapse, .side__me', sideEl)], { clearProps: 'opacity,transform' });
|
|
188
|
+
g.set([...$$(FADE, sideEl), ...$$('.gk-snav__item, .gk-brand, .gk-collapse, .gk-side__me', sideEl)], { clearProps: 'opacity,transform' });
|
|
189
189
|
g.set(pill.value, { clearProps: 'transform' }); railTl = null;
|
|
190
190
|
};
|
|
191
191
|
tl = railTl = g.timeline({ onComplete: cleanup });
|
|
@@ -211,8 +211,8 @@ export const Sidebar = defineComponent({
|
|
|
211
211
|
const el = side.value; if (!el) return;
|
|
212
212
|
const moved = !!shown && shown.page !== m.value.page && shown.rail === rail.value && shown.phone === phone.value; // a new page, not a boot / rail change
|
|
213
213
|
shown = { page: m.value.page, rail: rail.value, phone: phone.value };
|
|
214
|
-
M.indicator(pill.value, el.querySelector('.snav__item[aria-current="page"]'), { animate: moved && !railTl, radius: 14 });
|
|
215
|
-
const list = el.querySelector('.snav__subs');
|
|
214
|
+
M.indicator(pill.value, el.querySelector('.gk-snav__item[aria-current="page"]'), { animate: moved && !railTl, radius: 14 });
|
|
215
|
+
const list = el.querySelector('.gk-snav__subs');
|
|
216
216
|
if (moved && list && !list.hidden && !RM() && !railTl) {
|
|
217
217
|
g.fromTo(list, { height: 0, opacity: 0 }, { height: 'auto', opacity: 1, duration: 0.45, ease: 'power3.out', clearProps: 'height,opacity' });
|
|
218
218
|
g.fromTo(list.children, { opacity: 0, x: -8 }, { opacity: 1, x: 0, duration: 0.35, ease: 'power3.out', stagger: 0.03, delay: 0.06, clearProps: 'transform,opacity' });
|
|
@@ -223,12 +223,12 @@ export const Sidebar = defineComponent({
|
|
|
223
223
|
// the saved choice (or a narrow window) starts it as a rail; the classes go when the sidebar does
|
|
224
224
|
onMounted(() => {
|
|
225
225
|
const root = document.documentElement;
|
|
226
|
-
let r = root.classList.contains('is-rail');
|
|
226
|
+
let r = root.classList.contains('gk-is-rail');
|
|
227
227
|
try { const p = localStorage.getItem(`${props.storageKey}:pinned`); if (p === '0' || (p === null && innerWidth < props.railBreakpoint)) r = true; } catch {}
|
|
228
|
-
root.classList.toggle('is-rail', r); rail.value = r;
|
|
228
|
+
root.classList.toggle('gk-is-rail', r); rail.value = r;
|
|
229
229
|
O.initTips();
|
|
230
230
|
mq = matchMedia(`(max-width: ${props.mobile}px)`); onMq(); mq.addEventListener('change', onMq);
|
|
231
|
-
stopTrack = M.trackIndicator(pill.value, () => side.value?.querySelector('.snav__item[aria-current="page"]'), { radius: 14 });
|
|
231
|
+
stopTrack = M.trackIndicator(pill.value, () => side.value?.querySelector('.gk-snav__item[aria-current="page"]'), { radius: 14 });
|
|
232
232
|
counts = readCounts();
|
|
233
233
|
nextTick(() => {
|
|
234
234
|
placePill();
|
|
@@ -242,18 +242,18 @@ export const Sidebar = defineComponent({
|
|
|
242
242
|
onUpdated(() => {
|
|
243
243
|
const now = readCounts();
|
|
244
244
|
for (const id in now) if (now[id] !== counts[id] && now[id] > 0) {
|
|
245
|
-
const c = side.value?.querySelector(`.snav__item[data-id="${CSS.escape(id)}"] .snav__count`); if (c) M.flash(c);
|
|
245
|
+
const c = side.value?.querySelector(`.gk-snav__item[data-id="${CSS.escape(id)}"] .gk-snav__count`); if (c) M.flash(c);
|
|
246
246
|
}
|
|
247
247
|
counts = now;
|
|
248
248
|
});
|
|
249
249
|
onBeforeUnmount(() => {
|
|
250
250
|
stopTrack?.(); stopTrack = null; mq?.removeEventListener('change', onMq); railTl?.kill(); railTl = null; flyTimer?.kill(); flyTimer = null;
|
|
251
251
|
if (flyEl.value) g.killTweensOf(flyEl.value);
|
|
252
|
-
document.documentElement.classList.remove('is-rail', 'is-sideopen');
|
|
252
|
+
document.documentElement.classList.remove('gk-is-rail', 'gk-is-sideopen');
|
|
253
253
|
});
|
|
254
254
|
|
|
255
255
|
const toggleSubs = () => {
|
|
256
|
-
const list = side.value?.querySelector('.snav__subs'); if (!list) return;
|
|
256
|
+
const list = side.value?.querySelector('.gk-snav__subs'); if (!list) return;
|
|
257
257
|
const open = subs.shut;
|
|
258
258
|
g.killTweensOf([list, ...list.children]);
|
|
259
259
|
if (open) {
|
|
@@ -306,16 +306,16 @@ export const Sidebar = defineComponent({
|
|
|
306
306
|
const mm = m.value, w = W.value, l = L(), isRail = rail.value, user = props.user, brand = props.brand || { name: 'App' };
|
|
307
307
|
const navItem = (n) => {
|
|
308
308
|
const on = n.id === mm.page, c = countOf(n), list = mm.subsOf(n), open = on && !!list && (!isRail || phone.value);
|
|
309
|
-
return h('div', { class: 'snav__wrap', key: n.id }, [
|
|
309
|
+
return h('div', { class: 'gk-snav__wrap', key: n.id }, [
|
|
310
310
|
navLink(l, {
|
|
311
|
-
class: 'snav__item', 'data-id': n.id, href: mm.hrefOf(n), 'aria-current': on ? 'page' : undefined,
|
|
312
|
-
'aria-expanded': open ? !subs.shut : undefined, 'aria-controls': open ? `snav-subs-${n.id}` : undefined, 'aria-label': n.label,
|
|
311
|
+
class: 'gk-snav__item', 'data-id': n.id, href: mm.hrefOf(n), 'aria-current': on ? 'page' : undefined,
|
|
312
|
+
'aria-expanded': open ? !subs.shut : undefined, 'aria-controls': open ? `gk-snav-subs-${n.id}` : undefined, 'aria-label': n.label,
|
|
313
313
|
onClick: open ? (e) => { e.preventDefault(); toggleSubs(); } : undefined,
|
|
314
314
|
onPointerenter: (e) => { if (M.fine.matches) openFly(n, e.currentTarget); }, onPointerleave: closeFlySoon,
|
|
315
315
|
onFocus: (e) => openFly(n, e.currentTarget), onBlur: closeFlySoon,
|
|
316
|
-
}, [iconNode(n.icon), h('span', { class: 'snav__label' }, n.label), c > 0 ? h('span', { class: 'snav__count' }, c) : null,
|
|
317
|
-
list && !c ? h(Icon, { name: 'chevR', class: 'snav__chev' }) : null]),
|
|
318
|
-
open ? h('div', { class: 'snav__subs', id: `snav-subs-${n.id}`, hidden: subs.hidden },
|
|
316
|
+
}, [iconNode(n.icon), h('span', { class: 'gk-snav__label' }, n.label), c > 0 ? h('span', { class: 'gk-snav__count' }, c) : null,
|
|
317
|
+
list && !c ? h(Icon, { name: 'chevR', class: 'gk-snav__chev' }) : null]),
|
|
318
|
+
open ? h('div', { class: 'gk-snav__subs', id: `gk-snav-subs-${n.id}`, hidden: subs.hidden },
|
|
319
319
|
list.map((s) => navLink(l, { key: s.id, href: s.href, 'aria-current': s.id === mm.sub ? 'page' : undefined }, [s.label]))) : null,
|
|
320
320
|
]);
|
|
321
321
|
};
|
|
@@ -323,37 +323,37 @@ export const Sidebar = defineComponent({
|
|
|
323
323
|
const flyList = flyItem && mm.subsOf(flyItem), flyCount = flyItem ? countOf(flyItem) : 0;
|
|
324
324
|
const homeItem = mm.itemOf(props.home);
|
|
325
325
|
return [
|
|
326
|
-
h('aside', { ...attrs, class: ['side', attrs.class], id: '
|
|
327
|
-
h('div', { class: 'side__head' }, [
|
|
328
|
-
navLink(l, { class: 'brand', href: brand.href ?? (homeItem ? mm.hrefOf(homeItem) : mm.all[0] ? mm.hrefOf(mm.all[0]) : '/'), 'aria-label': brand.name }, [
|
|
329
|
-
h('span', { class: 'mark' }, [iconNode(brand.icon || 'logo')]),
|
|
330
|
-
h('span', { class: 'brand__text' }, [h('b', null, brand.name), brand.sub ? h('small', null, brand.sub) : null]),
|
|
326
|
+
h('aside', { ...attrs, class: ['gk-side', attrs.class], id: 'gk-side', 'aria-label': w.sidebar, ref: side }, [
|
|
327
|
+
h('div', { class: 'gk-side__head' }, [
|
|
328
|
+
navLink(l, { class: 'gk-brand', href: brand.href ?? (homeItem ? mm.hrefOf(homeItem) : mm.all[0] ? mm.hrefOf(mm.all[0]) : '/'), 'aria-label': brand.name }, [
|
|
329
|
+
h('span', { class: 'gk-mark' }, [iconNode(brand.icon || 'logo')]),
|
|
330
|
+
h('span', { class: 'gk-brand__text' }, [h('b', null, brand.name), brand.sub ? h('small', null, brand.sub) : null]),
|
|
331
331
|
]),
|
|
332
332
|
h('button', {
|
|
333
|
-
type: 'button', class: 'collapse', 'aria-label': isRail ? w.expand : w.collapse, 'data-tip': isRail ? w.expandTip : w.collapseTip,
|
|
333
|
+
type: 'button', class: 'gk-collapse', 'aria-label': isRail ? w.expand : w.collapse, 'data-tip': isRail ? w.expandTip : w.collapseTip,
|
|
334
334
|
'data-tip-side': isRail ? 'right' : undefined, onClick: (e) => { M.pop(e.currentTarget); setRail(!rail.value); },
|
|
335
335
|
}, [h(Icon, { name: 'panel' })]),
|
|
336
336
|
]),
|
|
337
|
-
h('nav', { class: 'snav', 'aria-label': w.main }, [
|
|
338
|
-
h('span', { class: 'snav__pill', ref: pill }),
|
|
339
|
-
...(props.nav || []).map((grp, i) => h('div', { class: 'snav__group', key: i }, [grp.label ? h('span', { class: 'side__group' }, grp.label) : null, ...(grp.items || []).map(navItem)])),
|
|
340
|
-
props.end?.length ? h('div', { class: 'snav__group snav__group--end', key: 'end' }, props.end.map(navItem)) : null,
|
|
337
|
+
h('nav', { class: 'gk-snav', 'aria-label': w.main }, [
|
|
338
|
+
h('span', { class: 'gk-snav__pill', ref: pill }),
|
|
339
|
+
...(props.nav || []).map((grp, i) => h('div', { class: 'gk-snav__group', key: i }, [grp.label ? h('span', { class: 'gk-side__group' }, grp.label) : null, ...(grp.items || []).map(navItem)])),
|
|
340
|
+
props.end?.length ? h('div', { class: 'gk-snav__group gk-snav__group--end', key: 'end' }, props.end.map(navItem)) : null,
|
|
341
341
|
]),
|
|
342
|
-
user ? h('div', { class: 'side__foot' }, [
|
|
343
|
-
h('button', { type: 'button', class: 'side__me', 'aria-label': `${user.name} — ${w.account}`, 'data-tip': isRail ? user.name : undefined, 'data-tip-side': isRail ? 'right' : undefined, onClick: openMe }, [
|
|
342
|
+
user ? h('div', { class: 'gk-side__foot' }, [
|
|
343
|
+
h('button', { type: 'button', class: 'gk-side__me', 'aria-label': `${user.name} — ${w.account}`, 'data-tip': isRail ? user.name : undefined, 'data-tip-side': isRail ? 'right' : undefined, onClick: openMe }, [
|
|
344
344
|
avatar(user, user.online ?? true),
|
|
345
|
-
h('span', { class: 'cell__text' }, [h('b', null, user.name), user.role ? h('small', null, user.role) : null]),
|
|
345
|
+
h('span', { class: 'gk-cell__text' }, [h('b', null, user.name), user.role ? h('small', null, user.role) : null]),
|
|
346
346
|
h(Icon, { name: 'sort' }),
|
|
347
347
|
]),
|
|
348
348
|
]) : null,
|
|
349
349
|
]),
|
|
350
|
-
h('div', { class: 'side__scrim', onClick: () => setSideOpen(false) }),
|
|
350
|
+
h('div', { class: 'gk-side__scrim', onClick: () => setSideOpen(false) }),
|
|
351
351
|
f && flyItem ? h(Teleport, { to: 'body' }, [h('div', {
|
|
352
|
-
ref: flyEl, class: 'flyout', 'data-id': flyItem.id, role: 'menu', style: { left: f.left + 'px', top: f.y + 'px' },
|
|
352
|
+
ref: flyEl, class: 'gk-flyout', 'data-id': flyItem.id, role: 'menu', style: { left: f.left + 'px', top: f.y + 'px' },
|
|
353
353
|
onPointerenter: () => flyTimer?.kill(), onPointerleave: closeFlySoon,
|
|
354
354
|
onClick: (e) => { if (e.target.closest('a')) closeFly(); },
|
|
355
355
|
}, [
|
|
356
|
-
h('div', { class: 'flyout__head' }, [h('b', null, [flyItem.label, flyCount ? h('span', { class: 'snav__count' }, flyCount) : null]), flyItem.blurb ? h('small', null, flyItem.blurb) : null]),
|
|
356
|
+
h('div', { class: 'gk-flyout__head' }, [h('b', null, [flyItem.label, flyCount ? h('span', { class: 'gk-snav__count' }, flyCount) : null]), flyItem.blurb ? h('small', null, flyItem.blurb) : null]),
|
|
357
357
|
...(flyList
|
|
358
358
|
? flyList.map((s) => navLink(l, { key: s.id, role: 'menuitem', href: s.href, 'aria-current': mm.page === flyItem.id && mm.sub === s.id ? 'page' : undefined }, [h(Icon, { name: 'chevR' }), s.label]))
|
|
359
359
|
: [navLink(l, { role: 'menuitem', href: mm.hrefOf(flyItem), 'aria-current': mm.page === flyItem.id ? 'page' : undefined }, [h(Icon, { name: 'arrowR' }), `${w.open} ${String(flyItem.label).toLowerCase()}`])]),
|
|
@@ -393,7 +393,7 @@ export const Topbar = defineComponent({
|
|
|
393
393
|
if (props.theme !== false) M.restoreTheme(`${props.storageKey}:theme`);
|
|
394
394
|
onScroll();
|
|
395
395
|
addEventListener('scroll', onScroll, { passive: true });
|
|
396
|
-
burgerApi = M.bindBurger(menuBtn.value, { controls: '
|
|
396
|
+
burgerApi = M.bindBurger(menuBtn.value, { controls: 'gk-side', escape: false, onToggle: (open) => setSideOpen(open) });
|
|
397
397
|
addEventListener(SIDE_EVENT, sync);
|
|
398
398
|
mag = M.magnetic(top.value);
|
|
399
399
|
// breadcrumbs slide in after a move
|
|
@@ -402,13 +402,13 @@ export const Topbar = defineComponent({
|
|
|
402
402
|
watch(count, (now, was) => {
|
|
403
403
|
if (now <= was || RM() || !bellBtn.value) return;
|
|
404
404
|
M.wiggle(bellBtn.value.querySelector('svg'));
|
|
405
|
-
g.fromTo(bellBtn.value.querySelector('.bell__n'), { scale: 0.4 }, { scale: 1, duration: 0.6, ease: 'back.out(3)' });
|
|
405
|
+
g.fromTo(bellBtn.value.querySelector('.gk-bell__n'), { scale: 0.4 }, { scale: 1, duration: 0.6, ease: 'back.out(3)' });
|
|
406
406
|
}, { flush: 'post' });
|
|
407
407
|
});
|
|
408
408
|
onBeforeUnmount(() => {
|
|
409
409
|
removeEventListener('scroll', onScroll); removeEventListener(SIDE_EVENT, sync);
|
|
410
410
|
burgerApi?.destroy(); burgerApi = null; mag?.destroy(); mag = null;
|
|
411
|
-
if (bellBtn.value) g.killTweensOf([bellBtn.value.querySelector('svg'), bellBtn.value.querySelector('.bell__n')]);
|
|
411
|
+
if (bellBtn.value) g.killTweensOf([bellBtn.value.querySelector('svg'), bellBtn.value.querySelector('.gk-bell__n')]);
|
|
412
412
|
});
|
|
413
413
|
|
|
414
414
|
return () => {
|
|
@@ -416,24 +416,24 @@ export const Topbar = defineComponent({
|
|
|
416
416
|
const subLabel = mm.sub && mm.subsOf(mm.item)?.find((s) => s.id === mm.sub)?.label;
|
|
417
417
|
const s = props.search === false ? null : props.search || {};
|
|
418
418
|
const bell = props.bell, primary = props.primary;
|
|
419
|
-
return h('header', { class: ['top', stuck.value && 'is-stuck'], ref: top }, [
|
|
420
|
-
h('div', { class: 'top__in' }, [
|
|
421
|
-
h('button', { type: 'button', class: 'iconbtn top__menu', 'aria-label': w.menu, ref: menuBtn }, [h('span', { class: 'burger', 'aria-hidden': 'true' }, [h('i'), h('i'), h('i')])]),
|
|
422
|
-
h('nav', { class: 'crumbs', 'aria-label': w.breadcrumb, ref: crumbs }, [
|
|
419
|
+
return h('header', { class: ['gk-top', stuck.value && 'gk-is-stuck'], ref: top }, [
|
|
420
|
+
h('div', { class: 'gk-top__in' }, [
|
|
421
|
+
h('button', { type: 'button', class: 'gk-iconbtn gk-top__menu', 'aria-label': w.menu, ref: menuBtn }, [h('span', { class: 'gk-burger', 'aria-hidden': 'true' }, [h('i'), h('i'), h('i')])]),
|
|
422
|
+
h('nav', { class: 'gk-crumbs', 'aria-label': w.breadcrumb, ref: crumbs }, [
|
|
423
423
|
...(props.crumbsRoot ? [h('span', null, props.crumbsRoot), h(Icon, { name: 'chevR' })] : []),
|
|
424
424
|
mm.item ? navLink(l, { href: mm.hrefOf(mm.item) }, [mm.item.label]) : null,
|
|
425
425
|
...(subLabel ? [h(Icon, { name: 'chevR' }), h('b', null, subLabel)] : []),
|
|
426
426
|
]),
|
|
427
|
-
s ? h('button', { type: 'button', class: 'search', 'aria-label': w.search, onClick: () => (s.onOpen ? s.onOpen() : props.onSearch?.()) }, [
|
|
427
|
+
s ? h('button', { type: 'button', class: 'gk-search', 'aria-label': w.search, onClick: () => (s.onOpen ? s.onOpen() : props.onSearch?.()) }, [
|
|
428
428
|
h(Icon, { name: 'search' }), h('span', null, s.placeholder || w.searchPlaceholder), h('kbd', null, w.searchKey)]) : null,
|
|
429
429
|
...(slots.default?.() ?? []),
|
|
430
430
|
props.theme !== false ? h('button', {
|
|
431
|
-
type: 'button', class: 'iconbtn top__theme', 'aria-label': w.theme, 'data-tip': w.themeTip,
|
|
431
|
+
type: 'button', class: 'gk-iconbtn gk-top__theme', 'aria-label': w.theme, 'data-tip': w.themeTip,
|
|
432
432
|
onClick: (e) => { M.pop(e.currentTarget); M.toggleTheme(e.currentTarget, { storageKey: `${props.storageKey}:theme` }); },
|
|
433
|
-
}, [h(Icon, { name: 'moon', class: 'i-moon' }), h(Icon, { name: 'sun', class: 'i-sun' })]) : null,
|
|
434
|
-
bell ? h('button', { type: 'button', class: 'iconbtn top__bell', 'aria-label': w.bell, 'data-tip': w.bell, ref: bellBtn, onClick: (e) => bell.onClick?.(e.currentTarget) }, [
|
|
435
|
-
h(Icon, { name: 'bell' }), h('span', { class: 'bell__n', hidden: !count.value }, count.value)]) : null,
|
|
436
|
-
primary ? h('button', { type: 'button', class: 'btn btn--primary top__new magnetic', 'data-tip': primary.tip || '', onClick: (e) => primary.run?.(e.currentTarget) }, [
|
|
433
|
+
}, [h(Icon, { name: 'moon', class: 'gk-i-moon' }), h(Icon, { name: 'sun', class: 'gk-i-sun' })]) : null,
|
|
434
|
+
bell ? h('button', { type: 'button', class: 'gk-iconbtn gk-top__bell', 'aria-label': w.bell, 'data-tip': w.bell, ref: bellBtn, onClick: (e) => bell.onClick?.(e.currentTarget) }, [
|
|
435
|
+
h(Icon, { name: 'bell' }), h('span', { class: 'gk-bell__n', hidden: !count.value }, count.value)]) : null,
|
|
436
|
+
primary ? h('button', { type: 'button', class: 'gk-btn gk-btn--primary gk-top__new gk-magnetic', 'data-tip': primary.tip || '', onClick: (e) => primary.run?.(e.currentTarget) }, [
|
|
437
437
|
iconNode(primary.icon || 'plus'), h('span', null, primary.label || w.primary)]) : null,
|
|
438
438
|
]),
|
|
439
439
|
]);
|
|
@@ -466,8 +466,8 @@ export const MobileTabbar = defineComponent({
|
|
|
466
466
|
const mm = m.value, w = wordsOf(props.words), l = { onNavigate: props.onNavigate, link: props.link };
|
|
467
467
|
const ids = props.tabbar || mm.all.slice(0, 4).map((it) => it.id);
|
|
468
468
|
const rest = mm.all.filter((it) => !ids.includes(it.id));
|
|
469
|
-
return h('nav', { class: 'tabbar', 'aria-label': w.tabs, ref: el }, [
|
|
470
|
-
h('span', { class: 'tabbar__line', ref: line }),
|
|
469
|
+
return h('nav', { class: 'gk-tabbar', 'aria-label': w.tabs, ref: el }, [
|
|
470
|
+
h('span', { class: 'gk-tabbar__line', ref: line }),
|
|
471
471
|
...ids.map((id) => { const it = mm.itemOf(id); return it ? navLink(l, { key: id, href: mm.hrefOf(it), 'data-id': id, 'aria-current': mm.page === id ? 'page' : undefined }, [iconNode(it.icon), h('small', null, it.label)]) : null; }),
|
|
472
472
|
rest.length ? h('button', {
|
|
473
473
|
type: 'button', 'data-more': '',
|
|
@@ -487,7 +487,7 @@ const seg = typeof Intl !== 'undefined' && typeof Intl.Segmenter === 'function'
|
|
|
487
487
|
const chars = (w) => (seg ? [...seg.segment(w)].map((x) => x.segment) : [...w]);
|
|
488
488
|
const splitTitle = (t) => String(t).trim().split(' ').flatMap((w, i) => [
|
|
489
489
|
i ? ' ' : null,
|
|
490
|
-
h('span', { class: 'word', 'aria-hidden': 'true', key: 'w' + i }, chars(w).map((c, j) => h('span', { class: 'ch', key: j }, c))),
|
|
490
|
+
h('span', { class: 'gk-word', 'aria-hidden': 'true', key: 'w' + i }, chars(w).map((c, j) => h('span', { class: 'gk-ch', key: j }, c))),
|
|
491
491
|
]).filter((x) => x !== null);
|
|
492
492
|
const normTab = (t) => (Array.isArray(t) ? { id: String(t[0]), label: t[1] ?? t[0], count: t[2], href: t[3] } : { ...t, id: String(t.id) });
|
|
493
493
|
const filled = (x) => x != null && x !== false && x !== '';
|
|
@@ -530,17 +530,17 @@ export const PageHeader = defineComponent({
|
|
|
530
530
|
const track = (on) => { stopTrack?.(); stopTrack = on && line.value ? M.trackIndicator(line.value, cur, { radius: 2, line: true }) : null; };
|
|
531
531
|
onMounted(() => {
|
|
532
532
|
M.title(h1.value);
|
|
533
|
-
M.slide(el.value.querySelectorAll('.phead__eyebrow, .phead p, .phead__actions > *'), { y: 10, stagger: 0.05, delay: 0.12 });
|
|
533
|
+
M.slide(el.value.querySelectorAll('.gk-phead__eyebrow, .gk-phead p, .gk-phead__actions > *'), { y: 10, stagger: 0.05, delay: 0.12 });
|
|
534
534
|
if (line.value) M.indicator(line.value, cur(), { animate: false, radius: 2, line: true });
|
|
535
535
|
track(!!state.value.list);
|
|
536
536
|
watch(() => props.title, () => M.title(h1.value), { flush: 'post' });
|
|
537
|
-
watch(() => (typeof props.sub === 'string' ? props.sub : null), () => { const p = el.value?.querySelector('.phead p'); if (p) M.slide([p], { y: 6 }); }, { flush: 'post' });
|
|
537
|
+
watch(() => (typeof props.sub === 'string' ? props.sub : null), () => { const p = el.value?.querySelector('.gk-phead p'); if (p) M.slide([p], { y: 6 }); }, { flush: 'post' });
|
|
538
538
|
watch(() => `${state.value.current}\u0001${!!state.value.list}`, () => { if (line.value) M.indicator(line.value, cur(), { animate: true, radius: 2, line: true }); }, { flush: 'post' });
|
|
539
539
|
watch(() => !!state.value.list, track, { flush: 'post' });
|
|
540
540
|
});
|
|
541
541
|
onBeforeUnmount(() => { stopTrack?.(); stopTrack = null; });
|
|
542
542
|
|
|
543
|
-
const badge = (n) => (n ? h('span', { class: 'badge' }, n) : null);
|
|
543
|
+
const badge = (n) => (n ? h('span', { class: 'gk-badge' }, n) : null);
|
|
544
544
|
return () => {
|
|
545
545
|
const w = wordsOf(props.words), title = String(props.title ?? '');
|
|
546
546
|
const { list, current, links, L } = state.value;
|
|
@@ -548,18 +548,18 @@ export const PageHeader = defineComponent({
|
|
|
548
548
|
const sub = slots.sub ? slots.sub() : props.sub;
|
|
549
549
|
const actions = slots.actions ? slots.actions() : props.actions;
|
|
550
550
|
return [
|
|
551
|
-
h('header', { ...attrs, class: ['phead', attrs.class], ref: el }, [
|
|
552
|
-
h('div', { class: 'phead__text' }, [
|
|
553
|
-
filled(eyebrow) ? h('span', { class: 'phead__eyebrow' }, eyebrow) : null,
|
|
551
|
+
h('header', { ...attrs, class: ['gk-phead', attrs.class], ref: el }, [
|
|
552
|
+
h('div', { class: 'gk-phead__text' }, [
|
|
553
|
+
filled(eyebrow) ? h('span', { class: 'gk-phead__eyebrow' }, eyebrow) : null,
|
|
554
554
|
h('h1', { ref: h1, 'data-text': title, 'data-split': title, 'aria-label': title }, splitTitle(title)),
|
|
555
555
|
filled(sub) ? h('p', null, sub) : null,
|
|
556
556
|
]),
|
|
557
|
-
filled(actions) ? h('div', { class: 'phead__actions' }, actions) : null,
|
|
557
|
+
filled(actions) ? h('div', { class: 'gk-phead__actions' }, actions) : null,
|
|
558
558
|
]),
|
|
559
559
|
list ? (links
|
|
560
|
-
? h('nav', { class: 'tabs', 'aria-label': w.sections, ref: tabsEl }, [h('span', { class: 'tabs__line', ref: line }),
|
|
560
|
+
? h('nav', { class: 'gk-tabs', 'aria-label': w.sections, ref: tabsEl }, [h('span', { class: 'gk-tabs__line', ref: line }),
|
|
561
561
|
...list.map((t) => navLink(L, { key: t.id, href: t.href ?? '#', 'aria-current': t.id === current ? 'page' : undefined }, [t.label, badge(t.count)]))])
|
|
562
|
-
: h('div', { class: 'tabs', role: 'tablist', ref: tabsEl }, [h('span', { class: 'tabs__line', ref: line }),
|
|
562
|
+
: h('div', { class: 'gk-tabs', role: 'tablist', ref: tabsEl }, [h('span', { class: 'gk-tabs__line', ref: line }),
|
|
563
563
|
...list.map((t) => h('button', {
|
|
564
564
|
key: t.id, type: 'button', role: 'tab', 'data-v': t.id, 'aria-selected': t.id === current,
|
|
565
565
|
onClick: () => { if (t.id !== current) choose(t.id); },
|
|
@@ -585,7 +585,7 @@ export const shellBootScript = ({ storageKey = 'gecko', railBreakpoint = 1280 }
|
|
|
585
585
|
* <NuxtPage />
|
|
586
586
|
* <template #extra>…buttons before the theme switch…</template>
|
|
587
587
|
* </AppShell>
|
|
588
|
-
* The whole frame: Sidebar (rail, flyout), Topbar, your page in <main class="view">, the phone tab bar,
|
|
588
|
+
* The whole frame: Sidebar (rail, flyout), Topbar, your page in <main class="gk-view">, the phone tab bar,
|
|
589
589
|
* the ⌘K palette (pages + your search(q) groups), keyboard shortcuts (⌘K / search, [ rail, ? list, Esc close,
|
|
590
590
|
* your keys) and the intro. When the path changes the new page slides in from the direction of travel.
|
|
591
591
|
* Use <PageHeader> at the top of each page. useShell() inside gives { route, navigate, palette, setRail… }.
|
|
@@ -628,24 +628,24 @@ export const AppShell = defineComponent({
|
|
|
628
628
|
O.bindEscape();
|
|
629
629
|
O.modal({
|
|
630
630
|
title: esc(w.shortcuts), size: 'sm',
|
|
631
|
-
body: `<dl class="keys">${list.map(([kk, v]) => `<dt>${String(kk).split(' ').map((x) => (x === 'or' || x === 'then' ? `<em>${x}</em>` : `<kbd>${esc(x)}</kbd>`)).join(' ')}</dt><dd>${esc(v)}</dd>`).join('')}</dl>`,
|
|
631
|
+
body: `<dl class="gk-keys">${list.map(([kk, v]) => `<dt>${String(kk).split(' ').map((x) => (x === 'or' || x === 'then' ? `<em>${x}</em>` : `<kbd>${esc(x)}</kbd>`)).join(' ')}</dt><dd>${esc(v)}</dd>`).join('')}</dl>`,
|
|
632
632
|
onMount: (el) => M.slide(el.querySelectorAll('dt, dd'), { y: 6, stagger: 0.015 }),
|
|
633
633
|
});
|
|
634
634
|
};
|
|
635
635
|
const playIntro = () => {
|
|
636
636
|
const el = root.value; if (!el) return null;
|
|
637
637
|
introTl?.progress(1);
|
|
638
|
-
const side = el.querySelector('.side'), pill = el.querySelector('.snav__pill'), phone = innerWidth <= props.mobile;
|
|
638
|
+
const side = el.querySelector('.gk-side'), pill = el.querySelector('.gk-snav__pill'), phone = innerWidth <= props.mobile;
|
|
639
639
|
M.ready.v = false;
|
|
640
640
|
const tl = g.timeline({ onComplete: () => { M.ready.v = true; } });
|
|
641
641
|
if (!phone && side) {
|
|
642
642
|
tl.fromTo(side, { x: -30, opacity: 0 }, { x: 0, opacity: 1, duration: D(0.7), ease: 'expo.out', clearProps: 'transform,opacity' });
|
|
643
|
-
tl.fromTo($$('.side__head > *, .side__group, .snav__item, .snav__subs > a, .side__foot > *', side), { opacity: 0, x: -10 }, { opacity: 1, x: 0, duration: D(0.5), ease: 'power3.out', stagger: D(0.025), clearProps: 'transform,opacity' }, D(0.1));
|
|
643
|
+
tl.fromTo($$('.gk-side__head > *, .gk-side__group, .gk-snav__item, .gk-snav__subs > a, .gk-side__foot > *', side), { opacity: 0, x: -10 }, { opacity: 1, x: 0, duration: D(0.5), ease: 'power3.out', stagger: D(0.025), clearProps: 'transform,opacity' }, D(0.1));
|
|
644
644
|
tl.fromTo(pill, { scale: 0.4, opacity: 0 }, { scale: 1, opacity: 1, duration: D(0.6), ease: 'back.out(2)', transformOrigin: '50% 50%', clearProps: 'transform' }, D(0.45));
|
|
645
645
|
}
|
|
646
|
-
const bits = el.querySelectorAll('.top__in > *');
|
|
646
|
+
const bits = el.querySelectorAll('.gk-top__in > *');
|
|
647
647
|
if (bits.length) tl.fromTo(bits, { y: -12, opacity: 0 }, { y: 0, opacity: 1, duration: D(0.6), ease: 'expo.out', stagger: D(0.05), clearProps: 'transform,opacity' }, D(0.15));
|
|
648
|
-
const tb = el.querySelector('.tabbar');
|
|
648
|
+
const tb = el.querySelector('.gk-tabbar');
|
|
649
649
|
if (phone && tb) tl.fromTo(tb, { y: 90 }, { y: 0, duration: D(0.7), ease: 'expo.out', clearProps: 'transform' }, D(0.2));
|
|
650
650
|
if (RM()) M.ready.v = true;
|
|
651
651
|
introTl = tl;
|
|
@@ -669,7 +669,7 @@ export const AppShell = defineComponent({
|
|
|
669
669
|
if (e.key === 'Escape') {
|
|
670
670
|
if (e.defaultPrevented) return;
|
|
671
671
|
if (O.closeTop()) { e.preventDefault(); return; }
|
|
672
|
-
if (document.documentElement.classList.contains('is-sideopen')) { setSideOpen(false); root.value?.querySelector('.top__menu')?.focus(); }
|
|
672
|
+
if (document.documentElement.classList.contains('gk-is-sideopen')) { setSideOpen(false); root.value?.querySelector('.gk-top__menu')?.focus(); }
|
|
673
673
|
return;
|
|
674
674
|
}
|
|
675
675
|
if (!props.shortcuts || e.target.closest?.('input, textarea, select, [contenteditable]') || e.metaKey || e.ctrlKey || e.altKey || O.stack.length) return;
|
|
@@ -703,11 +703,11 @@ export const AppShell = defineComponent({
|
|
|
703
703
|
...(props.shortcuts ? [{ icon: 'help', label: w.shortcuts, kbd: '?', run: showShortcuts }] : []),
|
|
704
704
|
...(props.intro ? [{ icon: 'refresh', label: w.replay, run: () => playIntro() }] : [])] } : null;
|
|
705
705
|
const bag = { nav: props.nav, end: props.end, path: props.path, base: props.base, home: props.home, onNavigate: props.onNavigate, link: props.link, words: props.words };
|
|
706
|
-
return h('div', { class: 't-app', ref: root }, [
|
|
706
|
+
return h('div', { class: 'gk-t-app', ref: root }, [
|
|
707
707
|
h(Sidebar, { ...bag, ref: sideRef, brand: props.brand, user: me, storageKey: props.storageKey, railBreakpoint: props.railBreakpoint, mobile: props.mobile }),
|
|
708
|
-
h('div', { class: 't-main' }, [
|
|
708
|
+
h('div', { class: 'gk-t-main' }, [
|
|
709
709
|
h(Topbar, { ...bag, crumbsRoot: props.crumbsRoot, search: top.search, theme: top.theme, bell: top.bell, primary: top.primary, onSearch: palette, storageKey: props.storageKey }, slots.extra ? { default: () => slots.extra() } : undefined),
|
|
710
|
-
h('main', { class: 'view', tabindex: -1, ref: view }, slots.default?.()),
|
|
710
|
+
h('main', { class: 'gk-view', tabindex: -1, ref: view }, slots.default?.()),
|
|
711
711
|
]),
|
|
712
712
|
h(MobileTabbar, { ...bag, tabbar: props.tabbar }),
|
|
713
713
|
]);
|
package/src/text.js
CHANGED
|
@@ -141,10 +141,10 @@ export const Typewriter = owned('Typewriter', {
|
|
|
141
141
|
props: { ...anyProps('phrases', 'speed', 'jitter', 'eraseSpeed', 'erase', 'hold', 'gap', 'delay', 'caret', 'locale', 'label'), loop: B, whenVisible: B, paused: B, onPhrase: Function },
|
|
142
142
|
handle: true,
|
|
143
143
|
fromSlot: (o, nodes) => { if (!o.phrases) { const t = textOf(nodes); o.phrases = t ? [t] : []; } },
|
|
144
|
-
cls: (o) => ['tw', 'tw--' + caretOf(o.caret)],
|
|
144
|
+
cls: (o) => ['gk-tw', 'gk-tw--' + caretOf(o.caret)],
|
|
145
145
|
kids: (o) => [
|
|
146
|
-
h('span', { class: 'tw__sr', 'data-allow-mismatch': 'text' }, o.label ?? listText(o.phrases, o.locale)),
|
|
147
|
-
h('span', { class: 'tw__vis', 'aria-hidden': 'true' }, [h('span', { class: 'tw__text' }), h('i', { class: 'tw__caret' })]),
|
|
146
|
+
h('span', { class: 'gk-tw__sr', 'data-allow-mismatch': 'text' }, o.label ?? listText(o.phrases, o.locale)),
|
|
147
|
+
h('span', { class: 'gk-tw__vis', 'aria-hidden': 'true' }, [h('span', { class: 'gk-tw__text' }), h('i', { class: 'gk-tw__caret' })]),
|
|
148
148
|
],
|
|
149
149
|
run: (el, { paused, ...o }) => { const t = M.typewriter(el, o); if (paused) t?.pause(); return t; },
|
|
150
150
|
update(t, next, prev) {
|
|
@@ -167,12 +167,12 @@ export const Rotator = owned('Rotator', {
|
|
|
167
167
|
props: { ...anyProps('words', 'every', 'effect', 'duration', 'ease', 'stagger', 'locale', 'label', 'index'), auto: B, whenVisible: B, paused: B, pill: B, onChange: Function },
|
|
168
168
|
defaults: { words: [] },
|
|
169
169
|
handle: true,
|
|
170
|
-
cls: (o) => ['rot', o.pill && 'rot--pill'],
|
|
170
|
+
cls: (o) => ['gk-rot', o.pill && 'gk-rot--pill'],
|
|
171
171
|
kids: (o) => {
|
|
172
172
|
const w = o.words[o.index ?? 0] ?? o.words[0] ?? '';
|
|
173
173
|
return [
|
|
174
|
-
h('span', { class: 'rot__sr', 'data-allow-mismatch': 'text' }, o.label ?? listText(o.words, o.locale)),
|
|
175
|
-
h('span', { class: 'rot__box', 'aria-hidden': 'true' }, [h('span', { class: 'rot__sizer' }, w), h('span', { class: 'rot__w' }, w)]),
|
|
174
|
+
h('span', { class: 'gk-rot__sr', 'data-allow-mismatch': 'text' }, o.label ?? listText(o.words, o.locale)),
|
|
175
|
+
h('span', { class: 'gk-rot__box', 'aria-hidden': 'true' }, [h('span', { class: 'gk-rot__sizer' }, w), h('span', { class: 'gk-rot__w' }, w)]),
|
|
176
176
|
];
|
|
177
177
|
},
|
|
178
178
|
run: (el, { index, paused, pill, ...o }) => {
|
|
@@ -205,7 +205,7 @@ export const Shine = defineComponent({
|
|
|
205
205
|
setup(props, { slots }) {
|
|
206
206
|
return () => {
|
|
207
207
|
const look = SHINE_LOOKS.includes(props.look) ? props.look : 'gradient';
|
|
208
|
-
return h(ShineMotion, { ...props, class: ['shine', 'shine--' + look] }, { default: () => slots.default?.() });
|
|
208
|
+
return h(ShineMotion, { ...props, class: ['gk-shine', 'gk-shine--' + look] }, { default: () => slots.default?.() });
|
|
209
209
|
};
|
|
210
210
|
},
|
|
211
211
|
});
|
|
@@ -318,7 +318,7 @@ export const BlurIn = defineComponent({
|
|
|
318
318
|
|
|
319
319
|
/**
|
|
320
320
|
* <ScrollProgress /> or <ScrollProgress :root="panel" @change="(p) => (read = p)" />
|
|
321
|
-
* Same as scrollProgress(bar, { root, onChange }): a thin line on .scroll-progress that fills as the page (or the
|
|
321
|
+
* Same as scrollProgress(bar, { root, onChange }): a thin line on .gk-scroll-progress that fills as the page (or the
|
|
322
322
|
* scrolling box root: element, template ref or selector) is read. @change(progress 0…1).
|
|
323
323
|
*/
|
|
324
324
|
export const ScrollProgress = defineComponent({
|
|
@@ -330,7 +330,7 @@ export const ScrollProgress = defineComponent({
|
|
|
330
330
|
const go = () => { p?.destroy(); p = M.scrollProgress(el.value, { root: deref(props.root), onChange: (v) => props.onChange?.(v) }); };
|
|
331
331
|
onMounted(() => { go(); watch(() => deref(props.root), go, { flush: 'post' }); });
|
|
332
332
|
onBeforeUnmount(() => { p?.destroy(); p = null; });
|
|
333
|
-
return () => h('div', { ref: el, 'aria-hidden': 'true', class: 'scroll-progress' });
|
|
333
|
+
return () => h('div', { ref: el, 'aria-hidden': 'true', class: 'gk-scroll-progress' });
|
|
334
334
|
},
|
|
335
335
|
});
|
|
336
336
|
|
|
@@ -350,7 +350,7 @@ const ODO_PROPS = anyProps('value', 'format', 'locale', 'duration', 'stagger', '
|
|
|
350
350
|
export const Odometer = owned('Odometer', {
|
|
351
351
|
props: ODO_PROPS,
|
|
352
352
|
defaults: { value: 0 },
|
|
353
|
-
cls: () => 'odo',
|
|
353
|
+
cls: () => 'gk-odo',
|
|
354
354
|
// without a locale the number is written in the reader's language, which the server may not share
|
|
355
355
|
rootAttrs: (o) => (o.locale == null ? { 'data-allow-mismatch': 'text' } : null),
|
|
356
356
|
kids: (o) => odoText(o.from ?? o.value, o),
|