@softure-ai/theme-notion 0.9.0 → 0.10.2
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 +51 -0
- package/README.md +102 -8
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/notion/FoldRow.d.ts +2 -0
- package/dist/notion/FoldRow.d.ts.map +1 -1
- package/dist/notion/FoldRow.js +3 -2
- package/dist/notion/FoldRow.js.map +1 -1
- package/dist/notion/InstallBar.d.ts +23 -0
- package/dist/notion/InstallBar.d.ts.map +1 -0
- package/dist/notion/InstallBar.js +16 -0
- package/dist/notion/InstallBar.js.map +1 -0
- package/dist/notion/LaunchScreen.d.ts +13 -0
- package/dist/notion/LaunchScreen.d.ts.map +1 -0
- package/dist/notion/LaunchScreen.js +11 -0
- package/dist/notion/LaunchScreen.js.map +1 -0
- package/dist/notion/MiniProgress.d.ts +13 -0
- package/dist/notion/MiniProgress.d.ts.map +1 -0
- package/dist/notion/MiniProgress.js +24 -0
- package/dist/notion/MiniProgress.js.map +1 -0
- package/dist/notion/Timeline.d.ts +15 -3
- package/dist/notion/Timeline.d.ts.map +1 -1
- package/dist/notion/Timeline.js +16 -4
- package/dist/notion/Timeline.js.map +1 -1
- package/dist/notion/UpdatePrompt.d.ts +13 -0
- package/dist/notion/UpdatePrompt.d.ts.map +1 -0
- package/dist/notion/UpdatePrompt.js +16 -0
- package/dist/notion/UpdatePrompt.js.map +1 -0
- package/dist/ui/accordion.d.ts +3 -1
- package/dist/ui/accordion.d.ts.map +1 -1
- package/dist/ui/accordion.js +2 -2
- package/dist/ui/accordion.js.map +1 -1
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/dialog.d.ts +5 -2
- package/dist/ui/dialog.d.ts.map +1 -1
- package/dist/ui/dialog.js +5 -4
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/dropdown-menu.d.ts +14 -5
- package/dist/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/ui/dropdown-menu.js +21 -10
- package/dist/ui/dropdown-menu.js.map +1 -1
- package/dist/ui/scroll-area.d.ts +2 -1
- package/dist/ui/scroll-area.d.ts.map +1 -1
- package/dist/ui/scroll-area.js +2 -2
- package/dist/ui/scroll-area.js.map +1 -1
- package/dist/ui/tabs.d.ts +7 -2
- package/dist/ui/tabs.d.ts.map +1 -1
- package/dist/ui/tabs.js +47 -5
- package/dist/ui/tabs.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/notion/FoldRow.tsx +8 -2
- package/src/notion/InstallBar.tsx +75 -0
- package/src/notion/LaunchScreen.tsx +37 -0
- package/src/notion/MiniProgress.tsx +67 -0
- package/src/notion/Timeline.tsx +65 -12
- package/src/notion/UpdatePrompt.tsx +47 -0
- package/src/ui/accordion.tsx +5 -1
- package/src/ui/dialog.tsx +16 -2
- package/src/ui/dropdown-menu.tsx +55 -16
- package/src/ui/scroll-area.tsx +5 -1
- package/src/ui/tabs.tsx +66 -8
package/dist/ui/tabs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/ui/tabs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/ui/tabs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAA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AI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EACzD,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,CAAC,KACrE,KAAK,GACT,GAC8B,CACnC,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,SAAS,EACT,IAAI,EACJ,GAAG,KAAK,EAGT;IACC,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAA;IAEzD,OAAO,CACL,KAAC,aAAa,CAAC,OAAO,iBACV,cAAc,EACxB,SAAS,EAAE,EAAE,CACX,wuBAAwuB,EACxuB,kRAAkR,EAClR,qPAAqP,EACrP,keAAke,EACle,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,OAAO,IAAI,uCAAuC,EACzE,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EAC2C;IACnD,OAAO,CACL,KAAC,aAAa,CAAC,OAAO,iBACV,cAAc,EACxB,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,KAC3C,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/theme-notion",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "SOFTURE AI Notion theme: shadcn/ui components (new-york v4, Radix, Tailwind CSS v4, lucide) with the Notion design system's tokens and deltas, ready to import.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/index.ts
CHANGED
|
@@ -48,8 +48,11 @@ export { Code, CodeBlock, type CodeBlockProps } from "./notion/Code.js";
|
|
|
48
48
|
export { DetailTable, type DetailRow, type DetailTableProps } from "./notion/DetailTable.js";
|
|
49
49
|
export { FilterChip, FilterChipAdd, type FilterChipAddProps, type FilterChipProps } from "./notion/FilterChip.js";
|
|
50
50
|
export { FoldRow, type FoldRowBadge, type FoldRowProps } from "./notion/FoldRow.js";
|
|
51
|
+
export { InstallBar, type InstallBarOffer, type InstallBarProps } from "./notion/InstallBar.js";
|
|
52
|
+
export { LaunchScreen, type LaunchScreenProps } from "./notion/LaunchScreen.js";
|
|
51
53
|
export { PALETTE_COLORS, type PaletteColor } from "./notion/palette.js";
|
|
52
54
|
export { MarkPopover, type MarkPopoverProps } from "./notion/MarkPopover.js";
|
|
55
|
+
export { MiniProgress, type MiniProgressProps } from "./notion/MiniProgress.js";
|
|
53
56
|
export { PageFrame, type PageFrameProps } from "./notion/PageFrame.js";
|
|
54
57
|
export { PageHeader, type PageCrumb, type PageHeaderProps } from "./notion/PageHeader.js";
|
|
55
58
|
export { PropertyList, type Property, type PropertyListProps } from "./notion/PropertyList.js";
|
|
@@ -82,5 +85,6 @@ export {
|
|
|
82
85
|
export { Status, type StatusProps } from "./notion/Status.js";
|
|
83
86
|
export { Steps, type StepItem, type StepState, type StepsLayout, type StepsProps } from "./notion/Steps.js";
|
|
84
87
|
export { TabBar, type TabBarItem, type TabBarProps } from "./notion/TabBar.js";
|
|
85
|
-
export { Timeline, type TimelineItem, type TimelineItemSize, type TimelineLine, type TimelineProps } from "./notion/Timeline.js";
|
|
88
|
+
export { Timeline, type TimelineItem, type TimelineItemFold, type TimelineItemSize, type TimelineLine, type TimelineProps } from "./notion/Timeline.js";
|
|
89
|
+
export { UpdatePrompt, type UpdatePromptProps } from "./notion/UpdatePrompt.js";
|
|
86
90
|
export { TONES, TONE_COLORS, TONE_EDGE, TONE_FILL, TONE_TEXT, type Tone } from "./notion/tones.js";
|
package/src/notion/FoldRow.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChevronRight } from "lucide-react";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
4
5
|
import { Badge } from "../ui/badge.js";
|
|
5
6
|
|
|
6
7
|
import { DetailTable, type DetailRow } from "./DetailTable.js";
|
|
@@ -48,6 +49,8 @@ export type FoldRowProps = FoldRowSummaryProps &
|
|
|
48
49
|
FoldRowDetailsProps & {
|
|
49
50
|
/** Indents the opened content to line up with the title after the chevron; by default it is padded equally. */
|
|
50
51
|
readonly isInset?: boolean;
|
|
52
|
+
/** `touch` makes the summary at least the touch target high (44 px) instead of the row height. */
|
|
53
|
+
readonly size?: "default" | "touch";
|
|
51
54
|
/** More content under the table when opened. */
|
|
52
55
|
readonly children?: ReactNode;
|
|
53
56
|
};
|
|
@@ -111,12 +114,15 @@ function FoldRowChevron() {
|
|
|
111
114
|
|
|
112
115
|
// An item as one folding list row: a native `<details>` that opens in place to its details, with no client state.
|
|
113
116
|
export function FoldRow(props: FoldRowProps) {
|
|
114
|
-
const { isInset = false, children } = props;
|
|
117
|
+
const { isInset = false, size = "default", children } = props;
|
|
115
118
|
return (
|
|
116
119
|
<details data-slot="fold-row" className="group/fold-row border-b border-border">
|
|
117
120
|
<summary
|
|
118
121
|
data-slot="fold-row-summary"
|
|
119
|
-
className=
|
|
122
|
+
className={cn(
|
|
123
|
+
"flex cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 rounded-md px-1 py-1 transition-colors duration-120 group-open/fold-row:bg-accent hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none [&::-webkit-details-marker]:hidden",
|
|
124
|
+
size === "touch" ? "min-h-touch-target" : "min-h-row-height",
|
|
125
|
+
)}
|
|
120
126
|
>
|
|
121
127
|
{props.summary === undefined ? (
|
|
122
128
|
<FoldRowFixedSummary title={props.title} facts={props.facts} badges={props.badges ?? []} />
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Download, Share, SquarePlus, X } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { Alert, AlertDescription, AlertTitle } from "../ui/alert.js";
|
|
5
|
+
import { Button } from "../ui/button.js";
|
|
6
|
+
|
|
7
|
+
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
8
|
+
|
|
9
|
+
/** The offer to show, as `useInstallOffer` in `@softure-ai/pwa/react` picks it. */
|
|
10
|
+
export type InstallBarOffer = "ios_steps" | "browser_prompt" | "none";
|
|
11
|
+
|
|
12
|
+
export interface InstallBarProps {
|
|
13
|
+
/** `offer` from `useInstallOffer`: the browser's prompt button, the iOS steps, or nothing. */
|
|
14
|
+
readonly offer: InstallBarOffer;
|
|
15
|
+
readonly title: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
/** The prompt button's text. */
|
|
18
|
+
readonly install: string;
|
|
19
|
+
/** The first iOS step, beside the Share icon. */
|
|
20
|
+
readonly shareStep: string;
|
|
21
|
+
/** The second iOS step, beside the Add to Home Screen icon. */
|
|
22
|
+
readonly addStep: string;
|
|
23
|
+
/** The close button's accessible name. */
|
|
24
|
+
readonly close: string;
|
|
25
|
+
/** The prompt button's action (`install` from `useInstallOffer`): the browser's install sheet. */
|
|
26
|
+
readonly onInstall: () => void;
|
|
27
|
+
/** The close button's action (`close` from `useInstallOffer`): the offer stays closed on this device. */
|
|
28
|
+
readonly onClose: () => void;
|
|
29
|
+
readonly className?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// The offer to install the app on a phone: a floating alert at the bottom of the screen, inside the safe-area insets
|
|
33
|
+
// like UpdatePrompt, with the browser's install button or the two iOS steps (Share, then Add to Home Screen) and a
|
|
34
|
+
// close button, both at the touch size on a phone. A polite status: it never interrupts a screen reader. The copy is
|
|
35
|
+
// the app's (`pwaMessages.en.install` in `@softure-ai/pwa` has the English text, keyed like these props).
|
|
36
|
+
export function InstallBar({ offer, title, description, install, shareStep, addStep, close, onInstall, onClose, className }: InstallBarProps) {
|
|
37
|
+
if (offer === "none") return null;
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
data-slot="install-bar"
|
|
41
|
+
data-offer={offer}
|
|
42
|
+
className={cn(
|
|
43
|
+
"pointer-events-none fixed inset-x-0 bottom-0 z-50 flex justify-center pt-4 pr-[calc(--spacing(4)+env(safe-area-inset-right))] pb-[calc(--spacing(4)+env(safe-area-inset-bottom))] pl-[calc(--spacing(4)+env(safe-area-inset-left))]",
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
>
|
|
47
|
+
<Alert role="status" aria-live="polite" className="pointer-events-auto max-w-md pr-14 shadow-menu md:pr-11">
|
|
48
|
+
<Download strokeWidth={ICON_STROKE_WIDTH} />
|
|
49
|
+
<AlertTitle>{title}</AlertTitle>
|
|
50
|
+
<AlertDescription>
|
|
51
|
+
<p>{description}</p>
|
|
52
|
+
{offer === "browser_prompt" ? (
|
|
53
|
+
<Button size="touch" className="mt-1 md:h-7" onClick={onInstall}>
|
|
54
|
+
{install}
|
|
55
|
+
</Button>
|
|
56
|
+
) : (
|
|
57
|
+
<ol data-slot="install-bar-steps" className="mt-1 grid gap-1.5 text-foreground">
|
|
58
|
+
<li className="flex items-center gap-2">
|
|
59
|
+
<Share aria-hidden="true" className="size-4 shrink-0" strokeWidth={ICON_STROKE_WIDTH} />
|
|
60
|
+
{shareStep}
|
|
61
|
+
</li>
|
|
62
|
+
<li className="flex items-center gap-2">
|
|
63
|
+
<SquarePlus aria-hidden="true" className="size-4 shrink-0" strokeWidth={ICON_STROKE_WIDTH} />
|
|
64
|
+
{addStep}
|
|
65
|
+
</li>
|
|
66
|
+
</ol>
|
|
67
|
+
)}
|
|
68
|
+
</AlertDescription>
|
|
69
|
+
<Button type="button" variant="ghost" size="icon-touch" aria-label={close} className="absolute top-0 right-0 md:top-1 md:right-1 md:size-7" onClick={onClose}>
|
|
70
|
+
<X aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
|
|
71
|
+
</Button>
|
|
72
|
+
</Alert>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { Progress } from "../ui/progress.js";
|
|
3
|
+
|
|
4
|
+
export interface LaunchScreenProps {
|
|
5
|
+
/** The app's name, shown under its icon. */
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** The app's icon, e.g. `${ICONS_PATH}/icon-192.png` from `@softure-ai/pwa`: the manifest's mark. */
|
|
8
|
+
readonly iconSrc: string;
|
|
9
|
+
/** The progress bar's accessible name (`pwaMessages.en.launch.label` in `@softure-ai/pwa`). */
|
|
10
|
+
readonly label: string;
|
|
11
|
+
/** The counter's inline script (`buildLaunchProgressScript()` from `@softure-ai/pwa`); without it the bar stays at 0. */
|
|
12
|
+
readonly script?: string;
|
|
13
|
+
readonly className?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// The screen an installed app shows from its first byte until the page arrives, streamed from `app/loading.tsx`: the
|
|
17
|
+
// app's icon and name, a progress bar and a percentage on the theme's background, full screen in light and dark. The
|
|
18
|
+
// counter script moves the bar, its indicator and the percentage through their `data-slot`s; the percentage is
|
|
19
|
+
// hidden from screen readers (the bar reports the value) and keeps the script's text if React hydrates the screen.
|
|
20
|
+
export function LaunchScreen({ name, iconSrc, label, script, className }: LaunchScreenProps) {
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
data-slot="launch-screen"
|
|
24
|
+
className={cn("fixed inset-0 z-50 flex flex-col items-center justify-center gap-4 bg-background p-6 text-foreground", className)}
|
|
25
|
+
>
|
|
26
|
+
<img data-slot="launch-screen-icon" src={iconSrc} alt="" width={64} height={64} className="size-16 rounded-2xl" />
|
|
27
|
+
<p data-slot="launch-screen-name" className="text-lg font-semibold">
|
|
28
|
+
{name}
|
|
29
|
+
</p>
|
|
30
|
+
<Progress value={0} aria-label={label} className="w-48" />
|
|
31
|
+
<p data-slot="launch-screen-percent" aria-hidden="true" suppressHydrationWarning className="text-sm text-muted-foreground tabular-nums">
|
|
32
|
+
0%
|
|
33
|
+
</p>
|
|
34
|
+
{script === undefined ? null : <script dangerouslySetInnerHTML={{ __html: script }} />}
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Progress as ProgressPrimitive } from "radix-ui";
|
|
4
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils.js";
|
|
7
|
+
|
|
8
|
+
import { TONE_FILL, type Tone } from "./tones.js";
|
|
9
|
+
|
|
10
|
+
export type MiniProgressProps = Omit<ComponentProps<typeof ProgressPrimitive.Root>, "children" | "max" | "value"> & {
|
|
11
|
+
/** 0–100, clamped; non-finite values read as 0. */
|
|
12
|
+
readonly value: number;
|
|
13
|
+
/** Text inside the bar, e.g. a formatted amount; defaults to the rounded percent. */
|
|
14
|
+
readonly label?: ReactNode;
|
|
15
|
+
/** Fill colour by meaning (the theme's tones); defaults to primary. */
|
|
16
|
+
readonly tone?: Tone;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function clampShare(value: number): number {
|
|
20
|
+
if (!Number.isFinite(value)) return 0;
|
|
21
|
+
return Math.min(100, Math.max(0, value));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const LABEL_CLASS = "absolute inset-0 flex items-center px-2 text-xs font-medium tabular-nums whitespace-nowrap";
|
|
25
|
+
|
|
26
|
+
// A share with its figure inside the bar, for a table cell or a tile: a 20 px track that takes the cell's width and
|
|
27
|
+
// carries the label, so a figure and a bar never collide in a narrow column. The label is drawn twice: in the text
|
|
28
|
+
// colour on the track, and in the page background clipped to the fill, so it reads at any value, also where the
|
|
29
|
+
// fill's edge crosses a letter. Both copies are hidden: the progress bar itself reports the value (and a string label
|
|
30
|
+
// as its value text). A label wider than the cell ends in an ellipsis.
|
|
31
|
+
export function MiniProgress({ value, label, tone, className, ...props }: MiniProgressProps) {
|
|
32
|
+
const share = clampShare(value);
|
|
33
|
+
const text = label ?? `${Math.round(share)}%`;
|
|
34
|
+
return (
|
|
35
|
+
<ProgressPrimitive.Root
|
|
36
|
+
data-slot="mini-progress"
|
|
37
|
+
data-tone={tone ?? "default"}
|
|
38
|
+
value={share}
|
|
39
|
+
max={100}
|
|
40
|
+
getValueLabel={typeof text === "string" ? () => text : undefined}
|
|
41
|
+
className={cn("relative h-5 w-full min-w-16 overflow-hidden rounded-sm bg-primary/12", className)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
<ProgressPrimitive.Indicator
|
|
45
|
+
data-slot="mini-progress-indicator"
|
|
46
|
+
className={cn(
|
|
47
|
+
"absolute inset-y-0 left-0 transition-[width]",
|
|
48
|
+
// In dark the default fill is the lighter link blue, as in `Progress`.
|
|
49
|
+
tone === undefined ? "bg-primary dark:bg-link" : TONE_FILL[tone],
|
|
50
|
+
)}
|
|
51
|
+
style={{ width: `${share}%` }}
|
|
52
|
+
/>
|
|
53
|
+
<span aria-hidden="true" data-slot="mini-progress-label" className={cn(LABEL_CLASS, "text-foreground")}>
|
|
54
|
+
<span className="truncate">{text}</span>
|
|
55
|
+
</span>
|
|
56
|
+
{/* The page background, not `primary-foreground`: white on the dark fills stays under 4.5:1. */}
|
|
57
|
+
<span
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
data-slot="mini-progress-label"
|
|
60
|
+
className={cn(LABEL_CLASS, "text-background")}
|
|
61
|
+
style={{ clipPath: `inset(0 ${100 - share}% 0 0)` }}
|
|
62
|
+
>
|
|
63
|
+
<span className="truncate">{text}</span>
|
|
64
|
+
</span>
|
|
65
|
+
</ProgressPrimitive.Root>
|
|
66
|
+
);
|
|
67
|
+
}
|
package/src/notion/Timeline.tsx
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { ChevronRight, type LucideIcon } from "lucide-react";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible.js";
|
|
5
6
|
|
|
6
7
|
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
7
8
|
import type { PaletteColor } from "./palette.js";
|
|
8
9
|
|
|
10
|
+
|
|
9
11
|
// `default`: a major entry with a filled round marker; `compact`: a minor entry between two major ones.
|
|
10
12
|
export type TimelineItemSize = "default" | "compact";
|
|
11
13
|
|
|
12
14
|
// The rail through an entry: `dashed` for something missing (a gap).
|
|
13
15
|
export type TimelineLine = "solid" | "dashed";
|
|
14
16
|
|
|
15
|
-
export interface
|
|
17
|
+
export interface TimelineItemFold {
|
|
18
|
+
// The open state when the app keeps it; left out, the entry keeps its own.
|
|
19
|
+
readonly isOpen?: boolean;
|
|
20
|
+
// Whether an entry that keeps its own state starts open; closed by default.
|
|
21
|
+
readonly isOpenInitially?: boolean;
|
|
22
|
+
readonly onOpenChange?: (isOpen: boolean) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface TimelineItemBase {
|
|
16
26
|
// Unique within the timeline; kept on the item as `data-item`.
|
|
17
27
|
readonly key: string;
|
|
18
28
|
readonly title: ReactNode;
|
|
@@ -32,14 +42,21 @@ export interface TimelineItem {
|
|
|
32
42
|
readonly color?: PaletteColor;
|
|
33
43
|
readonly size?: TimelineItemSize;
|
|
34
44
|
readonly line?: TimelineLine;
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
readonly onSelect?: () => void;
|
|
45
|
+
// Read before the body button's visible text ("Show on the map"), so the button's name starts with what it does and
|
|
46
|
+
// still contains every word it shows.
|
|
38
47
|
readonly actionLabel?: string;
|
|
39
48
|
// `data-*` attributes set on the item, for an app's own hooks.
|
|
40
49
|
readonly data?: Readonly<Record<`data-${string}`, string | undefined>>;
|
|
41
50
|
}
|
|
42
51
|
|
|
52
|
+
// What the body does: nothing, call `onSelect` as a button, or fold `children` open and closed as a disclosure button
|
|
53
|
+
// (`aria-expanded`), at least the touch target high.
|
|
54
|
+
export type TimelineItem = TimelineItemBase &
|
|
55
|
+
(
|
|
56
|
+
| { readonly onSelect?: () => void; readonly fold?: never }
|
|
57
|
+
| { readonly fold: TimelineItemFold; readonly onSelect?: never }
|
|
58
|
+
);
|
|
59
|
+
|
|
43
60
|
export interface TimelineProps {
|
|
44
61
|
// The list's accessible name.
|
|
45
62
|
readonly label: string;
|
|
@@ -105,6 +122,11 @@ const BODY_CLASS: Readonly<Record<TimelineItemSize, string>> = {
|
|
|
105
122
|
const BUTTON_CLASS =
|
|
106
123
|
"cursor-pointer text-foreground transition-colors duration-120 hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none";
|
|
107
124
|
|
|
125
|
+
// A folding body is at least the touch target high and leaves room for the chevron at its right edge.
|
|
126
|
+
const FOLD_BODY_CLASS = "group/timeline-fold relative min-h-touch-target pr-7";
|
|
127
|
+
const FOLD_CHEVRON_CLASS =
|
|
128
|
+
"absolute top-2 right-1.5 size-4 text-muted-foreground transition-transform duration-150 group-data-[state=open]/timeline-fold:rotate-90";
|
|
129
|
+
|
|
108
130
|
const ITEM_PADDING: Readonly<Record<TimelineItemSize, string>> = {
|
|
109
131
|
default: "pb-2",
|
|
110
132
|
compact: "pb-1",
|
|
@@ -132,11 +154,17 @@ function TimelineEntry({ item }: { readonly item: TimelineItem }) {
|
|
|
132
154
|
<span aria-hidden="true" data-slot="timeline-rail" className={cn(RAIL_CLASS, RAIL_LINE[line])} />
|
|
133
155
|
<TimelineMarker icon={item.icon} color={color} size={size} />
|
|
134
156
|
<div className={cn("flex min-w-0 flex-col", item.aside === undefined && "col-span-2")}>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
{item.children
|
|
139
|
-
|
|
157
|
+
{item.fold === undefined ? (
|
|
158
|
+
<>
|
|
159
|
+
<TimelineBody item={item} size={size} />
|
|
160
|
+
{item.children === undefined ? null : (
|
|
161
|
+
<div data-slot="timeline-item-content" className="px-2 pb-1">
|
|
162
|
+
{item.children}
|
|
163
|
+
</div>
|
|
164
|
+
)}
|
|
165
|
+
</>
|
|
166
|
+
) : (
|
|
167
|
+
<TimelineFold item={item} fold={item.fold} size={size} />
|
|
140
168
|
)}
|
|
141
169
|
</div>
|
|
142
170
|
{item.aside === undefined ? null : (
|
|
@@ -161,7 +189,7 @@ function TimelineMarker({ icon: Icon, color, size }: { readonly icon?: LucideIco
|
|
|
161
189
|
);
|
|
162
190
|
}
|
|
163
191
|
|
|
164
|
-
function
|
|
192
|
+
function TimelineBodyContent({ item, size }: { readonly item: TimelineItem; readonly size: TimelineItemSize }) {
|
|
165
193
|
const time =
|
|
166
194
|
item.time === undefined ? null : (
|
|
167
195
|
<span data-slot="timeline-item-time" className="text-small text-muted-foreground tabular-nums">
|
|
@@ -180,7 +208,7 @@ function TimelineBody({ item, size }: { readonly item: TimelineItem; readonly si
|
|
|
180
208
|
{item.badges}
|
|
181
209
|
</span>
|
|
182
210
|
);
|
|
183
|
-
|
|
211
|
+
return (
|
|
184
212
|
<>
|
|
185
213
|
{size === "default" ? (
|
|
186
214
|
<>
|
|
@@ -213,6 +241,10 @@ function TimelineBody({ item, size }: { readonly item: TimelineItem; readonly si
|
|
|
213
241
|
)}
|
|
214
242
|
</>
|
|
215
243
|
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function TimelineBody({ item, size }: { readonly item: TimelineItem; readonly size: TimelineItemSize }) {
|
|
247
|
+
const content = <TimelineBodyContent item={item} size={size} />;
|
|
216
248
|
if (item.onSelect === undefined) {
|
|
217
249
|
return (
|
|
218
250
|
<div data-slot="timeline-item-body" className={BODY_CLASS[size]}>
|
|
@@ -227,3 +259,24 @@ function TimelineBody({ item, size }: { readonly item: TimelineItem; readonly si
|
|
|
227
259
|
</button>
|
|
228
260
|
);
|
|
229
261
|
}
|
|
262
|
+
|
|
263
|
+
// The body as a disclosure button (`aria-expanded`, `aria-controls`) that folds the entry's content open and closed.
|
|
264
|
+
function TimelineFold({ item, fold, size }: { readonly item: TimelineItem; readonly fold: TimelineItemFold; readonly size: TimelineItemSize }) {
|
|
265
|
+
return (
|
|
266
|
+
<Collapsible
|
|
267
|
+
{...(fold.isOpen === undefined ? {} : { open: fold.isOpen })}
|
|
268
|
+
defaultOpen={fold.isOpenInitially ?? false}
|
|
269
|
+
{...(fold.onOpenChange === undefined ? {} : { onOpenChange: fold.onOpenChange })}
|
|
270
|
+
className="flex min-w-0 flex-col"
|
|
271
|
+
>
|
|
272
|
+
<CollapsibleTrigger data-slot="timeline-item-body" className={cn(BODY_CLASS[size], BUTTON_CLASS, FOLD_BODY_CLASS)}>
|
|
273
|
+
{item.actionLabel === undefined ? null : <span className="sr-only">{`${item.actionLabel}: `}</span>}
|
|
274
|
+
<TimelineBodyContent item={item} size={size} />
|
|
275
|
+
<ChevronRight aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} className={FOLD_CHEVRON_CLASS} />
|
|
276
|
+
</CollapsibleTrigger>
|
|
277
|
+
<CollapsibleContent data-slot="timeline-item-content" className="px-2 pb-1">
|
|
278
|
+
{item.children}
|
|
279
|
+
</CollapsibleContent>
|
|
280
|
+
</Collapsible>
|
|
281
|
+
);
|
|
282
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { RefreshCw } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { Alert, AlertDescription, AlertTitle } from "../ui/alert.js";
|
|
5
|
+
import { Button } from "../ui/button.js";
|
|
6
|
+
|
|
7
|
+
import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
|
|
8
|
+
|
|
9
|
+
export interface UpdatePromptProps {
|
|
10
|
+
/** A new build waits (`isUpdateReady` from `useServiceWorkerUpdate` in `@softure-ai/pwa/react`). */
|
|
11
|
+
readonly open: boolean;
|
|
12
|
+
readonly title: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
/** The button's text. */
|
|
15
|
+
readonly reload: string;
|
|
16
|
+
/** The button's action (`activate` from `useServiceWorkerUpdate`): the new build takes over and the page reloads. */
|
|
17
|
+
readonly onReload: () => void;
|
|
18
|
+
readonly className?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// The offer to reload into a new build: a floating alert at the bottom of the screen, above the home indicator and
|
|
22
|
+
// beside a notch (the safe-area insets), with a reload button at the touch height on a phone. It is a polite status,
|
|
23
|
+
// not an alert: the offer never interrupts what a screen reader is reading. The copy is the app's
|
|
24
|
+
// (`pwaMessages.en.update` in `@softure-ai/pwa` has the English text, keyed like these props).
|
|
25
|
+
export function UpdatePrompt({ open, title, description, reload, onReload, className }: UpdatePromptProps) {
|
|
26
|
+
if (!open) return null;
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
data-slot="update-prompt"
|
|
30
|
+
className={cn(
|
|
31
|
+
"pointer-events-none fixed inset-x-0 bottom-0 z-50 flex justify-center pt-4 pr-[calc(--spacing(4)+env(safe-area-inset-right))] pb-[calc(--spacing(4)+env(safe-area-inset-bottom))] pl-[calc(--spacing(4)+env(safe-area-inset-left))]",
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
34
|
+
>
|
|
35
|
+
<Alert role="status" aria-live="polite" className="pointer-events-auto max-w-md shadow-menu">
|
|
36
|
+
<RefreshCw strokeWidth={ICON_STROKE_WIDTH} />
|
|
37
|
+
<AlertTitle>{title}</AlertTitle>
|
|
38
|
+
<AlertDescription>
|
|
39
|
+
<p>{description}</p>
|
|
40
|
+
<Button size="touch" className="mt-1 md:h-7" onClick={onReload}>
|
|
41
|
+
{reload}
|
|
42
|
+
</Button>
|
|
43
|
+
</AlertDescription>
|
|
44
|
+
</Alert>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
package/src/ui/accordion.tsx
CHANGED
|
@@ -27,14 +27,18 @@ function AccordionItem({
|
|
|
27
27
|
function AccordionTrigger({
|
|
28
28
|
className,
|
|
29
29
|
children,
|
|
30
|
+
size = "default",
|
|
30
31
|
...props
|
|
31
|
-
}: React.ComponentProps<typeof AccordionPrimitive.Trigger>
|
|
32
|
+
}: React.ComponentProps<typeof AccordionPrimitive.Trigger> & {
|
|
33
|
+
size?: "default" | "touch"
|
|
34
|
+
}) {
|
|
32
35
|
return (
|
|
33
36
|
<AccordionPrimitive.Header className="flex">
|
|
34
37
|
<AccordionPrimitive.Trigger
|
|
35
38
|
data-slot="accordion-trigger"
|
|
36
39
|
className={cn(
|
|
37
40
|
"flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
|
|
41
|
+
size === "touch" && "min-h-touch-target",
|
|
38
42
|
className
|
|
39
43
|
)}
|
|
40
44
|
{...props}
|
package/src/ui/dialog.tsx
CHANGED
|
@@ -53,11 +53,17 @@ function DialogContent({
|
|
|
53
53
|
children,
|
|
54
54
|
showCloseButton = true,
|
|
55
55
|
closeLabel = messages.dialog.close,
|
|
56
|
+
closeButtonSize = "default",
|
|
57
|
+
size = "default",
|
|
56
58
|
...props
|
|
57
59
|
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
58
60
|
showCloseButton?: boolean
|
|
59
61
|
// The close button's hidden text, from the app's message layer.
|
|
60
62
|
closeLabel?: string
|
|
63
|
+
// `touch` draws the close button 44 x 44, centred on the same icon.
|
|
64
|
+
closeButtonSize?: "default" | "touch"
|
|
65
|
+
// `wide` is half the viewport from `lg`, `max-w-lg` below it.
|
|
66
|
+
size?: "default" | "wide"
|
|
61
67
|
}) {
|
|
62
68
|
return (
|
|
63
69
|
<DialogPortal data-slot="dialog-portal">
|
|
@@ -66,6 +72,7 @@ function DialogContent({
|
|
|
66
72
|
data-slot="dialog-content"
|
|
67
73
|
className={cn(
|
|
68
74
|
"fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl bg-background p-6 shadow-dialog duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
|
|
75
|
+
size === "wide" && "lg:max-w-1/2",
|
|
69
76
|
className
|
|
70
77
|
)}
|
|
71
78
|
{...props}
|
|
@@ -74,7 +81,11 @@ function DialogContent({
|
|
|
74
81
|
{showCloseButton && (
|
|
75
82
|
<DialogPrimitive.Close
|
|
76
83
|
data-slot="dialog-close"
|
|
77
|
-
className=
|
|
84
|
+
className={cn(
|
|
85
|
+
"absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
86
|
+
closeButtonSize === "touch" &&
|
|
87
|
+
"top-0.5 right-0.5 inline-flex size-touch-target items-center justify-center rounded-md"
|
|
88
|
+
)}
|
|
78
89
|
>
|
|
79
90
|
<XIcon />
|
|
80
91
|
<span className="sr-only">{closeLabel}</span>
|
|
@@ -98,10 +109,13 @@ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
98
109
|
function DialogFooter({
|
|
99
110
|
className,
|
|
100
111
|
showCloseButton = false,
|
|
112
|
+
closeLabel = messages.dialog.close,
|
|
101
113
|
children,
|
|
102
114
|
...props
|
|
103
115
|
}: React.ComponentProps<"div"> & {
|
|
104
116
|
showCloseButton?: boolean
|
|
117
|
+
// The close button's text, from the app's message layer.
|
|
118
|
+
closeLabel?: string
|
|
105
119
|
}) {
|
|
106
120
|
return (
|
|
107
121
|
<div
|
|
@@ -115,7 +129,7 @@ function DialogFooter({
|
|
|
115
129
|
{children}
|
|
116
130
|
{showCloseButton && (
|
|
117
131
|
<DialogPrimitive.Close asChild>
|
|
118
|
-
<Button variant="outline">
|
|
132
|
+
<Button variant="outline">{closeLabel}</Button>
|
|
119
133
|
</DialogPrimitive.Close>
|
|
120
134
|
)}
|
|
121
135
|
</div>
|