@behavioral-agentic-design-system/core 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/app/preview/components/page.tsx +138 -146
- package/src/app/shell.tsx +57 -4
- package/src/components/onboarding-wizard.tsx +1 -1
- package/src/components/ui/color-picker.tsx +171 -100
- package/src/stories/Accordion.stories.tsx +12 -9
- package/src/stories/ButtonGroup.stories.tsx +16 -16
- package/src/stories/ColorPicker.stories.tsx +36 -15
- package/src/stories/DatePicker.stories.tsx +2 -2
- package/src/stories/EmptyState.stories.tsx +21 -21
- package/src/stories/List.stories.tsx +28 -28
- package/src/stories/RatingGroup.stories.tsx +2 -2
- package/src/stories/SegmentedControl.stories.tsx +3 -3
- package/src/stories/TagsInput.stories.tsx +21 -21
- package/src/stories/Timeline.stories.tsx +50 -50
package/src/app/shell.tsx
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { useState, useEffect, useRef, useCallback, createContext, useContext, useMemo } from "react";
|
|
4
4
|
import { Tabs, TabsContent, TabsList, TabsPanels, TabsTrigger } from "@behavioral-agentic-design-system/core/components/ui/tabs";
|
|
5
|
+
import { Sheet, SheetContent, SheetHeader, SheetTitle } from "@behavioral-agentic-design-system/core/components/ui/sheet";
|
|
5
6
|
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
|
|
6
7
|
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
7
|
-
import { Sun, Moon, BookOpen, X, ExternalLink } from "lucide-react";
|
|
8
|
+
import { Sun, Moon, BookOpen, X, ExternalLink, Menu } from "lucide-react";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Inline GitHub mark. Lucide dropped brand icons (Github / Twitter / etc.) in
|
|
@@ -188,13 +189,15 @@ export const DEFAULT_TABS: ShellTab[] = [
|
|
|
188
189
|
*
|
|
189
190
|
* Forks that just want the default shell don't need to import this directly —
|
|
190
191
|
* they can re-export `@behavioral-agentic-design-system/core/app/page`. Use
|
|
191
|
-
* Shell directly when you need custom tabs (e.g.
|
|
192
|
-
*
|
|
192
|
+
* Shell directly when you need custom tabs (e.g. Components, Tokens, Changelog
|
|
193
|
+
* for a design-system docs site).
|
|
193
194
|
*/
|
|
194
195
|
export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
195
196
|
const initialTab = defaultTab ?? tabs[0]?.value ?? "home";
|
|
196
197
|
const [activeTab, setActiveTab] = useState(initialTab);
|
|
197
198
|
const [dark, setDark] = useState(false);
|
|
199
|
+
// Mobile nav: below md the tab strip collapses into a hamburger + Sheet.
|
|
200
|
+
const [mobileNavOpen, setMobileNavOpen] = useState(false);
|
|
198
201
|
// Fresh-fork onboarding: only render when brand still says "BADS" (the rename
|
|
199
202
|
// hasn't run yet) AND the user hasn't dismissed the wizard this session.
|
|
200
203
|
// Renamed forks never see this — they've already gone through onboarding.
|
|
@@ -510,7 +513,25 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
510
513
|
style={{ "--tabs-fade-duration": "260ms" } as React.CSSProperties}
|
|
511
514
|
className="flex-1 flex flex-col overflow-hidden"
|
|
512
515
|
>
|
|
513
|
-
<
|
|
516
|
+
{/* Mobile (<md): hamburger + active-tab label. The full tab strip is
|
|
517
|
+
hard to use on a phone, so it collapses into a Sheet drawer. */}
|
|
518
|
+
<div className="mt-2 mb-1 flex w-full items-center gap-2 px-4 md:hidden">
|
|
519
|
+
<Button
|
|
520
|
+
variant="ghost"
|
|
521
|
+
size="icon"
|
|
522
|
+
onClick={() => setMobileNavOpen(true)}
|
|
523
|
+
aria-label="Open navigation menu"
|
|
524
|
+
className="size-8 shrink-0 border border-foreground/30"
|
|
525
|
+
>
|
|
526
|
+
<Menu className="h-4 w-4" strokeWidth={1.5} />
|
|
527
|
+
</Button>
|
|
528
|
+
<span className="truncate text-sm font-medium text-foreground">
|
|
529
|
+
{tabs.find((t) => t.value === activeTab)?.label}
|
|
530
|
+
</span>
|
|
531
|
+
</div>
|
|
532
|
+
|
|
533
|
+
{/* Desktop (md+): the horizontal tab strip. */}
|
|
534
|
+
<div className="mt-2 mb-1 hidden w-full items-center px-4 overflow-x-auto scrollbar-none md:flex">
|
|
514
535
|
<TabsList className="bg-background text-muted-foreground inline-flex w-max shrink-0 items-center justify-center rounded-full px-0">
|
|
515
536
|
{tabs.map((tab) => (
|
|
516
537
|
<TabsTrigger
|
|
@@ -545,6 +566,38 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
545
566
|
</section>
|
|
546
567
|
</Tabs>
|
|
547
568
|
|
|
569
|
+
{/* Mobile navigation drawer — the tab list as a Sheet for small screens.
|
|
570
|
+
Excludes tabs marked hidden:"md" (dense iframe tabs that don't read
|
|
571
|
+
well on mobile), matching the desktop strip's behavior. */}
|
|
572
|
+
<Sheet open={mobileNavOpen} onOpenChange={setMobileNavOpen}>
|
|
573
|
+
<SheetContent side="left" className="w-72">
|
|
574
|
+
<SheetHeader>
|
|
575
|
+
<SheetTitle>{brand.name}</SheetTitle>
|
|
576
|
+
</SheetHeader>
|
|
577
|
+
<nav className="mt-4 flex flex-col gap-1 px-2">
|
|
578
|
+
{tabs
|
|
579
|
+
.filter((tab) => tab.hidden !== "md")
|
|
580
|
+
.map((tab) => (
|
|
581
|
+
<button
|
|
582
|
+
key={tab.value}
|
|
583
|
+
type="button"
|
|
584
|
+
onClick={() => {
|
|
585
|
+
selectTab(tab.value);
|
|
586
|
+
setMobileNavOpen(false);
|
|
587
|
+
}}
|
|
588
|
+
className={`rounded-md px-3 py-2 text-left text-sm font-medium transition-colors ${
|
|
589
|
+
activeTab === tab.value
|
|
590
|
+
? "bg-primary text-primary-foreground"
|
|
591
|
+
: "text-foreground hover:bg-muted"
|
|
592
|
+
}`}
|
|
593
|
+
>
|
|
594
|
+
{tab.label}
|
|
595
|
+
</button>
|
|
596
|
+
))}
|
|
597
|
+
</nav>
|
|
598
|
+
</SheetContent>
|
|
599
|
+
</Sheet>
|
|
600
|
+
|
|
548
601
|
{showOnboarding ? (
|
|
549
602
|
<div
|
|
550
603
|
role="dialog"
|
|
@@ -1092,7 +1092,7 @@ export function OnboardingWizard({
|
|
|
1092
1092
|
label="Industry or category"
|
|
1093
1093
|
value={draft.industry}
|
|
1094
1094
|
onChange={(industry) => updateDraft({ industry })}
|
|
1095
|
-
placeholder="Healthcare, education, devtools,
|
|
1095
|
+
placeholder="Healthcare, education, devtools, fintech..."
|
|
1096
1096
|
/>
|
|
1097
1097
|
<TextField
|
|
1098
1098
|
id="onboarding-audience"
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { Plus } from "lucide-react";
|
|
5
5
|
import { cn } from "../../lib/utils";
|
|
6
|
+
import { Popover, PopoverTrigger, PopoverContent } from "./popover";
|
|
7
|
+
import { Button } from "./button";
|
|
6
8
|
|
|
7
9
|
/* -------------------------------------------------------------------------- */
|
|
8
10
|
/* Helpers */
|
|
@@ -22,21 +24,6 @@ function rgbToHex(r: number, g: number, b: number): string {
|
|
|
22
24
|
return `#${to(r)}${to(g)}${to(b)}`;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
function luminance(hex: string): number {
|
|
26
|
-
const rgb = hexToRgb(hex);
|
|
27
|
-
if (!rgb) return 1;
|
|
28
|
-
const [r, g, b] = rgb.map((v) => {
|
|
29
|
-
const s = v / 255;
|
|
30
|
-
return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
|
|
31
|
-
});
|
|
32
|
-
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function contrastColor(hex: string): string {
|
|
36
|
-
if (!isValidHex(hex)) return "#ffffff";
|
|
37
|
-
return luminance(hex) > 0.179 ? "#000000" : "#ffffff";
|
|
38
|
-
}
|
|
39
|
-
|
|
40
27
|
function isValidHex(v: string): boolean {
|
|
41
28
|
return /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(v);
|
|
42
29
|
}
|
|
@@ -214,7 +201,6 @@ function ColorWheel({
|
|
|
214
201
|
commitHsv(h, ns, nv);
|
|
215
202
|
};
|
|
216
203
|
|
|
217
|
-
// thumb positions
|
|
218
204
|
const rad = (h * Math.PI) / 180;
|
|
219
205
|
const hueX = CENTER + RING_RADIUS * Math.sin(rad);
|
|
220
206
|
const hueY = CENTER - RING_RADIUS * Math.cos(rad);
|
|
@@ -229,7 +215,6 @@ function ColorWheel({
|
|
|
229
215
|
className={cn("relative select-none touch-none", disabled && "opacity-50")}
|
|
230
216
|
style={{ width: WHEEL_SIZE, height: WHEEL_SIZE }}
|
|
231
217
|
>
|
|
232
|
-
{/* Hue ring */}
|
|
233
218
|
<div
|
|
234
219
|
ref={ringRef}
|
|
235
220
|
role="slider"
|
|
@@ -251,14 +236,12 @@ function ColorWheel({
|
|
|
251
236
|
style={{ background: HUE_CONIC }}
|
|
252
237
|
/>
|
|
253
238
|
|
|
254
|
-
{/* Center hole masks the conic so only the ring band shows */}
|
|
255
239
|
<div
|
|
256
240
|
aria-hidden
|
|
257
241
|
className="absolute rounded-full bg-background pointer-events-none"
|
|
258
242
|
style={{ width: HOLE, height: HOLE, left: RING_THICKNESS, top: RING_THICKNESS }}
|
|
259
243
|
/>
|
|
260
244
|
|
|
261
|
-
{/* Saturation / brightness square */}
|
|
262
245
|
<div
|
|
263
246
|
ref={squareRef}
|
|
264
247
|
role="slider"
|
|
@@ -299,7 +282,6 @@ function ColorWheel({
|
|
|
299
282
|
/>
|
|
300
283
|
</div>
|
|
301
284
|
|
|
302
|
-
{/* Hue thumb (rendered last so it sits above the ring) */}
|
|
303
285
|
<span
|
|
304
286
|
aria-hidden
|
|
305
287
|
className={thumb}
|
|
@@ -328,15 +310,17 @@ export interface ColorPickerProps {
|
|
|
328
310
|
onValueChange?: (value: string) => void;
|
|
329
311
|
/** Preset swatch colors (hex strings) */
|
|
330
312
|
swatches?: string[];
|
|
331
|
-
/** Show a hex text input for custom colors */
|
|
313
|
+
/** Show a standalone hex text input for custom colors */
|
|
332
314
|
allowCustom?: boolean;
|
|
333
315
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
316
|
+
* Add an "add a custom color" tile (+) after the swatches. Clicking it opens
|
|
317
|
+
* a popover with a hue-ring + saturation/brightness color wheel (and a hex
|
|
318
|
+
* field); confirming appends the picked color to the swatches and selects it.
|
|
319
|
+
* The wheel only appears on demand — the swatch grid stays the default view.
|
|
338
320
|
*/
|
|
339
321
|
wheel?: boolean;
|
|
322
|
+
/** Fired when a color is added to the swatches via the wheel. */
|
|
323
|
+
onAddSwatch?: (hex: string) => void;
|
|
340
324
|
disabled?: boolean;
|
|
341
325
|
/** Accessible label for the radiogroup */
|
|
342
326
|
"aria-label"?: string;
|
|
@@ -350,6 +334,7 @@ export function ColorPicker({
|
|
|
350
334
|
swatches = [],
|
|
351
335
|
allowCustom = false,
|
|
352
336
|
wheel = false,
|
|
337
|
+
onAddSwatch,
|
|
353
338
|
disabled = false,
|
|
354
339
|
"aria-label": ariaLabel = "Color picker",
|
|
355
340
|
className,
|
|
@@ -359,9 +344,21 @@ export function ColorPicker({
|
|
|
359
344
|
const value = isControlled ? (valueProp ?? "") : valueState;
|
|
360
345
|
|
|
361
346
|
const [customInput, setCustomInput] = React.useState<string>(() =>
|
|
362
|
-
value &&
|
|
347
|
+
value && !swatches.includes(value) ? value : ""
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
// Colors the user has added through the wheel, appended after the presets.
|
|
351
|
+
const [addedSwatches, setAddedSwatches] = React.useState<string[]>([]);
|
|
352
|
+
const allSwatches = React.useMemo(
|
|
353
|
+
() => [...swatches, ...addedSwatches.filter((c) => !swatches.includes(c))],
|
|
354
|
+
[swatches, addedSwatches]
|
|
363
355
|
);
|
|
364
356
|
|
|
357
|
+
// Wheel popover state + its in-progress draft color.
|
|
358
|
+
const [wheelOpen, setWheelOpen] = React.useState(false);
|
|
359
|
+
const [draft, setDraft] = React.useState("#3b82f6");
|
|
360
|
+
const [draftInput, setDraftInput] = React.useState("#3b82f6");
|
|
361
|
+
|
|
365
362
|
const swatchRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
|
|
366
363
|
|
|
367
364
|
const commit = React.useCallback(
|
|
@@ -373,15 +370,6 @@ export function ColorPicker({
|
|
|
373
370
|
[disabled, isControlled, onValueChange]
|
|
374
371
|
);
|
|
375
372
|
|
|
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
|
-
|
|
385
373
|
const handleKeyDown = React.useCallback(
|
|
386
374
|
(e: React.KeyboardEvent<HTMLButtonElement>, index: number) => {
|
|
387
375
|
const btns = swatchRefs.current.filter((b): b is HTMLButtonElement => !!b);
|
|
@@ -419,80 +407,163 @@ export function ColorPicker({
|
|
|
419
407
|
if (isValidHex(v)) commit(v);
|
|
420
408
|
};
|
|
421
409
|
|
|
422
|
-
const
|
|
423
|
-
|
|
410
|
+
const openWheel = (open: boolean) => {
|
|
411
|
+
if (open) {
|
|
412
|
+
const seed = isValidHex(value) ? value : "#3b82f6";
|
|
413
|
+
setDraft(seed);
|
|
414
|
+
setDraftInput(seed);
|
|
415
|
+
}
|
|
416
|
+
setWheelOpen(open);
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
const setDraftColor = (hex: string) => {
|
|
420
|
+
setDraft(hex);
|
|
421
|
+
setDraftInput(hex);
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
const handleDraftInput = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
425
|
+
const v = e.target.value;
|
|
426
|
+
setDraftInput(v);
|
|
427
|
+
if (isValidHex(v)) setDraft(v);
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
const addColor = () => {
|
|
431
|
+
if (disabled || !isValidHex(draft)) return;
|
|
432
|
+
if (!allSwatches.includes(draft)) setAddedSwatches((prev) => [...prev, draft]);
|
|
433
|
+
commit(draft);
|
|
434
|
+
if (!swatches.includes(draft)) setCustomInput("");
|
|
435
|
+
onAddSwatch?.(draft);
|
|
436
|
+
setWheelOpen(false);
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
const selectedSwatchIdx = allSwatches.indexOf(value);
|
|
424
440
|
|
|
425
441
|
return (
|
|
426
442
|
<div className={cn("space-y-3", className)}>
|
|
427
|
-
{wheel && (
|
|
428
|
-
<
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
443
|
+
{(allSwatches.length > 0 || wheel) && (
|
|
444
|
+
<div className="flex flex-wrap items-center gap-1.5">
|
|
445
|
+
{allSwatches.length > 0 && (
|
|
446
|
+
<div
|
|
447
|
+
role="radiogroup"
|
|
448
|
+
aria-label={ariaLabel}
|
|
449
|
+
aria-disabled={disabled || undefined}
|
|
450
|
+
className="flex flex-wrap gap-1.5"
|
|
451
|
+
>
|
|
452
|
+
{allSwatches.map((swatch, i) => {
|
|
453
|
+
const isSelected = value === swatch;
|
|
454
|
+
const isRovingFocus = selectedSwatchIdx >= 0 ? isSelected : i === 0;
|
|
455
|
+
return (
|
|
456
|
+
<button
|
|
457
|
+
key={swatch}
|
|
458
|
+
ref={(el) => {
|
|
459
|
+
swatchRefs.current[i] = el;
|
|
460
|
+
}}
|
|
461
|
+
type="button"
|
|
462
|
+
role="radio"
|
|
463
|
+
aria-checked={isSelected}
|
|
464
|
+
aria-label={swatch}
|
|
465
|
+
tabIndex={isRovingFocus ? 0 : -1}
|
|
466
|
+
disabled={disabled}
|
|
467
|
+
onClick={() => {
|
|
468
|
+
commit(swatch);
|
|
469
|
+
setCustomInput("");
|
|
470
|
+
}}
|
|
471
|
+
onKeyDown={(e) => handleKeyDown(e, i)}
|
|
472
|
+
className={cn(
|
|
473
|
+
"size-7 shrink-0 rounded-md outline-none transition-[box-shadow]",
|
|
474
|
+
"focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
475
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
476
|
+
// Selected: an offset ring (radio-style), NOT a border on the color, so it
|
|
477
|
+
// reads as "selected" on any swatch instead of a harsh frame. Box-shadow
|
|
478
|
+
// rings are dropped in Windows High Contrast, so a forced-colors outline
|
|
479
|
+
// carries the selected state there (maps to a system color).
|
|
480
|
+
isSelected
|
|
481
|
+
? "ring-2 ring-offset-2 ring-offset-background ring-foreground forced-colors:outline forced-colors:outline-2 forced-colors:outline-offset-2"
|
|
482
|
+
: "hover:ring-2 hover:ring-offset-2 hover:ring-offset-background hover:ring-foreground/25"
|
|
483
|
+
)}
|
|
484
|
+
style={{
|
|
485
|
+
backgroundColor: swatch,
|
|
486
|
+
transitionDuration: "var(--duration-fast)",
|
|
487
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
488
|
+
}}
|
|
489
|
+
/>
|
|
490
|
+
);
|
|
491
|
+
})}
|
|
492
|
+
</div>
|
|
493
|
+
)}
|
|
494
|
+
|
|
495
|
+
{wheel && (
|
|
496
|
+
<Popover open={wheelOpen} onOpenChange={openWheel}>
|
|
497
|
+
<PopoverTrigger asChild>
|
|
498
|
+
<button
|
|
499
|
+
type="button"
|
|
500
|
+
aria-label="Add a custom color"
|
|
501
|
+
disabled={disabled}
|
|
502
|
+
className={cn(
|
|
503
|
+
"flex size-7 shrink-0 items-center justify-center rounded-md",
|
|
504
|
+
"border-2 border-dashed border-input text-muted-foreground",
|
|
505
|
+
"hover:border-foreground/40 hover:text-foreground",
|
|
506
|
+
"focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-offset-1",
|
|
507
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
508
|
+
"transition-[border-color,color]"
|
|
509
|
+
)}
|
|
510
|
+
style={{
|
|
511
|
+
transitionDuration: "var(--duration-fast)",
|
|
512
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
513
|
+
}}
|
|
514
|
+
>
|
|
515
|
+
<Plus className="size-4" strokeWidth={1.5} aria-hidden />
|
|
516
|
+
</button>
|
|
517
|
+
</PopoverTrigger>
|
|
518
|
+
<PopoverContent align="start" className="w-auto space-y-3">
|
|
519
|
+
<ColorWheel value={draft} onChange={setDraftColor} disabled={disabled} />
|
|
520
|
+
<div className="flex items-center gap-2">
|
|
521
|
+
<div
|
|
522
|
+
role="presentation"
|
|
523
|
+
className="size-8 shrink-0 rounded-md border border-input"
|
|
524
|
+
style={{ backgroundColor: isValidHex(draft) ? draft : "transparent" }}
|
|
480
525
|
/>
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
526
|
+
<input
|
|
527
|
+
type="text"
|
|
528
|
+
value={draftInput}
|
|
529
|
+
onChange={handleDraftInput}
|
|
530
|
+
disabled={disabled}
|
|
531
|
+
placeholder="#000000"
|
|
532
|
+
aria-label="Hex color"
|
|
533
|
+
spellCheck={false}
|
|
534
|
+
maxLength={7}
|
|
535
|
+
className={cn(
|
|
536
|
+
"h-9 w-full rounded-md border border-input bg-background px-2 py-1",
|
|
537
|
+
"font-mono text-sm text-foreground placeholder:text-muted-foreground",
|
|
538
|
+
"focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
539
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
540
|
+
"transition-[border-color,box-shadow]"
|
|
541
|
+
)}
|
|
542
|
+
style={{
|
|
543
|
+
transitionDuration: "var(--duration-fast)",
|
|
544
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
545
|
+
}}
|
|
546
|
+
/>
|
|
547
|
+
</div>
|
|
548
|
+
<Button
|
|
549
|
+
type="button"
|
|
550
|
+
onClick={addColor}
|
|
551
|
+
disabled={disabled || !isValidHex(draft)}
|
|
552
|
+
className="w-full"
|
|
553
|
+
>
|
|
554
|
+
Add color
|
|
555
|
+
</Button>
|
|
556
|
+
</PopoverContent>
|
|
557
|
+
</Popover>
|
|
558
|
+
)}
|
|
485
559
|
</div>
|
|
486
560
|
)}
|
|
487
561
|
|
|
488
|
-
{
|
|
562
|
+
{allowCustom && (
|
|
489
563
|
<div className="flex items-center gap-2">
|
|
490
564
|
<div
|
|
491
565
|
role="presentation"
|
|
492
|
-
className={cn(
|
|
493
|
-
"size-7 shrink-0 rounded-md border border-input",
|
|
494
|
-
"transition-colors"
|
|
495
|
-
)}
|
|
566
|
+
className={cn("size-7 shrink-0 rounded-md border border-input", "transition-colors")}
|
|
496
567
|
style={{
|
|
497
568
|
backgroundColor: value || "transparent",
|
|
498
569
|
transitionDuration: "var(--duration-fast)",
|
|
@@ -58,24 +58,27 @@ export const Variant_Multiple: Story = {
|
|
|
58
58
|
render: () => (
|
|
59
59
|
<Accordion type="multiple" className="w-[400px]">
|
|
60
60
|
<AccordionItem value="item-1">
|
|
61
|
-
<AccordionTrigger>
|
|
61
|
+
<AccordionTrigger>Token sync</AccordionTrigger>
|
|
62
62
|
<AccordionContent>
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
Tokens live in one source of truth and publish as CSS variables. When
|
|
64
|
+
the values change, every component that references them updates on the
|
|
65
|
+
next build.
|
|
65
66
|
</AccordionContent>
|
|
66
67
|
</AccordionItem>
|
|
67
68
|
<AccordionItem value="item-2">
|
|
68
|
-
<AccordionTrigger>
|
|
69
|
+
<AccordionTrigger>Component adoption</AccordionTrigger>
|
|
69
70
|
<AccordionContent>
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
Install the package, import the primitive you need, and drop it into a
|
|
72
|
+
route. Each component ships with an accessibility contract and a set
|
|
73
|
+
of documented variants.
|
|
72
74
|
</AccordionContent>
|
|
73
75
|
</AccordionItem>
|
|
74
76
|
<AccordionItem value="item-3">
|
|
75
|
-
<AccordionTrigger>
|
|
77
|
+
<AccordionTrigger>Versioning and releases</AccordionTrigger>
|
|
76
78
|
<AccordionContent>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
Releases follow semantic versioning. Breaking changes land in major
|
|
80
|
+
bumps with a migration note, and the changelog records every shipped
|
|
81
|
+
fix and feature.
|
|
79
82
|
</AccordionContent>
|
|
80
83
|
</AccordionItem>
|
|
81
84
|
</Accordion>
|
|
@@ -37,10 +37,10 @@ type Story = StoryObj<typeof ButtonGroup>
|
|
|
37
37
|
|
|
38
38
|
export const Default: Story = {
|
|
39
39
|
render: () => (
|
|
40
|
-
<ButtonGroup aria-label="
|
|
41
|
-
<Button variant="outline">All
|
|
42
|
-
<Button variant="outline">
|
|
43
|
-
<Button variant="outline">
|
|
40
|
+
<ButtonGroup aria-label="Component filter">
|
|
41
|
+
<Button variant="outline">All</Button>
|
|
42
|
+
<Button variant="outline">Published</Button>
|
|
43
|
+
<Button variant="outline">Draft</Button>
|
|
44
44
|
</ButtonGroup>
|
|
45
45
|
),
|
|
46
46
|
}
|
|
@@ -63,21 +63,21 @@ export const WithIcons: Story = {
|
|
|
63
63
|
|
|
64
64
|
export const Vertical: Story = {
|
|
65
65
|
render: () => (
|
|
66
|
-
<ButtonGroup orientation="vertical" aria-label="
|
|
67
|
-
<Button variant="outline">
|
|
68
|
-
<Button variant="outline">
|
|
69
|
-
<Button variant="outline">
|
|
70
|
-
<Button variant="outline">
|
|
66
|
+
<ButtonGroup orientation="vertical" aria-label="Design system views">
|
|
67
|
+
<Button variant="outline">Figma</Button>
|
|
68
|
+
<Button variant="outline">Storybook</Button>
|
|
69
|
+
<Button variant="outline">Code</Button>
|
|
70
|
+
<Button variant="outline">Tokens</Button>
|
|
71
71
|
</ButtonGroup>
|
|
72
72
|
),
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export const Variant_Default: Story = {
|
|
76
76
|
render: () => (
|
|
77
|
-
<ButtonGroup aria-label="
|
|
78
|
-
<Button variant="default">
|
|
79
|
-
<Button variant="default">
|
|
80
|
-
<Button variant="default">
|
|
77
|
+
<ButtonGroup aria-label="Release channel">
|
|
78
|
+
<Button variant="default">Stable</Button>
|
|
79
|
+
<Button variant="default">Beta</Button>
|
|
80
|
+
<Button variant="default">Alpha</Button>
|
|
81
81
|
</ButtonGroup>
|
|
82
82
|
),
|
|
83
83
|
}
|
|
@@ -155,15 +155,15 @@ export const RealisticUse: Story = {
|
|
|
155
155
|
|
|
156
156
|
{/* Reaction row */}
|
|
157
157
|
<div className="space-y-1.5">
|
|
158
|
-
<p className="text-xs font-medium text-muted-foreground">
|
|
159
|
-
<ButtonGroup aria-label="Rate this
|
|
158
|
+
<p className="text-xs font-medium text-muted-foreground">Feedback</p>
|
|
159
|
+
<ButtonGroup aria-label="Rate this component">
|
|
160
160
|
<Button variant="outline">
|
|
161
161
|
<ThumbsUpIcon strokeWidth={1.5} />
|
|
162
162
|
Helpful
|
|
163
163
|
</Button>
|
|
164
164
|
<Button variant="outline">
|
|
165
165
|
<ThumbsDownIcon strokeWidth={1.5} />
|
|
166
|
-
|
|
166
|
+
Not helpful
|
|
167
167
|
</Button>
|
|
168
168
|
<Button variant="outline">
|
|
169
169
|
<ShareIcon strokeWidth={1.5} />
|
|
@@ -46,33 +46,54 @@ export const WithCustomInput: Story = {
|
|
|
46
46
|
),
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
// Selection is shown by an offset ring (radio convention), not a checkmark —
|
|
50
|
+
// a check reads as a multi-select checkbox, but swatches are single-select.
|
|
51
|
+
export const Selected: Story = {
|
|
52
|
+
render: () => (
|
|
53
|
+
<ColorPicker
|
|
54
|
+
swatches={BRAND_SWATCHES}
|
|
55
|
+
defaultValue="#8b5cf6"
|
|
56
|
+
aria-label="A color is selected"
|
|
57
|
+
/>
|
|
58
|
+
),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const AddViaWheel: Story = {
|
|
62
|
+
render: function AddViaWheelPicker() {
|
|
63
|
+
const [color, setColor] = React.useState("#8b5cf6");
|
|
52
64
|
return (
|
|
53
65
|
<div className="space-y-3">
|
|
66
|
+
<p className="text-xs text-muted-foreground">
|
|
67
|
+
Click the dashed <span className="font-medium text-foreground">+</span> tile to open the
|
|
68
|
+
color wheel and add a custom swatch.
|
|
69
|
+
</p>
|
|
54
70
|
<ColorPicker
|
|
55
71
|
value={color}
|
|
56
72
|
onValueChange={setColor}
|
|
57
73
|
wheel
|
|
58
|
-
|
|
74
|
+
swatches={BRAND_SWATCHES}
|
|
75
|
+
aria-label="Pick a swatch or add a custom color"
|
|
59
76
|
/>
|
|
60
77
|
</div>
|
|
61
78
|
);
|
|
62
79
|
},
|
|
63
80
|
};
|
|
64
81
|
|
|
65
|
-
export const
|
|
66
|
-
render: function
|
|
67
|
-
const [color, setColor] = React.useState("
|
|
82
|
+
export const AddOnlyWheel: Story = {
|
|
83
|
+
render: function AddOnlyPicker() {
|
|
84
|
+
const [color, setColor] = React.useState("");
|
|
68
85
|
return (
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
<div className="space-y-3">
|
|
87
|
+
<p className="text-xs text-muted-foreground">
|
|
88
|
+
No presets — build the palette from scratch with the <span className="font-medium text-foreground">+</span> tile.
|
|
89
|
+
</p>
|
|
90
|
+
<ColorPicker
|
|
91
|
+
value={color}
|
|
92
|
+
onValueChange={setColor}
|
|
93
|
+
wheel
|
|
94
|
+
aria-label="Add a custom color"
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
76
97
|
);
|
|
77
98
|
},
|
|
78
99
|
};
|
|
@@ -176,7 +197,7 @@ export const RealisticUse: Story = {
|
|
|
176
197
|
style={{ backgroundColor: tagTextColor(tagColor) }}
|
|
177
198
|
aria-hidden
|
|
178
199
|
/>
|
|
179
|
-
|
|
200
|
+
Tokens
|
|
180
201
|
</div>
|
|
181
202
|
</div>
|
|
182
203
|
</CardContent>
|