@usableapp/cardds 0.7.121 → 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 +9 -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/words.d.ts +1 -1
- package/dist/words.js +2 -2
- package/docs/reference.md +5 -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/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
|
@@ -451,6 +451,11 @@ whose markup has rules, because the sheet's box is the step itself:
|
|
|
451
451
|
bottom layer), stays `duration` (4 s), slides out, never takes the cursor, never stops the member. `open` +
|
|
452
452
|
`onOpenChange(open, reason)` or `defaultOpen`; unmount it in `onClosed`. One at a time: the queue and the notification
|
|
453
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.
|
|
454
459
|
- **Mount a `Modal` only when it is to show.** A `Modal` first mounted with `open={false}` is drawn in place, then leaves,
|
|
455
460
|
and calls `onClosed` after about 700ms. Known fault, not fixed: under React StrictMode (any dev build) `onClosed` is
|
|
456
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.",
|