@behavioral-agentic-design-system/core 0.17.0 → 0.19.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.
Files changed (79) hide show
  1. package/package.json +1 -1
  2. package/scripts/check-stories.mjs +12 -5
  3. package/scripts/fix-stories.mjs +6 -6
  4. package/scripts/generate-stories.cjs +7 -7
  5. package/src/app/preview/components/page.tsx +119 -98
  6. package/src/components/ui/color-picker.tsx +318 -9
  7. package/src/stories/Accordion.stories.tsx +152 -0
  8. package/src/stories/Alert.stories.tsx +102 -0
  9. package/src/stories/AlertDialog.stories.tsx +125 -0
  10. package/src/stories/AspectRatio.stories.tsx +82 -0
  11. package/src/stories/Avatar.stories.tsx +36 -0
  12. package/src/stories/Badge.stories.tsx +54 -0
  13. package/src/stories/Breadcrumb.stories.tsx +36 -0
  14. package/src/stories/Button.stories.tsx +144 -0
  15. package/src/stories/ButtonGroup.stories.tsx +176 -0
  16. package/src/stories/Calendar.stories.tsx +67 -0
  17. package/src/stories/Card.stories.tsx +43 -0
  18. package/src/stories/Carousel.stories.tsx +233 -0
  19. package/src/stories/Chart.stories.tsx +174 -0
  20. package/src/stories/Checkbox.stories.tsx +32 -0
  21. package/src/stories/CircularProgress.stories.tsx +136 -0
  22. package/src/stories/Code.stories.tsx +131 -0
  23. package/src/stories/Collapsible.stories.tsx +27 -0
  24. package/src/stories/ColorPicker.stories.tsx +186 -0
  25. package/src/stories/Combobox.stories.tsx +168 -0
  26. package/src/stories/Command.stories.tsx +40 -0
  27. package/src/stories/ContextMenu.stories.tsx +293 -0
  28. package/src/stories/CopyButton.stories.tsx +111 -0
  29. package/src/stories/DatePicker.stories.tsx +176 -0
  30. package/src/stories/DateRangePicker.stories.tsx +95 -0
  31. package/src/stories/Dialog.stories.tsx +186 -0
  32. package/src/stories/DropdownMenu.stories.tsx +47 -0
  33. package/src/stories/EmptyState.stories.tsx +199 -0
  34. package/src/stories/Field.stories.tsx +155 -0
  35. package/src/stories/FileUpload.stories.tsx +134 -0
  36. package/src/stories/HoverCard.stories.tsx +149 -0
  37. package/src/stories/Indicator.stories.tsx +255 -0
  38. package/src/stories/Input.stories.tsx +69 -0
  39. package/src/stories/Kbd.stories.tsx +123 -0
  40. package/src/stories/Label.stories.tsx +27 -0
  41. package/src/stories/List.stories.tsx +159 -0
  42. package/src/stories/Menubar.stories.tsx +190 -0
  43. package/src/stories/MultiSelect.stories.tsx +107 -0
  44. package/src/stories/NativeSelect.stories.tsx +107 -0
  45. package/src/stories/NavigationMenu.stories.tsx +322 -0
  46. package/src/stories/NumberInput.stories.tsx +100 -0
  47. package/src/stories/Pagination.stories.tsx +201 -0
  48. package/src/stories/PasswordInput.stories.tsx +62 -0
  49. package/src/stories/PinInput.stories.tsx +136 -0
  50. package/src/stories/Popover.stories.tsx +37 -0
  51. package/src/stories/Progress.stories.tsx +64 -0
  52. package/src/stories/RadioGroup.stories.tsx +39 -0
  53. package/src/stories/RatingGroup.stories.tsx +102 -0
  54. package/src/stories/Resizable.stories.tsx +28 -0
  55. package/src/stories/Reveal.stories.tsx +63 -0
  56. package/src/stories/ScrollArea.stories.tsx +76 -0
  57. package/src/stories/SegmentedControl.stories.tsx +182 -0
  58. package/src/stories/Select.stories.tsx +62 -0
  59. package/src/stories/Separator.stories.tsx +28 -0
  60. package/src/stories/Sheet.stories.tsx +193 -0
  61. package/src/stories/Sidebar.stories.tsx +53 -0
  62. package/src/stories/Skeleton.stories.tsx +32 -0
  63. package/src/stories/Slider.stories.tsx +67 -0
  64. package/src/stories/Sonner.stories.tsx +146 -0
  65. package/src/stories/Spinner.stories.tsx +94 -0
  66. package/src/stories/Stepper.stories.tsx +228 -0
  67. package/src/stories/Switch.stories.tsx +58 -0
  68. package/src/stories/Table.stories.tsx +38 -0
  69. package/src/stories/Tabs.stories.tsx +128 -0
  70. package/src/stories/Tag.stories.tsx +51 -0
  71. package/src/stories/TagsInput.stories.tsx +154 -0
  72. package/src/stories/Textarea.stories.tsx +31 -0
  73. package/src/stories/TimePicker.stories.tsx +54 -0
  74. package/src/stories/Timeline.stories.tsx +263 -0
  75. package/src/stories/Toggle.stories.tsx +45 -0
  76. package/src/stories/ToggleGroup.stories.tsx +39 -0
  77. package/src/stories/Toolbar.stories.tsx +295 -0
  78. package/src/stories/Tooltip.stories.tsx +37 -0
  79. package/src/stories/TreeView.stories.tsx +293 -0
@@ -8,12 +8,24 @@ import { cn } from "../../lib/utils";
8
8
  /* Helpers */
9
9
  /* -------------------------------------------------------------------------- */
10
10
 
11
+ const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
12
+
13
+ function hexToRgb(hex: string): [number, number, number] | null {
14
+ if (!isValidHex(hex)) return null;
15
+ let h = hex.replace("#", "");
16
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
17
+ return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
18
+ }
19
+
20
+ function rgbToHex(r: number, g: number, b: number): string {
21
+ const to = (v: number) => Math.round(clamp(v, 0, 255)).toString(16).padStart(2, "0");
22
+ return `#${to(r)}${to(g)}${to(b)}`;
23
+ }
24
+
11
25
  function luminance(hex: string): number {
12
- const h = hex.replace("#", "");
13
- const full = h.length === 3
14
- ? h.split("").map((c) => parseInt(c + c, 16))
15
- : [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
16
- const [r, g, b] = full.map((v) => {
26
+ const rgb = hexToRgb(hex);
27
+ if (!rgb) return 1;
28
+ const [r, g, b] = rgb.map((v) => {
17
29
  const s = v / 255;
18
30
  return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
19
31
  });
@@ -21,7 +33,7 @@ function luminance(hex: string): number {
21
33
  }
22
34
 
23
35
  function contrastColor(hex: string): string {
24
- if (!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(hex)) return "#ffffff";
36
+ if (!isValidHex(hex)) return "#ffffff";
25
37
  return luminance(hex) > 0.179 ? "#000000" : "#ffffff";
26
38
  }
27
39
 
@@ -29,6 +41,281 @@ function isValidHex(v: string): boolean {
29
41
  return /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(v);
30
42
  }
31
43
 
44
+ /** hex -> {h: 0-360, s: 0-100, v: 0-100} */
45
+ function hexToHsv(hex: string): { h: number; s: number; v: number } {
46
+ const rgb = hexToRgb(hex);
47
+ if (!rgb) return { h: 0, s: 0, v: 100 };
48
+ const [r, g, b] = rgb.map((v) => v / 255);
49
+ const max = Math.max(r, g, b);
50
+ const min = Math.min(r, g, b);
51
+ const d = max - min;
52
+ let h = 0;
53
+ if (d !== 0) {
54
+ if (max === r) h = ((g - b) / d) % 6;
55
+ else if (max === g) h = (b - r) / d + 2;
56
+ else h = (r - g) / d + 4;
57
+ h *= 60;
58
+ if (h < 0) h += 360;
59
+ }
60
+ const s = max === 0 ? 0 : d / max;
61
+ return { h, s: s * 100, v: max * 100 };
62
+ }
63
+
64
+ /** {h: 0-360, s: 0-100, v: 0-100} -> hex */
65
+ function hsvToHex(h: number, s: number, v: number): string {
66
+ const sn = s / 100;
67
+ const vn = v / 100;
68
+ const c = vn * sn;
69
+ const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
70
+ const m = vn - c;
71
+ let r = 0, g = 0, b = 0;
72
+ if (h < 60) [r, g, b] = [c, x, 0];
73
+ else if (h < 120) [r, g, b] = [x, c, 0];
74
+ else if (h < 180) [r, g, b] = [0, c, x];
75
+ else if (h < 240) [r, g, b] = [0, x, c];
76
+ else if (h < 300) [r, g, b] = [x, 0, c];
77
+ else [r, g, b] = [c, 0, x];
78
+ return rgbToHex((r + m) * 255, (g + m) * 255, (b + m) * 255);
79
+ }
80
+
81
+ /* -------------------------------------------------------------------------- */
82
+ /* Color wheel (hue ring + saturation/brightness square) */
83
+ /* -------------------------------------------------------------------------- */
84
+
85
+ const WHEEL_SIZE = 208;
86
+ const RING_THICKNESS = 22;
87
+ const HOLE = WHEEL_SIZE - RING_THICKNESS * 2;
88
+ const SQUARE = Math.round(HOLE / Math.SQRT2);
89
+ const CENTER = WHEEL_SIZE / 2;
90
+ const RING_RADIUS = CENTER - RING_THICKNESS / 2;
91
+
92
+ const HUE_CONIC =
93
+ "conic-gradient(from 0deg, hsl(0 100% 50%), hsl(60 100% 50%), hsl(120 100% 50%), hsl(180 100% 50%), hsl(240 100% 50%), hsl(300 100% 50%), hsl(360 100% 50%))";
94
+
95
+ function ColorWheel({
96
+ value,
97
+ onChange,
98
+ disabled,
99
+ }: {
100
+ value: string;
101
+ onChange: (hex: string) => void;
102
+ disabled?: boolean;
103
+ }) {
104
+ const ringRef = React.useRef<HTMLDivElement>(null);
105
+ const squareRef = React.useRef<HTMLDivElement>(null);
106
+
107
+ const { h, s, v } = isValidHex(value) ? hexToHsv(value) : { h: 0, s: 0, v: 100 };
108
+
109
+ const commitHsv = React.useCallback(
110
+ (nh: number, ns: number, nv: number) => {
111
+ if (disabled) return;
112
+ onChange(hsvToHex(((nh % 360) + 360) % 360, clamp(ns, 0, 100), clamp(nv, 0, 100)));
113
+ },
114
+ [disabled, onChange]
115
+ );
116
+
117
+ const pointerFromRing = (clientX: number, clientY: number) => {
118
+ const el = ringRef.current;
119
+ if (!el) return;
120
+ const r = el.getBoundingClientRect();
121
+ const dx = clientX - (r.left + r.width / 2);
122
+ const dy = clientY - (r.top + r.height / 2);
123
+ let ang = (Math.atan2(dx, -dy) * 180) / Math.PI; // 0 = top, clockwise
124
+ if (ang < 0) ang += 360;
125
+ commitHsv(ang, s, v);
126
+ };
127
+
128
+ const pointerFromSquare = (clientX: number, clientY: number) => {
129
+ const el = squareRef.current;
130
+ if (!el) return;
131
+ const r = el.getBoundingClientRect();
132
+ const ns = clamp((clientX - r.left) / r.width, 0, 1) * 100;
133
+ const nv = (1 - clamp((clientY - r.top) / r.height, 0, 1)) * 100;
134
+ commitHsv(h, ns, nv);
135
+ };
136
+
137
+ const dragRing = (e: React.PointerEvent) => {
138
+ if (disabled) return;
139
+ e.preventDefault();
140
+ (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
141
+ pointerFromRing(e.clientX, e.clientY);
142
+ };
143
+ const moveRing = (e: React.PointerEvent) => {
144
+ if (disabled || !(e.currentTarget as HTMLElement).hasPointerCapture(e.pointerId)) return;
145
+ pointerFromRing(e.clientX, e.clientY);
146
+ };
147
+ const dragSquare = (e: React.PointerEvent) => {
148
+ if (disabled) return;
149
+ e.preventDefault();
150
+ (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
151
+ pointerFromSquare(e.clientX, e.clientY);
152
+ };
153
+ const moveSquare = (e: React.PointerEvent) => {
154
+ if (disabled || !(e.currentTarget as HTMLElement).hasPointerCapture(e.pointerId)) return;
155
+ pointerFromSquare(e.clientX, e.clientY);
156
+ };
157
+
158
+ const ringKey = (e: React.KeyboardEvent) => {
159
+ if (disabled) return;
160
+ const big = e.key === "PageUp" || e.key === "PageDown";
161
+ const step = big ? 10 : 1;
162
+ let nh = h;
163
+ switch (e.key) {
164
+ case "ArrowRight":
165
+ case "ArrowUp":
166
+ case "PageUp":
167
+ nh = h + step;
168
+ break;
169
+ case "ArrowLeft":
170
+ case "ArrowDown":
171
+ case "PageDown":
172
+ nh = h - step;
173
+ break;
174
+ case "Home":
175
+ nh = 0;
176
+ break;
177
+ case "End":
178
+ nh = 359;
179
+ break;
180
+ default:
181
+ return;
182
+ }
183
+ e.preventDefault();
184
+ commitHsv(nh, s, v);
185
+ };
186
+
187
+ const squareKey = (e: React.KeyboardEvent) => {
188
+ if (disabled) return;
189
+ let ns = s;
190
+ let nv = v;
191
+ switch (e.key) {
192
+ case "ArrowRight":
193
+ ns = s + 2;
194
+ break;
195
+ case "ArrowLeft":
196
+ ns = s - 2;
197
+ break;
198
+ case "ArrowUp":
199
+ nv = v + 2;
200
+ break;
201
+ case "ArrowDown":
202
+ nv = v - 2;
203
+ break;
204
+ case "Home":
205
+ ns = 0;
206
+ break;
207
+ case "End":
208
+ ns = 100;
209
+ break;
210
+ default:
211
+ return;
212
+ }
213
+ e.preventDefault();
214
+ commitHsv(h, ns, nv);
215
+ };
216
+
217
+ // thumb positions
218
+ const rad = (h * Math.PI) / 180;
219
+ const hueX = CENTER + RING_RADIUS * Math.sin(rad);
220
+ const hueY = CENTER - RING_RADIUS * Math.cos(rad);
221
+ const svX = (s / 100) * SQUARE;
222
+ const svY = (1 - v / 100) * SQUARE;
223
+
224
+ const thumb =
225
+ "absolute size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white pointer-events-none shadow-[0_0_0_1px_rgba(0,0,0,0.45)]";
226
+
227
+ return (
228
+ <div
229
+ className={cn("relative select-none touch-none", disabled && "opacity-50")}
230
+ style={{ width: WHEEL_SIZE, height: WHEEL_SIZE }}
231
+ >
232
+ {/* Hue ring */}
233
+ <div
234
+ ref={ringRef}
235
+ role="slider"
236
+ aria-label="Hue"
237
+ aria-valuemin={0}
238
+ aria-valuemax={360}
239
+ aria-valuenow={Math.round(h)}
240
+ aria-valuetext={`${Math.round(h)} degrees`}
241
+ aria-disabled={disabled || undefined}
242
+ tabIndex={disabled ? -1 : 0}
243
+ onPointerDown={dragRing}
244
+ onPointerMove={moveRing}
245
+ onKeyDown={ringKey}
246
+ className={cn(
247
+ "absolute inset-0 rounded-full",
248
+ !disabled && "cursor-pointer",
249
+ "outline-none focus-visible:ring-[3px] focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-background"
250
+ )}
251
+ style={{ background: HUE_CONIC }}
252
+ />
253
+
254
+ {/* Center hole masks the conic so only the ring band shows */}
255
+ <div
256
+ aria-hidden
257
+ className="absolute rounded-full bg-background pointer-events-none"
258
+ style={{ width: HOLE, height: HOLE, left: RING_THICKNESS, top: RING_THICKNESS }}
259
+ />
260
+
261
+ {/* Saturation / brightness square */}
262
+ <div
263
+ ref={squareRef}
264
+ role="slider"
265
+ aria-label="Saturation and brightness"
266
+ aria-valuemin={0}
267
+ aria-valuemax={100}
268
+ aria-valuenow={Math.round(s)}
269
+ aria-valuetext={`Saturation ${Math.round(s)} percent, brightness ${Math.round(v)} percent`}
270
+ aria-disabled={disabled || undefined}
271
+ tabIndex={disabled ? -1 : 0}
272
+ onPointerDown={dragSquare}
273
+ onPointerMove={moveSquare}
274
+ onKeyDown={squareKey}
275
+ className={cn(
276
+ "absolute rounded-md",
277
+ !disabled && "cursor-crosshair",
278
+ "outline-none focus-visible:ring-[3px] focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-background"
279
+ )}
280
+ style={{
281
+ width: SQUARE,
282
+ height: SQUARE,
283
+ left: CENTER - SQUARE / 2,
284
+ top: CENTER - SQUARE / 2,
285
+ background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${Math.round(h)} 100% 50%))`,
286
+ }}
287
+ >
288
+ <span
289
+ aria-hidden
290
+ className={thumb}
291
+ style={{
292
+ left: svX,
293
+ top: svY,
294
+ backgroundColor: isValidHex(value) ? value : "#ffffff",
295
+ transitionProperty: "box-shadow",
296
+ transitionDuration: "var(--duration-fast)",
297
+ transitionTimingFunction: "var(--ease-out)",
298
+ }}
299
+ />
300
+ </div>
301
+
302
+ {/* Hue thumb (rendered last so it sits above the ring) */}
303
+ <span
304
+ aria-hidden
305
+ className={thumb}
306
+ style={{
307
+ left: hueX,
308
+ top: hueY,
309
+ backgroundColor: `hsl(${Math.round(h)} 100% 50%)`,
310
+ transitionProperty: "box-shadow",
311
+ transitionDuration: "var(--duration-fast)",
312
+ transitionTimingFunction: "var(--ease-out)",
313
+ }}
314
+ />
315
+ </div>
316
+ );
317
+ }
318
+
32
319
  /* -------------------------------------------------------------------------- */
33
320
  /* ColorPicker */
34
321
  /* -------------------------------------------------------------------------- */
@@ -43,6 +330,13 @@ export interface ColorPickerProps {
43
330
  swatches?: string[];
44
331
  /** Show a hex text input for custom colors */
45
332
  allowCustom?: boolean;
333
+ /**
334
+ * Show a hue-ring + saturation/brightness color wheel above the swatches.
335
+ * The wheel is a pointer/keyboard enhancement; the swatches + hex field
336
+ * remain the primary keyboard/screen-reader path. Enabling the wheel always
337
+ * surfaces the hex field too, so an exact value can still be typed.
338
+ */
339
+ wheel?: boolean;
46
340
  disabled?: boolean;
47
341
  /** Accessible label for the radiogroup */
48
342
  "aria-label"?: string;
@@ -55,6 +349,7 @@ export function ColorPicker({
55
349
  onValueChange,
56
350
  swatches = [],
57
351
  allowCustom = false,
352
+ wheel = false,
58
353
  disabled = false,
59
354
  "aria-label": ariaLabel = "Color picker",
60
355
  className,
@@ -64,7 +359,7 @@ export function ColorPicker({
64
359
  const value = isControlled ? (valueProp ?? "") : valueState;
65
360
 
66
361
  const [customInput, setCustomInput] = React.useState<string>(() =>
67
- value && !swatches.includes(value) ? value : ""
362
+ value && (wheel || !swatches.includes(value)) ? value : ""
68
363
  );
69
364
 
70
365
  const swatchRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
@@ -78,6 +373,15 @@ export function ColorPicker({
78
373
  [disabled, isControlled, onValueChange]
79
374
  );
80
375
 
376
+ // Keep the hex field mirrored when the wheel (or a swatch) drives the value.
377
+ const commitFromControl = React.useCallback(
378
+ (color: string) => {
379
+ commit(color);
380
+ setCustomInput(color);
381
+ },
382
+ [commit]
383
+ );
384
+
81
385
  const handleKeyDown = React.useCallback(
82
386
  (e: React.KeyboardEvent<HTMLButtonElement>, index: number) => {
83
387
  const btns = swatchRefs.current.filter((b): b is HTMLButtonElement => !!b);
@@ -116,9 +420,14 @@ export function ColorPicker({
116
420
  };
117
421
 
118
422
  const selectedSwatchIdx = swatches.indexOf(value);
423
+ const showHex = allowCustom || wheel;
119
424
 
120
425
  return (
121
- <div className={cn("space-y-2", className)}>
426
+ <div className={cn("space-y-3", className)}>
427
+ {wheel && (
428
+ <ColorWheel value={value} onChange={commitFromControl} disabled={disabled} />
429
+ )}
430
+
122
431
  {swatches.length > 0 && (
123
432
  <div
124
433
  role="radiogroup"
@@ -176,7 +485,7 @@ export function ColorPicker({
176
485
  </div>
177
486
  )}
178
487
 
179
- {allowCustom && (
488
+ {showHex && (
180
489
  <div className="flex items-center gap-2">
181
490
  <div
182
491
  role="presentation"
@@ -0,0 +1,152 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import {
3
+ Accordion,
4
+ AccordionItem,
5
+ AccordionTrigger,
6
+ AccordionContent,
7
+ } from "@behavioral-agentic-design-system/core/components/ui/accordion";
8
+
9
+ // Note: Accordion drives its transition duration/timing via inline style with
10
+ // var() references (BADS motion tokens), not Tailwind duration utilities.
11
+ // Never write an arbitrary-value duration class literally in the accordion
12
+ // source or here — Tailwind's content scanner extracts class-like tokens even
13
+ // from comments and compiles them into invalid CSS that breaks the build.
14
+
15
+ const meta: Meta<typeof Accordion> = {
16
+ title: "Components/Accordion",
17
+ component: Accordion,
18
+ parameters: { layout: "centered" },
19
+ tags: ["autodocs"],
20
+ };
21
+
22
+ export default meta;
23
+ type Story = StoryObj<typeof meta>;
24
+
25
+ export const Default: Story = {
26
+ render: () => (
27
+ <Accordion type="single" collapsible className="w-[400px]">
28
+ <AccordionItem value="item-1">
29
+ <AccordionTrigger>What is BADS?</AccordionTrigger>
30
+ <AccordionContent>
31
+ BADS (Behavioral Agentic Design System) is a portable, distributable
32
+ design system built as the starting point for client engagements. It
33
+ ships tokens, components, ethics layers, and agent interfaces in one
34
+ cohesive package.
35
+ </AccordionContent>
36
+ </AccordionItem>
37
+ <AccordionItem value="item-2">
38
+ <AccordionTrigger>How do I customize tokens?</AccordionTrigger>
39
+ <AccordionContent>
40
+ Edit <code>tokens.json</code> and run{" "}
41
+ <code>pnpm build:tokens</code>. Both the published CSS and the local
42
+ preview regenerate automatically.
43
+ </AccordionContent>
44
+ </AccordionItem>
45
+ <AccordionItem value="item-3">
46
+ <AccordionTrigger>What accessibility standard does BADS target?</AccordionTrigger>
47
+ <AccordionContent>
48
+ BADS targets WCAG 2.2 AAA out of the box — 7:1 contrast for normal
49
+ text, 44 × 44 px touch targets, reduced-motion respected, and
50
+ focus-visible on every interactive element.
51
+ </AccordionContent>
52
+ </AccordionItem>
53
+ </Accordion>
54
+ ),
55
+ };
56
+
57
+ export const Variant_Multiple: Story = {
58
+ render: () => (
59
+ <Accordion type="multiple" className="w-[400px]">
60
+ <AccordionItem value="item-1">
61
+ <AccordionTrigger>Primary membership</AccordionTrigger>
62
+ <AccordionContent>
63
+ Covers the account holder and up to two dependents. Includes all
64
+ scheduled group classes and open lap swim.
65
+ </AccordionContent>
66
+ </AccordionItem>
67
+ <AccordionItem value="item-2">
68
+ <AccordionTrigger>Guest passes</AccordionTrigger>
69
+ <AccordionContent>
70
+ Members can bring one guest per visit at no charge. Guests must
71
+ sign a liability waiver at the front desk.
72
+ </AccordionContent>
73
+ </AccordionItem>
74
+ <AccordionItem value="item-3">
75
+ <AccordionTrigger>Facility hours</AccordionTrigger>
76
+ <AccordionContent>
77
+ Weekdays 5:30 am – 10:00 pm. Weekends 7:00 am – 8:00 pm. Holiday
78
+ hours posted on the bulletin board.
79
+ </AccordionContent>
80
+ </AccordionItem>
81
+ </Accordion>
82
+ ),
83
+ };
84
+
85
+ export const Disabled: Story = {
86
+ render: () => (
87
+ <Accordion type="single" collapsible className="w-[400px]">
88
+ <AccordionItem value="item-1">
89
+ <AccordionTrigger>Available — click to expand</AccordionTrigger>
90
+ <AccordionContent>
91
+ This item is enabled and interactive.
92
+ </AccordionContent>
93
+ </AccordionItem>
94
+ <AccordionItem value="item-2">
95
+ <AccordionTrigger disabled>Disabled item</AccordionTrigger>
96
+ <AccordionContent>
97
+ This content is inaccessible when the trigger is disabled.
98
+ </AccordionContent>
99
+ </AccordionItem>
100
+ <AccordionItem value="item-3">
101
+ <AccordionTrigger>Another available item</AccordionTrigger>
102
+ <AccordionContent>
103
+ This item is also enabled and interactive.
104
+ </AccordionContent>
105
+ </AccordionItem>
106
+ </Accordion>
107
+ ),
108
+ };
109
+
110
+ export const RealisticUse: Story = {
111
+ render: () => (
112
+ <div className="w-[480px] rounded-lg border bg-card p-6">
113
+ <h3 className="mb-4 text-2xl font-semibold">Frequently asked questions</h3>
114
+ <Accordion type="single" collapsible>
115
+ <AccordionItem value="q1">
116
+ <AccordionTrigger>How long does onboarding take?</AccordionTrigger>
117
+ <AccordionContent className="text-muted-foreground">
118
+ Most teams are fully set up within one afternoon. The onboarding
119
+ wizard walks you through brand tokens, voice calibration, and
120
+ component scoping — no design-system experience required.
121
+ </AccordionContent>
122
+ </AccordionItem>
123
+ <AccordionItem value="q2">
124
+ <AccordionTrigger>Can I use my own font stack?</AccordionTrigger>
125
+ <AccordionContent className="text-muted-foreground">
126
+ Yes. Add your font files to <code>public/fonts/</code> and declare
127
+ them in <code>brand-fonts.json</code>. Run{" "}
128
+ <code>pnpm build:fonts</code> and the CSS updates automatically.
129
+ </AccordionContent>
130
+ </AccordionItem>
131
+ <AccordionItem value="q3">
132
+ <AccordionTrigger>Is Figma sync supported?</AccordionTrigger>
133
+ <AccordionContent className="text-muted-foreground">
134
+ Figma sync (Token Studio export → BADS import) is a v2 feature on
135
+ the roadmap. Today, tokens live in <code>tokens.json</code> and
136
+ are the single source of truth.
137
+ </AccordionContent>
138
+ </AccordionItem>
139
+ <AccordionItem value="q4">
140
+ <AccordionTrigger>What if I need a component BADS doesn't ship?</AccordionTrigger>
141
+ <AccordionContent className="text-muted-foreground">
142
+ Run the Component Readiness Audit in{" "}
143
+ <code>prompts/component-readiness-audit.md</code>. If the outcome
144
+ is "new primitive," surface it for approval. The Night Shift agent
145
+ builds one new primitive per night and hands you a draft PR in the
146
+ morning.
147
+ </AccordionContent>
148
+ </AccordionItem>
149
+ </Accordion>
150
+ </div>
151
+ ),
152
+ };
@@ -0,0 +1,102 @@
1
+ // These stories exercise the icon + title + description grid layout in Alert,
2
+ // AND the surface-hierarchy + accent contract: default = subtle primary tint +
3
+ // 4px primary left-accent bar + primary icon; destructive = full red border +
4
+ // 4px red left bar + red icon/text + subtle red tint. The colored-icon +
5
+ // left-accent language matches the Sonner toasts so alerts and notifications
6
+ // read as one family. (Accent/border colors use arbitrary `border-[var(--token)]!`
7
+ // because the named border-color utilities don't emit a rule in this Tailwind v4
8
+ // setup.) Any change to alertVariants should re-snapshot here in Chromatic.
9
+ import type { Meta, StoryObj } from "@storybook/react";
10
+ import { AlertCircleIcon } from "lucide-react";
11
+ import { Alert, AlertTitle, AlertDescription } from "@behavioral-agentic-design-system/core/components/ui/alert";
12
+ import { Card, CardContent, CardHeader, CardTitle } from "@behavioral-agentic-design-system/core/components/ui/card";
13
+
14
+ const meta: Meta<typeof Alert> = {
15
+ title: "Components/Alert",
16
+ component: Alert,
17
+ parameters: { layout: "centered" },
18
+ tags: ["autodocs"],
19
+ };
20
+
21
+ export default meta;
22
+ type Story = StoryObj<typeof meta>;
23
+
24
+ export const Default: Story = {
25
+ render: () => (<div className="w-[420px] flex flex-col gap-3">
26
+ <Alert>
27
+ <AlertCircleIcon className="h-5 w-5" />
28
+ <AlertTitle>Heads up</AlertTitle>
29
+ <AlertDescription>You can update settings any time.</AlertDescription>
30
+ </Alert>
31
+ <Alert variant="destructive">
32
+ <AlertCircleIcon className="h-5 w-5" />
33
+ <AlertTitle>Save failed</AlertTitle>
34
+ <AlertDescription>Couldn&apos;t reach the server. Try again.</AlertDescription>
35
+ </Alert>
36
+ </div>),
37
+ };
38
+
39
+ export const Variant_Default: Story = {
40
+ render: () => (<div className="w-[420px]">
41
+ <Alert variant="default">
42
+ <AlertCircleIcon className="h-5 w-5" />
43
+ <AlertTitle>Default</AlertTitle>
44
+ <AlertDescription>Heads up — something to read.</AlertDescription>
45
+ </Alert>
46
+ </div>),
47
+ };
48
+
49
+ export const Variant_Destructive: Story = {
50
+ render: () => (<div className="w-[420px]">
51
+ <Alert variant="destructive">
52
+ <AlertCircleIcon className="h-5 w-5" />
53
+ <AlertTitle>Destructive</AlertTitle>
54
+ <AlertDescription>Couldn't reach the server. Try again.</AlertDescription>
55
+ </Alert>
56
+ </div>),
57
+ };
58
+
59
+ // NestedInCard verifies the hierarchy contract — an Alert sitting inside a
60
+ // Card must remain visually distinct. Pre-fix, both surfaces used bg-card and
61
+ // the alert disappeared into the card.
62
+ export const NestedInCard: Story = {
63
+ render: () => (
64
+ <Card className="w-[460px]">
65
+ <CardHeader>
66
+ <CardTitle>Account settings</CardTitle>
67
+ </CardHeader>
68
+ <CardContent className="flex flex-col gap-3">
69
+ <Alert>
70
+ <AlertCircleIcon className="h-5 w-5" />
71
+ <AlertTitle>Email not verified</AlertTitle>
72
+ <AlertDescription>
73
+ Send a new verification link or skip for now.
74
+ </AlertDescription>
75
+ </Alert>
76
+ <Alert variant="destructive">
77
+ <AlertCircleIcon className="h-5 w-5" />
78
+ <AlertTitle>Plan downgrade pending</AlertTitle>
79
+ <AlertDescription>
80
+ Takes effect at the next billing cycle. Cancel anytime.
81
+ </AlertDescription>
82
+ </Alert>
83
+ </CardContent>
84
+ </Card>
85
+ ),
86
+ };
87
+
88
+ export const RealisticUse: Story = {
89
+ render: () => (<div className="w-[420px] flex flex-col gap-3">
90
+ <Alert>
91
+ <AlertCircleIcon className="h-5 w-5" />
92
+ <AlertTitle>Heads up</AlertTitle>
93
+ <AlertDescription>You can update settings any time.</AlertDescription>
94
+ </Alert>
95
+ <Alert variant="destructive">
96
+ <AlertCircleIcon className="h-5 w-5" />
97
+ <AlertTitle>Save failed</AlertTitle>
98
+ <AlertDescription>Couldn&apos;t reach the server. Try again.</AlertDescription>
99
+ </Alert>
100
+ </div>),
101
+ };
102
+