@behavioral-agentic-design-system/core 0.6.0 → 0.8.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +35 -6
  3. package/scripts/bads-sync.mjs +1 -1
  4. package/scripts/build-fonts.cjs +15 -8
  5. package/scripts/build-tokens.cjs +139 -23
  6. package/src/api/brand-fonts.ts +27 -6
  7. package/src/api/layers/file.ts +4 -3
  8. package/src/api/layers.ts +41 -12
  9. package/src/api/onboarding-extract.ts +435 -0
  10. package/src/api/onboarding.ts +82 -0
  11. package/src/api/site-auth.ts +50 -0
  12. package/src/app/font-ready.tsx +1 -1
  13. package/src/app/layout.tsx +9 -3
  14. package/src/app/preview/components/page.tsx +78 -1
  15. package/src/app/preview/icons/page.tsx +5 -0
  16. package/src/app/shell.tsx +90 -23
  17. package/src/app/site-login/page.tsx +82 -0
  18. package/src/brand-fonts.css +5 -0
  19. package/src/components/Foundations/Colors.stories.tsx +10 -1
  20. package/src/components/Foundations/Motion.stories.tsx +66 -0
  21. package/src/components/customize/letter-spacing.tsx +3 -2
  22. package/src/components/customize/type-scale.tsx +3 -2
  23. package/src/components/customize-tab.tsx +11 -7
  24. package/src/components/home-tab.tsx +498 -235
  25. package/src/components/layers-tab.tsx +313 -10
  26. package/src/components/onboarding-wizard.tsx +1421 -0
  27. package/src/components/ui/alert.tsx +2 -2
  28. package/src/components/ui/bottom-sheet.tsx +124 -0
  29. package/src/components/ui/button.tsx +1 -1
  30. package/src/components/ui/chart.tsx +115 -14
  31. package/src/components/ui/checkbox.tsx +3 -2
  32. package/src/components/ui/dialog.tsx +7 -4
  33. package/src/components/ui/dropdown-menu.tsx +4 -0
  34. package/src/components/ui/index.ts +1 -0
  35. package/src/components/ui/popover.tsx +6 -0
  36. package/src/components/ui/radio-group.tsx +4 -3
  37. package/src/components/ui/scroll-area.tsx +5 -0
  38. package/src/components/ui/select.tsx +4 -0
  39. package/src/components/ui/sheet.tsx +8 -1
  40. package/src/components/ui/slider.tsx +22 -7
  41. package/src/components/ui/switch.tsx +3 -3
  42. package/src/components/ui/tabs.tsx +6 -0
  43. package/src/components/ui/tooltip.tsx +4 -0
  44. package/src/fonts/HyperlegibleSans-Bold.woff2 +0 -0
  45. package/src/fonts/HyperlegibleSans-BoldItalic.woff2 +0 -0
  46. package/src/fonts/HyperlegibleSans-Italic.woff2 +0 -0
  47. package/src/fonts/HyperlegibleSans-Medium.woff2 +0 -0
  48. package/src/fonts/HyperlegibleSans-MediumItalic.woff2 +0 -0
  49. package/src/fonts/HyperlegibleSans-Regular.woff2 +0 -0
  50. package/src/fonts/InterVariable-Italic.woff2 +0 -0
  51. package/src/fonts/InterVariable.woff2 +0 -0
  52. package/src/fonts.css +99 -0
  53. package/src/hooks/use-global-primary-color.ts +114 -68
  54. package/src/hooks/use-global-serif-font.ts +1 -1
  55. package/src/hooks/use-portal-theme-class.tsx +90 -0
  56. package/src/lib/storage.ts +2 -2
  57. package/src/styles.css +151 -61
  58. package/src/tokens.default.json +4 -4
  59. package/src/tokens.json +159 -162
  60. package/src/app/preview/login/page.tsx +0 -5
  61. package/src/app/preview/mail/page.tsx +0 -4
  62. package/src/app/preview/pricing/page.tsx +0 -4
  63. package/src/components/admin-menu.stories.tsx +0 -68
  64. package/src/components/admin-menu.tsx +0 -59
@@ -15,14 +15,14 @@ const alertVariants = cva(
15
15
  // bg-muted gives default alerts a subtle surface bump so they read as
16
16
  // a callout even when nested inside a Card (which is also bg-card).
17
17
  // Without this, default alert + card = identical surfaces, no hierarchy.
18
- default: "bg-muted text-foreground",
18
+ default: "border-l-4 border-l-primary bg-primary/5 text-foreground [&>svg]:text-primary dark:bg-primary/10",
19
19
  // bg-destructive/10 gives destructive alerts a soft red tint without
20
20
  // overwhelming the surface. Composite contrast (destructive on
21
21
  // destructive/10 over card) stays above AA 4.5:1 across the default
22
22
  // BADS palette; forks with very saturated destructive tokens should
23
23
  // re-check with `pnpm wcag:audit` after token edits.
24
24
  destructive:
25
- "bg-destructive/10 text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current",
25
+ "border-l-4 border-l-destructive bg-destructive/5 text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current dark:bg-destructive/10",
26
26
  },
27
27
  },
28
28
  defaultVariants: {
@@ -0,0 +1,124 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+
5
+ import { cn } from "../../lib/utils"
6
+ import {
7
+ Sheet,
8
+ SheetClose,
9
+ SheetContent,
10
+ SheetDescription,
11
+ SheetFooter,
12
+ SheetHeader,
13
+ SheetTitle,
14
+ SheetTrigger,
15
+ } from "./sheet"
16
+
17
+ /**
18
+ * BottomSheet — a bottom-anchored disclosure surface, the dominant
19
+ * secondary-content container in current production apps (Raycast, Linear
20
+ * mobile, Arc). Built on the Radix Dialog–backed Sheet primitive with
21
+ * `side="bottom"`, so it inherits Sheet's focus trap, ESC/overlay dismissal,
22
+ * scroll lock, and AAA-tuned focus ring for free.
23
+ *
24
+ * What this adds over `<SheetContent side="bottom">`:
25
+ * - Rounded top corners + a centered grab-handle affordance (the visual
26
+ * signal users now read as "this panel came from the bottom").
27
+ * - Mobile-first sizing: caps at 85svh and scrolls internally so a tall
28
+ * sheet never pushes its footer off-screen.
29
+ * - A coherent BottomSheet* API surface so callers don't mix Sheet and
30
+ * BottomSheet names.
31
+ *
32
+ * Not draggable. This wrapper is intentionally built on Radix, not vaul, so
33
+ * there are no drag-to-dismiss physics or snap points — dismissal is via the
34
+ * grab handle (decorative), overlay click, ESC, or an explicit close button.
35
+ * If a fork needs true drag/snap behavior, that's a separate vaul-backed
36
+ * primitive and a deliberate dependency decision (see CHANGELOG 2026-05-31).
37
+ */
38
+
39
+ function BottomSheet({ ...props }: React.ComponentProps<typeof Sheet>) {
40
+ return <Sheet data-slot="bottom-sheet" {...props} />
41
+ }
42
+
43
+ function BottomSheetTrigger({
44
+ ...props
45
+ }: React.ComponentProps<typeof SheetTrigger>) {
46
+ return <SheetTrigger data-slot="bottom-sheet-trigger" {...props} />
47
+ }
48
+
49
+ function BottomSheetClose({
50
+ ...props
51
+ }: React.ComponentProps<typeof SheetClose>) {
52
+ return <SheetClose data-slot="bottom-sheet-close" {...props} />
53
+ }
54
+
55
+ function BottomSheetContent({
56
+ className,
57
+ children,
58
+ showHandle = true,
59
+ showCloseButton = true,
60
+ ...props
61
+ }: React.ComponentProps<typeof SheetContent> & {
62
+ /** Show the decorative grab-handle affordance at the top. Default true. */
63
+ showHandle?: boolean
64
+ }) {
65
+ return (
66
+ <SheetContent
67
+ side="bottom"
68
+ showCloseButton={showCloseButton}
69
+ data-slot="bottom-sheet-content"
70
+ className={cn(
71
+ // Rounded top + capped height + internal scroll so a tall sheet keeps
72
+ // its footer reachable. svh tracks the mobile dynamic viewport.
73
+ "max-h-[85svh] gap-0 overflow-y-auto rounded-t-xl pb-[max(1rem,env(safe-area-inset-bottom))]",
74
+ className
75
+ )}
76
+ {...props}
77
+ >
78
+ {showHandle && (
79
+ <div
80
+ aria-hidden="true"
81
+ className="mx-auto mt-3 mb-1 h-1.5 w-12 shrink-0 rounded-full bg-muted-foreground/30"
82
+ />
83
+ )}
84
+ {children}
85
+ </SheetContent>
86
+ )
87
+ }
88
+
89
+ // Header/Footer/Title/Description are 1:1 with Sheet's — re-exported under the
90
+ // BottomSheet name so callers get a single coherent API.
91
+ function BottomSheetHeader({
92
+ ...props
93
+ }: React.ComponentProps<typeof SheetHeader>) {
94
+ return <SheetHeader data-slot="bottom-sheet-header" {...props} />
95
+ }
96
+
97
+ function BottomSheetFooter({
98
+ ...props
99
+ }: React.ComponentProps<typeof SheetFooter>) {
100
+ return <SheetFooter data-slot="bottom-sheet-footer" {...props} />
101
+ }
102
+
103
+ function BottomSheetTitle({
104
+ ...props
105
+ }: React.ComponentProps<typeof SheetTitle>) {
106
+ return <SheetTitle data-slot="bottom-sheet-title" {...props} />
107
+ }
108
+
109
+ function BottomSheetDescription({
110
+ ...props
111
+ }: React.ComponentProps<typeof SheetDescription>) {
112
+ return <SheetDescription data-slot="bottom-sheet-description" {...props} />
113
+ }
114
+
115
+ export {
116
+ BottomSheet,
117
+ BottomSheetTrigger,
118
+ BottomSheetClose,
119
+ BottomSheetContent,
120
+ BottomSheetHeader,
121
+ BottomSheetFooter,
122
+ BottomSheetTitle,
123
+ BottomSheetDescription,
124
+ }
@@ -5,7 +5,7 @@ import { Slot } from "@radix-ui/react-slot"
5
5
  import { cn } from "../../lib/utils"
6
6
 
7
7
  const buttonVariants = cva(
8
- "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ "inline-flex shrink-0 items-center justify-center gap-2 rounded-full text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
9
9
  {
10
10
  variants: {
11
11
  variant: {
@@ -34,49 +34,150 @@ function useChart() {
34
34
  return context
35
35
  }
36
36
 
37
+ // Recharts v3 components that ship a stroke-dasharray entrance animation.
38
+ // Animation is ON by default — the ResizeObserver gate below ensures the
39
+ // chart never mounts during SSR or before its container has measurable
40
+ // dimensions, which is what causes the "invisible chart" bug in plain
41
+ // Recharts v3. Pass `animate={false}` on the container if you need to
42
+ // freeze the chart at its final state (e.g. for screenshots or print).
43
+ const ANIMATED_RECHARTS_COMPONENTS = new Set<React.ElementType>([
44
+ RechartsPrimitive.Line,
45
+ RechartsPrimitive.Area,
46
+ RechartsPrimitive.Bar,
47
+ RechartsPrimitive.Pie,
48
+ RechartsPrimitive.Radar,
49
+ RechartsPrimitive.RadialBar,
50
+ RechartsPrimitive.Scatter,
51
+ ])
52
+
53
+ function injectAnimationDefault(
54
+ node: React.ReactNode,
55
+ animate: boolean
56
+ ): React.ReactNode {
57
+ // When animate is true we leave Recharts' defaults alone (entrance
58
+ // animation on). When animate is false we walk the tree and force
59
+ // isAnimationActive={false} on every animated primitive.
60
+ if (animate) return node
61
+ if (Array.isArray(node)) {
62
+ return node.map((child, i) => (
63
+ <React.Fragment key={i}>{injectAnimationDefault(child, animate)}</React.Fragment>
64
+ ))
65
+ }
66
+ if (!React.isValidElement(node)) return node
67
+ const element = node as React.ReactElement<any>
68
+ const props = element.props || {}
69
+ const isAnimated = ANIMATED_RECHARTS_COMPONENTS.has(
70
+ element.type as React.ElementType
71
+ )
72
+ const needsDefault =
73
+ isAnimated && props.isAnimationActive === undefined
74
+ const hasChildren = props.children !== undefined
75
+ if (!needsDefault && !hasChildren) return element
76
+ const nextProps: Record<string, unknown> = {}
77
+ if (needsDefault) nextProps.isAnimationActive = false
78
+ if (hasChildren) {
79
+ nextProps.children = injectAnimationDefault(props.children, animate)
80
+ }
81
+ return React.cloneElement(element, nextProps)
82
+ }
83
+
84
+ function usePrefersReducedMotion() {
85
+ const [reduced, setReduced] = React.useState(false)
86
+ React.useEffect(() => {
87
+ if (typeof window === "undefined" || !window.matchMedia) return
88
+ const mql = window.matchMedia("(prefers-reduced-motion: reduce)")
89
+ setReduced(mql.matches)
90
+ const onChange = (e: MediaQueryListEvent) => setReduced(e.matches)
91
+ mql.addEventListener("change", onChange)
92
+ return () => mql.removeEventListener("change", onChange)
93
+ }, [])
94
+ return reduced
95
+ }
96
+
37
97
  function ChartContainer({
38
98
  id,
39
99
  className,
40
100
  children,
41
101
  config,
42
102
  style,
103
+ animate = true,
43
104
  ...props
44
105
  }: React.ComponentProps<"div"> & {
45
106
  config: ChartConfig
107
+ /**
108
+ * Whether the chart plays Recharts' default entrance animation. On by
109
+ * default — the ResizeObserver gate ensures the chart only mounts once
110
+ * the container is measurable, which prevents the SSR-then-hydrate
111
+ * invisible-chart bug. Pass `animate={false}` to freeze the chart at
112
+ * its final state (e.g. for screenshots, print). Users with
113
+ * `prefers-reduced-motion: reduce` get `animate={false}` automatically
114
+ * regardless of this prop (SC 2.3.3).
115
+ */
116
+ animate?: boolean
46
117
  children: React.ComponentProps<
47
118
  typeof RechartsPrimitive.ResponsiveContainer
48
119
  >["children"]
49
120
  }) {
50
121
  const uniqueId = React.useId()
51
122
  const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
52
-
53
- // Recharts' ResponsiveContainer can't measure during SSR (no DOM), so it
54
- // logs a "width(-1) and height(-1)" warning to the dev terminal on every
55
- // request. Gating render until after mount keeps the chart a client-only
56
- // tree — the wrapping div still SSRs and reserves layout, only the chart
57
- // itself waits one tick to mount once the container is measurable.
58
- const [mounted, setMounted] = React.useState(false)
59
- React.useEffect(() => setMounted(true), [])
123
+ const prefersReducedMotion = usePrefersReducedMotion()
124
+ const effectiveAnimate = animate && !prefersReducedMotion
125
+
126
+ // ResponsiveContainer logs "width(-1) and height(-1)" whenever it renders
127
+ // before the wrapping div has a measurable size — SSR, first paint, or
128
+ // any container-query-gated height that hasn't kicked in yet. Gate on a
129
+ // ResizeObserver so the chart only mounts once we've observed non-zero
130
+ // width AND height. The wrapping div still SSRs so layout is reserved.
131
+ const containerRef = React.useRef<HTMLDivElement | null>(null)
132
+ const [hasSize, setHasSize] = React.useState(false)
133
+
134
+ React.useEffect(() => {
135
+ const el = containerRef.current
136
+ if (!el) return
137
+ const observer = new ResizeObserver((entries) => {
138
+ for (const entry of entries) {
139
+ const { width, height } = entry.contentRect
140
+ if (width > 0 && height > 0) {
141
+ setHasSize(true)
142
+ return
143
+ }
144
+ }
145
+ setHasSize(false)
146
+ })
147
+ observer.observe(el)
148
+ return () => observer.disconnect()
149
+ }, [])
150
+
151
+ // Recursively default isAnimationActive={false} on every animated Recharts
152
+ // child. Consumers can override per-element by passing the prop explicitly,
153
+ // or opt the whole tree back in via the `animate` prop on the container.
154
+ const safeChildren = React.useMemo(
155
+ () => injectAnimationDefault(children, effectiveAnimate) as typeof children,
156
+ [children, effectiveAnimate]
157
+ )
60
158
 
61
159
  return (
62
160
  <ChartContext.Provider value={{ config }}>
63
161
  <div
162
+ ref={containerRef}
64
163
  data-slot="chart"
65
164
  data-chart={chartId}
66
165
  className={cn(
166
+ // Default to block. The prior default `display: grid` (a leftover
167
+ // from older shadcn chart code) confused Recharts v3's
168
+ // ResizeObserver and caused it to measure -1x-1 through the
169
+ // implicit auto rows. Consumers pass w-full + an explicit height
170
+ // class; block lets those determine the box.
67
171
  "relative w-full text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
68
172
  className
69
173
  )}
70
- style={{
71
- display: "grid",
72
- ...style,
73
- }}
174
+ style={style}
74
175
  {...props}
75
176
  >
76
177
  <ChartStyle id={chartId} config={config} />
77
- {mounted ? (
178
+ {hasSize ? (
78
179
  <RechartsPrimitive.ResponsiveContainer width="100%" height="100%">
79
- {children}
180
+ {safeChildren}
80
181
  </RechartsPrimitive.ResponsiveContainer>
81
182
  ) : null}
82
183
  </div>
@@ -14,14 +14,15 @@ function Checkbox({
14
14
  <CheckboxPrimitive.Root
15
15
  data-slot="checkbox"
16
16
  className={cn(
17
- "peer inline-flex size-8 shrink-0 items-center justify-center rounded-[4px] bg-muted leading-none outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-2 aria-invalid:ring-destructive/60 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
17
+ "peer inline-flex size-8 shrink-0 items-center justify-center rounded-[4px] border-2 border-muted-foreground/60 bg-white leading-none shadow-xs transition-[background-color,border-color,color] duration-[210ms] ease-in-out outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground dark:aria-invalid:ring-destructive/40",
18
18
  className
19
19
  )}
20
20
  {...props}
21
21
  >
22
22
  <CheckboxPrimitive.Indicator
23
+ forceMount
23
24
  data-slot="checkbox-indicator"
24
- className="grid place-content-center text-current transition-none"
25
+ className="grid place-content-center text-current opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out data-[state=checked]:opacity-100 data-[state=checked]:scale-100 data-[state=indeterminate]:opacity-100 data-[state=indeterminate]:scale-100"
25
26
  >
26
27
  <CheckIcon className="size-6" strokeWidth={3} />
27
28
  </CheckboxPrimitive.Indicator>
@@ -6,10 +6,11 @@ import { XIcon } from "lucide-react"
6
6
  import * as DialogPrimitive from "@radix-ui/react-dialog"
7
7
 
8
8
  import { cn } from "../../lib/utils"
9
+ import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
9
10
  import { Button } from "./button"
10
11
 
11
12
  const dialogContentVariants = cva(
12
- "fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
13
+ "fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-2xl ring-1 ring-white/10 duration-200 outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
13
14
  {
14
15
  variants: {
15
16
  size: {
@@ -59,7 +60,7 @@ function DialogOverlay({
59
60
  <DialogPrimitive.Overlay
60
61
  data-slot="dialog-overlay"
61
62
  className={cn(
62
- "fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
63
+ "fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
63
64
  className
64
65
  )}
65
66
  {...props}
@@ -77,20 +78,22 @@ function DialogContent({
77
78
  VariantProps<typeof dialogContentVariants> & {
78
79
  showCloseButton?: boolean
79
80
  }) {
81
+ // See use-portal-theme-class.ts.
82
+ const portalThemeClass = usePortalThemeClass()
80
83
  return (
81
84
  <DialogPortal data-slot="dialog-portal">
82
85
  <DialogOverlay />
83
86
  <DialogPrimitive.Content
84
87
  data-slot="dialog-content"
85
88
  data-size={size ?? "default"}
86
- className={cn(dialogContentVariants({ size }), className)}
89
+ className={cn(dialogContentVariants({ size }), portalThemeClass, className)}
87
90
  {...props}
88
91
  >
89
92
  {children}
90
93
  {showCloseButton && (
91
94
  <DialogPrimitive.Close
92
95
  data-slot="dialog-close"
93
- className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
96
+ className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-8"
94
97
  >
95
98
  <XIcon />
96
99
  <span className="sr-only">Close</span>
@@ -5,6 +5,7 @@ import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"
5
5
  import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
6
6
 
7
7
  import { cn } from "../../lib/utils"
8
+ import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
8
9
 
9
10
  function DropdownMenu({
10
11
  ...props
@@ -36,6 +37,8 @@ function DropdownMenuContent({
36
37
  sideOffset = 4,
37
38
  ...props
38
39
  }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
40
+ // See use-portal-theme-class.ts.
41
+ const portalThemeClass = usePortalThemeClass()
39
42
  return (
40
43
  <DropdownMenuPrimitive.Portal>
41
44
  <DropdownMenuPrimitive.Content
@@ -43,6 +46,7 @@ function DropdownMenuContent({
43
46
  sideOffset={sideOffset}
44
47
  className={cn(
45
48
  "z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
49
+ portalThemeClass,
46
50
  className
47
51
  )}
48
52
  {...props}
@@ -24,6 +24,7 @@ export * from "./scroll-area";
24
24
  export * from "./select";
25
25
  export * from "./separator";
26
26
  export * from "./sheet";
27
+ export * from "./bottom-sheet";
27
28
  export * from "./sidebar";
28
29
  export * from "./skeleton";
29
30
  export * from "./slider";
@@ -4,6 +4,7 @@ import * as React from "react"
4
4
  import * as PopoverPrimitive from "@radix-ui/react-popover"
5
5
 
6
6
  import { cn } from "../../lib/utils"
7
+ import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
7
8
 
8
9
  function Popover({
9
10
  ...props
@@ -23,6 +24,10 @@ function PopoverContent({
23
24
  sideOffset = 4,
24
25
  ...props
25
26
  }: React.ComponentProps<typeof PopoverPrimitive.Content>) {
27
+ // See use-portal-theme-class.ts: lets a PortalThemeProvider scope class
28
+ // (e.g. "atrium-theme") apply to portal content so theme-scoped CSS
29
+ // variables resolve inside the portal.
30
+ const portalThemeClass = usePortalThemeClass()
26
31
  return (
27
32
  <PopoverPrimitive.Portal>
28
33
  <PopoverPrimitive.Content
@@ -31,6 +36,7 @@ function PopoverContent({
31
36
  sideOffset={sideOffset}
32
37
  className={cn(
33
38
  "z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
39
+ portalThemeClass,
34
40
  className
35
41
  )}
36
42
  {...props}
@@ -27,16 +27,17 @@ function RadioGroupItem({
27
27
  <RadioGroupPrimitive.Item
28
28
  data-slot="radio-group-item"
29
29
  className={cn(
30
- "aspect-square size-9 shrink-0 rounded-full bg-muted text-primary outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-2 aria-invalid:ring-destructive/60 data-[state=checked]:bg-primary",
30
+ "aspect-square size-9 shrink-0 rounded-full border-2 border-muted-foreground/60 bg-white text-primary shadow-xs transition-[background-color,border-color,color] duration-[210ms] ease-in-out outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 data-[state=checked]:bg-primary data-[state=checked]:border-primary",
31
31
  className
32
32
  )}
33
33
  {...props}
34
34
  >
35
35
  <RadioGroupPrimitive.Indicator
36
+ forceMount
36
37
  data-slot="radio-group-indicator"
37
- className="relative flex items-center justify-center"
38
+ className="flex h-full w-full items-center justify-center opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out data-[state=checked]:opacity-100 data-[state=checked]:scale-100"
38
39
  >
39
- <CircleIcon className="absolute top-1/2 left-1/2 size-3 -translate-x-1/2 -translate-y-1/2 fill-primary-foreground" />
40
+ <CircleIcon className="size-4 fill-primary-foreground stroke-primary-foreground" />
40
41
  </RadioGroupPrimitive.Indicator>
41
42
  </RadioGroupPrimitive.Item>
42
43
  )
@@ -18,6 +18,11 @@ function ScrollArea({
18
18
  >
19
19
  <ScrollAreaPrimitive.Viewport
20
20
  data-slot="scroll-area-viewport"
21
+ // tabIndex={0} makes the scroll region reachable by keyboard so its
22
+ // overflow content is navigable without a mouse (WCAG 2.1.1, axe
23
+ // scrollable-region-focusable). The focus-visible ring below already
24
+ // anticipates this — Radix's Viewport just isn't focusable on its own.
25
+ tabIndex={0}
21
26
  className="size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1"
22
27
  >
23
28
  {children}
@@ -5,6 +5,7 @@ import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"
5
5
  import * as SelectPrimitive from "@radix-ui/react-select"
6
6
 
7
7
  import { cn } from "../../lib/utils"
8
+ import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
8
9
 
9
10
  function Select({
10
11
  ...props
@@ -57,6 +58,8 @@ function SelectContent({
57
58
  align = "center",
58
59
  ...props
59
60
  }: React.ComponentProps<typeof SelectPrimitive.Content>) {
61
+ // See use-portal-theme-class.ts.
62
+ const portalThemeClass = usePortalThemeClass()
60
63
  return (
61
64
  <SelectPrimitive.Portal>
62
65
  <SelectPrimitive.Content
@@ -65,6 +68,7 @@ function SelectContent({
65
68
  "relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
66
69
  position === "popper" &&
67
70
  "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
71
+ portalThemeClass,
68
72
  className
69
73
  )}
70
74
  position={position}
@@ -5,6 +5,7 @@ import { XIcon } from "lucide-react"
5
5
  import * as SheetPrimitive from "@radix-ui/react-dialog"
6
6
 
7
7
  import { cn } from "../../lib/utils"
8
+ import { usePortalThemeClass } from "../../hooks/use-portal-theme-class"
8
9
 
9
10
  function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
10
11
  return <SheetPrimitive.Root data-slot="sheet" {...props} />
@@ -36,7 +37,7 @@ function SheetOverlay({
36
37
  <SheetPrimitive.Overlay
37
38
  data-slot="sheet-overlay"
38
39
  className={cn(
39
- "fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
40
+ "fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
40
41
  className
41
42
  )}
42
43
  {...props}
@@ -54,6 +55,11 @@ function SheetContent({
54
55
  side?: "top" | "right" | "bottom" | "left"
55
56
  showCloseButton?: boolean
56
57
  }) {
58
+ // Apply the active portal theme scope to the content's className so any
59
+ // theme-scoped CSS variables a consumer uses (`--shell-chrome-bg-rgb`,
60
+ // `--brand-*`) resolve correctly inside the Radix portal. Returns "" if
61
+ // no PortalThemeProvider is mounted — additive, no breaking changes.
62
+ const portalThemeClass = usePortalThemeClass()
57
63
  return (
58
64
  <SheetPortal>
59
65
  <SheetOverlay />
@@ -69,6 +75,7 @@ function SheetContent({
69
75
  "inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
70
76
  side === "bottom" &&
71
77
  "inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
78
+ portalThemeClass,
72
79
  className
73
80
  )}
74
81
  {...props}
@@ -11,6 +11,8 @@ function Slider({
11
11
  value,
12
12
  min = 0,
13
13
  max = 100,
14
+ "aria-label": ariaLabel,
15
+ "aria-labelledby": ariaLabelledby,
14
16
  ...props
15
17
  }: React.ComponentProps<typeof SliderPrimitive.Root>) {
16
18
  const _values = React.useMemo(
@@ -54,13 +56,26 @@ function Slider({
54
56
  )}
55
57
  />
56
58
  </SliderPrimitive.Track>
57
- {Array.from({ length: _values.length }, (_, index) => (
58
- <SliderPrimitive.Thumb
59
- data-slot="slider-thumb"
60
- key={index}
61
- className="block size-8 shrink-0 rounded-full border-2 border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
62
- />
63
- ))}
59
+ {Array.from({ length: _values.length }, (_, index) => {
60
+ // Radix puts role="slider" on the thumb, not the Root, so the
61
+ // accessible name has to live here — a label on Root alone fails
62
+ // axe's aria-input-field-name (WCAG 4.1.2). Forward the consumer's
63
+ // label to every thumb; for a range (2+ thumbs) disambiguate which
64
+ // end each thumb controls so they don't announce identically.
65
+ const thumbLabel =
66
+ ariaLabel && _values.length > 1
67
+ ? `${ariaLabel} ${index === 0 ? "minimum" : "maximum"}`
68
+ : ariaLabel
69
+ return (
70
+ <SliderPrimitive.Thumb
71
+ data-slot="slider-thumb"
72
+ key={index}
73
+ aria-label={thumbLabel}
74
+ aria-labelledby={ariaLabelledby}
75
+ className="block size-8 shrink-0 rounded-full border-2 border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
76
+ />
77
+ )
78
+ })}
64
79
  </SliderPrimitive.Root>
65
80
  )
66
81
  }
@@ -18,14 +18,14 @@ function Switch({
18
18
  data-slot="switch"
19
19
  data-size={size}
20
20
  className={cn(
21
- "peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[2.3rem] data-[size=default]:w-16 data-[size=sm]:h-7 data-[size=sm]:w-12 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",
21
+ "peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-[background-color] duration-[210ms] ease-in-out outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[2.3rem] data-[size=default]:w-16 data-[size=sm]:h-7 data-[size=sm]:w-12 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",
22
22
  className
23
23
  )}
24
24
  {...props}
25
25
  >
26
26
  <CheckIcon
27
27
  strokeWidth={3}
28
- className="pointer-events-none absolute left-2 size-4 text-primary-foreground opacity-0 scale-50 -translate-x-1 transition-all duration-200 group-data-[state=checked]/switch:opacity-100 group-data-[state=checked]/switch:scale-100 group-data-[state=checked]/switch:translate-x-0"
28
+ className="pointer-events-none absolute left-2 size-4 text-primary-foreground opacity-0 scale-75 transition-[opacity,transform] duration-[120ms] ease-out group-data-[state=checked]/switch:opacity-100 group-data-[state=checked]/switch:scale-100"
29
29
  />
30
30
  <SwitchPrimitive.Thumb
31
31
  data-slot="switch-thumb"
@@ -36,7 +36,7 @@ function Switch({
36
36
  // the thumb always contrasts the track: near-white thumb on
37
37
  // near-black track in light, near-black thumb on near-white
38
38
  // track in dark.
39
- "pointer-events-none block rounded-full bg-white data-[state=checked]:bg-primary-foreground ring-0 transition-[transform,background-color] duration-200 group-data-[size=default]/switch:size-8 group-data-[size=sm]/switch:size-6 data-[state=checked]:translate-x-[calc(100%-4px)] data-[state=unchecked]:translate-x-[2px]"
39
+ "pointer-events-none block rounded-full bg-white data-[state=checked]:bg-primary-foreground ring-0 shadow-sm transition-[translate,background-color] duration-[175ms] ease-[cubic-bezier(0.25,0.46,0.45,0.94)] group-data-[size=default]/switch:size-8 group-data-[size=sm]/switch:size-6 data-[state=checked]:translate-x-[calc(100%-4px)] data-[state=unchecked]:translate-x-[2px]"
40
40
  )}
41
41
  />
42
42
  </SwitchPrimitive.Root>
@@ -64,6 +64,12 @@ function TabsTrigger({
64
64
  <TabsPrimitive.Trigger
65
65
  data-slot="tabs-trigger"
66
66
  className={cn(
67
+ // Active-state text uses --foreground rather than --accent-foreground.
68
+ // The runtime brand-picker (use-global-primary-color → pickAccentForeground)
69
+ // already guards --accent-foreground against AAA failures, but
70
+ // --foreground vs --accent is structurally safe in every theme
71
+ // (~13:1 dark, ~20:1 light) and matches the Calendar range-middle
72
+ // pattern, so nested tabs can never regress on brand swaps.
67
73
  "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground ring-offset-background transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-accent data-[state=active]:text-foreground data-[state=active]:shadow-xs",
68
74
  className
69
75
  )}