@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.
Files changed (34) hide show
  1. package/client/components/ui/avatar-identity.tsx +16 -3
  2. package/client/components/ui/avatar.tsx +32 -4
  3. package/client/components/ui/back-link.tsx +35 -0
  4. package/client/components/ui/card.tsx +20 -3
  5. package/client/components/ui/centered-page.tsx +27 -0
  6. package/client/components/ui/checkbox-field.tsx +57 -0
  7. package/client/components/ui/dialog.tsx +6 -0
  8. package/client/components/ui/icon-button.tsx +45 -0
  9. package/client/components/ui/layout.tsx +32 -5
  10. package/client/components/ui/modal-panel.tsx +35 -4
  11. package/client/components/ui/outline-node.tsx +112 -0
  12. package/client/components/ui/radio-card.tsx +54 -0
  13. package/client/components/ui/resource-thumbnail.tsx +12 -1
  14. package/client/components/ui/side-nav.tsx +126 -0
  15. package/client/components/ui/status-pill.tsx +37 -4
  16. package/client/components/ui/table.tsx +26 -4
  17. package/client/components/ui/typography.tsx +29 -2
  18. package/client/global.css +815 -9
  19. package/client/ui/Avatar.stories.tsx +78 -0
  20. package/client/ui/BackLink.stories.tsx +50 -0
  21. package/client/ui/Card.stories.tsx +30 -0
  22. package/client/ui/CenteredPage.stories.tsx +43 -0
  23. package/client/ui/CheckboxField.stories.tsx +68 -0
  24. package/client/ui/Dialog.stories.tsx +31 -0
  25. package/client/ui/IconButton.stories.tsx +77 -0
  26. package/client/ui/OutlineNode.stories.tsx +106 -0
  27. package/client/ui/RadioCard.stories.tsx +75 -0
  28. package/client/ui/SideNav.stories.tsx +68 -0
  29. package/client/ui/StatusPill.stories.tsx +78 -0
  30. package/client/ui/Table/Table.stories.tsx +32 -0
  31. package/dist/index.cjs.js +1 -1
  32. package/dist/index.d.ts +84 -0
  33. package/dist/index.es.js +398 -40
  34. package/package.json +1 -1
@@ -0,0 +1,54 @@
1
+ import * as React from "react";
2
+ import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
3
+
4
+ import { cn } from "@/lib/utils";
5
+
6
+ /**
7
+ * RadioCard — a single-choice picker where each option is a card with a title and a line of
8
+ * explanation (for example a role and what it allows). Built on Radix RadioGroup, so keyboard
9
+ * navigation, `value` and `onValueChange` work as in `RadioGroup`.
10
+ *
11
+ * <RadioCardGroup value={role} onValueChange={setRole}>
12
+ * <RadioCardItem value="admin" title="Admin" description="Can edit everything." />
13
+ * </RadioCardGroup>
14
+ */
15
+ const RadioCardGroup = React.forwardRef<
16
+ React.ElementRef<typeof RadioGroupPrimitive.Root>,
17
+ React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
18
+ >(({ className, ...props }, ref) => (
19
+ <RadioGroupPrimitive.Root
20
+ ref={ref}
21
+ className={cn("radio-card-group", className)}
22
+ {...props}
23
+ />
24
+ ));
25
+ RadioCardGroup.displayName = "RadioCardGroup";
26
+
27
+ interface RadioCardItemProps
28
+ extends Omit<
29
+ React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>,
30
+ "title" | "children"
31
+ > {
32
+ title: React.ReactNode;
33
+ description?: React.ReactNode;
34
+ }
35
+
36
+ const RadioCardItem = React.forwardRef<
37
+ React.ElementRef<typeof RadioGroupPrimitive.Item>,
38
+ RadioCardItemProps
39
+ >(({ className, title, description, ...props }, ref) => (
40
+ <RadioGroupPrimitive.Item
41
+ ref={ref}
42
+ className={cn("radio-card", className)}
43
+ {...props}
44
+ >
45
+ <span className="radio-card__title">{title}</span>
46
+ {description ? (
47
+ <span className="radio-card__description">{description}</span>
48
+ ) : null}
49
+ </RadioGroupPrimitive.Item>
50
+ ));
51
+ RadioCardItem.displayName = "RadioCardItem";
52
+
53
+ export { RadioCardGroup, RadioCardItem };
54
+ export type { RadioCardItemProps };
@@ -1,17 +1,28 @@
1
1
  import * as React from "react";
2
+ import { cn } from "@/lib/utils";
2
3
 
3
4
  export interface ResourceThumbnailProps {
4
5
  src: string;
5
6
  alt?: string;
7
+ /**
8
+ * `default` fills its container at 16:9. `preview` keeps the image's own proportions, at most 160px
9
+ * tall (a live preview of a pasted URL). `thumb` is a 56 × 40 table thumbnail.
10
+ */
11
+ size?: "default" | "preview" | "thumb";
6
12
  }
7
13
 
8
14
  export function ResourceThumbnail({
9
15
  src,
10
16
  alt = "",
17
+ size = "default",
11
18
  }: ResourceThumbnailProps) {
12
19
  return (
13
20
  <img
14
- className="resource-thumbnail"
21
+ className={cn(
22
+ "resource-thumbnail",
23
+ size === "preview" && "resource-thumbnail--preview",
24
+ size === "thumb" && "resource-thumbnail--thumb",
25
+ )}
15
26
  src={src}
16
27
  alt={alt}
17
28
  loading="lazy"
@@ -0,0 +1,126 @@
1
+ import * as React from "react";
2
+ import { Slot, Slottable } from "@radix-ui/react-slot";
3
+
4
+ import { cn } from "@/lib/utils";
5
+
6
+ /**
7
+ * SideNav — grouped, icon-led navigation for an app shell's side panel
8
+ * (put it inside `LayoutPanel`; use `width="rail"` there when `collapsed`).
9
+ *
10
+ * <SideNav aria-label="Admin sections" collapsed={collapsed}>
11
+ * <SideNavGroup label="Overview">
12
+ * <SideNavItem icon={<LayoutDashboard />} active>Dashboard</SideNavItem>
13
+ * </SideNavGroup>
14
+ * </SideNav>
15
+ *
16
+ * `collapsed` hides group labels and item text and centres the icons. A collapsed item
17
+ * keeps its text as a `title` tooltip and an accessible name.
18
+ */
19
+
20
+ interface SideNavContextValue {
21
+ collapsed: boolean;
22
+ }
23
+
24
+ const SideNavContext = React.createContext<SideNavContextValue>({
25
+ collapsed: false,
26
+ });
27
+
28
+ interface SideNavProps extends React.HTMLAttributes<HTMLElement> {
29
+ /** Icon-only rail. Default `false`. */
30
+ collapsed?: boolean;
31
+ }
32
+
33
+ const SideNav = React.forwardRef<HTMLElement, SideNavProps>(
34
+ ({ className, collapsed = false, children, ...props }, ref) => (
35
+ <SideNavContext.Provider value={{ collapsed }}>
36
+ <nav
37
+ ref={ref}
38
+ data-collapsed={collapsed || undefined}
39
+ className={cn("side-nav", collapsed && "side-nav--collapsed", className)}
40
+ {...props}
41
+ >
42
+ {children}
43
+ </nav>
44
+ </SideNavContext.Provider>
45
+ ),
46
+ );
47
+ SideNav.displayName = "SideNav";
48
+
49
+ interface SideNavGroupProps extends React.HTMLAttributes<HTMLDivElement> {
50
+ /** Group heading, shown above the items (hidden when the nav is collapsed). */
51
+ label?: React.ReactNode;
52
+ }
53
+
54
+ const SideNavGroup = React.forwardRef<HTMLDivElement, SideNavGroupProps>(
55
+ ({ className, label, children, ...props }, ref) => {
56
+ const headingId = React.useId();
57
+ return (
58
+ <div
59
+ ref={ref}
60
+ role="group"
61
+ aria-labelledby={label ? headingId : undefined}
62
+ className={cn("side-nav__group", className)}
63
+ {...props}
64
+ >
65
+ {label ? (
66
+ <span id={headingId} className="side-nav__heading">
67
+ {label}
68
+ </span>
69
+ ) : null}
70
+ {children}
71
+ </div>
72
+ );
73
+ },
74
+ );
75
+ SideNavGroup.displayName = "SideNavGroup";
76
+
77
+ interface SideNavItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
78
+ /** Leading icon (a lucide icon element, for example). */
79
+ icon?: React.ReactNode;
80
+ /** The current page. Sets `aria-current="page"` and the highlighted look. */
81
+ active?: boolean;
82
+ /**
83
+ * Render the child element (an `<a>` or a router `<Link>`) instead of a `<button>`;
84
+ * the icon is placed inside it, before the child's own text.
85
+ */
86
+ asChild?: boolean;
87
+ }
88
+
89
+ const SideNavItem = React.forwardRef<HTMLButtonElement, SideNavItemProps>(
90
+ ({ className, icon, active = false, asChild = false, children, ...props }, ref) => {
91
+ const { collapsed } = React.useContext(SideNavContext);
92
+ const Comp = asChild ? Slot : "button";
93
+ const label = typeof children === "string" ? children : undefined;
94
+
95
+ return (
96
+ <Comp
97
+ ref={ref}
98
+ {...(asChild ? {} : { type: "button" })}
99
+ aria-current={active ? "page" : undefined}
100
+ aria-label={collapsed ? label : undefined}
101
+ title={collapsed ? label : undefined}
102
+ className={cn(
103
+ "side-nav__item",
104
+ active && "side-nav__item--active",
105
+ className,
106
+ )}
107
+ {...props}
108
+ >
109
+ {icon ? (
110
+ <span className="side-nav__icon" aria-hidden="true">
111
+ {icon}
112
+ </span>
113
+ ) : null}
114
+ {asChild ? (
115
+ <Slottable>{children}</Slottable>
116
+ ) : (
117
+ <span className="side-nav__label">{children}</span>
118
+ )}
119
+ </Comp>
120
+ );
121
+ },
122
+ );
123
+ SideNavItem.displayName = "SideNavItem";
124
+
125
+ export { SideNav, SideNavGroup, SideNavItem };
126
+ export type { SideNavProps, SideNavGroupProps, SideNavItemProps };
@@ -19,10 +19,28 @@ import { cn } from "@/lib/utils";
19
19
 
20
20
  /* The four invoice states in `Invoice::STATUS_*`, no more — an unknown status
21
21
  falls back to `neutral` rather than inventing a colour for it. */
22
- type StatusPillTone = "unpaid" | "paid" | "waived" | "void" | "neutral";
22
+ type StatusPillTone =
23
+ | "unpaid"
24
+ | "paid"
25
+ | "waived"
26
+ | "void"
27
+ | "neutral"
28
+ // Generic tones, for roles, record states and flags that are not invoice states.
29
+ | "info"
30
+ | "success"
31
+ | "warning"
32
+ | "danger"
33
+ | "accent"
34
+ | "inactive"
35
+ // A quiet gray chip for the ordinary case (a customer, an unset flag).
36
+ | "plain";
37
+
38
+ /** `chip` — sentence case in a slightly tighter pill (roles, record states), instead of the uppercase default. */
39
+ type StatusPillAppearance = "default" | "chip";
23
40
 
24
41
  interface StatusPillProps extends React.HTMLAttributes<HTMLSpanElement> {
25
42
  tone?: StatusPillTone;
43
+ appearance?: StatusPillAppearance;
26
44
  children: React.ReactNode;
27
45
  }
28
46
 
@@ -32,6 +50,13 @@ const TONES: readonly StatusPillTone[] = [
32
50
  "waived",
33
51
  "void",
34
52
  "neutral",
53
+ "info",
54
+ "success",
55
+ "warning",
56
+ "danger",
57
+ "accent",
58
+ "inactive",
59
+ "plain",
35
60
  ];
36
61
 
37
62
  /** Maps an API status string onto a tone, defaulting to `neutral`. */
@@ -42,10 +67,18 @@ function toneForStatus(status?: string | null): StatusPillTone {
42
67
  }
43
68
 
44
69
  const StatusPill = React.forwardRef<HTMLSpanElement, StatusPillProps>(
45
- ({ tone = "neutral", children, className, ...props }, ref) => (
70
+ (
71
+ { tone = "neutral", appearance = "default", children, className, ...props },
72
+ ref,
73
+ ) => (
46
74
  <span
47
75
  ref={ref}
48
- className={cn("status-pill", `status-pill--${tone}`, className)}
76
+ className={cn(
77
+ "status-pill",
78
+ `status-pill--${tone}`,
79
+ appearance === "chip" && "status-pill--chip",
80
+ className,
81
+ )}
49
82
  {...props}
50
83
  >
51
84
  {children}
@@ -55,4 +88,4 @@ const StatusPill = React.forwardRef<HTMLSpanElement, StatusPillProps>(
55
88
  StatusPill.displayName = "StatusPill";
56
89
 
57
90
  export { StatusPill, toneForStatus };
58
- export type { StatusPillProps, StatusPillTone };
91
+ export type { StatusPillProps, StatusPillTone, StatusPillAppearance };
@@ -28,6 +28,8 @@ import { cn } from "@/lib/utils";
28
28
  */
29
29
  type TableDensity = "compact" | "balanced" | "spacious";
30
30
  type TableAlign = "left" | "center" | "right";
31
+ /** `card` wraps the table in a bordered, rounded card with a tinted header and row hover. */
32
+ type TableAppearance = "plain" | "card";
31
33
 
32
34
  // ---------------------------------------------------------------------------
33
35
  // Root
@@ -36,13 +38,30 @@ type TableAlign = "left" | "center" | "right";
36
38
  interface TableProps extends React.TableHTMLAttributes<HTMLTableElement> {
37
39
  /** Figma `Density`. Sets the cell's vertical padding; heights follow. Default `compact`. */
38
40
  density?: TableDensity;
41
+ /** Visual frame. Default `plain`; `card` is the admin / back-office look. */
42
+ appearance?: TableAppearance;
39
43
  /** Wrapper class, for width or overflow handling. */
40
44
  containerClassName?: string;
41
45
  }
42
46
 
43
47
  const Table = React.forwardRef<HTMLTableElement, TableProps>(
44
- ({ className, containerClassName, density = "compact", ...props }, ref) => (
45
- <div className={cn("table-wrapper", containerClassName)}>
48
+ (
49
+ {
50
+ className,
51
+ containerClassName,
52
+ density = "compact",
53
+ appearance = "plain",
54
+ ...props
55
+ },
56
+ ref,
57
+ ) => (
58
+ <div
59
+ className={cn(
60
+ "table-wrapper",
61
+ appearance === "card" && "table-wrapper--card",
62
+ containerClassName,
63
+ )}
64
+ >
46
65
  <table
47
66
  ref={ref}
48
67
  data-density={density}
@@ -172,17 +191,19 @@ interface TableBodyCellProps
172
191
  tag?: React.ReactNode;
173
192
  /** Figma `Content type=… + Action`: pass one or more `TableAction`. */
174
193
  action?: React.ReactNode;
194
+ /** Bold the cell's content (a total row, a key figure). */
195
+ strong?: boolean;
175
196
  }
176
197
 
177
198
  const TableCell = React.forwardRef<HTMLTableCellElement, TableBodyCellProps>(
178
199
  (
179
- { className, align = "left", text, tag, action, children, ...props },
200
+ { className, align = "left", strong = false, text, tag, action, children, ...props },
180
201
  ref,
181
202
  ) => (
182
203
  <td
183
204
  ref={ref}
184
205
  data-align={align}
185
- className={cn("table-cell", className)}
206
+ className={cn("table-cell", strong && "table-cell--strong", className)}
186
207
  {...props}
187
208
  >
188
209
  <span className="table-cell-inner">
@@ -251,5 +272,6 @@ export type {
251
272
  TableCellProps,
252
273
  TableBodyCellProps,
253
274
  TableDensity,
275
+ TableAppearance,
254
276
  TableAlign,
255
277
  };
@@ -49,16 +49,43 @@ const defaultElementMap: Record<Variant, React.ElementType> = {
49
49
  interface TextProps extends React.HTMLAttributes<HTMLElement> {
50
50
  variant?: Variant;
51
51
  as?: React.ElementType;
52
+ /** `muted` — quieter helper text (hints, secondary lines). Default inherits the surrounding colour. */
53
+ tone?: "default" | "muted";
54
+ /** `strong` — semibold, for a label inside running text. */
55
+ strong?: boolean;
56
+ /** `center` — centre the text (wrapped lines too). Default follows the surrounding alignment. */
57
+ align?: "start" | "center";
58
+ /** `relaxed` — a 1.5 line height for short paragraphs that should breathe. */
59
+ leading?: "default" | "relaxed";
52
60
  }
53
61
 
54
62
  const Text = React.forwardRef<HTMLElement, TextProps>(
55
- ({ className, variant = "body-base", as, ...props }, ref) => {
63
+ (
64
+ {
65
+ className,
66
+ variant = "body-base",
67
+ as,
68
+ tone = "default",
69
+ strong = false,
70
+ align,
71
+ leading = "default",
72
+ ...props
73
+ },
74
+ ref,
75
+ ) => {
56
76
  const Component = as || defaultElementMap[variant];
57
77
 
58
78
  return (
59
79
  <Component
60
80
  ref={ref}
61
- className={cn(typographyVariants({ variant }), className)}
81
+ className={cn(
82
+ typographyVariants({ variant }),
83
+ tone === "muted" && "typo--muted",
84
+ strong && "typo--strong",
85
+ align === "center" && "typo--center",
86
+ leading === "relaxed" && "typo--relaxed",
87
+ className,
88
+ )}
62
89
  {...props}
63
90
  />
64
91
  );