@syscore/ui-library 2.0.0-beta-publish-workflow-beta.9 → 2.0.0-beta-publish-workflow-beta.11
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/client/components/ui/avatar-identity.tsx +16 -3
- package/client/components/ui/avatar.tsx +32 -4
- package/client/components/ui/back-link.tsx +35 -0
- package/client/components/ui/card.tsx +20 -3
- package/client/components/ui/centered-page.tsx +27 -0
- package/client/components/ui/checkbox-field.tsx +57 -0
- package/client/components/ui/dialog.tsx +6 -0
- package/client/components/ui/icon-button.tsx +45 -0
- package/client/components/ui/layout.tsx +32 -5
- package/client/components/ui/modal-panel.tsx +35 -4
- package/client/components/ui/outline-node.tsx +112 -0
- package/client/components/ui/radio-card.tsx +54 -0
- package/client/components/ui/resource-thumbnail.tsx +12 -1
- package/client/components/ui/side-nav.tsx +126 -0
- package/client/components/ui/status-pill.tsx +37 -4
- package/client/components/ui/table.tsx +26 -4
- package/client/components/ui/typography.tsx +29 -2
- package/client/global.css +815 -9
- package/client/ui/Avatar.stories.tsx +78 -0
- package/client/ui/BackLink.stories.tsx +50 -0
- package/client/ui/Card.stories.tsx +30 -0
- package/client/ui/CenteredPage.stories.tsx +43 -0
- package/client/ui/CheckboxField.stories.tsx +68 -0
- package/client/ui/Dialog.stories.tsx +31 -0
- package/client/ui/IconButton.stories.tsx +77 -0
- package/client/ui/OutlineNode.stories.tsx +106 -0
- package/client/ui/RadioCard.stories.tsx +75 -0
- package/client/ui/SideNav.stories.tsx +68 -0
- package/client/ui/StatusPill.stories.tsx +78 -0
- package/client/ui/Table/Table.stories.tsx +32 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +84 -0
- package/dist/index.es.js +398 -40
- package/package.json +1 -1
|
@@ -14,10 +14,16 @@ const avatarIdentityVariants = cva("avatar-identity", {
|
|
|
14
14
|
right: "avatar-identity--right",
|
|
15
15
|
left: "avatar-identity--left",
|
|
16
16
|
},
|
|
17
|
+
/** `soft` — a table-row identity: pale initials disc, no ring, name over a quieter email. */
|
|
18
|
+
appearance: {
|
|
19
|
+
default: "",
|
|
20
|
+
soft: "avatar-identity--soft",
|
|
21
|
+
},
|
|
17
22
|
},
|
|
18
23
|
defaultVariants: {
|
|
19
24
|
size: "xlarge",
|
|
20
25
|
textDirection: "right",
|
|
26
|
+
appearance: "default",
|
|
21
27
|
},
|
|
22
28
|
});
|
|
23
29
|
|
|
@@ -38,6 +44,8 @@ export interface AvatarIdentityProps
|
|
|
38
44
|
email?: string;
|
|
39
45
|
/** Override initials. Defaults to the first letters of `name`. */
|
|
40
46
|
initials?: string;
|
|
47
|
+
/** A glyph shown on the face instead of initials (for an account with no readable name). */
|
|
48
|
+
icon?: React.ReactNode;
|
|
41
49
|
src?: string;
|
|
42
50
|
alt?: string;
|
|
43
51
|
showText?: boolean;
|
|
@@ -59,10 +67,12 @@ const AvatarIdentity = React.forwardRef<HTMLDivElement, AvatarIdentityProps>(
|
|
|
59
67
|
className,
|
|
60
68
|
size,
|
|
61
69
|
textDirection,
|
|
70
|
+
appearance,
|
|
62
71
|
variant = "placeholder",
|
|
63
72
|
name = "",
|
|
64
73
|
email = "",
|
|
65
74
|
initials,
|
|
75
|
+
icon,
|
|
66
76
|
src,
|
|
67
77
|
alt,
|
|
68
78
|
showText = true,
|
|
@@ -76,7 +86,10 @@ const AvatarIdentity = React.forwardRef<HTMLDivElement, AvatarIdentityProps>(
|
|
|
76
86
|
return (
|
|
77
87
|
<div
|
|
78
88
|
ref={ref}
|
|
79
|
-
className={cn(
|
|
89
|
+
className={cn(
|
|
90
|
+
avatarIdentityVariants({ size, textDirection, appearance }),
|
|
91
|
+
className,
|
|
92
|
+
)}
|
|
80
93
|
{...props}
|
|
81
94
|
>
|
|
82
95
|
<div className="avatar-identity__face" data-face={face}>
|
|
@@ -90,7 +103,7 @@ const AvatarIdentity = React.forwardRef<HTMLDivElement, AvatarIdentityProps>(
|
|
|
90
103
|
|
|
91
104
|
{face === "initials" ? (
|
|
92
105
|
<span className="avatar-identity__initials" aria-hidden={showText}>
|
|
93
|
-
{letters}
|
|
106
|
+
{icon ?? letters}
|
|
94
107
|
</span>
|
|
95
108
|
) : null}
|
|
96
109
|
|
|
@@ -110,7 +123,7 @@ const AvatarIdentity = React.forwardRef<HTMLDivElement, AvatarIdentityProps>(
|
|
|
110
123
|
{showText ? (
|
|
111
124
|
<div className="avatar-identity__text">
|
|
112
125
|
<p className="avatar-identity__name">{name}</p>
|
|
113
|
-
<p className="avatar-identity__email">{email}</p>
|
|
126
|
+
{email ? <p className="avatar-identity__email">{email}</p> : null}
|
|
114
127
|
</div>
|
|
115
128
|
) : null}
|
|
116
129
|
</div>
|
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
4
|
|
|
4
5
|
import { cn } from "@/lib/utils";
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Avatar sizes and the `brand` look (initials on the brand teal, with a thin gradient ring —
|
|
9
|
+
* the signed-in user's disc in a header). Defaults reproduce the previous avatar exactly.
|
|
10
|
+
*/
|
|
11
|
+
const avatarVariants = cva("avatar", {
|
|
12
|
+
variants: {
|
|
13
|
+
size: {
|
|
14
|
+
sm: "avatar--sm",
|
|
15
|
+
md: "",
|
|
16
|
+
lg: "avatar--lg",
|
|
17
|
+
xl: "avatar--xl",
|
|
18
|
+
},
|
|
19
|
+
appearance: {
|
|
20
|
+
default: "",
|
|
21
|
+
brand: "avatar--brand",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
size: "md",
|
|
26
|
+
appearance: "default",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export interface AvatarProps
|
|
31
|
+
extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>,
|
|
32
|
+
VariantProps<typeof avatarVariants> {}
|
|
33
|
+
|
|
6
34
|
const Avatar = React.forwardRef<
|
|
7
35
|
React.ElementRef<typeof AvatarPrimitive.Root>,
|
|
8
|
-
|
|
9
|
-
>(({ className, ...props }, ref) => (
|
|
36
|
+
AvatarProps
|
|
37
|
+
>(({ className, size, appearance, ...props }, ref) => (
|
|
10
38
|
<AvatarPrimitive.Root
|
|
11
39
|
ref={ref}
|
|
12
|
-
className={cn(
|
|
40
|
+
className={cn(avatarVariants({ size, appearance }), className)}
|
|
13
41
|
{...props}
|
|
14
42
|
/>
|
|
15
43
|
));
|
|
@@ -39,4 +67,4 @@ const AvatarFallback = React.forwardRef<
|
|
|
39
67
|
));
|
|
40
68
|
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
41
69
|
|
|
42
|
-
export { Avatar, AvatarImage, AvatarFallback };
|
|
70
|
+
export { Avatar, AvatarImage, AvatarFallback, avatarVariants };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
3
|
+
import { ArrowLeft } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* BackLink — the "← Back to <list>" control above a detail page's title.
|
|
9
|
+
* Renders a `<button>`; pass `asChild` with a router `<Link>` or `<a>` to navigate by href
|
|
10
|
+
* (the arrow is placed inside that element).
|
|
11
|
+
*/
|
|
12
|
+
interface BackLinkProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
13
|
+
asChild?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const BackLink = React.forwardRef<HTMLButtonElement, BackLinkProps>(
|
|
17
|
+
({ className, asChild = false, children, ...props }, ref) => {
|
|
18
|
+
const Comp = asChild ? Slot : "button";
|
|
19
|
+
return (
|
|
20
|
+
<Comp
|
|
21
|
+
ref={ref}
|
|
22
|
+
{...(asChild ? {} : { type: "button" })}
|
|
23
|
+
className={cn("back-link", className)}
|
|
24
|
+
{...props}
|
|
25
|
+
>
|
|
26
|
+
<ArrowLeft className="back-link__icon" aria-hidden="true" />
|
|
27
|
+
{asChild ? <Slottable>{children}</Slottable> : <span>{children}</span>}
|
|
28
|
+
</Comp>
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
BackLink.displayName = "BackLink";
|
|
33
|
+
|
|
34
|
+
export { BackLink };
|
|
35
|
+
export type { BackLinkProps };
|
|
@@ -12,27 +12,44 @@ const cardVariants = cva("card", {
|
|
|
12
12
|
elevated: "card--elevated",
|
|
13
13
|
filled: "card--filled",
|
|
14
14
|
interactive: "card--interactive",
|
|
15
|
+
/** A bordered 16px-radius panel for a side summary. */
|
|
16
|
+
panel: "card--panel",
|
|
17
|
+
/** A bordered 12px-radius box nested inside a form or another card. */
|
|
18
|
+
inset: "card--inset",
|
|
15
19
|
},
|
|
16
20
|
padding: {
|
|
17
21
|
default: "",
|
|
18
22
|
spacious: "card--padding-spacious",
|
|
19
23
|
},
|
|
24
|
+
/** `relaxed` — more air between heading, description and content (dense back-office pages). */
|
|
25
|
+
spacing: {
|
|
26
|
+
default: "",
|
|
27
|
+
relaxed: "card--spacing-relaxed",
|
|
28
|
+
},
|
|
20
29
|
},
|
|
21
30
|
defaultVariants: {
|
|
22
31
|
variant: "default",
|
|
23
32
|
padding: "default",
|
|
33
|
+
spacing: "default",
|
|
24
34
|
},
|
|
25
35
|
});
|
|
26
36
|
|
|
27
37
|
interface CardProps
|
|
28
38
|
extends React.HTMLAttributes<HTMLDivElement>,
|
|
29
|
-
VariantProps<typeof cardVariants> {
|
|
39
|
+
VariantProps<typeof cardVariants> {
|
|
40
|
+
/** Pin the card 96px from the top of the window while the page scrolls (a live summary beside a long form). */
|
|
41
|
+
sticky?: boolean;
|
|
42
|
+
}
|
|
30
43
|
|
|
31
44
|
const Card = React.forwardRef<HTMLDivElement, CardProps>(
|
|
32
|
-
({ className, variant, padding, ...props }, ref) => (
|
|
45
|
+
({ className, variant, padding, spacing, sticky = false, ...props }, ref) => (
|
|
33
46
|
<div
|
|
34
47
|
ref={ref}
|
|
35
|
-
className={cn(
|
|
48
|
+
className={cn(
|
|
49
|
+
cardVariants({ variant, padding, spacing }),
|
|
50
|
+
sticky && "card--sticky",
|
|
51
|
+
className,
|
|
52
|
+
)}
|
|
36
53
|
{...props}
|
|
37
54
|
/>
|
|
38
55
|
),
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* CenteredPage — a full-window page that sets a single panel near the top, centred, on the page
|
|
7
|
+
* background (a signed-out landing, an error or a hand-off screen). The panel is 420px wide and
|
|
8
|
+
* never wider than the window.
|
|
9
|
+
*
|
|
10
|
+
* <CenteredPage>
|
|
11
|
+
* <ModalPanel align="center">…</ModalPanel>
|
|
12
|
+
* </CenteredPage>
|
|
13
|
+
*/
|
|
14
|
+
export interface CenteredPageProps extends React.HTMLAttributes<HTMLElement> {
|
|
15
|
+
as?: React.ElementType;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const CenteredPage = React.forwardRef<HTMLElement, CenteredPageProps>(
|
|
19
|
+
({ as: Component = "main", className, children, ...props }, ref) => (
|
|
20
|
+
<Component ref={ref} className={cn("centered-page", className)} {...props}>
|
|
21
|
+
<div className="centered-page__body">{children}</div>
|
|
22
|
+
</Component>
|
|
23
|
+
),
|
|
24
|
+
);
|
|
25
|
+
CenteredPage.displayName = "CenteredPage";
|
|
26
|
+
|
|
27
|
+
export { CenteredPage };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
import { Checkbox } from "./checkbox";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* CheckboxField — a checkbox with its label (and optional description) as one control.
|
|
8
|
+
* Clicking the text toggles the box. `onCheckedChange` receives `boolean | "indeterminate"`
|
|
9
|
+
* exactly as the plain `Checkbox` does.
|
|
10
|
+
*/
|
|
11
|
+
interface CheckboxFieldProps
|
|
12
|
+
extends Omit<React.ComponentPropsWithoutRef<typeof Checkbox>, "children"> {
|
|
13
|
+
label: React.ReactNode;
|
|
14
|
+
/** Quieter helper text under the label. */
|
|
15
|
+
description?: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const CheckboxField = React.forwardRef<
|
|
19
|
+
React.ElementRef<typeof Checkbox>,
|
|
20
|
+
CheckboxFieldProps
|
|
21
|
+
>(({ className, label, description, id, disabled, ...props }, ref) => {
|
|
22
|
+
const generatedId = React.useId();
|
|
23
|
+
const fieldId = id ?? generatedId;
|
|
24
|
+
const descriptionId = description ? `${fieldId}-description` : undefined;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
className={cn(
|
|
29
|
+
"checkbox-field",
|
|
30
|
+
disabled && "checkbox-field--disabled",
|
|
31
|
+
className,
|
|
32
|
+
)}
|
|
33
|
+
>
|
|
34
|
+
<Checkbox
|
|
35
|
+
ref={ref}
|
|
36
|
+
id={fieldId}
|
|
37
|
+
disabled={disabled}
|
|
38
|
+
aria-describedby={descriptionId}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
<div className="checkbox-field__text">
|
|
42
|
+
<label htmlFor={fieldId} className="checkbox-field__label">
|
|
43
|
+
{label}
|
|
44
|
+
</label>
|
|
45
|
+
{description ? (
|
|
46
|
+
<span id={descriptionId} className="checkbox-field__description">
|
|
47
|
+
{description}
|
|
48
|
+
</span>
|
|
49
|
+
) : null}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
CheckboxField.displayName = "CheckboxField";
|
|
55
|
+
|
|
56
|
+
export { CheckboxField };
|
|
57
|
+
export type { CheckboxFieldProps };
|
|
@@ -51,6 +51,7 @@ function DialogContent({
|
|
|
51
51
|
children,
|
|
52
52
|
showCloseButton = true,
|
|
53
53
|
size = "default",
|
|
54
|
+
appearance = "default",
|
|
54
55
|
...props
|
|
55
56
|
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
56
57
|
showCloseButton?: boolean;
|
|
@@ -60,6 +61,10 @@ function DialogContent({
|
|
|
60
61
|
* (`height: calc(100vh - 90px)`), no fixed max-width. Default is the
|
|
61
62
|
* existing centered modal. */
|
|
62
63
|
size?: "default" | "fullscreen";
|
|
64
|
+
/** `"form"` — the back-office dialog: a 560px panel with roomier padding, a
|
|
65
|
+
* left-aligned title and description (16px, page font) and a 12px footer gap.
|
|
66
|
+
* Default is the centred customer-facing modal, unchanged. */
|
|
67
|
+
appearance?: "default" | "form";
|
|
63
68
|
}) {
|
|
64
69
|
return (
|
|
65
70
|
<DialogPortal data-slot="dialog-portal">
|
|
@@ -74,6 +79,7 @@ function DialogContent({
|
|
|
74
79
|
className={cn(
|
|
75
80
|
"dialog-content",
|
|
76
81
|
size === "fullscreen" && "dialog-content--fullscreen",
|
|
82
|
+
appearance === "form" && "dialog-content--form",
|
|
77
83
|
className,
|
|
78
84
|
)}
|
|
79
85
|
{...props}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* IconButton — a quiet, icon-only button for toolbars, tree rows and shell chrome (a sidebar
|
|
8
|
+
* toggle, move up / down, edit, delete). It has no label, so always pass `aria-label`.
|
|
9
|
+
*
|
|
10
|
+
* <IconButton aria-label="Edit" size="sm"><Pencil size={15} /></IconButton>
|
|
11
|
+
*
|
|
12
|
+
* `md` (36px) is for chrome, `sm` (28px) for rows, and `bare` has no box at all — it only adds the
|
|
13
|
+
* focus ring and pointer around its child (an `Avatar`, for example).
|
|
14
|
+
*/
|
|
15
|
+
const iconButtonVariants = cva("icon-button", {
|
|
16
|
+
variants: {
|
|
17
|
+
size: {
|
|
18
|
+
sm: "icon-button--sm",
|
|
19
|
+
md: "icon-button--md",
|
|
20
|
+
bare: "icon-button--bare",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: { size: "md" },
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export interface IconButtonProps
|
|
27
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
28
|
+
VariantProps<typeof iconButtonVariants> {
|
|
29
|
+
/** The accessible name; an icon alone has none. */
|
|
30
|
+
"aria-label": string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
34
|
+
({ className, size, type = "button", ...props }, ref) => (
|
|
35
|
+
<button
|
|
36
|
+
ref={ref}
|
|
37
|
+
type={type}
|
|
38
|
+
className={cn(iconButtonVariants({ size }), className)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
IconButton.displayName = "IconButton";
|
|
44
|
+
|
|
45
|
+
export { IconButton, iconButtonVariants };
|
|
@@ -382,6 +382,7 @@ GridSpan.displayName = "GridSpan";
|
|
|
382
382
|
|
|
383
383
|
type ColumnsPreset =
|
|
384
384
|
| "sidebar"
|
|
385
|
+
| "main-aside"
|
|
385
386
|
| "sidebar-right"
|
|
386
387
|
| "wide-sidebar"
|
|
387
388
|
| "narrow-sidebar"
|
|
@@ -391,7 +392,7 @@ type ColumnsPreset =
|
|
|
391
392
|
| "1-3"
|
|
392
393
|
| "3-1";
|
|
393
394
|
|
|
394
|
-
type ColumnsCollapse = "sm" | "md" | "lg";
|
|
395
|
+
type ColumnsCollapse = "sm" | "md" | "lg" | "xl";
|
|
395
396
|
|
|
396
397
|
interface ColumnsProps extends React.HTMLAttributes<HTMLElement> {
|
|
397
398
|
as?: React.ElementType;
|
|
@@ -404,11 +405,15 @@ interface ColumnsProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
404
405
|
columnGap?: SpaceInput;
|
|
405
406
|
rowGap?: SpaceInput;
|
|
406
407
|
collapse?: ColumnsCollapse;
|
|
408
|
+
/** Cross-axis alignment of the columns. `start` lets a short column (a sticky aside) keep its own height. */
|
|
409
|
+
align?: "stretch" | "start";
|
|
407
410
|
}
|
|
408
411
|
|
|
409
412
|
/** Sidebar widths reuse the panel scale so a Columns sidebar and a LayoutPanel match. */
|
|
410
413
|
const ColumnsPresetMap: Record<ColumnsPreset, string> = {
|
|
411
414
|
sidebar: "var(--layout-panel-width-default) 1fr",
|
|
415
|
+
// A flexible main column and a 20–27.5rem aside (a form beside its live summary).
|
|
416
|
+
"main-aside": "minmax(0, 1fr) minmax(20rem, 27.5rem)",
|
|
412
417
|
"sidebar-right": "1fr var(--layout-panel-width-default)",
|
|
413
418
|
"wide-sidebar": "var(--layout-panel-width-wide) 1fr",
|
|
414
419
|
"narrow-sidebar": "var(--layout-panel-width-narrow) 1fr",
|
|
@@ -430,6 +435,7 @@ const Columns = React.forwardRef<HTMLElement, ColumnsProps>(
|
|
|
430
435
|
columnGap,
|
|
431
436
|
rowGap,
|
|
432
437
|
collapse,
|
|
438
|
+
align,
|
|
433
439
|
className,
|
|
434
440
|
style,
|
|
435
441
|
...props
|
|
@@ -443,6 +449,7 @@ const Columns = React.forwardRef<HTMLElement, ColumnsProps>(
|
|
|
443
449
|
className={cn(
|
|
444
450
|
"columns-layout",
|
|
445
451
|
collapse && `columns-layout--collapse-${collapse}`,
|
|
452
|
+
align === "start" && "columns-layout--align-start",
|
|
446
453
|
className,
|
|
447
454
|
)}
|
|
448
455
|
style={{
|
|
@@ -612,7 +619,7 @@ type LayoutHeight = "fill" | "auto";
|
|
|
612
619
|
type LayoutPanelPlacement = "start" | "end";
|
|
613
620
|
|
|
614
621
|
/** Panel widths come from `--layout-panel-width-*`, never from app-side px. */
|
|
615
|
-
type LayoutPanelWidth = "narrow" | "default" | "wide";
|
|
622
|
+
type LayoutPanelWidth = "rail" | "nav" | "narrow" | "default" | "wide";
|
|
616
623
|
/** Content measures come from `--layout-measure-*`, never from app-side px. */
|
|
617
624
|
type LayoutMeasure = "sm" | "md" | "lg" | "full";
|
|
618
625
|
|
|
@@ -633,7 +640,7 @@ function panelWidthVar(
|
|
|
633
640
|
if (typeof width === "number") {
|
|
634
641
|
warnOnce(
|
|
635
642
|
`LayoutPanel: width={${width}} freezes ${width}px into this app. ` +
|
|
636
|
-
`Use width="narrow" | "default" | "wide" so --layout-panel-width-* stays in control.`,
|
|
643
|
+
`Use width="rail" | "nav" | "narrow" | "default" | "wide" so --layout-panel-width-* stays in control.`,
|
|
637
644
|
);
|
|
638
645
|
return `${width}px`;
|
|
639
646
|
}
|
|
@@ -686,13 +693,21 @@ function slotIdOf(element: React.ReactElement): LayoutSlotId | undefined {
|
|
|
686
693
|
interface LayoutHeaderProps extends LayoutSlotHTMLProps {
|
|
687
694
|
/** Kept narrow so the landmark cannot be lost by accident. */
|
|
688
695
|
as?: "header" | "div";
|
|
696
|
+
/** Pin the header to the top of the window while the page scrolls underneath it. */
|
|
697
|
+
sticky?: boolean;
|
|
689
698
|
}
|
|
690
699
|
|
|
691
700
|
const LayoutHeader = markSlot(
|
|
692
701
|
React.forwardRef<HTMLElement, LayoutHeaderProps>(
|
|
693
|
-
({ as = "header", ...props }, ref) => {
|
|
702
|
+
({ as = "header", sticky = false, ...props }, ref) => {
|
|
694
703
|
const Component = as as React.ElementType;
|
|
695
|
-
return
|
|
704
|
+
return (
|
|
705
|
+
<Component
|
|
706
|
+
ref={ref}
|
|
707
|
+
className={cn("layout-header", sticky && "layout-header--sticky")}
|
|
708
|
+
{...props}
|
|
709
|
+
/>
|
|
710
|
+
);
|
|
696
711
|
},
|
|
697
712
|
),
|
|
698
713
|
"header",
|
|
@@ -748,6 +763,14 @@ interface LayoutPanelProps extends LayoutSlotHTMLProps {
|
|
|
748
763
|
placement?: LayoutPanelPlacement;
|
|
749
764
|
/** Named width backed by `--layout-panel-width-*`. Default `default` (17.5rem). */
|
|
750
765
|
width?: LayoutPanelWidth;
|
|
766
|
+
/**
|
|
767
|
+
* `nav` — a side navigation: pinned under a sticky `LayoutHeader`, as tall as the window,
|
|
768
|
+
* scrolling inside itself, no divider line. Pair it with `SideNav`; use `width="nav"` (or
|
|
769
|
+
* `"rail"` when collapsed). Default is the plain panel.
|
|
770
|
+
*/
|
|
771
|
+
appearance?: "default" | "nav";
|
|
772
|
+
/** With `appearance="nav"`: the icon-only rail (hidden on phones). Pair it with `SideNav collapsed`. */
|
|
773
|
+
collapsed?: boolean;
|
|
751
774
|
/** Named inset backed by `--layout-panel-padding`. Default `xl`. */
|
|
752
775
|
padding?: SpaceName;
|
|
753
776
|
isScrollable?: boolean;
|
|
@@ -761,6 +784,8 @@ const LayoutPanel = markSlot(
|
|
|
761
784
|
placement = "start",
|
|
762
785
|
width,
|
|
763
786
|
padding,
|
|
787
|
+
appearance = "default",
|
|
788
|
+
collapsed = false,
|
|
764
789
|
isScrollable = true,
|
|
765
790
|
tabIndex,
|
|
766
791
|
"aria-label": ariaLabel,
|
|
@@ -776,6 +801,7 @@ const LayoutPanel = markSlot(
|
|
|
776
801
|
"layout-panel",
|
|
777
802
|
`layout-panel--${placement}`,
|
|
778
803
|
isScrollable && "layout-panel--scrollable",
|
|
804
|
+
appearance === "nav" && "layout-panel--nav",
|
|
779
805
|
)}
|
|
780
806
|
style={{
|
|
781
807
|
...(width != null
|
|
@@ -785,6 +811,7 @@ const LayoutPanel = markSlot(
|
|
|
785
811
|
? { ["--layout-panel-padding" as string]: tokenCss(padding) }
|
|
786
812
|
: undefined),
|
|
787
813
|
}}
|
|
814
|
+
data-collapsed={collapsed || undefined}
|
|
788
815
|
tabIndex={tabIndex ?? (isScrollable ? 0 : undefined)}
|
|
789
816
|
aria-label={
|
|
790
817
|
ariaLabel ?? (placement === "end" ? "Details" : "Navigation")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { cn } from "@/lib/utils";
|
|
3
|
+
import type { SpaceName } from "./layout";
|
|
3
4
|
|
|
4
5
|
interface ModalOverlayProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
6
|
zIndex?: number;
|
|
@@ -54,11 +55,21 @@ interface ModalCloseRowProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
54
55
|
onClose?: () => void;
|
|
55
56
|
label?: string;
|
|
56
57
|
icon?: React.ReactNode;
|
|
58
|
+
/** `roomy` sets the close button 16px from the panel's top and right edge (default is 8px). */
|
|
59
|
+
inset?: "default" | "roomy";
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
const ModalCloseRow = React.forwardRef<HTMLDivElement, ModalCloseRowProps>(
|
|
60
|
-
({ onClose, label = "Close", icon, className, ...props }, ref) => (
|
|
61
|
-
<div
|
|
63
|
+
({ onClose, label = "Close", icon, inset = "default", className, ...props }, ref) => (
|
|
64
|
+
<div
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={cn(
|
|
67
|
+
"modal-close-row",
|
|
68
|
+
inset === "roomy" && "modal-close-row--roomy",
|
|
69
|
+
className,
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
>
|
|
62
73
|
<button
|
|
63
74
|
type="button"
|
|
64
75
|
className="modal-close"
|
|
@@ -81,6 +92,12 @@ interface ModalPanelProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
81
92
|
align?: PanelAlign;
|
|
82
93
|
angle?: number;
|
|
83
94
|
height?: number;
|
|
95
|
+
/** Space between the panel's children, as a `--space-*` token. Default `xl` (24px). */
|
|
96
|
+
gap?: SpaceName;
|
|
97
|
+
/** Top inset, as a `--space-*` token. Default `xl` (24px). */
|
|
98
|
+
paddingTop?: SpaceName;
|
|
99
|
+
/** Bottom inset, as a `--space-*` token. Default `xl` (24px). */
|
|
100
|
+
paddingBottom?: SpaceName;
|
|
84
101
|
}
|
|
85
102
|
|
|
86
103
|
const ModalPanel = React.forwardRef<HTMLDivElement, ModalPanelProps>(
|
|
@@ -91,6 +108,9 @@ const ModalPanel = React.forwardRef<HTMLDivElement, ModalPanelProps>(
|
|
|
91
108
|
align = "start",
|
|
92
109
|
angle = 114.72731273771963,
|
|
93
110
|
height,
|
|
111
|
+
gap,
|
|
112
|
+
paddingTop,
|
|
113
|
+
paddingBottom,
|
|
94
114
|
className,
|
|
95
115
|
style,
|
|
96
116
|
...props
|
|
@@ -111,6 +131,13 @@ const ModalPanel = React.forwardRef<HTMLDivElement, ModalPanelProps>(
|
|
|
111
131
|
? { ["--panel-gradient-angle" as string]: `${angle}deg` }
|
|
112
132
|
: null),
|
|
113
133
|
...(height !== undefined ? { height } : null),
|
|
134
|
+
...(gap ? { ["--modal-panel-gap" as string]: `var(--space-${gap})` } : null),
|
|
135
|
+
...(paddingTop
|
|
136
|
+
? { ["--modal-panel-padding-top" as string]: `var(--space-${paddingTop})` }
|
|
137
|
+
: null),
|
|
138
|
+
...(paddingBottom
|
|
139
|
+
? { ["--modal-panel-padding-bottom" as string]: `var(--space-${paddingBottom})` }
|
|
140
|
+
: null),
|
|
114
141
|
...style,
|
|
115
142
|
} as React.CSSProperties
|
|
116
143
|
}
|
|
@@ -122,11 +149,15 @@ ModalPanel.displayName = "ModalPanel";
|
|
|
122
149
|
|
|
123
150
|
interface ModalTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
124
151
|
as?: React.ElementType;
|
|
152
|
+
/** `large` — a 28px title for a welcome / landing panel. Default is the 20px modal title. */
|
|
153
|
+
size?: "default" | "large";
|
|
125
154
|
}
|
|
126
155
|
|
|
127
156
|
const ModalTitle = React.forwardRef<HTMLHeadingElement, ModalTitleProps>(
|
|
128
|
-
({ as: Component = "h2", children, className, ...props }, ref) => (
|
|
129
|
-
<div
|
|
157
|
+
({ as: Component = "h2", size = "default", children, className, ...props }, ref) => (
|
|
158
|
+
<div
|
|
159
|
+
className={cn("modal-title", size === "large" && "modal-title--large", className)}
|
|
160
|
+
>
|
|
130
161
|
<Component ref={ref} className="modal-title__text heading-xxsmall" {...props}>
|
|
131
162
|
{children}
|
|
132
163
|
</Component>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* OutlineNode — one row of an editable outline / tree (for example concept › feature ›
|
|
8
|
+
* requirement). The nesting is visual, driven by `level`; put child nodes inside the parent.
|
|
9
|
+
*
|
|
10
|
+
* <OutlineNode level="section">
|
|
11
|
+
* <OutlineNodeHead>
|
|
12
|
+
* <OutlineNodeTitle>Air · Clean air <OutlineNodeMeta>12 pts</OutlineNodeMeta></OutlineNodeTitle>
|
|
13
|
+
* <OutlineNodeControls>…icon buttons…</OutlineNodeControls>
|
|
14
|
+
* </OutlineNodeHead>
|
|
15
|
+
* <OutlineNode level="branch">…</OutlineNode>
|
|
16
|
+
* </OutlineNode>
|
|
17
|
+
*
|
|
18
|
+
* `OutlineNodeTitle` takes an optional bold `code` (`A02 · Air quality`).
|
|
19
|
+
* `section` is a bordered card, `branch` is indented with a guide line, `leaf` is a compact row
|
|
20
|
+
* with a hover highlight.
|
|
21
|
+
*/
|
|
22
|
+
const outlineNodeVariants = cva("tree-node", {
|
|
23
|
+
variants: {
|
|
24
|
+
level: {
|
|
25
|
+
section: "tree-node--section",
|
|
26
|
+
branch: "tree-node--branch",
|
|
27
|
+
leaf: "tree-node--leaf",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: { level: "section" },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
interface OutlineNodeProps
|
|
34
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
35
|
+
VariantProps<typeof outlineNodeVariants> {
|
|
36
|
+
/** Greyed out, for items that are hidden or switched off. */
|
|
37
|
+
inactive?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const OutlineNode = React.forwardRef<HTMLDivElement, OutlineNodeProps>(
|
|
41
|
+
({ className, level, inactive = false, ...props }, ref) => (
|
|
42
|
+
<div
|
|
43
|
+
ref={ref}
|
|
44
|
+
data-inactive={inactive || undefined}
|
|
45
|
+
className={cn(outlineNodeVariants({ level }), className)}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
),
|
|
49
|
+
);
|
|
50
|
+
OutlineNode.displayName = "OutlineNode";
|
|
51
|
+
|
|
52
|
+
/** Title on the left, controls on the right; wraps on narrow widths. */
|
|
53
|
+
const OutlineNodeHead = React.forwardRef<
|
|
54
|
+
HTMLDivElement,
|
|
55
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
56
|
+
>(({ className, ...props }, ref) => (
|
|
57
|
+
<div ref={ref} className={cn("tree-node__head", className)} {...props} />
|
|
58
|
+
));
|
|
59
|
+
OutlineNodeHead.displayName = "OutlineNodeHead";
|
|
60
|
+
|
|
61
|
+
interface OutlineNodeTitleProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
62
|
+
/** A bold code or prefix before the name (`A02`); a "·" separator is added after it. */
|
|
63
|
+
code?: React.ReactNode;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Inline group for the node's name and its badges. */
|
|
67
|
+
const OutlineNodeTitle = React.forwardRef<HTMLDivElement, OutlineNodeTitleProps>(
|
|
68
|
+
({ className, code, children, ...props }, ref) => (
|
|
69
|
+
<div ref={ref} className={cn("tree-node__title", className)} {...props}>
|
|
70
|
+
{code != null ? (
|
|
71
|
+
<>
|
|
72
|
+
<strong className="tree-node__code">{code}</strong>
|
|
73
|
+
{"· "}
|
|
74
|
+
</>
|
|
75
|
+
) : null}
|
|
76
|
+
{children}
|
|
77
|
+
</div>
|
|
78
|
+
),
|
|
79
|
+
);
|
|
80
|
+
OutlineNodeTitle.displayName = "OutlineNodeTitle";
|
|
81
|
+
|
|
82
|
+
/** Small secondary text next to the name (points, counts). */
|
|
83
|
+
const OutlineNodeMeta = React.forwardRef<
|
|
84
|
+
HTMLSpanElement,
|
|
85
|
+
React.HTMLAttributes<HTMLSpanElement>
|
|
86
|
+
>(({ className, ...props }, ref) => (
|
|
87
|
+
<span ref={ref} className={cn("tree-node__meta", className)} {...props} />
|
|
88
|
+
));
|
|
89
|
+
OutlineNodeMeta.displayName = "OutlineNodeMeta";
|
|
90
|
+
|
|
91
|
+
/** Row of icon buttons (move up / down, edit, delete). */
|
|
92
|
+
const OutlineNodeControls = React.forwardRef<
|
|
93
|
+
HTMLDivElement,
|
|
94
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
95
|
+
>(({ className, ...props }, ref) => (
|
|
96
|
+
<div
|
|
97
|
+
ref={ref}
|
|
98
|
+
className={cn("tree-node__controls", className)}
|
|
99
|
+
{...props}
|
|
100
|
+
/>
|
|
101
|
+
));
|
|
102
|
+
OutlineNodeControls.displayName = "OutlineNodeControls";
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
OutlineNode,
|
|
106
|
+
OutlineNodeHead,
|
|
107
|
+
OutlineNodeTitle,
|
|
108
|
+
OutlineNodeMeta,
|
|
109
|
+
OutlineNodeControls,
|
|
110
|
+
outlineNodeVariants,
|
|
111
|
+
};
|
|
112
|
+
export type { OutlineNodeProps, OutlineNodeTitleProps };
|