@gecko-ui-kit/react 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 +70 -34
- 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 +53 -53
- package/src/controls.d.ts +4 -4
- package/src/controls.js +30 -30
- 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 +33 -33
- package/src/forms.js +10 -10
- package/src/motion.d.ts +3 -3
- package/src/motion.js +10 -10
- package/src/overlays.d.ts +6 -2
- package/src/overlays.js +21 -18
- package/src/shell.js +76 -76
- package/src/text.js +10 -10
package/src/effects.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { IconLike } from './core.js';
|
|
|
3
3
|
import type { ButtonProps } from './basics.js';
|
|
4
4
|
|
|
5
5
|
type ButtonAttrs = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>;
|
|
6
|
-
/** The look of a .btn (same as <Button>): variant, size, icon, block. */
|
|
6
|
+
/** The look of a .gk-btn (same as <Button>): variant, size, icon, block. */
|
|
7
7
|
interface BtnLook {
|
|
8
8
|
/** primary · dark · danger · ghost … (btn--variant). */
|
|
9
9
|
variant?: string;
|
|
@@ -16,7 +16,7 @@ interface BtnLook {
|
|
|
16
16
|
/* ------------------------------------------------------------------ indicator */
|
|
17
17
|
|
|
18
18
|
export interface IndicatorOptions {
|
|
19
|
-
/** Which element in the pill's parent is the active one. Default: [aria-current], [aria-selected="true"], [aria-pressed="true"], .is-active. */
|
|
19
|
+
/** Which element in the pill's parent is the active one. Default: [aria-current], [aria-selected="true"], [aria-pressed="true"], .gk-is-active. */
|
|
20
20
|
selector?: string;
|
|
21
21
|
/** Corner radius of the pill in px (13; 99 = round ends). */
|
|
22
22
|
radius?: number;
|
|
@@ -63,9 +63,9 @@ export interface PageSwapProps extends Omit<React.HTMLAttributes<HTMLElement>, '
|
|
|
63
63
|
swapKey: React.Key;
|
|
64
64
|
/** 1 = forward (new page from the right), -1 = back (from the left). */
|
|
65
65
|
dir?: 1 | -1 | number;
|
|
66
|
-
/** Blocks that fade and drop on the way out (.card, .kpi, .lane, [data-swap]). */
|
|
66
|
+
/** Blocks that fade and drop on the way out (.gk-card, .gk-kpi, .lane, [data-swap]). */
|
|
67
67
|
leave?: string;
|
|
68
|
-
/** Header parts that lift away (.phead, .tabs, .toolbar, .chips). */
|
|
68
|
+
/** Header parts that lift away (.gk-phead, .gk-tabs, .gk-toolbar, .gk-chips). */
|
|
69
69
|
head?: string;
|
|
70
70
|
/** Timing for this swap only (default: the shared swapTiming). */
|
|
71
71
|
timing?: SwapTiming;
|
|
@@ -401,7 +401,7 @@ export interface BurgerProps extends Omit<ButtonAttrs, 'onToggle'> {
|
|
|
401
401
|
escape?: boolean;
|
|
402
402
|
/** sm (iconbtn--sm). */
|
|
403
403
|
size?: string;
|
|
404
|
-
/** Class of the three lines (size them with --burger-w, --burger-h, --burger-t). */
|
|
404
|
+
/** Class of the three lines (size them with --gk-burger-w, --gk-burger-h, --gk-burger-t). */
|
|
405
405
|
iconClassName?: string;
|
|
406
406
|
}
|
|
407
407
|
/** <Burger open={open} onToggle={setOpen} controls="menu" /> — three lines that turn into an ✕. */
|
package/src/effects.js
CHANGED
|
@@ -31,19 +31,19 @@ const svgOf = (html, className) => {
|
|
|
31
31
|
const inner = html.slice(html.indexOf('>') + 1, html.lastIndexOf('</svg>'));
|
|
32
32
|
return () => h('svg', { className, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true, dangerouslySetInnerHTML: { __html: inner } });
|
|
33
33
|
};
|
|
34
|
-
const BinSvg = svgOf(M.binIcon, 'bin');
|
|
35
|
-
const DownloadSvg = svgOf(M.downloadIcon, 'dl');
|
|
34
|
+
const BinSvg = svgOf(M.binIcon, 'gk-bin');
|
|
35
|
+
const DownloadSvg = svgOf(M.downloadIcon, 'gk-dl');
|
|
36
36
|
const btnSig = (p) => [p.variant, p.size, p.block, p.className, p.type, textOf(p.children), typeof p.icon === 'string' ? p.icon : ''].join('|');
|
|
37
37
|
|
|
38
38
|
/* ------------------------------------------------------------------ indicator */
|
|
39
39
|
|
|
40
|
-
const ACTIVE = '[aria-current]:not([aria-current="false"]), [aria-selected="true"], [aria-pressed="true"], .is-active';
|
|
40
|
+
const ACTIVE = '[aria-current]:not([aria-current="false"]), [aria-selected="true"], [aria-pressed="true"], .gk-is-active';
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* const pill = useIndicator(current, { radius: 99, line: false, lead, trail, cross, selector })
|
|
44
|
-
* <nav className="menu"><span ref={pill} className="menu__pill" />{items with aria-current}</nav>
|
|
44
|
+
* <nav className="gk-menu"><span ref={pill} className="gk-menu__pill" />{items with aria-current}</nav>
|
|
45
45
|
* Same as indicator(pill, active) + trackIndicator(): when `current` changes, the pill stretches to the
|
|
46
|
-
* element in its parent that matches `selector` (default: aria-current / aria-selected / aria-pressed / .is-active).
|
|
46
|
+
* element in its parent that matches `selector` (default: aria-current / aria-selected / aria-pressed / .gk-is-active).
|
|
47
47
|
*/
|
|
48
48
|
export function useIndicator(active, { selector = ACTIVE, radius, line, lead, trail, cross } = {}) {
|
|
49
49
|
const pill = useRef(null), first = useRef(true);
|
|
@@ -65,16 +65,16 @@ export function useIndicator(active, { selector = ACTIVE, radius, line, lead, tr
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* <Indicator as="nav" active={page} className="menu" pillClassName="menu__pill" radius={99}>…buttons with aria-current…</Indicator>
|
|
68
|
+
* <Indicator as="nav" active={page} className="gk-menu" pillClassName="menu__pill" radius={99}>…buttons with aria-current…</Indicator>
|
|
69
69
|
* A box with a stretchy pill (or underline with line) that follows the active child.
|
|
70
70
|
*/
|
|
71
71
|
export const Indicator = forwardRef(function Indicator({ as = 'div', active, selector, radius = 13, line = false, lead, trail, cross, pillClassName, pillStyle, style, children, ...rest }, ref) {
|
|
72
72
|
const pill = useIndicator(active, { selector, radius, line, lead, trail, cross });
|
|
73
73
|
const base = { position: 'absolute', inset: 0, pointerEvents: 'none', opacity: 0 };
|
|
74
|
-
if (!pillClassName) base.background = 'var(--accent)';
|
|
74
|
+
if (!pillClassName) base.background = 'var(--gk-accent)';
|
|
75
75
|
// isolation + z-index -1: the pill sits on the box's background but under the items, with no CSS needed
|
|
76
76
|
return h(as, { ref, ...rest, style: { position: 'relative', isolation: 'isolate', ...style } },
|
|
77
|
-
h('span', { ref: pill, className: cx('indicator__pill', pillClassName), 'aria-hidden': true, style: { ...base, zIndex: -1, ...pillStyle } }),
|
|
77
|
+
h('span', { ref: pill, className: cx('gk-indicator__pill', pillClassName), 'aria-hidden': true, style: { ...base, zIndex: -1, ...pillStyle } }),
|
|
78
78
|
children);
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -130,7 +130,7 @@ export function useFeedback() {
|
|
|
130
130
|
tick: (up, x) => { const el = elOf(x, ref.current); if (el) M.tick(el, !!up); },
|
|
131
131
|
};
|
|
132
132
|
}, []);
|
|
133
|
-
useEffect(() => () => { for (const el of used.current) { M.g.killTweensOf([el, el.querySelector?.('svg')].filter(Boolean)); el.classList?.remove('is-flash'); } used.current.clear(); }, []);
|
|
133
|
+
useEffect(() => () => { for (const el of used.current) { M.g.killTweensOf([el, el.querySelector?.('svg')].filter(Boolean)); el.classList?.remove('gk-is-flash'); } used.current.clear(); }, []);
|
|
134
134
|
return api;
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -308,9 +308,9 @@ export function useTheme({ storageKey = 'gecko:theme', duration, easing } = {})
|
|
|
308
308
|
if (!root.dataset.theme && o.current.storageKey) M.restoreTheme(o.current.storageKey);
|
|
309
309
|
setT(readTheme());
|
|
310
310
|
const sync = () => setT(readTheme());
|
|
311
|
-
addEventListener('themechange', sync);
|
|
311
|
+
addEventListener('gk:themechange', sync);
|
|
312
312
|
const mo = new MutationObserver(sync); mo.observe(root, { attributes: true, attributeFilter: ['data-theme'] });
|
|
313
|
-
return () => { removeEventListener('themechange', sync); mo.disconnect(); };
|
|
313
|
+
return () => { removeEventListener('gk:themechange', sync); mo.disconnect(); };
|
|
314
314
|
}, []);
|
|
315
315
|
const set = useMemo(() => (next, from) => {
|
|
316
316
|
const cur = readTheme();
|
|
@@ -328,13 +328,13 @@ export const ThemeToggle = forwardRef(function ThemeToggle({ storageKey, duratio
|
|
|
328
328
|
const [t, setTheme] = useTheme(defined({ storageKey, duration, easing }));
|
|
329
329
|
const dark = t === 'dark';
|
|
330
330
|
return h('button', {
|
|
331
|
-
ref, type: 'button', 'aria-label': label, ...rest, className: cx('iconbtn', size && 'iconbtn--' + size, className),
|
|
331
|
+
ref, type: 'button', 'aria-label': label, ...rest, className: cx('gk-iconbtn', size && 'gk-iconbtn--' + size, className),
|
|
332
332
|
onClick: (e) => {
|
|
333
333
|
onClick?.(e); if (e.defaultPrevented) return;
|
|
334
334
|
const next = dark ? 'light' : 'dark', b = e.currentTarget;
|
|
335
335
|
M.pop(b); setTheme(next, b); onChange?.(next);
|
|
336
336
|
},
|
|
337
|
-
}, h(Icon, { name: dark ? 'sun' : 'moon', className: dark ? 'i-sun' : 'i-moon' }));
|
|
337
|
+
}, h(Icon, { name: dark ? 'sun' : 'moon', className: dark ? 'gk-i-sun' : 'gk-i-moon' }));
|
|
338
338
|
});
|
|
339
339
|
|
|
340
340
|
/* ------------------------------------------------------------------ send / delete */
|
|
@@ -444,7 +444,7 @@ function HoldInner({ fref, confirmed, duration, look = 'fill', tone = 'bad', hin
|
|
|
444
444
|
}, [confirmed]);
|
|
445
445
|
const setRef = (n) => { el.current = n; assignRef(fref, n); };
|
|
446
446
|
if (look === 'ring') {
|
|
447
|
-
return h('button', { ref: setRef, type: 'button', 'aria-label': textOf(children), ...rest, className: cx('iconbtn', size && 'iconbtn--' + size, className) }, iconNode(icon));
|
|
447
|
+
return h('button', { ref: setRef, type: 'button', 'aria-label': textOf(children), ...rest, className: cx('gk-iconbtn', size && 'gk-iconbtn--' + size, className) }, iconNode(icon));
|
|
448
448
|
}
|
|
449
449
|
return h(Button, { ref: setRef, variant, size, block, className, icon, ...rest }, textOf(children));
|
|
450
450
|
}
|
|
@@ -457,8 +457,8 @@ export const HoldButton = keyed('HoldButton', HoldInner, (p) => [btnSig(p), p.lo
|
|
|
457
457
|
|
|
458
458
|
/* ------------------------------------------------------------------ expanding search */
|
|
459
459
|
|
|
460
|
-
const GLASS_IN = '<g class="xs__glass"><circle cx="10.5" cy="10.5" r="6"/><path d="M15 15l4.5 4.5"/></g>';
|
|
461
|
-
const CROSS_IN = '<path class="xs__x" d="M7 7l10 10" pathLength="1" stroke-dasharray="1" stroke-dashoffset="1"/><path class="xs__x" d="M17 7 7 17" pathLength="1" stroke-dasharray="1" stroke-dashoffset="1"/>';
|
|
460
|
+
const GLASS_IN = '<g class="gk-xs__glass"><circle cx="10.5" cy="10.5" r="6"/><path d="M15 15l4.5 4.5"/></g>';
|
|
461
|
+
const CROSS_IN = '<path class="gk-xs__x" d="M7 7l10 10" pathLength="1" stroke-dasharray="1" stroke-dashoffset="1"/><path class="gk-xs__x" d="M17 7 7 17" pathLength="1" stroke-dasharray="1" stroke-dashoffset="1"/>';
|
|
462
462
|
const svg2 = (className, html) => h('svg', { className, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', 'aria-hidden': true, dangerouslySetInnerHTML: { __html: html } });
|
|
463
463
|
|
|
464
464
|
function SearchInner({ fref, placeholder = 'Search…', label = 'Search', closeLabel = 'Close search', name = 'q', look = 'outline', size = 'md', width, typing, autoClose, shortcut,
|
|
@@ -479,10 +479,10 @@ function SearchInner({ fref, placeholder = 'Search…', label = 'Search', closeL
|
|
|
479
479
|
const a = api.current; api.current = null; if (!a) return;
|
|
480
480
|
killAll(a.el); a.destroy();
|
|
481
481
|
// leave the markup closed, as React drew it (StrictMode mounts it again on the same element)
|
|
482
|
-
a.el.classList.remove('is-open', 'is-closing'); M.g.set([a.el, a.input], { clearProps: 'width,transform,opacity' });
|
|
483
|
-
a.el.querySelector('.xs__btn')?.setAttribute('aria-expanded', 'false');
|
|
484
|
-
a.input.tabIndex = -1; a.input.placeholder = ''; const c = a.el.querySelector('.xs__close'); if (c) c.tabIndex = -1;
|
|
485
|
-
a.el.querySelectorAll('.xs__x').forEach((x) => x.setAttribute('stroke-dashoffset', '1'));
|
|
482
|
+
a.el.classList.remove('gk-is-open', 'gk-is-closing'); M.g.set([a.el, a.input], { clearProps: 'width,transform,opacity' });
|
|
483
|
+
a.el.querySelector('.gk-xs__btn')?.setAttribute('aria-expanded', 'false');
|
|
484
|
+
a.input.tabIndex = -1; a.input.placeholder = ''; const c = a.el.querySelector('.gk-xs__close'); if (c) c.tabIndex = -1;
|
|
485
|
+
a.el.querySelectorAll('.gk-xs__x').forEach((x) => x.setAttribute('stroke-dashoffset', '1'));
|
|
486
486
|
};
|
|
487
487
|
}, []);
|
|
488
488
|
useIsoLayoutEffect(() => { if (api.current) Object.assign(api.current.opts, { key: '', ...opts }); }, [width, typing, autoClose, placeholder, shortcut]);
|
|
@@ -495,11 +495,11 @@ function SearchInner({ fref, placeholder = 'Search…', label = 'Search', closeL
|
|
|
495
495
|
}, [open]);
|
|
496
496
|
return h('form', {
|
|
497
497
|
ref: (n) => { box.current = n; assignRef(fref, n); }, role: 'search', 'data-placeholder': placeholder, ...rest,
|
|
498
|
-
className: cx('xs', look === 'quiet' && 'xs--quiet', size === 'sm' && 'xs--sm', className),
|
|
498
|
+
className: cx('gk-xs', look === 'quiet' && 'gk-xs--quiet', size === 'sm' && 'gk-xs--sm', className),
|
|
499
499
|
},
|
|
500
|
-
h('button', { type: 'button', className: 'xs__btn', 'aria-label': label, 'aria-expanded': 'false', 'aria-controls': id }, svg2('xs__ic', GLASS_IN)),
|
|
501
|
-
h('input', { className: 'xs__input', id, type: 'search', name, 'aria-label': label, autoComplete: 'off', spellCheck: false, enterKeyHint: 'search', tabIndex: -1, defaultValue: value ?? defaultValue }),
|
|
502
|
-
h('button', { type: 'button', className: 'xs__close', 'aria-label': closeLabel, tabIndex: -1 }, svg2(undefined, CROSS_IN)));
|
|
500
|
+
h('button', { type: 'button', className: 'gk-xs__btn', 'aria-label': label, 'aria-expanded': 'false', 'aria-controls': id }, svg2('gk-xs__ic', GLASS_IN)),
|
|
501
|
+
h('input', { className: 'gk-xs__input', id, type: 'search', name, 'aria-label': label, autoComplete: 'off', spellCheck: false, enterKeyHint: 'search', tabIndex: -1, defaultValue: value ?? defaultValue }),
|
|
502
|
+
h('button', { type: 'button', className: 'gk-xs__close', 'aria-label': closeLabel, tabIndex: -1 }, svg2(undefined, CROSS_IN)));
|
|
503
503
|
}
|
|
504
504
|
/**
|
|
505
505
|
* <ExpandSearch placeholder="Search bikes…" width={280} shortcut="/" onChange={setQuery} onSearch={go} />
|
|
@@ -525,17 +525,17 @@ function LiquidInner({ fref, items = [], value, defaultValue = 0, onChange, mode
|
|
|
525
525
|
useIsoLayoutEffect(() => { const a = api.current; if (a && typeof v === 'number' && a.index !== v) a.select(v); }, [v]);
|
|
526
526
|
return h('nav', {
|
|
527
527
|
ref: (n) => { nav.current = n; assignRef(fref, n); }, 'aria-label': label, ...rest,
|
|
528
|
-
className: cx('lq', !labels && 'lq--icons', !goo && 'lq--plain', className), style: { '--lq-goo': `url(#${fid})`, ...style },
|
|
528
|
+
className: cx('gk-lq', !labels && 'gk-lq--icons', !goo && 'gk-lq--plain', className), style: { '--gk-lq-goo': `url(#${fid})`, ...style },
|
|
529
529
|
},
|
|
530
|
-
h('svg', { className: 'lq__defs', width: 0, height: 0, 'aria-hidden': true, focusable: 'false' },
|
|
530
|
+
h('svg', { className: 'gk-lq__defs', width: 0, height: 0, 'aria-hidden': true, focusable: 'false' },
|
|
531
531
|
h('filter', { id: fid, x: '-10%', y: '-90%', width: '120%', height: '280%', colorInterpolationFilters: 'sRGB' },
|
|
532
532
|
h('feGaussianBlur', { in: 'SourceGraphic', stdDeviation: 7 }),
|
|
533
533
|
h('feColorMatrix', { values: '1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 24 -11' }))),
|
|
534
|
-
h('span', { className: 'lq__goo', 'aria-hidden': true }, h('span', { className: 'lq__body' }), h('span', { className: 'lq__drop' }), h('span', { className: 'lq__drop' }), h('span', { className: 'lq__bub' })),
|
|
535
|
-
h('span', { className: 'lq__dot', 'aria-hidden': true }),
|
|
534
|
+
h('span', { className: 'gk-lq__goo', 'aria-hidden': true }, h('span', { className: 'gk-lq__body' }), h('span', { className: 'gk-lq__drop' }), h('span', { className: 'gk-lq__drop' }), h('span', { className: 'gk-lq__bub' })),
|
|
535
|
+
h('span', { className: 'gk-lq__dot', 'aria-hidden': true }),
|
|
536
536
|
items.map((it, i) => h(it.href ? (linkAs || 'a') : 'button', {
|
|
537
|
-
key: i, className: cx('lq__tab', i === first && 'is-on'), ...(it.href ? { href: it.href } : { type: 'button' }), 'aria-current': i === first ? 'page' : undefined,
|
|
538
|
-
}, h('span', { className: 'lq__ic', 'aria-hidden': true }, iconNode(it.icon)), h('span', { className: 'lq__lb' }, it.label))));
|
|
537
|
+
key: i, className: cx('gk-lq__tab', i === first && 'gk-is-on'), ...(it.href ? { href: it.href } : { type: 'button' }), 'aria-current': i === first ? 'page' : undefined,
|
|
538
|
+
}, h('span', { className: 'gk-lq__ic', 'aria-hidden': true }, iconNode(it.icon)), h('span', { className: 'gk-lq__lb' }, it.label))));
|
|
539
539
|
}
|
|
540
540
|
/**
|
|
541
541
|
* <LiquidTabs items={[{ label: 'Home', icon: 'home' }, { label: 'Bikes', icon: 'box' }]} value={tab} onChange={setTab} mode="dip" />
|
|
@@ -560,7 +560,7 @@ export const Burger = forwardRef(function Burger({ open, defaultOpen = false, on
|
|
|
560
560
|
M.burger(el.current, !!on, { duration: first.current ? 0 : duration });
|
|
561
561
|
first.current = false;
|
|
562
562
|
}, [on]);
|
|
563
|
-
useEffect(() => () => { const b = el.current; if (!b) return; b.__burger?.tl?.kill(); M.g.set(b.querySelectorAll('.burger > i'), { clearProps: 'all' }); delete b.__burger; }, []);
|
|
563
|
+
useEffect(() => () => { const b = el.current; if (!b) return; b.__burger?.tl?.kill(); M.g.set(b.querySelectorAll('.gk-burger > i'), { clearProps: 'all' }); delete b.__burger; }, []);
|
|
564
564
|
const latest = useLatest({ on, set, escape });
|
|
565
565
|
useEffect(() => {
|
|
566
566
|
if (!escape) return;
|
|
@@ -574,7 +574,7 @@ export const Burger = forwardRef(function Burger({ open, defaultOpen = false, on
|
|
|
574
574
|
}, [escape]);
|
|
575
575
|
return h('button', {
|
|
576
576
|
ref: (n) => { el.current = n; assignRef(ref, n); }, type: 'button', 'aria-expanded': !!on, 'aria-label': on ? w.close : w.open, 'aria-controls': controls || undefined, ...rest,
|
|
577
|
-
className: cx('iconbtn', size && 'iconbtn--' + size, on && 'is-open', className),
|
|
577
|
+
className: cx('gk-iconbtn', size && 'gk-iconbtn--' + size, on && 'gk-is-open', className),
|
|
578
578
|
onClick: (e) => { onClick?.(e); if (!e.defaultPrevented) set(!on, e.currentTarget); },
|
|
579
|
-
}, h('span', { className: cx('burger', iconClassName), 'aria-hidden': true }, h('i'), h('i'), h('i')));
|
|
579
|
+
}, h('span', { className: cx('gk-burger', iconClassName), 'aria-hidden': true }, h('i'), h('i'), h('i')));
|
|
580
580
|
});
|
package/src/forms.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
Most are mounted pieces: the vanilla code builds them inside one element; these components pass props in
|
|
5
5
|
as options, keep `value` in step through the piece's own set(), and clean up on unmount.
|
|
6
6
|
PasswordToggle is drawn by React; Wizard draws your React step content into its panels through portals;
|
|
7
|
-
useValidation is a small hook for the red-field pattern (.field.is-bad + hint + shake). */
|
|
7
|
+
useValidation is a small hook for the red-field pattern (.gk-field.gk-is-bad + hint + shake). */
|
|
8
8
|
import { forwardRef, useId, useRef, useState, useCallback, useImperativeHandle, Fragment } from 'react';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
10
|
import * as C from '@gecko-ui-kit/components';
|
|
@@ -215,7 +215,7 @@ export const AuthForm = mounted('AuthForm', withDefault(C.authForm, 'mode', 'def
|
|
|
215
215
|
/** The eye with the slash (the same drawing as passwordToggle()). */
|
|
216
216
|
const EYE = h('svg', { viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true },
|
|
217
217
|
h('path', { d: 'M2.5 12C4.7 8.1 8 6.2 12 6.2s7.3 1.9 9.5 5.8c-2.2 3.9-5.5 5.8-9.5 5.8S4.7 15.9 2.5 12z' }), h('circle', { cx: 12, cy: 12, r: 2.9 }),
|
|
218
|
-
h('path', { className: 'pwm__cut', pathLength: 1, d: 'M4.6 4.2l15.2 15.6' }), h('path', { className: 'pwm__slash', pathLength: 1, d: 'M4.6 4.2l15.2 15.6' }));
|
|
218
|
+
h('path', { className: 'gk-pwm__cut', pathLength: 1, d: 'M4.6 4.2l15.2 15.6' }), h('path', { className: 'gk-pwm__slash', pathLength: 1, d: 'M4.6 4.2l15.2 15.6' }));
|
|
219
219
|
const EYE_WORDS = { show: 'Show password', hide: 'Hide password' };
|
|
220
220
|
|
|
221
221
|
/**
|
|
@@ -229,17 +229,17 @@ export const PasswordToggle = forwardRef(function PasswordToggle({ shown, defaul
|
|
|
229
229
|
const W = { ...EYE_WORDS, ...words };
|
|
230
230
|
const btn = useRef(null), first = useRef(true);
|
|
231
231
|
useIsoLayoutEffect(() => {
|
|
232
|
-
const lines = btn.current.querySelectorAll('.pwm__cut, .pwm__slash');
|
|
232
|
+
const lines = btn.current.querySelectorAll('.gk-pwm__cut, .gk-pwm__slash');
|
|
233
233
|
M.g.killTweensOf(lines);
|
|
234
234
|
if (first.current || M.RM()) M.g.set(lines, { strokeDashoffset: on ? 0 : 1 });
|
|
235
235
|
else M.g.to(lines, { strokeDashoffset: on ? 0 : 1, duration: on ? 0.34 : 0.22, ease: on ? 'power2.out' : 'power2.in' });
|
|
236
236
|
first.current = false;
|
|
237
237
|
}, [on]);
|
|
238
238
|
useIsoLayoutEffect(() => () => M.g.killTweensOf(btn.current?.querySelectorAll('*') ?? []), []);
|
|
239
|
-
return h('span', { className: 'pwm__wrap' },
|
|
240
|
-
h('input', { ref, id: inputId, ...rest, type: on ? 'text' : 'password', className: cx('input', className) }),
|
|
239
|
+
return h('span', { className: 'gk-pwm__wrap' },
|
|
240
|
+
h('input', { ref, id: inputId, ...rest, type: on ? 'text' : 'password', className: cx('gk-input', className) }),
|
|
241
241
|
h('button', {
|
|
242
|
-
ref: btn, type: 'button', className: cx('pwm__eye', on && 'is-on'), 'aria-controls': inputId, 'aria-label': on ? W.hide : W.show,
|
|
242
|
+
ref: btn, type: 'button', className: cx('gk-pwm__eye', on && 'gk-is-on'), 'aria-controls': inputId, 'aria-label': on ? W.hide : W.show,
|
|
243
243
|
onMouseDown: (e) => e.preventDefault(), // a mouse click keeps the caret in the field
|
|
244
244
|
onClick: () => { M.pop(btn.current); setOn(!on); },
|
|
245
245
|
}, EYE));
|
|
@@ -277,7 +277,7 @@ export const PasswordMeter = forwardRef(function PasswordMeter(props, ref) {
|
|
|
277
277
|
useIsoLayoutEffect(() => { cur.current?.check(); }, [value]); // a value set from code (e.g. cleared)
|
|
278
278
|
return h('span', { style: { display: 'contents' }, 'data-gecko': 'PasswordMeter' },
|
|
279
279
|
h('input', {
|
|
280
|
-
ref: input, type: 'password', autoComplete: 'new-password', ...inputProps, className: cx('input', className),
|
|
280
|
+
ref: input, type: 'password', autoComplete: 'new-password', ...inputProps, className: cx('gk-input', className),
|
|
281
281
|
...(value !== undefined ? { value } : { defaultValue }),
|
|
282
282
|
onChange: (e) => onValueChange?.(e.target.value, e),
|
|
283
283
|
}),
|
|
@@ -335,7 +335,7 @@ export const FileDrop = mounted('FileDrop', C.fileDrop);
|
|
|
335
335
|
|
|
336
336
|
const WizardBase = mounted('Wizard', (el, o) => {
|
|
337
337
|
const wz = C.wizard(el, { ...o, start: o.index ?? o.start });
|
|
338
|
-
o.onPanels?.(wz ? [...wz.el.querySelectorAll('.wz__panel:not(.wz__fin) > .wz__body')] : []);
|
|
338
|
+
o.onPanels?.(wz ? [...wz.el.querySelectorAll('.gk-wz__panel:not(.gk-wz__fin) > .gk-wz__body')] : []);
|
|
339
339
|
return wz;
|
|
340
340
|
}, {
|
|
341
341
|
update: inPlace({
|
|
@@ -367,8 +367,8 @@ const okMsg = (m) => (m == null || m === true || m === false || m === '' ? '' :
|
|
|
367
367
|
/**
|
|
368
368
|
* const v = useValidation({ email: (value) => (/^\S+@\S+\.\S+$/.test(value) ? '' : 'That email looks incomplete.') })
|
|
369
369
|
* <label className={cx('field', v.errors.email && 'is-bad')}><span>Email</span>
|
|
370
|
-
* <input className="input" {...v.field('email')} />
|
|
371
|
-
* <small className="field__hint">{v.errors.email || 'We send one email a month.'}</small></label>
|
|
370
|
+
* <input className="gk-input" {...v.field('email')} />
|
|
371
|
+
* <small className="gk-field__hint">{v.errors.email || 'We send one email a month.'}</small></label>
|
|
372
372
|
* <Button onClick={() => v.validate() && send(v.values())}>Join</Button>
|
|
373
373
|
* A rule gets (value, values) and returns '' (fine) or the message. validate() marks every bad field, shakes it and
|
|
374
374
|
* returns true when all are fine; with live (default) a red field is checked again on every key.
|
package/src/motion.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export interface TiltOptions {
|
|
|
58
58
|
scale?: number;
|
|
59
59
|
/** px of 3D depth; smaller = stronger (900). */
|
|
60
60
|
perspective?: number;
|
|
61
|
-
/** A soft light that follows the pointer (true). Colour: --tilt-glare. */
|
|
61
|
+
/** A soft light that follows the pointer (true). Colour: --gk-tilt-glare. */
|
|
62
62
|
glare?: boolean;
|
|
63
63
|
/** How far data-depth layers drift, as a share of their depth (0.25). */
|
|
64
64
|
parallax?: number;
|
|
@@ -67,7 +67,7 @@ export interface TiltOptions {
|
|
|
67
67
|
/** Seconds it takes to settle back (1). */
|
|
68
68
|
spring?: number;
|
|
69
69
|
}
|
|
70
|
-
/** <Tilt max={12} glare className="card">…children with data-depth…</Tilt> */
|
|
70
|
+
/** <Tilt max={12} glare className="gk-card">…children with data-depth…</Tilt> */
|
|
71
71
|
export const Tilt: React.ForwardRefExoticComponent<EnhancerProps<TiltOptions> & React.RefAttributes<HTMLElement>>;
|
|
72
72
|
|
|
73
73
|
/* ---------------- Spotlight ---------------- */
|
|
@@ -102,7 +102,7 @@ export interface MarqueeProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
102
102
|
direction?: 'left' | 'right';
|
|
103
103
|
/** Hover or keyboard focus slows it to a stop (true). */
|
|
104
104
|
pauseOnHover?: boolean;
|
|
105
|
-
/** Space between items: px, or any CSS length (default --marquee-gap, 40px). */
|
|
105
|
+
/** Space between items: px, or any CSS length (default --gk-marquee-gap, 40px). */
|
|
106
106
|
gap?: number | string;
|
|
107
107
|
/** Soften the left and right edges (true). */
|
|
108
108
|
fade?: boolean;
|
package/src/motion.js
CHANGED
|
@@ -10,7 +10,7 @@ import { h, cx, same, changedOnly, useLatest, useIsoLayoutEffect, enhancer } fro
|
|
|
10
10
|
|
|
11
11
|
const KINDS = ['rise', 'slide', 'deal', 'reveal'];
|
|
12
12
|
/**
|
|
13
|
-
* <Rise className="grid">{bikes.map((b) => <BikeCard key={b.id} bike={b} />)}</Rise>
|
|
13
|
+
* <Rise className="gk-grid">{bikes.map((b) => <BikeCard key={b.id} bike={b} />)}</Rise>
|
|
14
14
|
* <Rise kind="slide" x={-24} stagger={0.04}>{rows}</Rise> <Rise kind="deal" tilt={4}>{cards}</Rise>
|
|
15
15
|
* Same as rise / slide / deal(els, options): the children arrive one after another when it mounts, and children
|
|
16
16
|
* added later arrive the same way (animateNew). kind="reveal" is the small fade-down of reveal(el, y) on the
|
|
@@ -63,7 +63,7 @@ const MagneticMotion = enhancer('Magnetic', (el, o) => M.magnetic(el, o), { tag:
|
|
|
63
63
|
*/
|
|
64
64
|
export const Magnetic = forwardRef(function Magnetic({ magnet, className, style, ...props }, ref) {
|
|
65
65
|
return h(MagneticMotion, {
|
|
66
|
-
...props, ref, 'data-magnet': magnet, className: cx('magnetic', className),
|
|
66
|
+
...props, ref, 'data-magnet': magnet, className: cx('gk-magnetic', className),
|
|
67
67
|
style: props.as ? style : { display: 'inline-block', ...style },
|
|
68
68
|
});
|
|
69
69
|
});
|
|
@@ -71,7 +71,7 @@ Magnetic.displayName = 'Magnetic';
|
|
|
71
71
|
|
|
72
72
|
const LiftMotion = enhancer('Lift', (el, o) => M.lift(el, o.y), { options: ['y'] });
|
|
73
73
|
/**
|
|
74
|
-
* <Lift as="article" y={-6} className="card">…</Lift>
|
|
74
|
+
* <Lift as="article" y={-6} className="gk-card">…</Lift>
|
|
75
75
|
* Same as lift(el, y): the element rises a few pixels while the pointer is over it (mouse / trackpad only).
|
|
76
76
|
*/
|
|
77
77
|
export const Lift = forwardRef(function Lift(props, ref) {
|
|
@@ -85,11 +85,11 @@ const TiltMotion = enhancer('Tilt', (el, o) => M.tilt(el, o), {
|
|
|
85
85
|
options: ['max', 'scale', 'perspective', 'glare', 'parallax', 'follow', 'spring'], rerunOnChildren: true,
|
|
86
86
|
});
|
|
87
87
|
/**
|
|
88
|
-
* <Tilt max={12} glare className="card"><img data-depth="40" src="lamp.png" alt="" /><h3 data-depth="20">Lamp</h3></Tilt>
|
|
88
|
+
* <Tilt max={12} glare className="gk-card"><img data-depth="40" src="lamp.png" alt="" /><h3 data-depth="20">Lamp</h3></Tilt>
|
|
89
89
|
* Same as tilt(el, options). Children with data-depth float above the card. as="article" changes the element.
|
|
90
90
|
*/
|
|
91
91
|
export const Tilt = forwardRef(function Tilt({ className, ...props }, ref) {
|
|
92
|
-
return h(TiltMotion, { ...props, ref, className: cx('tilt', className) });
|
|
92
|
+
return h(TiltMotion, { ...props, ref, className: cx('gk-tilt', className) });
|
|
93
93
|
});
|
|
94
94
|
Tilt.displayName = 'Tilt';
|
|
95
95
|
|
|
@@ -99,14 +99,14 @@ const SpotlightMotion = enhancer('Spotlight', (el, o) => M.spotlight(el, o), {
|
|
|
99
99
|
options: ['items', 'size', 'follow', 'border', 'fill', 'focus'], rerunOnChildren: true,
|
|
100
100
|
});
|
|
101
101
|
/**
|
|
102
|
-
* <Spotlight className="plans" size={300}>{plans.map((p) => <div className="card" key={p.id}>…</div>)}</Spotlight>
|
|
102
|
+
* <Spotlight className="plans" size={300}>{plans.map((p) => <div className="gk-card" key={p.id}>…</div>)}</Spotlight>
|
|
103
103
|
* Same as spotlight(group, options): a soft light follows the pointer across the cards (its children, or `items`)
|
|
104
104
|
* and lights up their edges; a card with keyboard focus pulls the light onto itself.
|
|
105
105
|
*/
|
|
106
106
|
export const Spotlight = forwardRef(function Spotlight({ className, ...props }, ref) {
|
|
107
107
|
return h(SpotlightMotion, {
|
|
108
108
|
...props, ref,
|
|
109
|
-
className: cx('spotlight', props.border === false && 'spotlight--no-ring', props.fill === false && 'spotlight--no-fill', className),
|
|
109
|
+
className: cx('gk-spotlight', props.border === false && 'gk-spotlight--no-ring', props.fill === false && 'gk-spotlight--no-fill', className),
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
Spotlight.displayName = 'Spotlight';
|
|
@@ -137,7 +137,7 @@ export const Marquee = forwardRef(function Marquee({ as, listAs = 'ul', classNam
|
|
|
137
137
|
const latest = useLatest(o);
|
|
138
138
|
const el = useRef(null), cur = useRef(null), mine = useRef('');
|
|
139
139
|
const items = keyOf(children);
|
|
140
|
-
const own = cx('marquee', o.fade !== false && 'marquee--fade', className);
|
|
140
|
+
const own = cx('gk-marquee', o.fade !== false && 'gk-marquee--fade', className);
|
|
141
141
|
const node = el.current, ours = new Set(mine.current.split(/\s+/));
|
|
142
142
|
const kept = node ? [...node.classList].filter((c) => !ours.has(c)).join(' ') : '';
|
|
143
143
|
const proxy = useRef(null);
|
|
@@ -169,8 +169,8 @@ export const Marquee = forwardRef(function Marquee({ as, listAs = 'ul', classNam
|
|
|
169
169
|
}
|
|
170
170
|
if (c.items !== items) { c.items = items; c.m.refresh(); }
|
|
171
171
|
});
|
|
172
|
-
const gap = o.gap != null ? { '--marquee-gap': typeof o.gap === 'number' ? `${o.gap}px` : o.gap } : null;
|
|
172
|
+
const gap = o.gap != null ? { '--gk-marquee-gap': typeof o.gap === 'number' ? `${o.gap}px` : o.gap } : null;
|
|
173
173
|
const item = listAs === 'ul' || listAs === 'ol' ? 'li' : 'div';
|
|
174
174
|
return h(as || 'div', { ref: el, ...dom, className: cx(own, kept), style: gap ? { ...gap, ...style } : style },
|
|
175
|
-
h(listAs, { className: 'marquee__list' }, Children.map(children, (c) => (c == null || typeof c === 'boolean' ? null : h(item, null, c)))));
|
|
175
|
+
h(listAs, { className: 'gk-marquee__list' }, Children.map(children, (c) => (c == null || typeof c === 'boolean' ? null : h(item, null, c)))));
|
|
176
176
|
});
|
package/src/overlays.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import type * as React from 'react';
|
|
|
4
4
|
export type AnchorLike = HTMLElement | React.RefObject<HTMLElement | null> | null | undefined;
|
|
5
5
|
|
|
6
6
|
export interface ModalProps {
|
|
7
|
+
/** Labels: { close } is the ✕ button's accessible name (default 'Close'). */
|
|
8
|
+
words?: { close?: string };
|
|
7
9
|
/** Open (true) or closed (false). It opens and closes with its animation. */
|
|
8
10
|
open: boolean;
|
|
9
11
|
/** Called when the modal closes itself (✕, scrim, Esc): set open to false here. */
|
|
@@ -25,6 +27,8 @@ export interface ModalProps {
|
|
|
25
27
|
export function Modal(props: ModalProps): React.ReactElement | null;
|
|
26
28
|
|
|
27
29
|
export interface DrawerProps {
|
|
30
|
+
/** Labels: { close } is the ✕ button's accessible name (default 'Close'). */
|
|
31
|
+
words?: { close?: string };
|
|
28
32
|
/** Open (true) or closed (false). */
|
|
29
33
|
open: boolean;
|
|
30
34
|
/** Called when the drawer closes itself (✕, scrim, Esc, another drawer opening): set open to false here. */
|
|
@@ -69,7 +73,7 @@ export interface PopoverHandle {
|
|
|
69
73
|
close(): void;
|
|
70
74
|
/** True while it is open. */
|
|
71
75
|
readonly isOpen: boolean;
|
|
72
|
-
/** The open panel (.pop), or null. */
|
|
76
|
+
/** The open panel (.gk-pop), or null. */
|
|
73
77
|
readonly el: HTMLElement | null;
|
|
74
78
|
}
|
|
75
79
|
export interface PopoverProps {
|
|
@@ -275,7 +279,7 @@ export interface LoadingBarOptions {
|
|
|
275
279
|
mount?: AnchorLike | string;
|
|
276
280
|
/** Height in px (or any CSS length). Default 3. */
|
|
277
281
|
height?: number | string;
|
|
278
|
-
/** Any CSS colour. Default var(--accent). */
|
|
282
|
+
/** Any CSS colour. Default var(--gk-accent). */
|
|
279
283
|
color?: string;
|
|
280
284
|
/** Creep forward on its own: true, a speed (0.5 slower, 2 faster) or false. */
|
|
281
285
|
trickle?: boolean | number;
|
package/src/overlays.js
CHANGED
|
@@ -46,8 +46,9 @@ const isText = (x) => typeof x === 'string' || typeof x === 'number';
|
|
|
46
46
|
* Opens when `open` turns true (zooms out of `anchor` if given; bottom sheet on phones) and closes, animated,
|
|
47
47
|
* when it turns false. Closing from inside (✕, scrim, Esc) calls onClose: set open to false there.
|
|
48
48
|
* title, sub and footer may change while it is open; title and sub may be text or React nodes.
|
|
49
|
+
* words: { close } — the ✕ button's label (default 'Close'), e.g. words={{ close: 'ปิด' }}.
|
|
49
50
|
*/
|
|
50
|
-
export function Modal({ open, onClose, title = '', sub = '', size = '', anchor, footer, children }) {
|
|
51
|
+
export function Modal({ open, onClose, title = '', sub = '', size = '', anchor, footer, words, children }) {
|
|
51
52
|
const client = useClient();
|
|
52
53
|
const box = useRef(null);
|
|
53
54
|
if (client && !box.current) box.current = { title: holder('span'), sub: holder('span'), body: holder(), foot: holder() };
|
|
@@ -61,12 +62,12 @@ export function Modal({ open, onClose, title = '', sub = '', size = '', anchor,
|
|
|
61
62
|
O.bindEscape();
|
|
62
63
|
alive.current = true;
|
|
63
64
|
const l = O.modal({
|
|
64
|
-
title: '', size, anchor: deref(anchor), body: '', foot: ' ',
|
|
65
|
+
title: '', size, anchor: deref(anchor), body: '', foot: ' ', words: words ?? {},
|
|
65
66
|
onMount: (el) => {
|
|
66
|
-
const h3 = el.querySelector('.modal__head h3'); h3.id = titleId; h3.append(b.title);
|
|
67
|
+
const h3 = el.querySelector('.gk-modal__head h3'); h3.id = titleId; h3.append(b.title);
|
|
67
68
|
const p = document.createElement('p'); p.append(b.sub); h3.after(p);
|
|
68
|
-
el.querySelector('.modal__body').append(b.body);
|
|
69
|
-
const foot = el.querySelector('.modal__foot'); foot.textContent = ''; foot.append(b.foot);
|
|
69
|
+
el.querySelector('.gk-modal__body').append(b.body);
|
|
70
|
+
const foot = el.querySelector('.gk-modal__foot'); foot.textContent = ''; foot.append(b.foot);
|
|
70
71
|
b.body.querySelector(FOCUSABLE)?.focus({ preventScroll: true });
|
|
71
72
|
},
|
|
72
73
|
onClose: () => {
|
|
@@ -81,7 +82,8 @@ export function Modal({ open, onClose, title = '', sub = '', size = '', anchor,
|
|
|
81
82
|
// things that may change while it is open
|
|
82
83
|
useIsoLayoutEffect(() => {
|
|
83
84
|
const el = layer.current?.el; if (!el) return;
|
|
84
|
-
el.className = `modal ${size ? 'modal--' + size : ''}`;
|
|
85
|
+
el.className = `gk-modal ${size ? 'gk-modal--' + size : ''}`;
|
|
86
|
+
el.querySelector('.gk-modal__head [data-close]')?.setAttribute('aria-label', words?.close ?? 'Close');
|
|
85
87
|
if (isText(title)) { el.setAttribute('aria-label', String(title)); el.removeAttribute('aria-labelledby'); }
|
|
86
88
|
else { el.removeAttribute('aria-label'); el.setAttribute('aria-labelledby', titleId); }
|
|
87
89
|
const p = box.current.sub.parentElement; if (p) p.hidden = sub == null || sub === '' || sub === false;
|
|
@@ -98,9 +100,9 @@ export function Modal({ open, onClose, title = '', sub = '', size = '', anchor,
|
|
|
98
100
|
* <Drawer open={open} onClose={() => setOpen(false)} title="Somchai K." sub="Customer since 2023"
|
|
99
101
|
* head={<Avatar …/>} side="right" footer={<Button>Message</Button>}>…</Drawer>
|
|
100
102
|
* Slides in from the side (a bottom sheet on phones); its content drifts up as it lands. Opening a drawer
|
|
101
|
-
* closes any other drawer. Closing from inside (✕, scrim, Esc) calls onClose.
|
|
103
|
+
* closes any other drawer. Closing from inside (✕, scrim, Esc) calls onClose. words: { close } — the ✕ button's label.
|
|
102
104
|
*/
|
|
103
|
-
export function Drawer({ open, onClose, title = '', sub = '', head, side = 'right', footer, children }) {
|
|
105
|
+
export function Drawer({ open, onClose, title = '', sub = '', head, side = 'right', footer, words, children }) {
|
|
104
106
|
const client = useClient();
|
|
105
107
|
const box = useRef(null);
|
|
106
108
|
if (client && !box.current) box.current = { head: holder('span'), title: holder('span'), sub: holder('span'), body: holder(), foot: holder() };
|
|
@@ -114,13 +116,13 @@ export function Drawer({ open, onClose, title = '', sub = '', head, side = 'righ
|
|
|
114
116
|
O.bindEscape();
|
|
115
117
|
alive.current = true;
|
|
116
118
|
const l = O.drawer({
|
|
117
|
-
title: '', side, body: '', foot: ' ',
|
|
119
|
+
title: '', side, body: '', foot: ' ', words: words ?? {},
|
|
118
120
|
onMount: (el) => {
|
|
119
|
-
el.querySelector('.drawer__title').prepend(b.head);
|
|
120
|
-
const h3 = el.querySelector('.drawer__head h3'); h3.id = titleId; h3.append(b.title);
|
|
121
|
+
el.querySelector('.gk-drawer__title').prepend(b.head);
|
|
122
|
+
const h3 = el.querySelector('.gk-drawer__head h3'); h3.id = titleId; h3.append(b.title);
|
|
121
123
|
const p = document.createElement('p'); p.append(b.sub); h3.after(p);
|
|
122
|
-
el.querySelector('.drawer__body').append(b.body);
|
|
123
|
-
const foot = el.querySelector('.drawer__foot'); foot.textContent = ''; foot.append(b.foot);
|
|
124
|
+
el.querySelector('.gk-drawer__body').append(b.body);
|
|
125
|
+
const foot = el.querySelector('.gk-drawer__foot'); foot.textContent = ''; foot.append(b.foot);
|
|
124
126
|
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' });
|
|
125
127
|
},
|
|
126
128
|
onClose: () => {
|
|
@@ -134,6 +136,7 @@ export function Drawer({ open, onClose, title = '', sub = '', head, side = 'righ
|
|
|
134
136
|
|
|
135
137
|
useIsoLayoutEffect(() => {
|
|
136
138
|
const el = layer.current?.el; if (!el) return;
|
|
139
|
+
el.querySelector('.gk-drawer__head [data-close]')?.setAttribute('aria-label', words?.close ?? 'Close');
|
|
137
140
|
if (isText(title)) { el.setAttribute('aria-label', String(title)); el.removeAttribute('aria-labelledby'); }
|
|
138
141
|
else { el.removeAttribute('aria-label'); el.setAttribute('aria-labelledby', titleId); }
|
|
139
142
|
const p = box.current.sub.parentElement; if (p) p.hidden = sub == null || sub === '' || sub === false;
|
|
@@ -151,8 +154,8 @@ function openConfirm({ title = 'Are you sure?', body = '', ok = 'Confirm', cance
|
|
|
151
154
|
O.bindEscape();
|
|
152
155
|
const promise = new Promise((res) => {
|
|
153
156
|
layer = O.modal({
|
|
154
|
-
title: esc(title), size: 'sm', anchor: deref(anchor), body: body ? `<p class="muted">${esc(body)}</p>` : '',
|
|
155
|
-
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>`,
|
|
157
|
+
title: esc(title), size: 'sm', anchor: deref(anchor), body: body ? `<p class="gk-muted">${esc(body)}</p>` : '',
|
|
158
|
+
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>`,
|
|
156
159
|
onMount: (el, close) => {
|
|
157
160
|
el.setAttribute('aria-label', String(title));
|
|
158
161
|
el.querySelector('[data-ok]').addEventListener('click', () => { answered = true; res(true); close(); });
|
|
@@ -188,7 +191,7 @@ export function useConfirm() {
|
|
|
188
191
|
const Trigger = (props) => h('span', { ...props, style: { display: 'contents' }, suppressHydrationWarning: true });
|
|
189
192
|
|
|
190
193
|
/**
|
|
191
|
-
* <Popover content={(close) => <ShareForm onDone={close} />} align="end" label="Share" className="pop--wide">
|
|
194
|
+
* <Popover content={(close) => <ShareForm onDone={close} />} align="end" label="Share" className="gk-pop--wide">
|
|
192
195
|
* <Button icon="send">Share</Button>
|
|
193
196
|
* </Popover>
|
|
194
197
|
* A panel that pops out of its trigger (the one child). Clicking the trigger toggles it; a click outside,
|
|
@@ -357,7 +360,7 @@ export function Tooltip({ text, side = 'below', disabled = false, children }) {
|
|
|
357
360
|
return h(Fragment, null,
|
|
358
361
|
h(Trigger, { ref: wrap, 'data-gecko': 'Tooltip' }, children),
|
|
359
362
|
tip ? createPortal(h('div', {
|
|
360
|
-
ref: tipEl, id, role: 'tooltip', className: cx('tip', tip.right && 'is-side'),
|
|
363
|
+
ref: tipEl, id, role: 'tooltip', className: cx('gk-tip', tip.right && 'gk-is-side'),
|
|
361
364
|
style: { display: 'block', left: tip.left, top: tip.top },
|
|
362
365
|
}, text), document.body) : null);
|
|
363
366
|
}
|
|
@@ -402,7 +405,7 @@ export const CookieBanner = forwardRef(function CookieBanner({ onChange, mount,
|
|
|
402
405
|
|
|
403
406
|
/* ---------------- loading bar ---------------- */
|
|
404
407
|
/**
|
|
405
|
-
* const bar = useLoadingBar({ color: 'var(--good)' }); … bar.start(); await save(); bar.done()
|
|
408
|
+
* const bar = useLoadingBar({ color: 'var(--gk-good)' }); … bar.start(); await save(); bar.done()
|
|
406
409
|
* The thin loading line along the top of the page (or along the top of `mount`). Returns a handle that stays
|
|
407
410
|
* the same for the component's life: start() · done() · done(true) · fail() · set(0..1) · inc(n) · value ·
|
|
408
411
|
* loads · active · el. Every start() needs its done(); quick loads never show it. Removed on unmount.
|