@behavioral-agentic-design-system/core 0.24.0 → 0.27.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 (137) hide show
  1. package/package.json +5 -2
  2. package/scripts/build-tokens.cjs +87 -5
  3. package/src/app/preview/components/page.tsx +4745 -244
  4. package/src/app/shell.tsx +18 -6
  5. package/src/components/customize/brand-mark-section.tsx +1 -1
  6. package/src/components/customize-tab.tsx +2 -2
  7. package/src/components/home-tab.tsx +2 -2
  8. package/src/components/ui/action-bar.tsx +142 -0
  9. package/src/components/ui/affix.tsx +109 -0
  10. package/src/components/ui/alert.tsx +37 -3
  11. package/src/components/ui/anchor.tsx +136 -0
  12. package/src/components/ui/angle-slider.tsx +265 -0
  13. package/src/components/ui/autocomplete.tsx +223 -0
  14. package/src/components/ui/avatar.tsx +8 -2
  15. package/src/components/ui/blockquote.tsx +112 -0
  16. package/src/components/ui/bottom-navigation.tsx +144 -0
  17. package/src/components/ui/burger.tsx +117 -0
  18. package/src/components/ui/button.tsx +101 -3
  19. package/src/components/ui/calendar.tsx +1 -1
  20. package/src/components/ui/card.tsx +43 -5
  21. package/src/components/ui/carousel.tsx +10 -5
  22. package/src/components/ui/cascader.tsx +253 -0
  23. package/src/components/ui/checkbox-card.tsx +176 -0
  24. package/src/components/ui/checkbox-group.tsx +231 -0
  25. package/src/components/ui/checkbox.tsx +14 -3
  26. package/src/components/ui/chip.tsx +143 -0
  27. package/src/components/ui/circular-progress.tsx +2 -2
  28. package/src/components/ui/color-swatch.tsx +73 -0
  29. package/src/components/ui/copy-button.tsx +21 -4
  30. package/src/components/ui/date-picker.tsx +6 -3
  31. package/src/components/ui/date-range-picker.tsx +6 -3
  32. package/src/components/ui/float-label.tsx +114 -0
  33. package/src/components/ui/floating-action-button.tsx +179 -0
  34. package/src/components/ui/floating-panel.tsx +129 -0
  35. package/src/components/ui/format-number.tsx +122 -0
  36. package/src/components/ui/highlight.tsx +85 -0
  37. package/src/components/ui/image.tsx +195 -0
  38. package/src/components/ui/index.ts +51 -0
  39. package/src/components/ui/indicator.tsx +2 -2
  40. package/src/components/ui/input.tsx +48 -4
  41. package/src/components/ui/kbd.tsx +1 -1
  42. package/src/components/ui/link.tsx +158 -0
  43. package/src/components/ui/listbox.tsx +426 -0
  44. package/src/components/ui/loading-overlay.tsx +80 -0
  45. package/src/components/ui/marquee.tsx +193 -0
  46. package/src/components/ui/masonry.tsx +164 -0
  47. package/src/components/ui/meter.tsx +186 -0
  48. package/src/components/ui/motion-toggle.tsx +170 -0
  49. package/src/components/ui/notification.tsx +175 -0
  50. package/src/components/ui/overlay.tsx +63 -0
  51. package/src/components/ui/progress.tsx +95 -4
  52. package/src/components/ui/rating-group.tsx +1 -0
  53. package/src/components/ui/separator.tsx +57 -1
  54. package/src/components/ui/sidebar.tsx +1 -1
  55. package/src/components/ui/signature-pad.tsx +381 -0
  56. package/src/components/ui/skeleton.tsx +59 -2
  57. package/src/components/ui/skip-link.tsx +117 -0
  58. package/src/components/ui/slider.tsx +86 -1
  59. package/src/components/ui/spoiler.tsx +131 -0
  60. package/src/components/ui/tabs.tsx +1 -1
  61. package/src/components/ui/text.tsx +135 -0
  62. package/src/components/ui/textarea.tsx +66 -2
  63. package/src/components/ui/timeline.tsx +71 -14
  64. package/src/components/ui/timer.tsx +183 -0
  65. package/src/components/ui/tour.tsx +332 -0
  66. package/src/components/ui/transfer-list.tsx +343 -0
  67. package/src/components/ui/typing-indicator.tsx +96 -0
  68. package/src/components/ui/visually-hidden.tsx +42 -0
  69. package/src/components/ui/watermark.tsx +0 -0
  70. package/src/components/ui/word-rotate.tsx +82 -0
  71. package/src/data/docs-index.ts +10 -2
  72. package/src/stories/ActionBar.stories.tsx +201 -0
  73. package/src/stories/Affix.stories.tsx +165 -0
  74. package/src/stories/Alert.stories.tsx +58 -0
  75. package/src/stories/Anchor.stories.tsx +236 -0
  76. package/src/stories/AngleSlider.stories.tsx +128 -0
  77. package/src/stories/Autocomplete.stories.tsx +216 -0
  78. package/src/stories/Avatar.stories.tsx +73 -1
  79. package/src/stories/Blockquote.stories.tsx +148 -0
  80. package/src/stories/BottomNavigation.stories.tsx +195 -0
  81. package/src/stories/Burger.stories.tsx +79 -0
  82. package/src/stories/Button.stories.tsx +103 -2
  83. package/src/stories/Calendar.stories.tsx +4 -0
  84. package/src/stories/Card.stories.tsx +30 -0
  85. package/src/stories/Carousel.stories.tsx +2 -1
  86. package/src/stories/Cascader.stories.tsx +285 -0
  87. package/src/stories/Checkbox.stories.tsx +13 -0
  88. package/src/stories/CheckboxCard.stories.tsx +210 -0
  89. package/src/stories/CheckboxGroup.stories.tsx +186 -0
  90. package/src/stories/Chip.stories.tsx +173 -0
  91. package/src/stories/CircularProgress.stories.tsx +3 -0
  92. package/src/stories/ColorSwatch.stories.tsx +81 -0
  93. package/src/stories/CopyButton.stories.tsx +3 -3
  94. package/src/stories/DatePicker.stories.tsx +3 -0
  95. package/src/stories/DateRangePicker.stories.tsx +3 -0
  96. package/src/stories/Editable.stories.tsx +14 -0
  97. package/src/stories/FloatLabel.stories.tsx +148 -0
  98. package/src/stories/FloatingActionButton.stories.tsx +215 -0
  99. package/src/stories/FloatingPanel.stories.tsx +176 -0
  100. package/src/stories/FormatNumber.stories.tsx +308 -0
  101. package/src/stories/Highlight.stories.tsx +140 -0
  102. package/src/stories/Image.stories.tsx +141 -0
  103. package/src/stories/Indicator.stories.tsx +3 -0
  104. package/src/stories/Input.stories.tsx +33 -0
  105. package/src/stories/Kbd.stories.tsx +3 -0
  106. package/src/stories/Link.stories.tsx +198 -0
  107. package/src/stories/Listbox.stories.tsx +240 -0
  108. package/src/stories/LoadingOverlay.stories.tsx +148 -0
  109. package/src/stories/Marquee.stories.tsx +170 -0
  110. package/src/stories/Masonry.stories.tsx +227 -0
  111. package/src/stories/Meter.stories.tsx +150 -0
  112. package/src/stories/MotionToggle.stories.tsx +85 -0
  113. package/src/stories/Notification.stories.tsx +264 -0
  114. package/src/stories/Overlay.stories.tsx +169 -0
  115. package/src/stories/PasswordInput.stories.tsx +4 -0
  116. package/src/stories/Progress.stories.tsx +70 -27
  117. package/src/stories/RatingGroup.stories.tsx +5 -0
  118. package/src/stories/Separator.stories.tsx +41 -5
  119. package/src/stories/Sidebar.stories.tsx +2 -1
  120. package/src/stories/SignaturePad.stories.tsx +112 -0
  121. package/src/stories/Skeleton.stories.tsx +23 -4
  122. package/src/stories/SkipLink.stories.tsx +137 -0
  123. package/src/stories/Slider.stories.tsx +28 -0
  124. package/src/stories/Spoiler.stories.tsx +122 -0
  125. package/src/stories/Tabs.stories.tsx +2 -1
  126. package/src/stories/Text.stories.tsx +191 -0
  127. package/src/stories/Textarea.stories.tsx +58 -6
  128. package/src/stories/Timeline.stories.tsx +82 -0
  129. package/src/stories/Timer.stories.tsx +160 -0
  130. package/src/stories/Tour.stories.tsx +191 -0
  131. package/src/stories/TransferList.stories.tsx +190 -0
  132. package/src/stories/TypingIndicator.stories.tsx +139 -0
  133. package/src/stories/VisuallyHidden.stories.tsx +105 -0
  134. package/src/stories/Watermark.stories.tsx +212 -0
  135. package/src/stories/WordRotate.stories.tsx +101 -0
  136. package/src/styles.css +88 -6
  137. package/src/tokens.json +3 -3
@@ -0,0 +1,96 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cn } from "../../lib/utils"
5
+
6
+ /**
7
+ * TypingIndicator — three-dot animated is-typing signal for chat and AI
8
+ * response surfaces. Matches the pattern used by Signal, Slack, iMessage,
9
+ * and Ant Design X (Bubble.Typing).
10
+ *
11
+ * Motion: pattern (b) keyframe `typing-dot` defined in build-tokens.cjs,
12
+ * applied per-dot with a staggered `animationDelay` via inline style (pattern
13
+ * c). The three-dot sequence runs at 1.2 s per cycle, 200 ms apart.
14
+ * Reduced-motion: the base-layer `@media (prefers-reduced-motion: reduce)`
15
+ * forces `animation-duration: 0.01ms` — dots snap to their rest state
16
+ * instantly and the indicator reads as a static three-dot ellipsis.
17
+ *
18
+ * Accessibility: the outer span carries `role="status"` + `aria-label` so
19
+ * the typing state is announced politely to screen readers on mount. The dot
20
+ * spans are `aria-hidden` — the dots themselves carry no information; the
21
+ * label does. Pair with an aria-live region or Sonner toast for the actual
22
+ * response text.
23
+ *
24
+ * Ethics contract: no data collected, darkPatternRisk none. The indicator
25
+ * must reflect real async work — never fake a typing animation to add
26
+ * perceived thoughtfulness to an already-computed response (that's deceptive
27
+ * theater, not a loading state).
28
+ */
29
+
30
+ export interface TypingIndicatorProps
31
+ extends React.ComponentProps<"span"> {
32
+ /** Accessible label for screen readers. Default "Typing". */
33
+ label?: string
34
+ /** Visual size of the dot cluster. Default "default". */
35
+ size?: "sm" | "default" | "lg"
36
+ }
37
+
38
+ const DOT_SIZES: Record<NonNullable<TypingIndicatorProps["size"]>, string> = {
39
+ sm: "size-1",
40
+ default: "size-1.5",
41
+ lg: "size-2",
42
+ }
43
+
44
+ const GAP_SIZES: Record<NonNullable<TypingIndicatorProps["size"]>, string> = {
45
+ sm: "gap-0.5",
46
+ default: "gap-1",
47
+ lg: "gap-1.5",
48
+ }
49
+
50
+ const PADDING_SIZES: Record<NonNullable<TypingIndicatorProps["size"]>, string> = {
51
+ sm: "px-2 py-1",
52
+ default: "px-2.5 py-1.5",
53
+ lg: "px-3 py-2",
54
+ }
55
+
56
+ function TypingIndicator({
57
+ label = "Typing",
58
+ size = "default",
59
+ className,
60
+ ...props
61
+ }: TypingIndicatorProps) {
62
+ return (
63
+ <span
64
+ role="status"
65
+ aria-label={label}
66
+ data-slot="typing-indicator"
67
+ data-size={size}
68
+ className={cn(
69
+ "inline-flex items-center rounded-full bg-muted",
70
+ PADDING_SIZES[size],
71
+ className
72
+ )}
73
+ {...props}
74
+ >
75
+ {/* Dot cluster — aria-hidden; the role=status label carries meaning */}
76
+ <span
77
+ aria-hidden="true"
78
+ className={cn("flex items-center", GAP_SIZES[size])}
79
+ >
80
+ {[0, 1, 2].map((i) => (
81
+ <span
82
+ key={i}
83
+ data-slot="typing-indicator-dot"
84
+ className={cn("rounded-full bg-muted-foreground", DOT_SIZES[size])}
85
+ style={{
86
+ animation: "typing-dot 1.2s ease-in-out infinite",
87
+ animationDelay: `${i * 200}ms`,
88
+ }}
89
+ />
90
+ ))}
91
+ </span>
92
+ </span>
93
+ )
94
+ }
95
+
96
+ export { TypingIndicator }
@@ -0,0 +1,42 @@
1
+ import * as React from "react"
2
+ import { Slot } from "@radix-ui/react-slot"
3
+
4
+ import { cn } from "../../lib/utils"
5
+
6
+ /**
7
+ * VisuallyHidden — renders content invisible on screen but fully present in
8
+ * the accessibility tree, so screen readers announce it normally. The
9
+ * canonical use is giving icon-only controls an accessible name, or adding
10
+ * screen-reader-only context (table captions, live-region text) without
11
+ * disturbing the visual layout.
12
+ *
13
+ * Implementation note: CSS-only via Tailwind's `sr-only` utility (the same
14
+ * absolute-position + 1px clip technique Radix's react-visually-hidden ships).
15
+ * That package is intentionally NOT imported — it isn't a declared dependency
16
+ * of @behavioral-agentic-design-system/core, and the CSS pattern is identical.
17
+ *
18
+ * Zero-motion exception (documented, not omitted): this primitive has no
19
+ * interactive states — it is invisible and never a focus target — so the
20
+ * system-wide microanimation rule is vacuously satisfied. Never wrap
21
+ * focusable elements in it (an invisible focus stop strands keyboard users);
22
+ * to hide content FROM assistive tech instead, use `aria-hidden`.
23
+ */
24
+ function VisuallyHidden({
25
+ asChild = false,
26
+ className,
27
+ ...props
28
+ }: React.ComponentProps<"span"> & {
29
+ /** Merge the sr-only behavior onto the child element instead of rendering a wrapping span (Radix Slot pattern). */
30
+ asChild?: boolean
31
+ }) {
32
+ const Comp = asChild ? Slot : "span"
33
+ return (
34
+ <Comp
35
+ data-slot="visually-hidden"
36
+ className={cn("sr-only", className)}
37
+ {...props}
38
+ />
39
+ )
40
+ }
41
+
42
+ export { VisuallyHidden }
Binary file
@@ -0,0 +1,82 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cn } from "../../lib/utils"
5
+
6
+ export interface WordRotateProps {
7
+ /** Words to cycle through. Needs at least 2 to animate. */
8
+ words: string[]
9
+ /**
10
+ * Milliseconds each word is shown before transitioning.
11
+ * Default: 2000 (2 s).
12
+ */
13
+ interval?: number
14
+ /** Extra className on the outer inline wrapper. */
15
+ className?: string
16
+ }
17
+
18
+ /**
19
+ * WordRotate — cycles an array of words in place with a slide-fade exit/entrance.
20
+ * Zero dependencies; uses CSS transitions with token-driven duration/easing.
21
+ *
22
+ * Motion: current word slides up + fades out, next word slides in from below +
23
+ * fades in. Transition duration is var(--duration-base); easing is var(--ease-out).
24
+ * Reduced-motion: the base layer collapses all transitions to 0.01 ms.
25
+ *
26
+ * Accessibility: outer span carries aria-live="polite" + aria-atomic="true" so
27
+ * the current word is announced on each swap. The animated span is aria-hidden;
28
+ * a sr-only span carries the live-region text.
29
+ */
30
+ function WordRotate({
31
+ words,
32
+ interval = 2000,
33
+ className,
34
+ }: WordRotateProps) {
35
+ const [index, setIndex] = React.useState(0)
36
+ const [visible, setVisible] = React.useState(true)
37
+
38
+ React.useEffect(() => {
39
+ if (words.length <= 1) return
40
+ let swapId: ReturnType<typeof setTimeout>
41
+ const id = setInterval(() => {
42
+ // Phase 1: exit current word
43
+ setVisible(false)
44
+ // Phase 2: swap word + enter — timed to match transition-duration
45
+ swapId = setTimeout(() => {
46
+ setIndex((i) => (i + 1) % words.length)
47
+ setVisible(true)
48
+ }, 200)
49
+ }, interval)
50
+ return () => {
51
+ clearInterval(id)
52
+ clearTimeout(swapId)
53
+ }
54
+ }, [words.length, interval])
55
+
56
+ return (
57
+ <span
58
+ data-slot="word-rotate"
59
+ aria-live="polite"
60
+ aria-atomic="true"
61
+ className={cn("inline-block overflow-hidden", className)}
62
+ >
63
+ {/* Visual word — aria-hidden because sr-only below carries the live region */}
64
+ <span
65
+ aria-hidden="true"
66
+ className="inline-block transition-[opacity,transform]"
67
+ style={{
68
+ opacity: visible ? 1 : 0,
69
+ transform: visible ? "translateY(0)" : "translateY(-30%)",
70
+ transitionDuration: "var(--duration-base)",
71
+ transitionTimingFunction: "var(--ease-out)",
72
+ }}
73
+ >
74
+ {words[index]}
75
+ </span>
76
+ {/* Screen reader always gets the current word via the live region */}
77
+ <span className="sr-only">{words[index]}</span>
78
+ </span>
79
+ )
80
+ }
81
+
82
+ export { WordRotate }
@@ -61,17 +61,18 @@ export const DOCS_INDEX: DocGroup[] = [
61
61
  { title: "Storybook rule", path: "STORYBOOK_RULE.md" },
62
62
  { title: "CTA size contract", path: "prompts/cta-size-contract.md" },
63
63
  { title: "Motion spec", path: "prompts/motion-spec.md" },
64
+ { title: "Motion choreography", path: "prompts/motion-choreography.md", summary: "Page-scale motion for expressive/motion-led surfaces (hero, landing) — timing budget, stagger-by-hierarchy, coverage sweep, signature-techniques menu, linear() springs. Opt-in, gated on the brand's motion dial; reconciled with BADS' anti-defaults. Adapted from VibeCurb's awwwards-motion." },
64
65
  ],
65
66
  },
66
67
  {
67
68
  id: "agent-system",
68
69
  label: "Agent system",
69
- description: "How autonomous agents read BADS — instructions, operating modes, the nightly loops.",
70
+ description: "How autonomous agents read BADS — instructions, the Night Shift spec, the nightly loops.",
70
71
  entries: [
71
72
  { title: "CLAUDE.md", path: "CLAUDE.md", summary: "The agent contract — every workflow rule lives here." },
72
73
  { title: "AGENTS.md", path: "AGENTS.md", summary: "Loading precedence + escalation rules." },
73
74
  { title: "V0 system prompt", path: "V0_SYSTEM.md" },
74
- { title: "Circadian operating modes", path: "CIRCADIAN.md", summary: "What agents should and shouldn't do at different times of day." },
75
+ { title: "Night Shift spec", path: "CIRCADIAN.md", summary: "The overnight agent: what it audits, researches, builds, tests, merges, and reports each night." },
75
76
  { title: "Night Shift prompt", path: "scripts/prompts/night-shift.md", summary: "The full nightly research + auto-PR pass." },
76
77
  { title: "Agent roadmap", path: "docs/agent-roadmap.md" },
77
78
  { title: "Intent-driven context", path: "docs/intent-driven-context.md", summary: "Constraint vs guideline vs framing vs workflow — and what delivery each demands." },
@@ -89,6 +90,8 @@ export const DOCS_INDEX: DocGroup[] = [
89
90
  { title: "Skill — persona-pressure-test", path: ".claude/skills/persona-pressure-test/SKILL.md" },
90
91
  { title: "Skill — promote-prototype", path: ".claude/skills/promote-prototype/SKILL.md" },
91
92
  { title: "Skill — visual-verify", path: ".claude/skills/visual-verify/SKILL.md" },
93
+ { title: "Prompt — conceptual model", path: "prompts/conceptual-model.md", summary: "Before sketching a product surface, name its domain objects, states, relationships, and vocabulary — Jamie Mill's 'most neglected layer,' wired into Path B as design-exploration step 3.5. Feeds the real-content pool, state patterns, and primitive selection." },
94
+ { title: "Prompt — parallel rollout", path: "prompts/parallel-rollout.md", summary: "For a Path B build that's N similar surfaces: build one reference screen, turn it into an explicit contract, sign off on the contract, then fan the rest out against it (via Workflow) and verify each to the contract. Stops multi-screen drift. Adapted from the design-spec-framework." },
92
95
  { title: "Prompt — design directions", path: "prompts/design-directions.md" },
93
96
  { title: "Prompt — design critique", path: "prompts/design-critique.md" },
94
97
  { title: "Prompt — independent critique", path: "prompts/independent-critique.md" },
@@ -103,7 +106,9 @@ export const DOCS_INDEX: DocGroup[] = [
103
106
  entries: [
104
107
  { title: "Design rules", path: "DESIGN.md", summary: "Visual system + accessibility baseline." },
105
108
  { title: "Chart color palette", path: "docs/chart-color-palette.md", summary: "Accessible 5-color categorical palette for data viz — Okabe-Ito-derived, reviewed against WCAG 1.4.11 non-text contrast." },
109
+ { title: "Chart design", path: "docs/chart-design.md", summary: "Chart composition rules — grid, axes, labels, legend, tooltip, number formatting, states, motion. The 'data is the only saturated thing' register; companion to the color palette." },
106
110
  { title: "Privacy-first design (8 principles)", path: "layer-2-ethics-responsibility/privacy-first-design.md", summary: "Matthew Stephens' 8-principle privacy framework: minimize collection, transparency, expiration, no dark patterns, user control, ethical monetization, sustainable practices, accountability — mapped to BADS enforcement." },
111
+ { title: "Distress & reduced capacity", path: "layer-2-ethics-responsibility/distress-and-capacity.md", summary: "Designing critical flows for users in reduced-capacity states (stress, anxiety, grief, overwhelm) — a STATE, not a persona. The Low-Capacity Test release gate for high-stakes flows, plus the situational-distress persona and shame-free / no-silent-inference rules. Adapted from Matthew Stephens' 2026 mental-health-UX framework." },
107
112
  { title: "Gamification — responsible vs. manipulative", path: "layer-2-ethics-responsibility/gamification.md", summary: "Sir's 10 Core Drives (Octalysis 8 + Exploration & Discovery + Challenge & Competition) + the test gates that decide when Black Hat ships and when it refuses." },
108
113
  { title: "Corrections log", path: "corrections.md", summary: "Per-fork anti-pattern log. Read before every Path B build." },
109
114
  { title: "Anti-defaults refresh", path: "prompts/anti-defaults-refresh.md", summary: "Quarterly pressure-test of the current anti-defaults." },
@@ -177,3 +182,6 @@ export const DOCS_INDEX: DocGroup[] = [
177
182
  ];
178
183
 
179
184
  export const DOCS_TOTAL = DOCS_INDEX.reduce((sum, g) => sum + g.entries.length, 0);
185
+
186
+ // linters, checks, audits, reports, and CI workflows — automation scripts in pnpm + .github
187
+ export const AUTOMATION_COUNT = 48;
@@ -0,0 +1,201 @@
1
+ import * as React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { ArchiveIcon, DownloadIcon, Trash2Icon } from "lucide-react";
4
+ import { ActionBar } from "@behavioral-agentic-design-system/core/components/ui/action-bar";
5
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
6
+ import { Checkbox } from "@behavioral-agentic-design-system/core/components/ui/checkbox";
7
+ import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
8
+
9
+ const meta: Meta<typeof ActionBar> = {
10
+ title: "Components/ActionBar",
11
+ component: ActionBar,
12
+ parameters: { layout: "fullscreen" },
13
+ tags: ["autodocs"],
14
+ };
15
+
16
+ export default meta;
17
+ type Story = StoryObj<typeof meta>;
18
+
19
+ function Frame({ children }: { children: React.ReactNode }) {
20
+ return (
21
+ <div className="relative min-h-[280px] w-full overflow-hidden bg-background p-6">
22
+ {children}
23
+ </div>
24
+ );
25
+ }
26
+
27
+ function DemoActions({ disabled = false }: { disabled?: boolean }) {
28
+ return (
29
+ <>
30
+ <Button variant="ghost" size="xl" className="px-4" disabled={disabled}>
31
+ <ArchiveIcon strokeWidth={1.5} aria-hidden="true" />
32
+ Archive
33
+ </Button>
34
+ <Button variant="ghost" size="xl" className="px-4" disabled={disabled}>
35
+ <DownloadIcon strokeWidth={1.5} aria-hidden="true" />
36
+ Export
37
+ </Button>
38
+ <Button
39
+ variant="ghost"
40
+ size="xl"
41
+ className="px-4 text-destructive hover:text-destructive"
42
+ disabled={disabled}
43
+ >
44
+ <Trash2Icon strokeWidth={1.5} aria-hidden="true" />
45
+ Delete
46
+ </Button>
47
+ </>
48
+ );
49
+ }
50
+
51
+ export const Default: Story = {
52
+ render: () => (
53
+ <Frame>
54
+ <p className="text-sm text-muted-foreground">
55
+ 3 tokens selected in the audit table below the fold — the bar floats
56
+ over the content, anchored to the bottom edge.
57
+ </p>
58
+ <ActionBar
59
+ selectedCount={3}
60
+ onClearSelection={() => {}}
61
+ className="absolute bottom-6"
62
+ >
63
+ <DemoActions />
64
+ </ActionBar>
65
+ </Frame>
66
+ ),
67
+ };
68
+
69
+ export const ManySelected: Story = {
70
+ render: () => (
71
+ <Frame>
72
+ <p className="text-sm text-muted-foreground">
73
+ Select-all across a long registry list — the count stays a single
74
+ tabular-nums line at any magnitude.
75
+ </p>
76
+ <ActionBar
77
+ selectedCount={47}
78
+ onClearSelection={() => {}}
79
+ className="absolute bottom-6"
80
+ >
81
+ <DemoActions />
82
+ </ActionBar>
83
+ </Frame>
84
+ ),
85
+ };
86
+
87
+ export const ZeroSelected: Story = {
88
+ render: () => (
89
+ <Frame>
90
+ <p className="text-sm text-muted-foreground">
91
+ Nothing selected: the bar is dismissed but kept in the DOM
92
+ (opacity 0, translated down, inert) so the exit transition can play
93
+ and re-entry animates from the same node.
94
+ </p>
95
+ <ActionBar
96
+ selectedCount={0}
97
+ onClearSelection={() => {}}
98
+ className="absolute bottom-6"
99
+ >
100
+ <DemoActions />
101
+ </ActionBar>
102
+ </Frame>
103
+ ),
104
+ };
105
+
106
+ export const Disabled: Story = {
107
+ render: () => (
108
+ <Frame>
109
+ <p className="text-sm text-muted-foreground">
110
+ Bulk export is running — actions disable while the job is in flight,
111
+ but the count and clear control stay live.
112
+ </p>
113
+ <ActionBar
114
+ selectedCount={12}
115
+ onClearSelection={() => {}}
116
+ className="absolute bottom-6"
117
+ >
118
+ <DemoActions disabled />
119
+ </ActionBar>
120
+ </Frame>
121
+ ),
122
+ };
123
+
124
+ const REVIEWERS = [
125
+ { id: "jordan", name: "Jordan Reeves", email: "jordan@reeves.design" },
126
+ { id: "seoyun", name: "Seo-yun Park", email: "seoyun.park@figma.com" },
127
+ { id: "marcus", name: "Marcus Lindqvist", email: "marcus@lindqvist.dev" },
128
+ { id: "anika", name: "Anika Patel", email: "anika.patel@stripe.com" },
129
+ { id: "tomas", name: "Tomás Herrera", email: "tomas.herrera@vercel.com" },
130
+ { id: "yuki", name: "Yuki Tanaka", email: "yuki.tanaka@linear.app" },
131
+ ];
132
+
133
+ export const RealisticUse: Story = {
134
+ render: () => {
135
+ const [selected, setSelected] = React.useState<Set<string>>(
136
+ () => new Set(["seoyun", "anika"])
137
+ );
138
+
139
+ const toggle = (id: string, next: boolean) =>
140
+ setSelected((prev) => {
141
+ const copy = new Set(prev);
142
+ if (next) copy.add(id);
143
+ else copy.delete(id);
144
+ return copy;
145
+ });
146
+
147
+ return (
148
+ <div className="relative min-h-[420px] w-full overflow-hidden bg-background p-6">
149
+ <div className="mx-auto max-w-md">
150
+ <h2 className="text-2xl font-semibold text-foreground">
151
+ Workspace reviewers
152
+ </h2>
153
+ <p className="mt-1 text-sm text-muted-foreground">
154
+ Check reviewers to invite, export, or remove them in bulk.
155
+ </p>
156
+ <ul className="mt-4 divide-y divide-border rounded-lg border">
157
+ {REVIEWERS.map((person) => (
158
+ <li key={person.id} className="flex items-center gap-3 px-4 py-2">
159
+ <Checkbox
160
+ id={`reviewer-${person.id}`}
161
+ checked={selected.has(person.id)}
162
+ onCheckedChange={(next) => toggle(person.id, next === true)}
163
+ />
164
+ <Label
165
+ htmlFor={`reviewer-${person.id}`}
166
+ className="flex min-w-0 flex-1 cursor-pointer flex-col gap-0.5 py-1.5"
167
+ >
168
+ <span className="truncate text-sm font-medium text-foreground">
169
+ {person.name}
170
+ </span>
171
+ <span className="truncate text-sm text-muted-foreground">
172
+ {person.email}
173
+ </span>
174
+ </Label>
175
+ </li>
176
+ ))}
177
+ </ul>
178
+ </div>
179
+ <ActionBar
180
+ selectedCount={selected.size}
181
+ onClearSelection={() => setSelected(new Set())}
182
+ className="absolute bottom-6"
183
+ >
184
+ <Button variant="ghost" size="xl" className="px-4">
185
+ <DownloadIcon strokeWidth={1.5} aria-hidden="true" />
186
+ Export
187
+ </Button>
188
+ <Button
189
+ variant="ghost"
190
+ size="xl"
191
+ className="px-4 text-destructive hover:text-destructive"
192
+ onClick={() => setSelected(new Set())}
193
+ >
194
+ <Trash2Icon strokeWidth={1.5} aria-hidden="true" />
195
+ Remove
196
+ </Button>
197
+ </ActionBar>
198
+ </div>
199
+ );
200
+ },
201
+ };
@@ -0,0 +1,165 @@
1
+ import * as React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { ArrowUp, MessageCircle } from "lucide-react";
4
+ import { Affix } from "@behavioral-agentic-design-system/core/components/ui/affix";
5
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
6
+ import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
7
+
8
+ const meta: Meta<typeof Affix> = {
9
+ title: "Components/Affix",
10
+ component: Affix,
11
+ parameters: {
12
+ layout: "centered",
13
+ docs: {
14
+ description: {
15
+ component:
16
+ "Pins arbitrary content to a fixed viewport position — scroll-to-top buttons, chat FABs, floating action chrome. Renders through a document.body portal by default (usePortalThemeClass keeps theme-scoped variables reaching it); the wrapper itself is presentational, so accessible names, 44×44 targets, and interactive states belong to the children. Stories use withinPortal={false} inside a transformed frame so the fixed element pins to the demo frame instead of the Storybook viewport.",
17
+ },
18
+ },
19
+ },
20
+ tags: ["autodocs"],
21
+ };
22
+
23
+ export default meta;
24
+ type Story = StoryObj<typeof meta>;
25
+
26
+ /**
27
+ * Demo frame: `transform: translateZ(0)` makes this box the containing block
28
+ * for `position: fixed` descendants, so `withinPortal={false}` Affix content
29
+ * pins to the frame instead of the Storybook viewport. In a real app, keep
30
+ * the default portal and the content pins to the true viewport.
31
+ */
32
+ function DemoFrame({ children }: { children: React.ReactNode }) {
33
+ return (
34
+ <div className="relative h-64 w-96 overflow-hidden rounded-lg border border-border bg-card [transform:translateZ(0)]">
35
+ <div className="p-4">
36
+ <p className="text-sm font-medium text-foreground">design.bads.com</p>
37
+ <p className="text-sm text-muted-foreground">
38
+ The frame stands in for the viewport — the pinned content stays put
39
+ while everything else scrolls.
40
+ </p>
41
+ </div>
42
+ {children}
43
+ </div>
44
+ );
45
+ }
46
+
47
+ export const Default: Story = {
48
+ render: () => (
49
+ <DemoFrame>
50
+ <Affix withinPortal={false} position={{ bottom: 20, right: 20 }}>
51
+ <Button size="icon-xl" aria-label="Open chat">
52
+ <MessageCircle strokeWidth={1.5} aria-hidden="true" />
53
+ </Button>
54
+ </Affix>
55
+ </DemoFrame>
56
+ ),
57
+ };
58
+
59
+ export const TopRight: Story = {
60
+ render: () => (
61
+ <DemoFrame>
62
+ <Affix withinPortal={false} position={{ top: 16, right: 16 }}>
63
+ <Badge>36 components</Badge>
64
+ </Affix>
65
+ </DemoFrame>
66
+ ),
67
+ };
68
+
69
+ export const TopLeft: Story = {
70
+ render: () => (
71
+ <DemoFrame>
72
+ <Affix withinPortal={false} position={{ top: 16, left: 16 }}>
73
+ <Badge variant="secondary">Story coverage 98.4%</Badge>
74
+ </Affix>
75
+ </DemoFrame>
76
+ ),
77
+ };
78
+
79
+ export const CustomZIndex: Story = {
80
+ render: () => (
81
+ <DemoFrame>
82
+ {/* The zIndex prop controls stacking: the FAB (zIndex 50, default tier)
83
+ sits above the banner (zIndex 10) where the two overlap. */}
84
+ <Affix withinPortal={false} position={{ bottom: 0, left: 0, right: 0 }} zIndex={10}>
85
+ <div className="border-t border-border bg-muted px-4 py-3 text-sm text-muted-foreground">
86
+ Token build finished — 12,417 references scanned.
87
+ </div>
88
+ </Affix>
89
+ <Affix withinPortal={false} position={{ bottom: 12, right: 12 }} zIndex={50}>
90
+ <Button size="icon-xl" variant="outline" aria-label="Back to top">
91
+ <ArrowUp strokeWidth={1.5} aria-hidden="true" />
92
+ </Button>
93
+ </Affix>
94
+ </DemoFrame>
95
+ ),
96
+ };
97
+
98
+ // Real content from content/personas/bads.json (primary persona pool).
99
+ const changelog = [
100
+ {
101
+ date: "2026-05-26",
102
+ author: "Jordan Reeves",
103
+ entry: "Shared 36 components for review at design.bads.com/share/tokens-v2-proposal.",
104
+ },
105
+ {
106
+ date: "2026-01-15",
107
+ author: "Seo-yun Park",
108
+ entry: "Raised the contrast floor to 7:1 across every shipped token pair.",
109
+ },
110
+ {
111
+ date: "2025-11-20",
112
+ author: "Marcus Lindqvist",
113
+ entry: "Moved the touch-target audit to the 44×44px target across all CTAs.",
114
+ },
115
+ {
116
+ date: "2027-03-01",
117
+ author: "Anika Patel",
118
+ entry: "Scheduled the semantic-layer migration — token drift lint goes strict.",
119
+ },
120
+ {
121
+ date: "2026-05-26",
122
+ author: "Tomás Herrera",
123
+ entry: "Tuned every transition to the 180ms transition baseline.",
124
+ },
125
+ ];
126
+
127
+ export const RealisticUse: Story = {
128
+ render: function RealisticUseStory() {
129
+ const scrollRef = React.useRef<HTMLDivElement>(null);
130
+ return (
131
+ <div className="relative h-72 w-[420px] overflow-hidden rounded-lg border border-border bg-card [transform:translateZ(0)]">
132
+ <div ref={scrollRef} className="h-full overflow-y-auto p-4" tabIndex={0}>
133
+ <h3 className="text-base font-semibold text-foreground">
134
+ Design system changelog
135
+ </h3>
136
+ <ul className="mt-3 space-y-4">
137
+ {[...changelog, ...changelog].map((item, i) => (
138
+ <li key={i} className="space-y-1">
139
+ <p className="text-sm font-medium text-foreground">
140
+ {item.author}{" "}
141
+ <span className="font-normal text-muted-foreground">
142
+ · {item.date}
143
+ </span>
144
+ </p>
145
+ <p className="text-sm text-muted-foreground">{item.entry}</p>
146
+ </li>
147
+ ))}
148
+ </ul>
149
+ </div>
150
+ <Affix withinPortal={false} position={{ bottom: 16, right: 16 }}>
151
+ <Button
152
+ size="icon-xl"
153
+ variant="secondary"
154
+ aria-label="Scroll to top"
155
+ onClick={() =>
156
+ scrollRef.current?.scrollTo({ top: 0, behavior: "smooth" })
157
+ }
158
+ >
159
+ <ArrowUp strokeWidth={1.5} aria-hidden="true" />
160
+ </Button>
161
+ </Affix>
162
+ </div>
163
+ );
164
+ },
165
+ };