@vvedantb/ui 0.59.4 → 0.61.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 +44 -1
- package/app/src/index.ts +6 -0
- package/app/src/settings/ThemeModePicker.tsx +94 -0
- package/dist/app/src/index.js +1 -0
- package/dist/app/src/settings/ThemeModePicker.js +126 -0
- package/dist/shell/src/SidebarAccountMenu.js +69 -8
- package/dist/shell/src/index.js +1 -1
- package/dist/src/client.js +3 -1
- package/dist/src/index.js +2 -1
- package/dist/src/ui/badge.js +3 -1
- package/dist/src/ui/button.js +31 -3
- package/dist/src/ui/confirm-dialog-parts.js +6 -0
- package/dist/src/ui/field.js +317 -0
- package/dist/src/ui/search-input.js +5 -0
- package/dist/src/ui/spinner.js +2 -1
- package/dist/src/ui/tabs.js +3 -1
- package/package.json +3 -3
- package/shell/src/SidebarAccountMenu.tsx +34 -9
- package/shell/src/index.ts +1 -1
- package/src/client.ts +3 -1
- package/src/index.ts +2 -1
- package/src/ui/__snapshots__/alt-wrappers.test.tsx.snap +1 -1
- package/src/ui/badge.tsx +2 -1
- package/src/ui/button.tsx +41 -8
- package/src/ui/confirm-dialog-parts.tsx +6 -1
- package/src/ui/confirm-dialog.tsx +3 -0
- package/src/ui/field.tsx +148 -0
- package/src/ui/search-input.tsx +3 -1
- package/src/ui/spinner.tsx +4 -3
- package/src/ui/tabs.tsx +2 -1
package/README.md
CHANGED
|
@@ -26,6 +26,31 @@ Removed in 0.4.0-rc.1: the `/cn`, `/sonner`, `/audio`, `/shell`, `/app`, `/compo
|
|
|
26
26
|
@source "../node_modules/@vvedantb/ui/src/**/*.{ts,tsx}";
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
## Component docs and gallery
|
|
30
|
+
|
|
31
|
+
The web gallery in the repository (`apps/ui-gallery`) renders the components below on one page, in light and dark. Run it with `pnpm --filter ui-gallery dev`. It is the web counterpart of `apps/native-gallery`.
|
|
32
|
+
|
|
33
|
+
Each doc has a default usage sample, a variant or props table, a composition example and the `@vvedantb/native-ui` equivalent.
|
|
34
|
+
|
|
35
|
+
| Component | Doc |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `Button` | [docs/components/button.md](docs/components/button.md) |
|
|
38
|
+
| `Input` | [docs/components/input.md](docs/components/input.md) |
|
|
39
|
+
| `SearchInput` | [docs/components/search-input.md](docs/components/search-input.md) |
|
|
40
|
+
| `Field` | [docs/components/field.md](docs/components/field.md) |
|
|
41
|
+
| `Dialog` | [docs/components/dialog.md](docs/components/dialog.md) |
|
|
42
|
+
| `Sheet` | [docs/components/sheet.md](docs/components/sheet.md) |
|
|
43
|
+
| `AlertDialog` | [docs/components/alert-dialog.md](docs/components/alert-dialog.md) |
|
|
44
|
+
| `ConfirmDialog` | [docs/components/confirm-dialog.md](docs/components/confirm-dialog.md) |
|
|
45
|
+
| `Tabs` | [docs/components/tabs.md](docs/components/tabs.md) |
|
|
46
|
+
| `TabsBar` | [docs/components/tabs-bar.md](docs/components/tabs-bar.md) |
|
|
47
|
+
| `Badge` | [docs/components/badge.md](docs/components/badge.md) |
|
|
48
|
+
| `Spinner` | [docs/components/spinner.md](docs/components/spinner.md) |
|
|
49
|
+
| `PageTitle` | [docs/components/page-title.md](docs/components/page-title.md) |
|
|
50
|
+
| `Conversation` | [docs/components/conversation.md](docs/components/conversation.md) |
|
|
51
|
+
| `Message` | [docs/components/message.md](docs/components/message.md) |
|
|
52
|
+
| `PromptInput` | [docs/components/prompt-input.md](docs/components/prompt-input.md) |
|
|
53
|
+
|
|
29
54
|
## Reply chime
|
|
30
55
|
|
|
31
56
|
```tsx
|
|
@@ -292,6 +317,24 @@ import {
|
|
|
292
317
|
```
|
|
293
318
|
|
|
294
319
|
- `Button`: variants `flat`, `success` and `warning` (each is `ghost` plus an override). `loading` disables the button, sets `data-loading="true"` and shows a spinner in place of `startContent`; without `loading` there is no `data-loading` attribute. `endContent` renders after the children. Both are ignored with `asChild` (`loading` still disables).
|
|
320
|
+
- `Button` aliases and recipes: `variant` accepts `primary` (= `default`), `tertiary` (= `ghost`) and `danger` (= `destructive`); `size` accepts `md` (= `default`). Roles: `primary`/`default` is the one main action, `secondary` an alternative, `tertiary`/`ghost` a dismissive action, `destructive`/`danger` a destructive action, `success` and `warning` show status, and `outline`, `link` and `flat` are visual. The omitted-prop defaults stay `"default"`. `buttonVariants`, `badgeVariants` and `tabsBarVariants` are the cva recipes; the types `ButtonVariant`, `ButtonSize` and `ButtonShape` are exported. Use a recipe to style a link like a button. `UiConfigProvider` overrides apply to the `Button` component only, not to raw `buttonVariants()` calls.
|
|
321
|
+
|
|
322
|
+
```tsx
|
|
323
|
+
<a href="/docs" className={buttonVariants({ variant: "default" })}>Read the docs</a>
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
- Sizes: the canonical scale is `sm`, `default` (or `md`) and `lg`. `Spinner` `size="default"` equals `md`. `SearchInput` `size="default"` equals `md` (`h-10`); its omitted default stays `sm`. `ConfirmDialog` sizes are width caps (`sm`/`md`: `sm:max-w-96`), not a scale.
|
|
327
|
+
- `Field`, `FieldLabel`, `FieldControl`, `FieldDescription`, `FieldError`: a labelled control with the wiring done for you. `Field` generates the id (or takes `controlId`); `FieldLabel` sets `htmlFor`; `FieldControl` is an `Input` with that `id`, an `aria-describedby` that lists the description and error ids only while they render, and `aria-invalid` while an error renders. A plain `<Input />` is unchanged.
|
|
328
|
+
|
|
329
|
+
```tsx
|
|
330
|
+
<Field>
|
|
331
|
+
<FieldLabel>Email</FieldLabel>
|
|
332
|
+
<FieldControl type="email" />
|
|
333
|
+
<FieldDescription>We never share it.</FieldDescription>
|
|
334
|
+
{error ? <FieldError>{error}</FieldError> : null}
|
|
335
|
+
</Field>
|
|
336
|
+
```
|
|
337
|
+
|
|
295
338
|
- `DropdownMenuContent`: `fitViewport` caps the height on small screens and scrolls. It reads the optional `--vv-height` CSS variable, which the app may set to the visual viewport height (falls back to `70dvh`). `suppressAltKey` stops a bare Alt press from moving focus. `restoreScrollLockOnClose` calls `restoreModalScrollLock` on close (now and on the next tick). `ContextMenuContent` takes `suppressAltKey` too.
|
|
296
339
|
- `DropdownMenuItem` `endContent` and `ContextMenuItem` `startContent`, `description` and `endContent`: the label moves into a growing column (`min-w-0 flex-1`), the description sits under it and `endContent` sits at the end. `DropdownMenuSubTrigger` and `ContextMenuSubTrigger` take `startContent`.
|
|
297
340
|
- `PopoverContent` `fitViewport`: grows from the trigger (`--radix-popper-transform-origin`) and, on small screens, caps width to `100vw - 1.5rem` and height as above.
|
|
@@ -1235,7 +1278,7 @@ Single-plan callers need no change. To move to the multi-plan layout, replace
|
|
|
1235
1278
|
|
|
1236
1279
|
`SidebarAccountMenu` takes three optional props. Without them it renders as before.
|
|
1237
1280
|
|
|
1238
|
-
- `themeToggle={{ isDark, onToggle }}`: a "Light mode" / "Dark mode" item after `children`.
|
|
1281
|
+
- `themeToggle={{ isDark, onToggle }}`: a "Light mode" / "Dark mode" item after `children`. Pass `{ theme, onToggle }` instead to cycle light, neutral, dark; `nextThemeInCycle(theme)` gives the theme `onToggle` must set.
|
|
1239
1282
|
- `signOut={{ onSignOut, description? }}`: a separator and a danger "Sign out" item, last. It opens `SignOutDialog`; Alt-click skips the dialog and `ConfirmSkipHint` shows while Alt is held. The menu owns the dialog state. If `onSignOut` rejects, the dialog buttons enable again.
|
|
1240
1283
|
- `itemIconSize`: `size` of those two items' icons. Default: the icon's own size.
|
|
1241
1284
|
|
package/app/src/index.ts
CHANGED
|
@@ -42,6 +42,12 @@ export {
|
|
|
42
42
|
export { SettingsField } from "./settings/SettingsField.js";
|
|
43
43
|
export { SettingsStack } from "./settings/SettingsStack.js";
|
|
44
44
|
export { SettingsToggleRow } from "./settings/SettingsToggleRow.js";
|
|
45
|
+
export {
|
|
46
|
+
THEME_MODES,
|
|
47
|
+
ThemeModePicker,
|
|
48
|
+
type ThemeMode,
|
|
49
|
+
type ThemeModePickerProps,
|
|
50
|
+
} from "./settings/ThemeModePicker.js";
|
|
45
51
|
export {
|
|
46
52
|
SettingsEmptyState,
|
|
47
53
|
type SettingsEmptyStateConfig,
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { IconCheck, IconCircleHalf, IconDeviceDesktop, IconMoon, IconSun } from "@tabler/icons-react";
|
|
2
|
+
import { ListEnter } from "../../../src/motion/list-enter";
|
|
3
|
+
import { cn } from "../cn.js";
|
|
4
|
+
|
|
5
|
+
/** A theme the picker can show. `neutral` is `.dark.neutral`. */
|
|
6
|
+
export type ThemeMode = "light" | "neutral" | "dark" | "system";
|
|
7
|
+
|
|
8
|
+
/** Default order: light to dark, then system. */
|
|
9
|
+
export const THEME_MODES = ["light", "neutral", "dark", "system"] as const satisfies readonly ThemeMode[];
|
|
10
|
+
|
|
11
|
+
const LABELS: Record<ThemeMode, string> = { light: "Light", neutral: "Neutral", dark: "Dark", system: "System" };
|
|
12
|
+
const ICONS = { light: IconSun, neutral: IconCircleHalf, dark: IconMoon, system: IconDeviceDesktop };
|
|
13
|
+
// Swatches show the theme itself, so they use fixed colours, not tokens.
|
|
14
|
+
const SWATCHES: Record<ThemeMode, string> = {
|
|
15
|
+
light: "bg-white",
|
|
16
|
+
neutral: "bg-zinc-700",
|
|
17
|
+
dark: "bg-zinc-900",
|
|
18
|
+
system: "bg-linear-to-br from-white to-zinc-900",
|
|
19
|
+
};
|
|
20
|
+
const ICON_COLOURS: Record<ThemeMode, string> = {
|
|
21
|
+
light: "text-amber-500",
|
|
22
|
+
neutral: "text-zinc-300",
|
|
23
|
+
dark: "text-blue-300",
|
|
24
|
+
system: "text-muted-foreground",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type ThemeModePickerProps = {
|
|
28
|
+
/** The selected theme (the stored choice, not the resolved one). */
|
|
29
|
+
value: string | undefined;
|
|
30
|
+
onChange: (mode: ThemeMode) => void;
|
|
31
|
+
/** Themes to show, in order. Default `THEME_MODES`. */
|
|
32
|
+
modes?: readonly ThemeMode[];
|
|
33
|
+
/** Smaller tiles in two columns, for menus and dialogs. Default `false`. */
|
|
34
|
+
compact?: boolean;
|
|
35
|
+
className?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Theme tiles for an Appearance settings section: a swatch, an icon and a
|
|
40
|
+
* label for each theme, and a check on the selected one. Two columns on a
|
|
41
|
+
* phone, one row from `sm`.
|
|
42
|
+
*/
|
|
43
|
+
export function ThemeModePicker({ value, onChange, modes = THEME_MODES, compact = false, className }: ThemeModePickerProps) {
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
role="group"
|
|
47
|
+
aria-label="Theme"
|
|
48
|
+
className={cn("grid", compact ? "grid-cols-2 gap-1.5" : "grid-cols-2 gap-2 sm:grid-cols-4", className)}
|
|
49
|
+
>
|
|
50
|
+
{modes.map((mode, index) => {
|
|
51
|
+
const active = value === mode;
|
|
52
|
+
const Icon = ICONS[mode];
|
|
53
|
+
return (
|
|
54
|
+
<ListEnter key={mode} index={index} fast slide={false} staggerMax={8} className="h-full">
|
|
55
|
+
<button
|
|
56
|
+
type="button"
|
|
57
|
+
aria-pressed={active}
|
|
58
|
+
onClick={() => onChange(mode)}
|
|
59
|
+
className={cn(
|
|
60
|
+
// The border shows the selected state; idle tiles keep a transparent one to hold their size.
|
|
61
|
+
"relative flex h-full w-full flex-col items-center rounded-surface border font-medium motion-press active:scale-[0.96]",
|
|
62
|
+
compact ? "gap-1 p-2 text-2xs" : "gap-2 p-3 text-xs sm:gap-3 sm:p-4 sm:text-sm",
|
|
63
|
+
active
|
|
64
|
+
? "border-border bg-primary/8 text-primary"
|
|
65
|
+
: "border-transparent bg-surface-secondary/40 text-muted-foreground hover:bg-surface-secondary/60 hover:text-foreground",
|
|
66
|
+
)}
|
|
67
|
+
>
|
|
68
|
+
{active ? (
|
|
69
|
+
<span
|
|
70
|
+
className={cn(
|
|
71
|
+
"absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground",
|
|
72
|
+
compact ? "right-1 top-1 size-3.5" : "right-2 top-2 size-4",
|
|
73
|
+
)}
|
|
74
|
+
>
|
|
75
|
+
<IconCheck size={compact ? 8 : 10} strokeWidth={3} />
|
|
76
|
+
</span>
|
|
77
|
+
) : null}
|
|
78
|
+
<div
|
|
79
|
+
className={cn(
|
|
80
|
+
"flex w-full items-center justify-center rounded-lg",
|
|
81
|
+
compact ? "h-8" : "h-12 sm:h-16",
|
|
82
|
+
SWATCHES[mode],
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
<Icon size={compact ? 14 : 22} className={ICON_COLOURS[mode]} />
|
|
86
|
+
</div>
|
|
87
|
+
{LABELS[mode]}
|
|
88
|
+
</button>
|
|
89
|
+
</ListEnter>
|
|
90
|
+
);
|
|
91
|
+
})}
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
}
|
package/dist/app/src/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { SettingsSection } from "./settings/SettingsSection.js";
|
|
|
9
9
|
export { SettingsField } from "./settings/SettingsField.js";
|
|
10
10
|
export { SettingsStack } from "./settings/SettingsStack.js";
|
|
11
11
|
export { SettingsToggleRow } from "./settings/SettingsToggleRow.js";
|
|
12
|
+
export { THEME_MODES, ThemeModePicker } from "./settings/ThemeModePicker.js";
|
|
12
13
|
export { SettingsEmptyState } from "./settings/SettingsEmptyState.js";
|
|
13
14
|
export { DefaultSettingsLayout, SettingsPage } from "./settings/SettingsPage.js";
|
|
14
15
|
export { createUseStableAuth, resetStableAuthSession, useStableAuth } from "./auth/useStableAuth.js";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { IconCheck, IconCircleHalf, IconDeviceDesktop, IconMoon, IconSun } from "@tabler/icons-react";
|
|
3
|
+
import { ListEnter } from "../../../src/motion/list-enter.js";
|
|
4
|
+
import { cn } from "../cn.js";
|
|
5
|
+
|
|
6
|
+
/** A theme the picker can show. `neutral` is `.dark.neutral`. */
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
/** Default order: light to dark, then system. */
|
|
9
|
+
export const THEME_MODES = ["light", "neutral", "dark", "system"];
|
|
10
|
+
const LABELS = {
|
|
11
|
+
light: "Light",
|
|
12
|
+
neutral: "Neutral",
|
|
13
|
+
dark: "Dark",
|
|
14
|
+
system: "System"
|
|
15
|
+
};
|
|
16
|
+
const ICONS = {
|
|
17
|
+
light: IconSun,
|
|
18
|
+
neutral: IconCircleHalf,
|
|
19
|
+
dark: IconMoon,
|
|
20
|
+
system: IconDeviceDesktop
|
|
21
|
+
};
|
|
22
|
+
// Swatches show the theme itself, so they use fixed colours, not tokens.
|
|
23
|
+
const SWATCHES = {
|
|
24
|
+
light: "bg-white",
|
|
25
|
+
neutral: "bg-zinc-700",
|
|
26
|
+
dark: "bg-zinc-900",
|
|
27
|
+
system: "bg-linear-to-br from-white to-zinc-900"
|
|
28
|
+
};
|
|
29
|
+
const ICON_COLOURS = {
|
|
30
|
+
light: "text-amber-500",
|
|
31
|
+
neutral: "text-zinc-300",
|
|
32
|
+
dark: "text-blue-300",
|
|
33
|
+
system: "text-muted-foreground"
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Theme tiles for an Appearance settings section: a swatch, an icon and a
|
|
37
|
+
* label for each theme, and a check on the selected one. Two columns on a
|
|
38
|
+
* phone, one row from `sm`.
|
|
39
|
+
*/
|
|
40
|
+
export function ThemeModePicker(t0) {
|
|
41
|
+
const $ = _c(15);
|
|
42
|
+
const {
|
|
43
|
+
value,
|
|
44
|
+
onChange,
|
|
45
|
+
modes: t1,
|
|
46
|
+
compact: t2,
|
|
47
|
+
className
|
|
48
|
+
} = t0;
|
|
49
|
+
const modes = t1 === undefined ? THEME_MODES : t1;
|
|
50
|
+
const compact = t2 === undefined ? false : t2;
|
|
51
|
+
const t3 = compact ? "grid-cols-2 gap-1.5" : "grid-cols-2 gap-2 sm:grid-cols-4";
|
|
52
|
+
let t4;
|
|
53
|
+
if ($[0] !== className || $[1] !== t3) {
|
|
54
|
+
t4 = cn("grid", t3, className);
|
|
55
|
+
$[0] = className;
|
|
56
|
+
$[1] = t3;
|
|
57
|
+
$[2] = t4;
|
|
58
|
+
} else {
|
|
59
|
+
t4 = $[2];
|
|
60
|
+
}
|
|
61
|
+
let t5;
|
|
62
|
+
if ($[3] !== compact || $[4] !== modes || $[5] !== onChange || $[6] !== value) {
|
|
63
|
+
let t6;
|
|
64
|
+
if ($[8] !== compact || $[9] !== onChange || $[10] !== value) {
|
|
65
|
+
t6 = (mode, index) => {
|
|
66
|
+
const active = value === mode;
|
|
67
|
+
const Icon = ICONS[mode];
|
|
68
|
+
return /*#__PURE__*/_jsx(ListEnter, {
|
|
69
|
+
index: index,
|
|
70
|
+
fast: true,
|
|
71
|
+
slide: false,
|
|
72
|
+
staggerMax: 8,
|
|
73
|
+
className: "h-full",
|
|
74
|
+
children: /*#__PURE__*/_jsxs("button", {
|
|
75
|
+
type: "button",
|
|
76
|
+
"aria-pressed": active,
|
|
77
|
+
onClick: () => onChange(mode),
|
|
78
|
+
className: cn("relative flex h-full w-full flex-col items-center rounded-surface border font-medium motion-press active:scale-[0.96]", compact ? "gap-1 p-2 text-2xs" : "gap-2 p-3 text-xs sm:gap-3 sm:p-4 sm:text-sm", active ? "border-border bg-primary/8 text-primary" : "border-transparent bg-surface-secondary/40 text-muted-foreground hover:bg-surface-secondary/60 hover:text-foreground"),
|
|
79
|
+
children: [active ? /*#__PURE__*/_jsx("span", {
|
|
80
|
+
className: cn("absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground", compact ? "right-1 top-1 size-3.5" : "right-2 top-2 size-4"),
|
|
81
|
+
children: /*#__PURE__*/_jsx(IconCheck, {
|
|
82
|
+
size: compact ? 8 : 10,
|
|
83
|
+
strokeWidth: 3
|
|
84
|
+
})
|
|
85
|
+
}) : null, /*#__PURE__*/_jsx("div", {
|
|
86
|
+
className: cn("flex w-full items-center justify-center rounded-lg", compact ? "h-8" : "h-12 sm:h-16", SWATCHES[mode]),
|
|
87
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
88
|
+
size: compact ? 14 : 22,
|
|
89
|
+
className: ICON_COLOURS[mode]
|
|
90
|
+
})
|
|
91
|
+
}), LABELS[mode]]
|
|
92
|
+
})
|
|
93
|
+
}, mode);
|
|
94
|
+
};
|
|
95
|
+
$[8] = compact;
|
|
96
|
+
$[9] = onChange;
|
|
97
|
+
$[10] = value;
|
|
98
|
+
$[11] = t6;
|
|
99
|
+
} else {
|
|
100
|
+
t6 = $[11];
|
|
101
|
+
}
|
|
102
|
+
t5 = modes.map(t6);
|
|
103
|
+
$[3] = compact;
|
|
104
|
+
$[4] = modes;
|
|
105
|
+
$[5] = onChange;
|
|
106
|
+
$[6] = value;
|
|
107
|
+
$[7] = t5;
|
|
108
|
+
} else {
|
|
109
|
+
t5 = $[7];
|
|
110
|
+
}
|
|
111
|
+
let t6;
|
|
112
|
+
if ($[12] !== t4 || $[13] !== t5) {
|
|
113
|
+
t6 = /*#__PURE__*/_jsx("div", {
|
|
114
|
+
role: "group",
|
|
115
|
+
"aria-label": "Theme",
|
|
116
|
+
className: t4,
|
|
117
|
+
children: t5
|
|
118
|
+
});
|
|
119
|
+
$[12] = t4;
|
|
120
|
+
$[13] = t5;
|
|
121
|
+
$[14] = t6;
|
|
122
|
+
} else {
|
|
123
|
+
t6 = $[14];
|
|
124
|
+
}
|
|
125
|
+
return t6;
|
|
126
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import { IconLogout, IconMoon, IconSun } from "@tabler/icons-react";
|
|
3
|
+
import { IconCircleHalf, IconLogout, IconMoon, IconSun } from "@tabler/icons-react";
|
|
4
4
|
import { ConfirmSkipHint, skipConfirmTitle } from "../../app/src/confirm/ConfirmSkipHint.js";
|
|
5
5
|
import { useRequestConfirm } from "../../app/src/confirm/useRequestConfirm.js";
|
|
6
6
|
import { Button } from "../../src/ui/button.js";
|
|
@@ -98,13 +98,9 @@ export function SidebarAccountMenu(t0) {
|
|
|
98
98
|
}
|
|
99
99
|
let t9;
|
|
100
100
|
if ($[12] !== itemIconSize || $[13] !== themeToggle) {
|
|
101
|
-
t9 = themeToggle ? /*#__PURE__*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
size: itemIconSize
|
|
105
|
-
}) : /*#__PURE__*/_jsx(IconMoon, {
|
|
106
|
-
size: itemIconSize
|
|
107
|
-
}), themeToggle.isDark ? "Light mode" : "Dark mode"]
|
|
101
|
+
t9 = themeToggle ? /*#__PURE__*/_jsx(ThemeItem, {
|
|
102
|
+
toggle: themeToggle,
|
|
103
|
+
iconSize: itemIconSize
|
|
108
104
|
}) : null;
|
|
109
105
|
$[12] = itemIconSize;
|
|
110
106
|
$[13] = themeToggle;
|
|
@@ -654,3 +650,68 @@ export function SidebarAccountMenuPlaceholder(t0) {
|
|
|
654
650
|
}
|
|
655
651
|
return t2;
|
|
656
652
|
}
|
|
653
|
+
/** The theme the menu item moves to: light, then neutral, then dark, then light. */
|
|
654
|
+
export function nextThemeInCycle(theme) {
|
|
655
|
+
if (theme === "dark") return "light";
|
|
656
|
+
if (theme === "neutral") return "dark";
|
|
657
|
+
return "neutral";
|
|
658
|
+
}
|
|
659
|
+
const THEME_ITEM = {
|
|
660
|
+
light: {
|
|
661
|
+
label: "Light mode",
|
|
662
|
+
Icon: IconSun
|
|
663
|
+
},
|
|
664
|
+
neutral: {
|
|
665
|
+
label: "Neutral mode",
|
|
666
|
+
Icon: IconCircleHalf
|
|
667
|
+
},
|
|
668
|
+
dark: {
|
|
669
|
+
label: "Dark mode",
|
|
670
|
+
Icon: IconMoon
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
function ThemeItem(t0) {
|
|
674
|
+
const $ = _c(9);
|
|
675
|
+
const {
|
|
676
|
+
toggle,
|
|
677
|
+
iconSize
|
|
678
|
+
} = t0;
|
|
679
|
+
const next = "theme" in toggle ? nextThemeInCycle(toggle.theme) : toggle.isDark ? "light" : "dark";
|
|
680
|
+
const {
|
|
681
|
+
label,
|
|
682
|
+
Icon
|
|
683
|
+
} = THEME_ITEM[next];
|
|
684
|
+
let t1;
|
|
685
|
+
if ($[0] !== toggle) {
|
|
686
|
+
t1 = () => toggle.onToggle();
|
|
687
|
+
$[0] = toggle;
|
|
688
|
+
$[1] = t1;
|
|
689
|
+
} else {
|
|
690
|
+
t1 = $[1];
|
|
691
|
+
}
|
|
692
|
+
let t2;
|
|
693
|
+
if ($[2] !== Icon || $[3] !== iconSize) {
|
|
694
|
+
t2 = /*#__PURE__*/_jsx(Icon, {
|
|
695
|
+
size: iconSize
|
|
696
|
+
});
|
|
697
|
+
$[2] = Icon;
|
|
698
|
+
$[3] = iconSize;
|
|
699
|
+
$[4] = t2;
|
|
700
|
+
} else {
|
|
701
|
+
t2 = $[4];
|
|
702
|
+
}
|
|
703
|
+
let t3;
|
|
704
|
+
if ($[5] !== label || $[6] !== t1 || $[7] !== t2) {
|
|
705
|
+
t3 = /*#__PURE__*/_jsxs(DropdownMenuItem, {
|
|
706
|
+
onSelect: t1,
|
|
707
|
+
children: [t2, label]
|
|
708
|
+
});
|
|
709
|
+
$[5] = label;
|
|
710
|
+
$[6] = t1;
|
|
711
|
+
$[7] = t2;
|
|
712
|
+
$[8] = t3;
|
|
713
|
+
} else {
|
|
714
|
+
t3 = $[8];
|
|
715
|
+
}
|
|
716
|
+
return t3;
|
|
717
|
+
}
|
package/dist/shell/src/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export { SidebarRail, RailTile, RailDivider, RailCollapseTile, shellDockTileProp
|
|
|
15
15
|
export { SidebarResizeHandle, useAppShellResize } from "./SidebarResize.js";
|
|
16
16
|
export { SidebarIconTooltip } from "./SidebarIconTooltip.js";
|
|
17
17
|
export { SidebarPanel } from "./SidebarPanel.js";
|
|
18
|
-
export { SidebarAccountMenu, SidebarAccountMenuPlaceholder } from "./SidebarAccountMenu.js";
|
|
18
|
+
export { SidebarAccountMenu, SidebarAccountMenuPlaceholder, nextThemeInCycle } from "./SidebarAccountMenu.js";
|
|
19
19
|
export { SignOutDialog } from "./SignOutDialog.js";
|
|
20
20
|
export { PageHeaderBar } from "./PageHeaderBar.js";
|
|
21
21
|
export { PageWrapper } from "./PageWrapper.js";
|
package/dist/src/client.js
CHANGED
|
@@ -58,6 +58,7 @@ export * from "./ui/alert-dialog.js";
|
|
|
58
58
|
export * from "./ui/confirm-dialog.js";
|
|
59
59
|
export * from "./ui/dropdown-menu.js";
|
|
60
60
|
export * from "./ui/empty-state.js";
|
|
61
|
+
export * from "./ui/field.js";
|
|
61
62
|
export * from "./ui/hover-card.js";
|
|
62
63
|
export * from "./ui/input.js";
|
|
63
64
|
export * from "./ui/label.js";
|
|
@@ -183,7 +184,7 @@ export { SidebarRail, RailTile, RailDivider, RailCollapseTile, shellDockTileProp
|
|
|
183
184
|
export { SidebarResizeHandle, useAppShellResize } from "../shell/src/SidebarResize.js";
|
|
184
185
|
export { SidebarIconTooltip } from "../shell/src/SidebarIconTooltip.js";
|
|
185
186
|
export { SidebarPanel } from "../shell/src/SidebarPanel.js";
|
|
186
|
-
export { SidebarAccountMenu, SidebarAccountMenuPlaceholder } from "../shell/src/SidebarAccountMenu.js";
|
|
187
|
+
export { SidebarAccountMenu, SidebarAccountMenuPlaceholder, nextThemeInCycle } from "../shell/src/SidebarAccountMenu.js";
|
|
187
188
|
export { SignOutDialog } from "../shell/src/SignOutDialog.js";
|
|
188
189
|
export { PageHeaderBar } from "../shell/src/PageHeaderBar.js";
|
|
189
190
|
export { PageWrapper } from "../shell/src/PageWrapper.js";
|
|
@@ -214,6 +215,7 @@ export { SettingsSection } from "../app/src/settings/SettingsSection.js";
|
|
|
214
215
|
export { SettingsField } from "../app/src/settings/SettingsField.js";
|
|
215
216
|
export { SettingsStack } from "../app/src/settings/SettingsStack.js";
|
|
216
217
|
export { SettingsToggleRow } from "../app/src/settings/SettingsToggleRow.js";
|
|
218
|
+
export { THEME_MODES, ThemeModePicker } from "../app/src/settings/ThemeModePicker.js";
|
|
217
219
|
export { SettingsEmptyState } from "../app/src/settings/SettingsEmptyState.js";
|
|
218
220
|
export { DefaultSettingsLayout, SettingsPage } from "../app/src/settings/SettingsPage.js";
|
|
219
221
|
export { applyThemeClass, createThemeProvider, getSystemTheme } from "../app/src/theme/createThemeProvider.js";
|
package/dist/src/index.js
CHANGED
|
@@ -54,6 +54,7 @@ export * from "./ui/alert-dialog.js";
|
|
|
54
54
|
export * from "./ui/confirm-dialog.js";
|
|
55
55
|
export * from "./ui/dropdown-menu.js";
|
|
56
56
|
export * from "./ui/empty-state.js";
|
|
57
|
+
export * from "./ui/field.js";
|
|
57
58
|
export * from "./ui/hover-card.js";
|
|
58
59
|
export * from "./ui/input.js";
|
|
59
60
|
export * from "./ui/label.js";
|
|
@@ -183,7 +184,7 @@ export { SidebarRail, RailTile, RailDivider, RailCollapseTile, shellDockTileProp
|
|
|
183
184
|
export { SidebarResizeHandle, useAppShellResize } from "../shell/src/SidebarResize.js";
|
|
184
185
|
export { SidebarIconTooltip } from "../shell/src/SidebarIconTooltip.js";
|
|
185
186
|
export { SidebarPanel } from "../shell/src/SidebarPanel.js";
|
|
186
|
-
export { SidebarAccountMenu, SidebarAccountMenuPlaceholder } from "../shell/src/SidebarAccountMenu.js";
|
|
187
|
+
export { SidebarAccountMenu, SidebarAccountMenuPlaceholder, nextThemeInCycle } from "../shell/src/SidebarAccountMenu.js";
|
|
187
188
|
export { SignOutDialog } from "../shell/src/SignOutDialog.js";
|
|
188
189
|
export { PageHeaderBar } from "../shell/src/PageHeaderBar.js";
|
|
189
190
|
export { PageWrapper } from "../shell/src/PageWrapper.js";
|
package/dist/src/ui/badge.js
CHANGED
|
@@ -13,7 +13,9 @@ const badgeVariantClasses = {
|
|
|
13
13
|
success: "border-success/25 bg-success/12 text-success",
|
|
14
14
|
warning: "border-warning/25 bg-warning/12 text-warning"
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
/** The class recipe of `Badge`. Ignores `UiConfig.Badge` overrides. */
|
|
18
|
+
export const badgeVariants = cva(badgeBaseClasses, {
|
|
17
19
|
variants: {
|
|
18
20
|
variant: badgeVariantClasses
|
|
19
21
|
},
|
package/dist/src/ui/button.js
CHANGED
|
@@ -7,12 +7,27 @@ import { useCn, useUiConfig } from "./ui-config.js";
|
|
|
7
7
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
const ghostClass = "text-muted-foreground hover:bg-surface-tertiary hover:text-foreground";
|
|
9
9
|
const buttonBaseClasses = "inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium tracking-normal transition-[transform,background-color,box-shadow,opacity,border-color] duration-200 ease-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 active:scale-[0.96] active:duration-[var(--motion-fast,150ms)] [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0";
|
|
10
|
+
const defaultVariantClass = "bg-primary text-primary-foreground hover:-translate-y-0.5 hover:opacity-90";
|
|
11
|
+
const destructiveVariantClass = "bg-[oklch(47.2%_0.195_25.7)] text-white hover:bg-[oklch(42.5%_0.185_25.7)]";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Variant hierarchy:
|
|
15
|
+
* - `primary` (alias of `default`): the one main action.
|
|
16
|
+
* - `secondary`: an alternative action.
|
|
17
|
+
* - `tertiary` (alias of `ghost`): a dismissive action.
|
|
18
|
+
* - `destructive` (alias `danger`): a destructive action.
|
|
19
|
+
* - `success`, `warning`: status.
|
|
20
|
+
* - `outline`, `link`, `flat`: visual treatments with no fixed role.
|
|
21
|
+
*/
|
|
10
22
|
const buttonVariantClasses = {
|
|
11
|
-
default:
|
|
12
|
-
|
|
23
|
+
default: defaultVariantClass,
|
|
24
|
+
primary: defaultVariantClass,
|
|
25
|
+
destructive: destructiveVariantClass,
|
|
26
|
+
danger: destructiveVariantClass,
|
|
13
27
|
outline: "border border-border bg-transparent text-foreground hover:bg-default",
|
|
14
28
|
secondary: "bg-default text-default-foreground hover:bg-default/78",
|
|
15
29
|
ghost: ghostClass,
|
|
30
|
+
tertiary: ghostClass,
|
|
16
31
|
link: "text-primary underline-offset-4 hover:underline active:scale-100",
|
|
17
32
|
// Ghost plus an override; tailwind-merge drops the clashing ghost classes.
|
|
18
33
|
flat: `${ghostClass} bg-transparent text-muted hover:bg-surface-tertiary hover:text-foreground`,
|
|
@@ -24,6 +39,8 @@ const buttonVariantClasses = {
|
|
|
24
39
|
// No radius here: `shape` sets it.
|
|
25
40
|
const buttonSizeClasses = {
|
|
26
41
|
default: "h-10 px-4 py-2",
|
|
42
|
+
// Alias of `default`, for the canonical sm / md / lg scale.
|
|
43
|
+
md: "h-10 px-4 py-2",
|
|
27
44
|
xs: "h-7 px-2 text-xs hit-target [&_svg:not([class*='size-'])]:size-3.5",
|
|
28
45
|
sm: "h-8 px-3 text-xs max-sm:hit-target",
|
|
29
46
|
lg: "h-11 px-6",
|
|
@@ -38,10 +55,21 @@ const buttonShapeClasses = {
|
|
|
38
55
|
pill: "rounded-full",
|
|
39
56
|
rounded: "rounded-lg"
|
|
40
57
|
};
|
|
58
|
+
|
|
59
|
+
/** `primary`, `tertiary` and `danger` alias `default`, `ghost` and `destructive`. */
|
|
60
|
+
|
|
61
|
+
/** `md` aliases `default` (`h-10`). */
|
|
62
|
+
|
|
41
63
|
// `rounded` keeps the smaller radius the two 28px sizes had.
|
|
42
64
|
const roundedSmallSizes = ["xs", "icon-xs"];
|
|
43
65
|
const roundedSmallClass = "rounded-md";
|
|
44
|
-
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The class recipe of `Button`, for links and other elements that should look
|
|
69
|
+
* like one: `<a className={buttonVariants({ variant: "default" })}>`. It
|
|
70
|
+
* ignores `UiConfig.Button` overrides; only the `Button` component applies those.
|
|
71
|
+
*/
|
|
72
|
+
export const buttonVariants = cva(buttonBaseClasses, {
|
|
45
73
|
variants: {
|
|
46
74
|
variant: buttonVariantClasses,
|
|
47
75
|
size: buttonSizeClasses,
|
|
@@ -9,6 +9,12 @@ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, D
|
|
|
9
9
|
import { Input } from "./input.js";
|
|
10
10
|
import { useUiConfig } from "./ui-config.js";
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Width caps, not a size scale. `"default"` keeps the dialog's own width;
|
|
14
|
+
* `"sm"` and `"md"` cap the content at `sm:max-w-96` from the `sm` breakpoint.
|
|
15
|
+
* They also change the padding and type of the parts (see each part).
|
|
16
|
+
*/
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* App-wide classes for the confirm dialog parts, merged after each part's
|
|
14
20
|
* size classes (so an app can tighten `md`'s padding or widen its content).
|