@tokamaq/ui 0.0.0-stage → 0.1.0-dev.1

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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -2
  3. package/lint/index.js +22 -0
  4. package/lint/oxlint.json +58 -0
  5. package/lint/plugin.js +411 -0
  6. package/package.json +82 -4
  7. package/src/avatar.tsx +34 -0
  8. package/src/button.tsx +109 -0
  9. package/src/chip.tsx +52 -0
  10. package/src/cn.ts +71 -0
  11. package/src/code-block.tsx +58 -0
  12. package/src/collapsible.tsx +76 -0
  13. package/src/command.tsx +101 -0
  14. package/src/dialog.tsx +93 -0
  15. package/src/file-name.tsx +41 -0
  16. package/src/fonts/Geist-Variable.woff2 +0 -0
  17. package/src/fonts/GeistMono-Variable.woff2 +0 -0
  18. package/src/fonts/OFL.txt +92 -0
  19. package/src/fonts.css +15 -0
  20. package/src/icon.tsx +30 -0
  21. package/src/icons.ts +23 -0
  22. package/src/index.ts +24 -0
  23. package/src/input.tsx +86 -0
  24. package/src/kbd.tsx +33 -0
  25. package/src/kit/command.tsx +45 -0
  26. package/src/kit/contrast.ts +31 -0
  27. package/src/kit/controls.tsx +233 -0
  28. package/src/kit/disclosure.tsx +39 -0
  29. package/src/kit/frame.tsx +34 -0
  30. package/src/kit/inputs.tsx +53 -0
  31. package/src/kit/kit.tsx +76 -0
  32. package/src/kit/overlays.tsx +79 -0
  33. package/src/kit/rows.tsx +160 -0
  34. package/src/kit/tokens.tsx +189 -0
  35. package/src/menu.tsx +99 -0
  36. package/src/resizable.tsx +40 -0
  37. package/src/row-list.tsx +65 -0
  38. package/src/row.tsx +147 -0
  39. package/src/scroll-area.tsx +64 -0
  40. package/src/select.tsx +67 -0
  41. package/src/status-icon.tsx +49 -0
  42. package/src/switch.tsx +73 -0
  43. package/src/tabs.tsx +44 -0
  44. package/src/textarea.tsx +30 -0
  45. package/src/theme.css +397 -0
  46. package/src/tooltip.tsx +40 -0
  47. package/tests/setup.ts +29 -0
package/src/button.tsx ADDED
@@ -0,0 +1,109 @@
1
+ /*
2
+ <Button variant="brand" onClick={merge}>Merge</Button>
3
+ <Button>Cancel</Button>
4
+ <Button variant="ghost" icon={icons.more} label="Thread actions" />
5
+
6
+ brand or primary: the one main action in a region. outline: the default.
7
+ destructive: only the button that deletes. ghost: icon buttons and quiet
8
+ actions. An icon-only button needs a label; it becomes its name.
9
+ quiet: ink text on a soft fill that strengthens on hover, for notice actions.
10
+ bare: colour-only hover for chrome icons, with a 12 px glyph in the usual target.
11
+
12
+ size: md (32) is the default. sm (24) is for quiet actions in dense rows and
13
+ dialogs, with 12 px text and a 14 px icon. lg (48) only matches a roomy row.
14
+ */
15
+ import { Button as Base } from "@ui-sdk/solid/button";
16
+ import { omit } from "solid-js";
17
+ import type { ComponentProps, JSX } from "@solidjs/web";
18
+ import { cn, tv } from "./cn.ts";
19
+ import { Icon } from "./icon.tsx";
20
+
21
+ export const buttonVariants = tv({
22
+ base: [
23
+ "relative inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-sm",
24
+ "text-row font-medium whitespace-nowrap select-none transition duration-200 focus-ring",
25
+ "disabled:cursor-default disabled:opacity-50 data-disabled:cursor-default data-disabled:opacity-50",
26
+ "aria-disabled:cursor-default aria-disabled:opacity-50 aria-disabled:hover:bg-transparent",
27
+ "data-pending:cursor-progress",
28
+ ],
29
+ variants: {
30
+ variant: {
31
+ // The white label is 4.7:1 on the dark brand fill and brightening drops it to
32
+ // 4.1, so hover fills the top to full brand instead of brightening. Press keeps
33
+ // the key's darkening, restated so it wins over the hover reset.
34
+ brand: [
35
+ "key from-brand to-brand/85 text-brand-ink",
36
+ "hover:to-brand hover:brightness-100 active:brightness-90",
37
+ ],
38
+ primary: "key from-ink to-ink/85 text-stage light:hover:brightness-150",
39
+ destructive: "key from-removed to-removed/85 text-stage",
40
+ outline: [
41
+ "border-b-2 border-edge-strong inset-ring inset-ring-edge-strong text-ink shadow-quiet",
42
+ "hover:bg-edge active:bg-edge-strong/45",
43
+ ],
44
+ ghost:
45
+ "text-ink-2 hover:bg-edge hover:text-ink active:bg-edge-strong/45 data-open:bg-edge data-open:text-ink",
46
+ quiet: "bg-edge/50 text-ink hover:bg-edge",
47
+ bare: "text-ink-3 transition-none hover:text-ink",
48
+ },
49
+ size: { sm: "h-6 px-2 gap-1 text-label", md: "h-8 px-3", lg: "h-12 px-4" },
50
+ iconOnly: { true: "px-0" },
51
+ },
52
+ compoundVariants: [
53
+ { iconOnly: true, size: "sm", class: "w-6" },
54
+ { iconOnly: true, size: "md", class: "w-8" },
55
+ { iconOnly: true, size: "lg", class: "w-12" },
56
+ { iconOnly: true, variant: "ghost", class: "text-ink-3" },
57
+ ],
58
+ defaultVariants: { variant: "outline", size: "md" },
59
+ });
60
+
61
+ export type ButtonVariant = "brand" | "primary" | "outline" | "destructive" | "ghost" | "quiet" | "bare";
62
+ export type ButtonSize = "sm" | "md" | "lg";
63
+
64
+ export type ButtonLook = { variant?: ButtonVariant; size?: ButtonSize; class?: string } & (
65
+ | {
66
+ icon?: string;
67
+ /** A mark of your own (an agent's logo, say) in the icon's place, before the text. */
68
+ lead?: JSX.Element;
69
+ label?: undefined;
70
+ children: JSX.Element;
71
+ }
72
+ | { icon: string; lead?: undefined; label: string; children?: undefined }
73
+ );
74
+
75
+ export const lookKeys = ["variant", "size", "icon", "lead", "label", "children", "class"] as const;
76
+
77
+ export function buttonClass(props: ButtonLook): string {
78
+ return cn(
79
+ buttonVariants({ variant: props.variant, size: props.size, iconOnly: props.label !== undefined }),
80
+ props.class,
81
+ );
82
+ }
83
+
84
+ export function ButtonContent(props: ButtonLook): JSX.Element {
85
+ return (
86
+ <>
87
+ {props.icon && (
88
+ <Icon path={props.icon} size={props.variant === "bare" ? 12 : props.size === "sm" ? 14 : undefined} />
89
+ )}
90
+ {/* Beside the text, never inside it: the text is trimmed to its cap height to sit dead
91
+ centre, and a mark inside that line moves the line's baseline to the mark's bottom edge. */}
92
+ {props.lead}
93
+ {props.children !== undefined && (
94
+ <span class={props.variant === "quiet" ? undefined : "text-trim"}>{props.children}</span>
95
+ )}
96
+ </>
97
+ );
98
+ }
99
+
100
+ export type ButtonProps = Omit<ComponentProps<typeof Base>, "children" | "class"> & ButtonLook;
101
+
102
+ export function Button(props: ButtonProps): JSX.Element {
103
+ const rest = omit(props, ...lookKeys);
104
+ return (
105
+ <Base {...rest} data-slot="button" class={buttonClass(props)} aria-label={props.label}>
106
+ <ButtonContent {...props} />
107
+ </Base>
108
+ );
109
+ }
package/src/chip.tsx ADDED
@@ -0,0 +1,52 @@
1
+ /*
2
+ <Chip>feat/csv-export</Chip>
3
+ <Chip tone="added" label="3 checks passed">✓ 3</Chip>
4
+
5
+ One small fact: 32 tall (24 with size="sm"), radius 8, a leading icon
6
+ in ink-3 when given. A tone chip carries
7
+ a sign or a number too, never colour alone. A chip is not a button.
8
+ */
9
+ import type { JSX } from "@solidjs/web";
10
+ import { cn, tv } from "./cn.ts";
11
+ import { Icon } from "./icon.tsx";
12
+
13
+ export const chipVariants = tv({
14
+ base: "inline-flex items-center gap-2 rounded-sm px-2 whitespace-nowrap",
15
+ variants: {
16
+ tone: {
17
+ neutral: "bg-chip text-ink-2",
18
+ added: "bg-added-tint text-added",
19
+ removed: "bg-removed-tint text-removed",
20
+ warn: "bg-warn-tint text-warn",
21
+ info: "bg-info-tint text-info",
22
+ },
23
+ size: { md: "h-8 text-row", sm: "h-6 text-label" },
24
+ mono: { true: "text-data" },
25
+ },
26
+ defaultVariants: { tone: "neutral", size: "md" },
27
+ });
28
+
29
+ export type ChipProps = {
30
+ tone?: "neutral" | "added" | "removed" | "warn" | "info";
31
+ size?: "sm" | "md";
32
+ mono?: boolean;
33
+ label?: string;
34
+ /** A 14 px icon path before the text (Paper's branch and PR chips). */
35
+ icon?: string;
36
+ class?: string;
37
+ children: JSX.Element;
38
+ };
39
+
40
+ export function Chip(props: ChipProps): JSX.Element {
41
+ return (
42
+ <span
43
+ data-slot="chip"
44
+ role={props.label ? "img" : undefined}
45
+ aria-label={props.label}
46
+ class={cn(chipVariants({ tone: props.tone, size: props.size, mono: props.mono }), props.class)}
47
+ >
48
+ {props.icon && <Icon path={props.icon} size={14} class="text-ink-3" />}
49
+ <span class="text-trim">{props.children}</span>
50
+ </span>
51
+ );
52
+ }
package/src/cn.ts ADDED
@@ -0,0 +1,71 @@
1
+ import {
2
+ clsx,
3
+ createTV,
4
+ extendTailwindMerge,
5
+ type ClassValue,
6
+ type TWMergeConfig,
7
+ } from "tailwind-variants/config";
8
+
9
+ const colors = [
10
+ "window",
11
+ "stage",
12
+ "tray",
13
+ "card",
14
+ "band",
15
+ "ink",
16
+ "ink-2",
17
+ "ink-3",
18
+ "added",
19
+ "removed",
20
+ "warn",
21
+ "info",
22
+ "added-tint",
23
+ "removed-tint",
24
+ "warn-tint",
25
+ "info-tint",
26
+ "brand",
27
+ "brand-text",
28
+ "brand-ink",
29
+ "brand-tint",
30
+ "edge",
31
+ "edge-strong",
32
+ "lip",
33
+ "highlight",
34
+ "hover",
35
+ "selected",
36
+ ];
37
+
38
+ // Teaches merging our scales and helpers, so cn("px-3", "px-row") keeps px-row.
39
+ export const twMergeConfig = {
40
+ extend: {
41
+ theme: {
42
+ color: colors,
43
+ text: ["read", "row", "label", "data"],
44
+ radius: ["xs", "sm", "md", "lg", "inner"],
45
+ spacing: ["0", "1", "2", "3", "4", "6", "8", "12", "16"],
46
+ shadow: ["raised", "quiet"],
47
+ "inset-shadow": ["highlight"],
48
+ container: ["read", "thread", "dialog", "menu"],
49
+ },
50
+ classGroups: {
51
+ h: ["h-row"],
52
+ px: ["px-row"],
53
+ py: ["py-line"],
54
+ density: ["density-roomy", "density-normal", "density-dense"],
55
+ surface: ["surface-window", "surface-stage", "surface-tray", "surface-card", "surface-band"],
56
+ nest: [{ nest: ["xs", "sm", "md", "lg"] }],
57
+ key: ["lip", "highlight"],
58
+ "focus-ring": ["focus-ring"],
59
+ "text-trim": ["text-trim"],
60
+ link: ["link"],
61
+ },
62
+ },
63
+ } satisfies TWMergeConfig;
64
+
65
+ const merge = extendTailwindMerge(twMergeConfig);
66
+
67
+ export function cn(...inputs: ClassValue[]): string {
68
+ return merge(clsx(inputs));
69
+ }
70
+
71
+ export const tv = createTV({ twMergeConfig });
@@ -0,0 +1,58 @@
1
+ /*
2
+ <CodeBlock code={source} language="ts" />
3
+
4
+ Code you could copy: mono 14/20 on the surface's hover tone, radius 12
5
+ with 4 padding, scrolling sideways instead of wrapping. The copy key sits
6
+ in the top row beside the language; after a copy it shows a check and
7
+ its name says Copied.
8
+ */
9
+ import { createSignal, onCleanup } from "solid-js";
10
+ import type { JSX } from "@solidjs/web";
11
+ import { Button } from "./button.tsx";
12
+ import { cn } from "./cn.ts";
13
+ import { icons } from "./icons.ts";
14
+
15
+ const copyIcon =
16
+ "M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM5.00242 8L5.00019 20H14.9998V8H5.00242ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6Z";
17
+
18
+ export function CodeBlock(props: {
19
+ code: string;
20
+ language?: string;
21
+ copy?: (text: string) => Promise<void>;
22
+ class?: string;
23
+ }): JSX.Element {
24
+ const [copied, setCopied] = createSignal(false, { ownedWrite: true });
25
+ let timer: ReturnType<typeof setTimeout> | undefined;
26
+ onCleanup(() => clearTimeout(timer));
27
+
28
+ async function copy() {
29
+ try {
30
+ await (props.copy ?? ((text) => navigator.clipboard.writeText(text)))(props.code);
31
+ } catch {
32
+ return;
33
+ }
34
+ clearTimeout(timer);
35
+ setCopied(true);
36
+ timer = setTimeout(() => setCopied(false), 1500);
37
+ }
38
+
39
+ return (
40
+ <figure
41
+ data-slot="code-block"
42
+ class={cn("m-0 flex min-w-0 flex-col rounded-md bg-hover p-1", props.class)}
43
+ >
44
+ <div class="flex items-center gap-2 ps-3">
45
+ <span class="min-w-0 flex-1 truncate text-data text-ink-3">{props.language}</span>
46
+ <Button
47
+ variant="ghost"
48
+ icon={copied() ? icons.check : copyIcon}
49
+ label={copied() ? "Copied" : "Copy code"}
50
+ onClick={() => void copy()}
51
+ />
52
+ </div>
53
+ <pre class="m-0 overflow-x-auto overflow-y-hidden px-3 pb-3 font-mono text-row text-ink">
54
+ <code>{props.code}</code>
55
+ </pre>
56
+ </figure>
57
+ );
58
+ }
@@ -0,0 +1,76 @@
1
+ /*
2
+ <Collapsible.Root>
3
+ <Collapsible.Trigger lead={<StatusIcon status="done" />} trail="12s">
4
+ Worked <span class="text-label text-ink-3">4 actions</span>
5
+ </Collapsible.Trigger>
6
+ <Collapsible.Panel>…</Collapsible.Panel>
7
+ </Collapsible.Root>
8
+
9
+ One row that opens a panel under it. The trigger is a 32 px row with radius
10
+ 8: a 16 lead, the summary, one quiet trail and a chevron that turns when
11
+ open. filled sits on the surface's hover tone; quiet is bare until hover.
12
+ */
13
+ import * as Base from "@ui-sdk/solid/collapsible";
14
+ import { omit } from "solid-js";
15
+ import type { ComponentProps, JSX } from "@solidjs/web";
16
+ import { cn, tv } from "./cn.ts";
17
+ import { Icon } from "./icon.tsx";
18
+ import { icons } from "./icons.ts";
19
+
20
+ type Classed<T extends (props: any) => JSX.Element> = Omit<ComponentProps<T>, "class"> & { class?: string };
21
+
22
+ export const triggerVariants = tv({
23
+ slots: {
24
+ root: [
25
+ "group/trigger flex h-8 min-w-0 cursor-pointer items-center gap-2 rounded-sm ps-2 pe-3",
26
+ "text-row text-ink-2 transition duration-200 focus-ring data-disabled:cursor-default",
27
+ ],
28
+ lead: "flex w-4 shrink-0 justify-center text-ink-3",
29
+ title: "flex min-w-0 flex-1 items-center gap-2 truncate",
30
+ trail: "shrink-0 text-data text-ink-3",
31
+ },
32
+ variants: {
33
+ variant: {
34
+ filled: { root: "bg-hover hover:bg-selected" },
35
+ quiet: { root: "hover:bg-hover" },
36
+ },
37
+ },
38
+ defaultVariants: { variant: "filled" },
39
+ });
40
+
41
+ export const Root = Base.Collapsible;
42
+
43
+ export function Trigger(
44
+ props: Omit<ComponentProps<typeof Base.CollapsibleTrigger>, "class" | "children"> & {
45
+ variant?: "filled" | "quiet";
46
+ lead?: JSX.Element;
47
+ trail?: JSX.Element;
48
+ class?: string;
49
+ children: JSX.Element;
50
+ },
51
+ ): JSX.Element {
52
+ const rest = omit(props, "variant", "lead", "trail", "class", "children");
53
+ const slots = () => triggerVariants({ variant: props.variant });
54
+ return (
55
+ <Base.CollapsibleTrigger {...rest} class={cn(slots().root(), props.class)}>
56
+ {props.lead && <span class={slots().lead()}>{props.lead}</span>}
57
+ <span class={slots().title()}>{props.children}</span>
58
+ {props.trail && <span class={slots().trail()}>{props.trail}</span>}
59
+ <span class="flex text-ink-3 transition duration-200 group-data-open/trigger:rotate-180">
60
+ <Icon path={icons.chevronDown} size={14} />
61
+ </span>
62
+ </Base.CollapsibleTrigger>
63
+ );
64
+ }
65
+
66
+ export function Panel(props: Classed<typeof Base.CollapsiblePanel>): JSX.Element {
67
+ return (
68
+ <Base.CollapsiblePanel
69
+ {...omit(props, "class")}
70
+ class={cn(
71
+ "transition duration-150 data-starting-style:opacity-0 data-ending-style:opacity-0",
72
+ props.class,
73
+ )}
74
+ />
75
+ );
76
+ }
@@ -0,0 +1,101 @@
1
+ /*
2
+ <Command.Root onAction={run}>
3
+ <Command.Search label="Search views and commands" placeholder="Search" />
4
+ <Command.Empty>Nothing matches.</Command.Empty>
5
+ <Command.List>
6
+ <Command.Group>
7
+ <Command.GroupLabel>Views</Command.GroupLabel>
8
+ <Command.Item value="notes" icon={notesIcon}>Notes</Command.Item>
9
+ </Command.Group>
10
+ </Command.List>
11
+ </Command.Root>
12
+
13
+ A search row over a list of 32 rows with radius 8. Put it in a
14
+ Dialog.Content with p-1 and rounded-md for a palette. Keys go in the
15
+ item's children as a Kbd; they show, they are not bound here.
16
+ */
17
+ import * as Base from "@ui-sdk/solid/command";
18
+ import { omit } from "solid-js";
19
+ import type { ComponentProps, JSX } from "@solidjs/web";
20
+ import { cn } from "./cn.ts";
21
+ import { Icon } from "./icon.tsx";
22
+ import { icons } from "./icons.ts";
23
+ import { itemClass } from "./menu.tsx";
24
+
25
+ type Classed<T extends (props: any) => JSX.Element> = Omit<ComponentProps<T>, "class"> & { class?: string };
26
+
27
+ export function Root(props: Classed<typeof Base.Command>) {
28
+ return <Base.Command {...omit(props, "class")} class={cn("flex min-h-0 flex-col", props.class)} />;
29
+ }
30
+
31
+ export function Search(
32
+ props: Omit<ComponentProps<typeof Base.CommandInput>, "class" | "aria-label"> & {
33
+ label: string;
34
+ class?: string;
35
+ },
36
+ ) {
37
+ return (
38
+ <div class={cn("flex h-12 shrink-0 items-center gap-2 px-3 text-ink-3", props.class)}>
39
+ <Icon path={icons.search} />
40
+ <Base.CommandInput
41
+ {...omit(props, "class", "label")}
42
+ aria-label={props.label}
43
+ class="h-full min-w-0 flex-1 border-0 bg-transparent text-row text-ink outline-none placeholder:text-ink-3"
44
+ />
45
+ </div>
46
+ );
47
+ }
48
+
49
+ export function List(props: Classed<typeof Base.CommandList>) {
50
+ return (
51
+ <Base.CommandList
52
+ {...omit(props, "class")}
53
+ class={cn("flex min-h-0 flex-col gap-1 overflow-y-auto empty:hidden", props.class)}
54
+ />
55
+ );
56
+ }
57
+
58
+ export function Empty(props: Classed<typeof Base.CommandEmpty>) {
59
+ return (
60
+ <Base.CommandEmpty
61
+ {...omit(props, "class")}
62
+ class={cn("hidden px-3 pt-2 pb-4 text-row text-ink-3 data-empty:block", props.class)}
63
+ />
64
+ );
65
+ }
66
+
67
+ export const Group = Base.CommandGroup;
68
+
69
+ export function GroupLabel(props: Classed<typeof Base.CommandGroupLabel>) {
70
+ return (
71
+ <Base.CommandGroupLabel
72
+ {...omit(props, "class")}
73
+ class={cn("flex h-8 items-center px-2 text-label text-ink-3", props.class)}
74
+ />
75
+ );
76
+ }
77
+
78
+ export function Item(props: Classed<typeof Base.CommandItem> & { icon?: string }) {
79
+ return (
80
+ <Base.CommandItem
81
+ {...omit(props, "class", "icon", "children")}
82
+ class={cn(
83
+ itemClass,
84
+ "cursor-pointer data-pending:cursor-progress *:data-[slot=kbd]:ms-auto *:data-[slot=kbd]:ps-4",
85
+ props.class,
86
+ )}
87
+ >
88
+ {props.icon && <Icon path={props.icon} class="text-ink-3" />}
89
+ {props.children}
90
+ </Base.CommandItem>
91
+ );
92
+ }
93
+
94
+ export function Separator(props: Classed<typeof Base.CommandSeparator>) {
95
+ return (
96
+ <Base.CommandSeparator
97
+ {...omit(props, "class")}
98
+ class={cn("-mx-1 my-1 h-px border-0 bg-edge", props.class)}
99
+ />
100
+ );
101
+ }
package/src/dialog.tsx ADDED
@@ -0,0 +1,93 @@
1
+ /*
2
+ <Dialog.Root>
3
+ <Dialog.Trigger>Rename</Dialog.Trigger>
4
+ <Dialog.Backdrop />
5
+ <Dialog.Content>
6
+ <Dialog.Title>Rename thread</Dialog.Title>
7
+ <Dialog.Description>Only you see the new name.</Dialog.Description>
8
+ <div class="flex justify-end gap-2">
9
+ <Dialog.Close>Cancel</Dialog.Close>
10
+ <Dialog.Close variant="brand">Save</Dialog.Close>
11
+ </div>
12
+ </Dialog.Content>
13
+ </Dialog.Root>
14
+
15
+ A stage panel, radius 16, padding 24, at most 440 wide, over a dimmed
16
+ window. Trigger and Close take the Button look props.
17
+ */
18
+ import * as Base from "@ui-sdk/solid/dialog";
19
+ import { omit } from "solid-js";
20
+ import type { ComponentProps, JSX } from "@solidjs/web";
21
+ import { ButtonContent, buttonClass, lookKeys, type ButtonLook } from "./button.tsx";
22
+ import { cn } from "./cn.ts";
23
+
24
+ type Classed<T extends (props: any) => JSX.Element> = Omit<ComponentProps<T>, "class"> & { class?: string };
25
+
26
+ export const Root = Base.Dialog;
27
+
28
+ export function Trigger(
29
+ props: Omit<ComponentProps<typeof Base.DialogTrigger>, "children" | "class"> & ButtonLook,
30
+ ) {
31
+ const rest = omit(props, ...lookKeys);
32
+ return (
33
+ <Base.DialogTrigger {...rest} class={buttonClass(props)} aria-label={props.label}>
34
+ <ButtonContent {...props} />
35
+ </Base.DialogTrigger>
36
+ );
37
+ }
38
+
39
+ export function Close(
40
+ props: Omit<ComponentProps<typeof Base.DialogClose>, "children" | "class"> & ButtonLook,
41
+ ) {
42
+ const rest = omit(props, ...lookKeys);
43
+ return (
44
+ <Base.DialogClose {...rest} class={buttonClass(props)} aria-label={props.label}>
45
+ <ButtonContent {...props} />
46
+ </Base.DialogClose>
47
+ );
48
+ }
49
+
50
+ export function Backdrop(props: Classed<typeof Base.DialogBackdrop>) {
51
+ return (
52
+ <Base.DialogBackdrop
53
+ {...omit(props, "class")}
54
+ class={cn(
55
+ "fixed inset-0 z-50 bg-window/70 transition duration-150 data-starting-style:opacity-0 data-ending-style:opacity-0",
56
+ props.class,
57
+ )}
58
+ />
59
+ );
60
+ }
61
+
62
+ export function Content(props: Classed<typeof Base.DialogContent>) {
63
+ return (
64
+ <Base.DialogContent
65
+ {...omit(props, "class")}
66
+ class={cn(
67
+ // The library renders a plain element, not a native modal: place and stack it here.
68
+ "fixed inset-0 z-50 m-auto flex h-fit max-h-dvh w-full max-w-dialog flex-col gap-2 overflow-auto rounded-lg border-0",
69
+ "surface-stage p-6 inset-ring inset-ring-edge backdrop:bg-window/70",
70
+ "transition duration-150 data-starting-style:opacity-0 data-ending-style:opacity-0",
71
+ props.class,
72
+ )}
73
+ />
74
+ );
75
+ }
76
+
77
+ export function Title(props: Classed<typeof Base.DialogTitle>) {
78
+ return (
79
+ <Base.DialogTitle
80
+ {...omit(props, "class")}
81
+ class={cn("m-0 text-read font-semibold text-ink", props.class)}
82
+ />
83
+ );
84
+ }
85
+
86
+ export function Description(props: Classed<typeof Base.DialogDescription>) {
87
+ return (
88
+ <Base.DialogDescription
89
+ {...omit(props, "class")}
90
+ class={cn("m-0 mb-4 text-row text-ink-2", props.class)}
91
+ />
92
+ );
93
+ }
@@ -0,0 +1,41 @@
1
+ /*
2
+ <FileName path="src/invoices/InvoiceTable.tsx" />
3
+
4
+ A file name that truncates in the base name and keeps its extension. The
5
+ folder shows as a data prefix when there is room; the full path is the
6
+ accessible name and the tooltip.
7
+ */
8
+ import type { JSX } from "@solidjs/web";
9
+ import { cn } from "./cn.ts";
10
+
11
+ export function splitPath(path: string): { folder: string; base: string; extension: string } {
12
+ const slash = path.lastIndexOf("/") + 1;
13
+ const name = path.slice(slash);
14
+ const dot = name.lastIndexOf(".");
15
+ const cut = dot > 0 ? dot : name.length;
16
+ return { folder: path.slice(0, slash), base: name.slice(0, cut), extension: name.slice(cut) };
17
+ }
18
+
19
+ export function FileName(props: { path: string; folder?: boolean; class?: string }): JSX.Element {
20
+ const parts = () => splitPath(props.path);
21
+ return (
22
+ <span
23
+ data-slot="file-name"
24
+ title={props.path}
25
+ aria-label={props.path}
26
+ class={cn("flex min-w-0 items-baseline", props.class)}
27
+ >
28
+ {props.folder !== false && parts().folder && (
29
+ <span aria-hidden="true" class="min-w-0 truncate pe-1 text-data text-ink-3">
30
+ {parts().folder}
31
+ </span>
32
+ )}
33
+ <span aria-hidden="true" class="min-w-0 truncate">
34
+ {parts().base}
35
+ </span>
36
+ <span aria-hidden="true" class="shrink-0">
37
+ {parts().extension}
38
+ </span>
39
+ </span>
40
+ );
41
+ }
Binary file