@usableapp/cardds 0.7.120 → 0.7.122
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/CHANGELOG.md +18 -0
- package/css/actions.css +1 -1
- package/css/layover.css +31 -0
- package/dist/cardds.css +32 -1
- package/dist/catalog.json +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layover/CountIn.d.ts +27 -0
- package/dist/layover/CountIn.js +46 -0
- package/dist/templates/Home.d.ts +2 -0
- package/dist/templates/Home.js +1 -1
- package/dist/words.d.ts +1 -1
- package/dist/words.js +2 -2
- package/docs/reference.md +7 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ export * from './media/Tile.js';
|
|
|
105
105
|
export * from './media/Mosaic.js';
|
|
106
106
|
export * from './layover/Banner.js';
|
|
107
107
|
export * from './layover/Callout.js';
|
|
108
|
+
export * from './layover/CountIn.js';
|
|
108
109
|
export * from './layover/Snackbar.js';
|
|
109
110
|
export * from './journey/Route.js';
|
|
110
111
|
export * from './journey/JourneyBadge.js';
|
package/dist/index.js
CHANGED
|
@@ -108,6 +108,7 @@ export * from './media/Tile.js';
|
|
|
108
108
|
export * from './media/Mosaic.js';
|
|
109
109
|
export * from './layover/Banner.js';
|
|
110
110
|
export * from './layover/Callout.js';
|
|
111
|
+
export * from './layover/CountIn.js';
|
|
111
112
|
export * from './layover/Snackbar.js';
|
|
112
113
|
export * from './journey/Route.js';
|
|
113
114
|
export * from './journey/JourneyBadge.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react';
|
|
2
|
+
export type CountInReason = 'done' | 'cancel';
|
|
3
|
+
export interface CountInProps extends Omit<ComponentProps<'div'>, 'onClick' | 'children'> {
|
|
4
|
+
/** CONTROLLED: counting over the screen — with `onOpenChange`; or `defaultOpen` */
|
|
5
|
+
open?: boolean;
|
|
6
|
+
/** UNCONTROLLED: starts counting (default true — mounting it is starting the count) */
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
/** it asks to leave: the count reached its end (`done`) or the member tapped to stop it (`cancel`) */
|
|
9
|
+
onOpenChange?: (open: boolean, reason: CountInReason) => void;
|
|
10
|
+
/** the number it starts from, counting down one a second to 1 (default 5) */
|
|
11
|
+
from?: number;
|
|
12
|
+
/** the count ran out: the app starts what it was counting in to (its own sound, its own buzz) */
|
|
13
|
+
onDone?: () => void;
|
|
14
|
+
/** the member tapped anywhere: the count stops, nothing starts */
|
|
15
|
+
onCancel?: () => void;
|
|
16
|
+
/** it has faded out: the app unmounts it now */
|
|
17
|
+
onClosed?: () => void;
|
|
18
|
+
/** the tap-anywhere control's name for a screen reader (default: cardds's own "Cancel", in the page's language) */
|
|
19
|
+
cancelLabel?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* CountIn — a count laid over the whole screen, one BIG number a second (5 4 3 2 1), then it tells the app it is done. Ready, set, go: before
|
|
23
|
+
* something starts that the member must be ready for. A tap anywhere stops it. A child of the `Screen`, over everything, on the scrim.
|
|
24
|
+
* Controlled like an input: `open` + `onOpenChange(open, reason)`, or `defaultOpen`; `onDone` / `onCancel` say which way it ended.
|
|
25
|
+
* The count itself is all it shows: a sound or a buzz at the end is the app's.
|
|
26
|
+
*/
|
|
27
|
+
export declare function CountIn({ open, defaultOpen, onOpenChange, from, onDone, onCancel, onClosed, cancelLabel, className, ...rest }: CountInProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { cx } from '../cx.js';
|
|
4
|
+
import { word } from '../words.js';
|
|
5
|
+
import { reducedMotion, useControlled, useLatest } from '../state.js';
|
|
6
|
+
/**
|
|
7
|
+
* CountIn — a count laid over the whole screen, one BIG number a second (5 4 3 2 1), then it tells the app it is done. Ready, set, go: before
|
|
8
|
+
* something starts that the member must be ready for. A tap anywhere stops it. A child of the `Screen`, over everything, on the scrim.
|
|
9
|
+
* Controlled like an input: `open` + `onOpenChange(open, reason)`, or `defaultOpen`; `onDone` / `onCancel` say which way it ended.
|
|
10
|
+
* The count itself is all it shows: a sound or a buzz at the end is the app's.
|
|
11
|
+
*/
|
|
12
|
+
export function CountIn({ open, defaultOpen = true, onOpenChange, from = 5, onDone, onCancel, onClosed, cancelLabel, className, ...rest }) {
|
|
13
|
+
const [shown, request] = useControlled(open, defaultOpen, onOpenChange);
|
|
14
|
+
const [entered, setEntered] = useState(false); // its first frame is out of sight, so one mounted open fades in
|
|
15
|
+
const [n, setN] = useState(from);
|
|
16
|
+
const done = useLatest(onDone);
|
|
17
|
+
const closed = useLatest(onClosed);
|
|
18
|
+
const up = shown && entered;
|
|
19
|
+
useEffect(() => { const f = requestAnimationFrame(() => setEntered(true)); return () => cancelAnimationFrame(f); }, []);
|
|
20
|
+
useEffect(() => { if (shown)
|
|
21
|
+
setN(from); }, [shown, from]); // each opening counts from the top
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!up)
|
|
24
|
+
return;
|
|
25
|
+
const t = setTimeout(() => {
|
|
26
|
+
if (n > 1)
|
|
27
|
+
setN(n - 1);
|
|
28
|
+
else {
|
|
29
|
+
request(false, 'done');
|
|
30
|
+
done.current?.();
|
|
31
|
+
}
|
|
32
|
+
}, 1000);
|
|
33
|
+
return () => clearTimeout(t);
|
|
34
|
+
}, [up, n, request]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (shown || !entered)
|
|
37
|
+
return;
|
|
38
|
+
const ms = reducedMotion() ? 0 : quickMs();
|
|
39
|
+
const t = setTimeout(() => closed.current?.(), ms);
|
|
40
|
+
return () => clearTimeout(t);
|
|
41
|
+
}, [shown, entered]);
|
|
42
|
+
const cancel = () => { if (!up)
|
|
43
|
+
return; request(false, 'cancel'); onCancel?.(); };
|
|
44
|
+
return (_jsxs("div", { className: cx('count-in', up && 'count-in--open', className), inert: !up, ...rest, children: [_jsx("button", { type: "button", className: "count-in__cancel", "aria-label": cancelLabel ?? word('cancel'), onClick: cancel }), _jsx("span", { className: "count-in__number", "aria-live": "assertive", "aria-atomic": "true", children: _jsx("span", { className: "count-in__digit", children: n }, n) })] }));
|
|
45
|
+
}
|
|
46
|
+
const quickMs = () => (parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--motion-quick')) || 0.2) * 1000;
|
package/dist/templates/Home.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface HomeSheet {
|
|
|
21
21
|
onTabChange?: (tab: string) => void;
|
|
22
22
|
/** the SHEET BODY — rendered only while the sheet is open (or kept, with `keep`); a function gets the chosen tab */
|
|
23
23
|
body: ReactNode | ((tab?: string) => ReactNode);
|
|
24
|
+
/** a row pinned under the SHEET HEAD, outside the body's scroll and pull — see `StackSheet top`; a function gets the chosen tab (return null for no row) */
|
|
25
|
+
top?: ReactNode | ((tab?: string) => ReactNode);
|
|
24
26
|
/** the SHEET FOOT: the CTA at the sheet's bottom (one row); a function gets the chosen tab */
|
|
25
27
|
foot?: ReactNode | ((tab?: string) => ReactNode);
|
|
26
28
|
}
|
package/dist/templates/Home.js
CHANGED
|
@@ -51,5 +51,5 @@ export function Home({ top, title, sheets, open: openProp, defaultOpen = null, o
|
|
|
51
51
|
const [tabs, setTabs] = useState(() => Object.fromEntries(sheets.map((x, i) => [i, x.defaultTab ?? x.tabs?.[0]?.id])));
|
|
52
52
|
const shows = (i) => i === shown || i === leaving || (keep && seen.has(i));
|
|
53
53
|
const tabOf = (i) => sheets[i].tab ?? tabs[i];
|
|
54
|
-
return (_jsxs(Screen, { fill: true, top: top, ...rest, children: [_jsx(Text, { level: "h1", as: "h1", sr: true, children: title }), _jsx(SheetStack, { closed: true, open: shown, onOpenChange: request, onRefresh: onRefresh, refreshing: refreshing, mark: mark, rise: rise, base: base, children: sheets.map((s, i) => (_jsx(StackSheet, { tone: s.tone ?? TONES[i], paper: s.paper, title: s.title, icon: s.icon, tabs: s.tabs, tab: tabOf(i), onTabChange: (t) => { setTabs((v) => ({ ...v, [i]: t })); s.onTabChange?.(t); }, backLabel: backLabel, backAt: backAt, foot: typeof s.foot === 'function' ? s.foot(tabOf(i)) : s.foot, children: shows(i) ? (typeof s.body === 'function' ? s.body(tabOf(i)) : s.body) : null }, i))) }), children] }));
|
|
54
|
+
return (_jsxs(Screen, { fill: true, top: top, ...rest, children: [_jsx(Text, { level: "h1", as: "h1", sr: true, children: title }), _jsx(SheetStack, { closed: true, open: shown, onOpenChange: request, onRefresh: onRefresh, refreshing: refreshing, mark: mark, rise: rise, base: base, children: sheets.map((s, i) => (_jsx(StackSheet, { tone: s.tone ?? TONES[i], paper: s.paper, title: s.title, icon: s.icon, tabs: s.tabs, tab: tabOf(i), onTabChange: (t) => { setTabs((v) => ({ ...v, [i]: t })); s.onTabChange?.(t); }, backLabel: backLabel, backAt: backAt, top: shows(i) ? (typeof s.top === 'function' ? s.top(tabOf(i)) : s.top) : null, foot: typeof s.foot === 'function' ? s.foot(tabOf(i)) : s.foot, children: shows(i) ? (typeof s.body === 'function' ? s.body(tabOf(i)) : s.body) : null }, i))) }), children] }));
|
|
55
55
|
}
|
package/dist/words.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type WordKey = 'resize' | 'back' | 'next' | 'previous' | 'skip' | 'digit' | 'progress' | 'image' | 'mood' | 'photos' | 'voiceNote' | 'play' | 'pause' | 'to' | 'turnToBack' | 'turnToPicture' | 'turnToFront' | 'message' | 'address' | 'toMessage' | 'toAddress' | 'stampOn' | 'stampOff' | 'stamps' | 'unread' | 'remove';
|
|
1
|
+
export type WordKey = 'resize' | 'back' | 'next' | 'previous' | 'skip' | 'digit' | 'progress' | 'image' | 'mood' | 'photos' | 'voiceNote' | 'play' | 'pause' | 'to' | 'turnToBack' | 'turnToPicture' | 'turnToFront' | 'message' | 'address' | 'toMessage' | 'toAddress' | 'stampOn' | 'stampOff' | 'stamps' | 'unread' | 'remove' | 'cancel';
|
|
2
2
|
type Words = Record<WordKey, string>;
|
|
3
3
|
/** add or retune the words for a language (`'lo'`, or `'th'` to change one) — once, at app start. Missing words fall back to English. */
|
|
4
4
|
export declare function setWords(lang: string, words: Partial<Words>): void;
|
package/dist/words.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const sets = {
|
|
2
2
|
en: { resize: 'Resize', back: 'Back', next: 'Next', previous: 'Previous', skip: 'Skip', digit: 'Digit', progress: 'Progress', image: 'Image', mood: 'Mood', photos: 'Photos', voiceNote: 'Voice note',
|
|
3
|
-
play: 'Play', pause: 'Pause', to: 'To', turnToBack: 'See the back', turnToPicture: 'See the picture', turnToFront: 'See the front', message: 'Message', address: 'Address', toMessage: 'Back to the message', toAddress: 'On to the address', stampOn: 'Stick a stamp', stampOff: 'Take the stamp off', stamps: 'Choose a stamp', unread: 'Unread', remove: 'Remove' },
|
|
3
|
+
play: 'Play', pause: 'Pause', to: 'To', turnToBack: 'See the back', turnToPicture: 'See the picture', turnToFront: 'See the front', message: 'Message', address: 'Address', toMessage: 'Back to the message', toAddress: 'On to the address', stampOn: 'Stick a stamp', stampOff: 'Take the stamp off', stamps: 'Choose a stamp', unread: 'Unread', remove: 'Remove', cancel: 'Cancel' },
|
|
4
4
|
th: { resize: 'ปรับความสูง', back: 'กลับ', next: 'ถัดไป', previous: 'ก่อนหน้า', skip: 'ข้าม', digit: 'หลักที่', progress: 'ความคืบหน้า', image: 'รูปภาพ', mood: 'อารมณ์', photos: 'รูปภาพ', voiceNote: 'ข้อความเสียง',
|
|
5
|
-
play: 'ฟังเสียง', pause: 'หยุดเสียง', to: 'ถึง', turnToBack: 'พลิกดูด้านหลัง', turnToPicture: 'พลิกดูรูป', turnToFront: 'พลิกดูด้านหน้า', message: 'ข้อความ', address: 'จ่าหน้า', toMessage: 'เลื่อนกลับไปข้อความ', toAddress: 'เลื่อนไปจ่าหน้า', stampOn: 'ติดแสตมป์', stampOff: 'แกะแสตมป์ออก', stamps: 'เลือกแสตมป์', unread: 'ยังไม่ได้อ่าน', remove: 'เอาออก' },
|
|
5
|
+
play: 'ฟังเสียง', pause: 'หยุดเสียง', to: 'ถึง', turnToBack: 'พลิกดูด้านหลัง', turnToPicture: 'พลิกดูรูป', turnToFront: 'พลิกดูด้านหน้า', message: 'ข้อความ', address: 'จ่าหน้า', toMessage: 'เลื่อนกลับไปข้อความ', toAddress: 'เลื่อนไปจ่าหน้า', stampOn: 'ติดแสตมป์', stampOff: 'แกะแสตมป์ออก', stamps: 'เลือกแสตมป์', unread: 'ยังไม่ได้อ่าน', remove: 'เอาออก', cancel: 'ยกเลิก' },
|
|
6
6
|
};
|
|
7
7
|
/** add or retune the words for a language (`'lo'`, or `'th'` to change one) — once, at app start. Missing words fall back to English. */
|
|
8
8
|
export function setWords(lang, words) {
|
package/docs/reference.md
CHANGED
|
@@ -300,6 +300,8 @@ the card is the material, the sheet is what it is in the stack.
|
|
|
300
300
|
that tab shows, and a tapped tab asks `onTabChange(tab)`. Something outside
|
|
301
301
|
the stack (a card in the base) brings a sheet up on a named tab by setting
|
|
302
302
|
that sheet's `tab` and the Home's `open` together. Story `Home · Feed`.
|
|
303
|
+
A sheet's `top` reaches `StackSheet top`; like `body` and `foot` it may be a
|
|
304
|
+
function of the tab, returning null where that tab has no row.
|
|
303
305
|
- **Five sheets max.** Slots are declared per `:nth-child` in `stack.css`; a
|
|
304
306
|
sixth would render at slot 0, on top of the first.
|
|
305
307
|
- **Every head needs its own `.sheet-stack__back`** if the stack is `--tap`. It stays
|
|
@@ -449,6 +451,11 @@ whose markup has rules, because the sheet's box is the step itself:
|
|
|
449
451
|
bottom layer), stays `duration` (4 s), slides out, never takes the cursor, never stops the member. `open` +
|
|
450
452
|
`onOpenChange(open, reason)` or `defaultOpen`; unmount it in `onClosed`. One at a time: the queue and the notification
|
|
451
453
|
list are the app's — the app shows its newest notification in it, `onTap` opens that notification.
|
|
454
|
+
- **A count before a start is a `CountIn`** (2026-10-25): one BIG number a second over the whole screen (`from`, default 5:
|
|
455
|
+
5 4 3 2 1), on the scrim, then `onDone` — the app starts what it counted in to and plays its own sound or buzz (the
|
|
456
|
+
component has none). A tap anywhere stops it: `onCancel`. A child of the `Screen`. `open` + `onOpenChange(open, reason)`
|
|
457
|
+
(`done` | `cancel`) or `defaultOpen`; unmount it in `onClosed`. The number is `--fs-giant` and grows with the text scale;
|
|
458
|
+
bigger through `--count-in-size`. A screen reader hears each number (`aria-live`). Not `Countdown`, which is a small link that waits.
|
|
452
459
|
- **Mount a `Modal` only when it is to show.** A `Modal` first mounted with `open={false}` is drawn in place, then leaves,
|
|
453
460
|
and calls `onClosed` after about 700ms. Known fault, not fixed: under React StrictMode (any dev build) `onClosed` is
|
|
454
461
|
never called for a `Modal` mounted that way. Keep the app's own `mounted` flag: set it when the question is asked,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usableapp/cardds",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.122",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "card-first mobile design system, React-first: the components in src/ are thin wrappers over the CSS contract (css/*.css stays the only truth); gallery/ shows every story live (npm run dev), tests/ measures the geometry.",
|