@vitavision/workbench 0.2.1 → 0.3.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/README.md +6 -5
- package/dist/index.d.ts +201 -7
- package/dist/index.js +260 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/AppShell.tsx +5 -13
- package/src/components/NavRail.tsx +198 -0
- package/src/components/PlaybackBar.tsx +6 -38
- package/src/components/SequenceNavigator.tsx +33 -8
- package/src/components/SplitPane.tsx +4 -14
- package/src/components/StatusBar.tsx +61 -0
- package/src/components/Stepper.tsx +146 -0
- package/src/components/TreeView.tsx +5 -24
- package/src/components/dropFiles.ts +2 -7
- package/src/components/splitSize.ts +3 -11
- package/src/components/stepperModel.ts +48 -0
- package/src/components/treeModel.ts +1 -3
- package/src/components/usePlayback.ts +11 -10
- package/src/index.ts +12 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitavision/workbench",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Studio-app building blocks on @vitavision/ui: app shell, split panes, tree view, playback bar and playhead store, file drop (toasts re-exported from @vitavision/ui).",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react-dom": "^19.2.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@vitavision/ui": "^0.
|
|
49
|
+
"@vitavision/ui": "^0.14.0",
|
|
50
50
|
"lucide-react": "^1.48.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
@@ -34,7 +34,8 @@ export interface AppShellProps {
|
|
|
34
34
|
header?: ReactNode;
|
|
35
35
|
/**
|
|
36
36
|
* A fixed-width column at the far left, outside the resizable panels: an icon rail of
|
|
37
|
-
* workspaces
|
|
37
|
+
* workspaces, such as a `NavRail`. It takes its content's width and is a `<nav>` named by
|
|
38
|
+
* `railLabel`.
|
|
38
39
|
*/
|
|
39
40
|
rail?: ReactNode;
|
|
40
41
|
/** Names the rail's landmark (`<nav>`). Defaults to "Workspaces". */
|
|
@@ -45,7 +46,7 @@ export interface AppShellProps {
|
|
|
45
46
|
main: ReactNode;
|
|
46
47
|
/** The panel right of the main surface — an inspector. */
|
|
47
48
|
right?: ReactNode;
|
|
48
|
-
/** The strip along the bottom, across the whole width — a `PlaybackBar`, a
|
|
49
|
+
/** The strip along the bottom, across the whole width — a `PlaybackBar`, a `StatusBar`. */
|
|
49
50
|
bottom?: ReactNode;
|
|
50
51
|
/** Names the left panel's landmark (`<aside>`). Defaults to "Navigator". */
|
|
51
52
|
leftLabel?: string | undefined;
|
|
@@ -133,17 +134,8 @@ export function AppShell({
|
|
|
133
134
|
);
|
|
134
135
|
|
|
135
136
|
return (
|
|
136
|
-
<div
|
|
137
|
-
className={
|
|
138
|
-
"grid h-dvh w-full grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden bg-ground text-fg",
|
|
139
|
-
className,
|
|
140
|
-
)}
|
|
141
|
-
>
|
|
142
|
-
{header ? (
|
|
143
|
-
<header className="min-w-0 border-b border-line bg-surface">{header}</header>
|
|
144
|
-
) : (
|
|
145
|
-
<div aria-hidden />
|
|
146
|
-
)}
|
|
137
|
+
<div className={cn("grid h-dvh w-full grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden bg-ground text-fg", className)}>
|
|
138
|
+
{header ? <header className="min-w-0 border-b border-line bg-surface">{header}</header> : <div aria-hidden />}
|
|
147
139
|
{hasRail ? (
|
|
148
140
|
<div className="flex min-h-0 min-w-0">
|
|
149
141
|
<nav aria-label={railLabel} className="h-full shrink-0 overflow-y-auto border-r border-line bg-surface">
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The workspaces of a studio app as a column of icons down its left edge: Library, Teach,
|
|
3
|
+
* Inspect. One is current; choosing another swaps the screen.
|
|
4
|
+
*
|
|
5
|
+
* Each item is a button, or — through `asChild` — the app's own link element, so a router's
|
|
6
|
+
* `<Link>` keeps client-side navigation and this package never imports a router.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
cloneElement,
|
|
11
|
+
createContext,
|
|
12
|
+
isValidElement,
|
|
13
|
+
use,
|
|
14
|
+
useId,
|
|
15
|
+
useState,
|
|
16
|
+
type HTMLAttributes,
|
|
17
|
+
type MouseEvent,
|
|
18
|
+
type ReactElement,
|
|
19
|
+
type ReactNode,
|
|
20
|
+
} from "react";
|
|
21
|
+
|
|
22
|
+
import { Tooltip, cn, focusRing } from "@vitavision/ui";
|
|
23
|
+
|
|
24
|
+
/** How a `NavRail` shows its items' labels. */
|
|
25
|
+
export type NavRailLabels = "visible" | "tooltip";
|
|
26
|
+
|
|
27
|
+
/** Props of `NavRail`. */
|
|
28
|
+
export interface NavRailProps {
|
|
29
|
+
/** The current item's `value`, or `null` for none. Leave undefined to let the rail keep it. */
|
|
30
|
+
value?: string | null | undefined;
|
|
31
|
+
/** The current item at first, when the rail keeps it (`value` undefined). */
|
|
32
|
+
defaultValue?: string | undefined;
|
|
33
|
+
/** Called with an item's `value` when a person chooses an item other than the current one. */
|
|
34
|
+
onValueChange?: ((value: string) => void) | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* `"visible"` (the default) sets each label under its icon; `"tooltip"` draws icon-only
|
|
37
|
+
* buttons and shows the label in a tooltip on hover or focus.
|
|
38
|
+
*/
|
|
39
|
+
labels?: NavRailLabels | undefined;
|
|
40
|
+
/** The `NavRailItem`s, in order. */
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
/** Merged with the list's own classes through `cn`. */
|
|
43
|
+
className?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Props of `NavRailItem`. */
|
|
47
|
+
export interface NavRailItemProps {
|
|
48
|
+
/** Identifies the item to the rail's `value`. Unique within the rail. */
|
|
49
|
+
value: string;
|
|
50
|
+
/** The item's name: its text under the icon, or its tooltip and accessible name. */
|
|
51
|
+
label: string;
|
|
52
|
+
/** The item's icon, decorative (`aria-hidden`): the label carries the meaning. */
|
|
53
|
+
icon: ReactNode;
|
|
54
|
+
/**
|
|
55
|
+
* A mark on the icon's corner: a number is drawn as a count (over 99 as "99+"), anything
|
|
56
|
+
* else as given. It describes the item (`aria-describedby`); it is not part of its name.
|
|
57
|
+
*/
|
|
58
|
+
badge?: ReactNode | number;
|
|
59
|
+
/** Shown but not choosable. A link item gets `aria-disabled` and its clicks are cancelled. */
|
|
60
|
+
disabled?: boolean | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Render onto the one child element — a router's `<Link to="…" />` or an `<a href>` —
|
|
63
|
+
* instead of a `<button>`. Give the child without content: the icon and label become its
|
|
64
|
+
* children. Its own `className` is kept beside the item's, and its own `onClick` runs first;
|
|
65
|
+
* calling `event.preventDefault()` there keeps the item from being chosen.
|
|
66
|
+
*/
|
|
67
|
+
asChild?: boolean | undefined;
|
|
68
|
+
/** With `asChild`, the one element to render as. */
|
|
69
|
+
children?: ReactElement | undefined;
|
|
70
|
+
/** Merged with the item's own classes through `cn`. */
|
|
71
|
+
className?: string | undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface NavRailState {
|
|
75
|
+
value: string | null;
|
|
76
|
+
labels: NavRailLabels;
|
|
77
|
+
choose: (value: string) => void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const NavRailContext = createContext<NavRailState | null>(null);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A vertical rail of workspaces: `NavRailItem`s as a list of buttons (or the app's links, via
|
|
84
|
+
* `asChild`), one of them current. Controlled with `value` and `onValueChange`, or kept by the
|
|
85
|
+
* rail from `defaultValue`.
|
|
86
|
+
*
|
|
87
|
+
* The current item carries `aria-current="page"` and `data-state="active"` (the others
|
|
88
|
+
* `"inactive"`). Every item is its own Tab stop. The rail is a plain list with no landmark of
|
|
89
|
+
* its own: `AppShell`'s `rail` slot is already a named `<nav>`, so elsewhere wrap it in a
|
|
90
|
+
* `<nav aria-label="…">`.
|
|
91
|
+
*/
|
|
92
|
+
export function NavRail({ value, defaultValue, onValueChange, labels = "visible", children, className }: NavRailProps) {
|
|
93
|
+
const [kept, setKept] = useState<string | null>(defaultValue ?? null);
|
|
94
|
+
const current = value === undefined ? kept : value;
|
|
95
|
+
const choose = (next: string) => {
|
|
96
|
+
if (next === current) return;
|
|
97
|
+
if (value === undefined) setKept(next);
|
|
98
|
+
onValueChange?.(next);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<NavRailContext value={{ value: current, labels, choose }}>
|
|
103
|
+
<ul data-labels={labels} className={cn("flex flex-col items-center gap-1 p-1.5", className)}>
|
|
104
|
+
{children}
|
|
105
|
+
</ul>
|
|
106
|
+
</NavRailContext>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* One workspace of a `NavRail`: an icon over its label, or an icon-only button with the label
|
|
112
|
+
* in a tooltip (the rail's `labels`). A `<button>` by default; with `asChild`, the one child
|
|
113
|
+
* element (the app's link) takes the item's look, `aria-current` and click.
|
|
114
|
+
*/
|
|
115
|
+
export function NavRailItem({ value, label, icon, badge, disabled = false, asChild = false, children, className }: NavRailItemProps) {
|
|
116
|
+
const rail = use(NavRailContext);
|
|
117
|
+
if (rail === null) throw new Error("NavRailItem must be rendered inside a NavRail.");
|
|
118
|
+
const badgeId = useId();
|
|
119
|
+
|
|
120
|
+
const active = rail.value === value;
|
|
121
|
+
const iconOnly = rail.labels === "tooltip";
|
|
122
|
+
const hasBadge = badge !== undefined && badge !== null && badge !== false;
|
|
123
|
+
|
|
124
|
+
const content = (
|
|
125
|
+
<>
|
|
126
|
+
<span aria-hidden className="relative grid place-items-center [&>svg]:size-4.5">
|
|
127
|
+
{icon}
|
|
128
|
+
{hasBadge && (
|
|
129
|
+
<span
|
|
130
|
+
id={badgeId}
|
|
131
|
+
data-badge=""
|
|
132
|
+
className={cn(
|
|
133
|
+
"absolute -top-1.5 left-[calc(100%-0.375rem)]",
|
|
134
|
+
typeof badge === "number" &&
|
|
135
|
+
"min-w-4 rounded-full bg-signal px-1 text-center font-mono text-[10px] leading-4 text-signal-fg tabular-nums",
|
|
136
|
+
)}
|
|
137
|
+
>
|
|
138
|
+
{typeof badge === "number" ? formatCount(badge) : badge}
|
|
139
|
+
</span>
|
|
140
|
+
)}
|
|
141
|
+
</span>
|
|
142
|
+
{!iconOnly && <span className="max-w-full truncate text-[10px] leading-tight">{label}</span>}
|
|
143
|
+
</>
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const shared = {
|
|
147
|
+
"aria-current": active ? ("page" as const) : undefined,
|
|
148
|
+
"aria-label": iconOnly ? label : undefined,
|
|
149
|
+
"aria-describedby": hasBadge ? badgeId : undefined,
|
|
150
|
+
"data-state": active ? "active" : "inactive",
|
|
151
|
+
"data-disabled": disabled ? "" : undefined,
|
|
152
|
+
};
|
|
153
|
+
const classes = cn(
|
|
154
|
+
"relative flex flex-col items-center justify-center gap-0.5 rounded-control text-fg-muted transition-colors",
|
|
155
|
+
iconOnly ? "size-9" : "w-14 px-1 py-1.5",
|
|
156
|
+
active ? "bg-signal/12 text-fg [&_svg]:text-signal" : "hover:bg-raised hover:text-fg",
|
|
157
|
+
disabled && "cursor-not-allowed opacity-50 hover:bg-transparent hover:text-fg-muted",
|
|
158
|
+
focusRing,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
let item: ReactElement;
|
|
162
|
+
if (asChild && isValidElement<ChildProps>(children)) {
|
|
163
|
+
const own = children.props;
|
|
164
|
+
// `@vitavision/ui` keeps its Slot to itself, and this package takes no Radix dependency of
|
|
165
|
+
// its own: the one child element is cloned with the item's props merged in.
|
|
166
|
+
// oxlint-disable-next-line react/no-clone-element -- the asChild merge, see above
|
|
167
|
+
item = cloneElement(children, {
|
|
168
|
+
...shared,
|
|
169
|
+
"aria-disabled": disabled ? true : undefined,
|
|
170
|
+
className: cn(classes, className, own.className),
|
|
171
|
+
onClick: (event: MouseEvent<HTMLElement>) => {
|
|
172
|
+
own.onClick?.(event);
|
|
173
|
+
if (disabled) {
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (!event.defaultPrevented) rail.choose(value);
|
|
178
|
+
},
|
|
179
|
+
children: content,
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
item = (
|
|
183
|
+
<button type="button" {...shared} disabled={disabled} onClick={() => rail.choose(value)} className={cn(classes, className)}>
|
|
184
|
+
{content}
|
|
185
|
+
</button>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return <li>{iconOnly ? <Tooltip content={label}>{item}</Tooltip> : item}</li>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** The props `asChild` reads from, and merges into, the child element. */
|
|
193
|
+
type ChildProps = HTMLAttributes<HTMLElement> & Partial<Record<`data-${string}`, string>>;
|
|
194
|
+
|
|
195
|
+
/** A badge count: up to 99 as is, more as "99+". */
|
|
196
|
+
function formatCount(count: number): string {
|
|
197
|
+
return count > 99 ? "99+" : String(count);
|
|
198
|
+
}
|
|
@@ -10,17 +10,7 @@
|
|
|
10
10
|
* named for what they do, the time in mono so it does not jitter as digits change.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
ChevronFirst,
|
|
15
|
-
ChevronLast,
|
|
16
|
-
Pause,
|
|
17
|
-
Play,
|
|
18
|
-
Repeat,
|
|
19
|
-
SkipBack,
|
|
20
|
-
SkipForward,
|
|
21
|
-
StepBack,
|
|
22
|
-
StepForward,
|
|
23
|
-
} from "lucide-react";
|
|
13
|
+
import { ChevronFirst, ChevronLast, Pause, Play, Repeat, SkipBack, SkipForward, StepBack, StepForward } from "lucide-react";
|
|
24
14
|
import type { ComponentPropsWithRef, KeyboardEvent, ReactNode } from "react";
|
|
25
15
|
|
|
26
16
|
import { type MeasureTone, Select, Slider, byDensity, cn, focusRing, toneColor, useDensity } from "@vitavision/ui";
|
|
@@ -131,11 +121,7 @@ export function PlaybackBar({
|
|
|
131
121
|
data-playing={playing ? "" : undefined}
|
|
132
122
|
data-empty={empty ? "" : undefined}
|
|
133
123
|
onKeyDown={onKeyDown}
|
|
134
|
-
className={cn(
|
|
135
|
-
"flex w-full min-w-0 items-center bg-surface",
|
|
136
|
-
byDensity(density, "gap-3 px-3 py-2", "gap-2 px-2 py-1"),
|
|
137
|
-
className,
|
|
138
|
-
)}
|
|
124
|
+
className={cn("flex w-full min-w-0 items-center bg-surface", byDensity(density, "gap-3 px-3 py-2", "gap-2 px-2 py-1"), className)}
|
|
139
125
|
>
|
|
140
126
|
<div className="flex shrink-0 items-center gap-0.5">
|
|
141
127
|
<BarButton label="Jump to start" onClick={() => seek(0)} disabled={empty || index === 0}>
|
|
@@ -151,22 +137,13 @@ export function PlaybackBar({
|
|
|
151
137
|
<BarButton label="Step back" onClick={() => seek(index - 1)} disabled={empty || index === 0}>
|
|
152
138
|
<StepBack className="size-4" aria-hidden />
|
|
153
139
|
</BarButton>
|
|
154
|
-
<BarButton
|
|
155
|
-
label={playing ? "Pause" : "Play"}
|
|
156
|
-
onClick={() => onPlayingChange(!playing)}
|
|
157
|
-
disabled={empty}
|
|
158
|
-
className="text-fg"
|
|
159
|
-
>
|
|
140
|
+
<BarButton label={playing ? "Pause" : "Play"} onClick={() => onPlayingChange(!playing)} disabled={empty} className="text-fg">
|
|
160
141
|
{playing ? <Pause className="size-4" aria-hidden /> : <Play className="size-4" aria-hidden />}
|
|
161
142
|
</BarButton>
|
|
162
143
|
<BarButton label="Step forward" onClick={() => seek(index + 1)} disabled={empty || index >= last}>
|
|
163
144
|
<StepForward className="size-4" aria-hidden />
|
|
164
145
|
</BarButton>
|
|
165
|
-
<BarButton
|
|
166
|
-
label="Next marker"
|
|
167
|
-
onClick={() => nextMarker && seek(nextMarker.index)}
|
|
168
|
-
disabled={nextMarker === undefined}
|
|
169
|
-
>
|
|
146
|
+
<BarButton label="Next marker" onClick={() => nextMarker && seek(nextMarker.index)} disabled={nextMarker === undefined}>
|
|
170
147
|
<SkipForward className="size-4" aria-hidden />
|
|
171
148
|
</BarButton>
|
|
172
149
|
<BarButton label="Jump to end" onClick={() => seek(last)} disabled={empty || index >= last}>
|
|
@@ -194,15 +171,7 @@ export function PlaybackBar({
|
|
|
194
171
|
))}
|
|
195
172
|
</div>
|
|
196
173
|
)}
|
|
197
|
-
<Slider
|
|
198
|
-
value={index}
|
|
199
|
-
onValueChange={seek}
|
|
200
|
-
min={0}
|
|
201
|
-
max={last}
|
|
202
|
-
step={1}
|
|
203
|
-
disabled={empty}
|
|
204
|
-
aria-label="Playback position"
|
|
205
|
-
/>
|
|
174
|
+
<Slider value={index} onValueChange={seek} min={0} max={last} step={1} disabled={empty} aria-label="Playback position" />
|
|
206
175
|
</div>
|
|
207
176
|
|
|
208
177
|
{/* Not an <output>: that is a live region, and this changes every frame. */}
|
|
@@ -270,8 +239,7 @@ function MarkerTick({
|
|
|
270
239
|
}
|
|
271
240
|
|
|
272
241
|
/** Props of the bar's icon button. */
|
|
273
|
-
interface BarButtonProps
|
|
274
|
-
extends Omit<ComponentPropsWithRef<"button">, "type" | "title" | "aria-label" | "aria-pressed" | "children"> {
|
|
242
|
+
interface BarButtonProps extends Omit<ComponentPropsWithRef<"button">, "type" | "title" | "aria-label" | "aria-pressed" | "children"> {
|
|
275
243
|
label: string;
|
|
276
244
|
pressed?: boolean | undefined;
|
|
277
245
|
children: ReactNode;
|
|
@@ -10,10 +10,21 @@
|
|
|
10
10
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
11
11
|
import { useEffect, useRef, type ReactNode } from "react";
|
|
12
12
|
|
|
13
|
-
import { Button, Kbd, cn, focusRing } from "@vitavision/ui";
|
|
13
|
+
import { Button, Kbd, StatusDot, cn, focusRing, type Tone } from "@vitavision/ui";
|
|
14
14
|
|
|
15
15
|
import { stepIndex } from "./sequence";
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* A per-item status — "not found" in a batch run, "rejected" by a reviewer — drawn as a dot in
|
|
19
|
+
* the thumbnail's corner and said in words in the item's name.
|
|
20
|
+
*/
|
|
21
|
+
export interface SequenceItemStatus {
|
|
22
|
+
/** The dot's colour, by meaning; also the item's `data-status`. */
|
|
23
|
+
tone: Tone;
|
|
24
|
+
/** The status in words, appended to the item's name and tooltip: `"frame_0003.bmp, not found"`. */
|
|
25
|
+
label: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
17
28
|
/** One item of a `SequenceNavigator`. */
|
|
18
29
|
export interface SequenceItem {
|
|
19
30
|
/** Its identity, unique in the sequence. */
|
|
@@ -22,6 +33,8 @@ export interface SequenceItem {
|
|
|
22
33
|
label: string;
|
|
23
34
|
/** A thumbnail URL, loaded lazily. Without it, the default rendering is the label. */
|
|
24
35
|
thumbnail?: string | undefined;
|
|
36
|
+
/** A status, drawn as a dot in the thumbnail's corner over any thumbnail rendering. */
|
|
37
|
+
status?: SequenceItemStatus | undefined;
|
|
25
38
|
}
|
|
26
39
|
|
|
27
40
|
/** Props of `SequenceNavigator`. */
|
|
@@ -49,8 +62,11 @@ export interface SequenceNavigatorProps {
|
|
|
49
62
|
* ("3 / 50").
|
|
50
63
|
*
|
|
51
64
|
* The current thumbnail carries `aria-current="true"` and `data-current`, has an outline,
|
|
52
|
-
* and is scrolled into view when it changes.
|
|
53
|
-
*
|
|
65
|
+
* and is scrolled into view when it changes. An item with a `status` shows a dot in its
|
|
66
|
+
* corner, carries `data-status` (the tone) and is named `"label, status"`. `[` and `]` step
|
|
67
|
+
* from anywhere outside a text field. Thumbnails load lazily, so a capture of thousands of
|
|
68
|
+
* frames opens at once. The strip is as wide as its thumbnails, so previous and next stay
|
|
69
|
+
* beside a short sequence; a long one scrolls.
|
|
54
70
|
*/
|
|
55
71
|
export function SequenceNavigator({
|
|
56
72
|
items,
|
|
@@ -104,22 +120,27 @@ export function SequenceNavigator({
|
|
|
104
120
|
disabled={items.length < 2 || atStart}
|
|
105
121
|
onClick={() => step(-1)}
|
|
106
122
|
/>
|
|
107
|
-
|
|
123
|
+
{/* The padding (and the matching scroll padding, for the current item scrolled into view)
|
|
124
|
+
is the room for the current ring and the focus outline: the scroller clips at its edge. */}
|
|
125
|
+
<ol ref={listRef} aria-label={ariaLabel} className="flex min-w-0 scroll-px-1 gap-1 overflow-x-auto p-1">
|
|
108
126
|
{items.map((item) => {
|
|
109
127
|
const current = item.id === value;
|
|
128
|
+
const { status } = item;
|
|
129
|
+
const name = status ? `${item.label}, ${status.label}` : item.label;
|
|
110
130
|
return (
|
|
111
131
|
<li key={item.id} className="shrink-0">
|
|
112
132
|
<button
|
|
113
133
|
type="button"
|
|
114
|
-
title={
|
|
115
|
-
aria-label={
|
|
134
|
+
title={name}
|
|
135
|
+
aria-label={name}
|
|
116
136
|
aria-current={current ? "true" : undefined}
|
|
117
137
|
data-current={current ? "" : undefined}
|
|
138
|
+
data-status={status?.tone}
|
|
118
139
|
onClick={() => {
|
|
119
140
|
if (!current) onValueChange(item.id);
|
|
120
141
|
}}
|
|
121
142
|
className={cn(
|
|
122
|
-
"block h-10 w-14 overflow-hidden rounded-control border border-line bg-raised text-fg",
|
|
143
|
+
"relative block h-10 w-14 overflow-hidden rounded-control border border-line bg-raised text-fg",
|
|
123
144
|
"data-current:ring-2 data-current:ring-signal",
|
|
124
145
|
focusRing,
|
|
125
146
|
)}
|
|
@@ -129,7 +150,11 @@ export function SequenceNavigator({
|
|
|
129
150
|
) : item.thumbnail ? (
|
|
130
151
|
<img src={item.thumbnail} alt="" loading="lazy" decoding="async" className="h-full w-full object-cover" />
|
|
131
152
|
) : (
|
|
132
|
-
<span className="block truncate px-1 font-mono text-[10px]">{item.label}</span>
|
|
153
|
+
<span className={cn("block truncate px-1 font-mono text-[10px]", status && "pr-3")}>{item.label}</span>
|
|
154
|
+
)}
|
|
155
|
+
{status && (
|
|
156
|
+
// The surface-coloured backing keeps the dot legible over any thumbnail.
|
|
157
|
+
<StatusDot tone={status.tone} className="absolute top-0.5 right-0.5 rounded-full bg-surface p-0.5" />
|
|
133
158
|
)}
|
|
134
159
|
</button>
|
|
135
160
|
</li>
|
|
@@ -12,12 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { useCallback, useId, useRef, useState } from "react";
|
|
15
|
-
import type {
|
|
16
|
-
CSSProperties,
|
|
17
|
-
KeyboardEvent,
|
|
18
|
-
PointerEvent as ReactPointerEvent,
|
|
19
|
-
ReactNode,
|
|
20
|
-
} from "react";
|
|
15
|
+
import type { CSSProperties, KeyboardEvent, PointerEvent as ReactPointerEvent, ReactNode } from "react";
|
|
21
16
|
|
|
22
17
|
import { cn, focusRing } from "@vitavision/ui";
|
|
23
18
|
|
|
@@ -117,9 +112,7 @@ export function SplitPane({
|
|
|
117
112
|
|
|
118
113
|
const limits = length === null ? null : resolveLimits(length, minSize, maxSize, collapsible);
|
|
119
114
|
const size =
|
|
120
|
-
controlledSize ??
|
|
121
|
-
internalSize ??
|
|
122
|
-
(length === null || limits === null ? null : clampSize(resolveSize(defaultSize, length), limits));
|
|
115
|
+
controlledSize ?? internalSize ?? (length === null || limits === null ? null : clampSize(resolveSize(defaultSize, length), limits));
|
|
123
116
|
const collapsed = size === 0;
|
|
124
117
|
const controlled = controlledSize !== undefined;
|
|
125
118
|
|
|
@@ -227,8 +220,7 @@ export function SplitPane({
|
|
|
227
220
|
// Before the first measurement (and on the server) the pane is sized by CSS alone, from
|
|
228
221
|
// the default; afterwards by the measured size. The limits stay in CSS too, so a window
|
|
229
222
|
// resize never pushes the pane outside them between two measurements.
|
|
230
|
-
const basis =
|
|
231
|
-
size !== null ? `${size}px` : typeof defaultSize === "number" ? `${defaultSize}px` : defaultSize;
|
|
223
|
+
const basis = size !== null ? `${size}px` : typeof defaultSize === "number" ? `${defaultSize}px` : defaultSize;
|
|
232
224
|
const cssSize = (value: PaneSize) => (typeof value === "number" ? `${value}px` : value);
|
|
233
225
|
const sizedStyle: CSSProperties = {
|
|
234
226
|
flex: `0 0 ${basis}`,
|
|
@@ -254,9 +246,7 @@ export function SplitPane({
|
|
|
254
246
|
{sizedPane === "start" ? first : second}
|
|
255
247
|
</div>
|
|
256
248
|
);
|
|
257
|
-
const rest = (
|
|
258
|
-
<div className={cn(paneClasses, "flex-1 basis-0")}>{sizedPane === "start" ? second : first}</div>
|
|
259
|
-
);
|
|
249
|
+
const rest = <div className={cn(paneClasses, "flex-1 basis-0")}>{sizedPane === "start" ? second : first}</div>;
|
|
260
250
|
|
|
261
251
|
return (
|
|
262
252
|
<div
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The status line along the foot of a studio app: what the app is doing and what it is
|
|
3
|
+
* showing — the duration of the last operation, the current frame, the model in use.
|
|
4
|
+
*
|
|
5
|
+
* Studio apps each grew one, and each placed, sized and spaced its facts differently. This is
|
|
6
|
+
* the one line, built from `ReadoutStrip`, so the facts read like the readouts everywhere else:
|
|
7
|
+
* mono, quiet labels, separated by a dot.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ReactNode } from "react";
|
|
11
|
+
|
|
12
|
+
import { ReadoutStrip, cn, type ReadoutItem } from "@vitavision/ui";
|
|
13
|
+
|
|
14
|
+
/** Props of `StatusBar`. */
|
|
15
|
+
export interface StatusBarProps {
|
|
16
|
+
/** The facts at the left end, in order. Items whose `value` is `null` or `undefined` are skipped. */
|
|
17
|
+
start?: ReadoutItem[] | undefined;
|
|
18
|
+
/** The facts at the right end, in order. Items whose `value` is `null` or `undefined` are skipped. */
|
|
19
|
+
end?: ReadoutItem[] | undefined;
|
|
20
|
+
/** Drawn between the two ends, e.g. a `ProgressBar` while an operation runs. */
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
/** Names the bar. Defaults to "Status". */
|
|
23
|
+
"aria-label"?: string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Announce changes to the bar's content politely (`role="status"`) instead of leaving it a
|
|
26
|
+
* plain named group. Defaults to false.
|
|
27
|
+
*/
|
|
28
|
+
live?: boolean | undefined;
|
|
29
|
+
/** Merged with the bar's own classes through `cn`. */
|
|
30
|
+
className?: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* One 24 px line of facts for `AppShell`'s `bottom` slot: a `ReadoutStrip` of `start` items at
|
|
35
|
+
* the left end, one of `end` items at the right end, and `children` between them.
|
|
36
|
+
*
|
|
37
|
+
* It is a `role="group"` named by `aria-label` ("Status"). With `live` it is a
|
|
38
|
+
* `role="status"` instead (a polite live region, and `data-live`), so a screen reader
|
|
39
|
+
* announces what changes in it: use that for facts worth hearing when they change (an
|
|
40
|
+
* operation finished), not for ones that change many times a second. The line does not wrap;
|
|
41
|
+
* keep it to a few short facts.
|
|
42
|
+
*/
|
|
43
|
+
export function StatusBar({ start, end, children, "aria-label": ariaLabel = "Status", live = false, className }: StatusBarProps) {
|
|
44
|
+
const hasChildren = children !== undefined && children !== null && children !== false;
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
role={live ? "status" : "group"}
|
|
48
|
+
aria-label={ariaLabel}
|
|
49
|
+
aria-live={live ? "polite" : undefined}
|
|
50
|
+
data-live={live ? "" : undefined}
|
|
51
|
+
className={cn("flex h-6 min-w-0 items-center gap-3 overflow-hidden px-3", className)}
|
|
52
|
+
>
|
|
53
|
+
{start && <ReadoutStrip items={start} className={STRIP} />}
|
|
54
|
+
{hasChildren && <div className="flex min-w-0 flex-1 items-center gap-2">{children}</div>}
|
|
55
|
+
{end && <ReadoutStrip items={end} className={cn(STRIP, "ml-auto")} />}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** One line: the strip's own wrapping would push the second line out of a 24 px bar. */
|
|
61
|
+
const STRIP = "shrink-0 flex-nowrap whitespace-nowrap";
|