banhaten 0.5.0 → 0.6.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 (290) hide show
  1. package/CHANGELOG.md +177 -139
  2. package/CONTRIBUTING.md +46 -46
  3. package/README.md +192 -192
  4. package/SECURITY.md +15 -15
  5. package/banhaten.config.example.json +11 -11
  6. package/docs/design-spacing.md +13 -13
  7. package/docs/design-system/README.md +22 -22
  8. package/docs/design-system/adoption-quality-remediation.md +87 -87
  9. package/docs/design-system/agent-usage.md +13 -13
  10. package/docs/design-system/appearance-presets.md +189 -189
  11. package/docs/design-system/appearances/default.md +94 -94
  12. package/docs/design-system/appearances/rounded.md +95 -95
  13. package/docs/design-system/appearances/sharp.md +95 -95
  14. package/docs/design-system/component-docs-pattern.md +81 -81
  15. package/docs/design-system/component-implementation-ownership-audit.md +245 -245
  16. package/docs/design-system/component-quality-audit-2026-08-20.md +225 -225
  17. package/docs/design-system/component-showcase-consistency-report.md +219 -219
  18. package/docs/design-system/component-token-consistency-audit.md +173 -173
  19. package/docs/design-system/components/README.md +91 -90
  20. package/docs/design-system/components/accordion.md +52 -52
  21. package/docs/design-system/components/activity-feed.md +93 -93
  22. package/docs/design-system/components/activity-heatmap.md +56 -56
  23. package/docs/design-system/components/alert-dialog.md +71 -71
  24. package/docs/design-system/components/alert.md +103 -97
  25. package/docs/design-system/components/app-header.md +97 -0
  26. package/docs/design-system/components/aspect-ratio.md +45 -45
  27. package/docs/design-system/components/attribute.md +101 -89
  28. package/docs/design-system/components/autocomplete.md +75 -75
  29. package/docs/design-system/components/avatar.md +53 -53
  30. package/docs/design-system/components/badge.md +55 -55
  31. package/docs/design-system/components/banner.md +86 -86
  32. package/docs/design-system/components/breadcrumbs.md +181 -177
  33. package/docs/design-system/components/button-group.md +97 -97
  34. package/docs/design-system/components/button.md +80 -80
  35. package/docs/design-system/components/card.md +102 -88
  36. package/docs/design-system/components/carousel.md +46 -46
  37. package/docs/design-system/components/catalog-components.md +46 -46
  38. package/docs/design-system/components/checkbox.md +53 -53
  39. package/docs/design-system/components/collapsible.md +63 -63
  40. package/docs/design-system/components/command.md +61 -61
  41. package/docs/design-system/components/context-menu.md +45 -45
  42. package/docs/design-system/components/date-picker.md +80 -80
  43. package/docs/design-system/components/divider.md +102 -102
  44. package/docs/design-system/components/empty-state.md +56 -56
  45. package/docs/design-system/components/field.md +70 -70
  46. package/docs/design-system/components/file-upload.md +186 -186
  47. package/docs/design-system/components/hover-card.md +47 -47
  48. package/docs/design-system/components/icons.md +48 -48
  49. package/docs/design-system/components/input-group.md +57 -57
  50. package/docs/design-system/components/input-otp.md +56 -56
  51. package/docs/design-system/components/input.md +111 -109
  52. package/docs/design-system/components/item.md +58 -58
  53. package/docs/design-system/components/kbd.md +49 -49
  54. package/docs/design-system/components/label.md +49 -49
  55. package/docs/design-system/components/menu.md +94 -73
  56. package/docs/design-system/components/menubar.md +46 -46
  57. package/docs/design-system/components/modal.md +104 -104
  58. package/docs/design-system/components/native-select.md +53 -53
  59. package/docs/design-system/components/navigation-menu.md +49 -49
  60. package/docs/design-system/components/onboarding-step-list-item.md +81 -81
  61. package/docs/design-system/components/page-header.md +127 -93
  62. package/docs/design-system/components/pagination.md +56 -56
  63. package/docs/design-system/components/popover.md +59 -59
  64. package/docs/design-system/components/progress-slider.md +49 -49
  65. package/docs/design-system/components/progress.md +76 -76
  66. package/docs/design-system/components/radio-card.md +50 -50
  67. package/docs/design-system/components/radio-group.md +56 -56
  68. package/docs/design-system/components/resizable.md +43 -43
  69. package/docs/design-system/components/scroll-area.md +50 -50
  70. package/docs/design-system/components/segmented-control.md +54 -54
  71. package/docs/design-system/components/select.md +68 -64
  72. package/docs/design-system/components/sheet.md +66 -66
  73. package/docs/design-system/components/sidebar.md +167 -111
  74. package/docs/design-system/components/skeleton.md +74 -74
  75. package/docs/design-system/components/slideout.md +64 -64
  76. package/docs/design-system/components/slider.md +62 -62
  77. package/docs/design-system/components/social-button.md +49 -49
  78. package/docs/design-system/components/spinner.md +62 -62
  79. package/docs/design-system/components/steps.md +65 -65
  80. package/docs/design-system/components/table.md +499 -422
  81. package/docs/design-system/components/tabs.md +74 -59
  82. package/docs/design-system/components/tag.md +79 -79
  83. package/docs/design-system/components/textarea.md +49 -49
  84. package/docs/design-system/components/timeline.md +82 -82
  85. package/docs/design-system/components/toast.md +57 -57
  86. package/docs/design-system/components/toggle.md +80 -80
  87. package/docs/design-system/components/toolbar.md +89 -89
  88. package/docs/design-system/components/tooltip.md +92 -92
  89. package/docs/design-system/components/typography.md +18 -18
  90. package/docs/design-system/density-and-elevation.md +65 -65
  91. package/docs/design-system/design-system-test-missing-items.md +368 -368
  92. package/docs/design-system/direction-and-localization.md +23 -23
  93. package/docs/design-system/form-recipes.md +73 -73
  94. package/docs/design-system/gap-promotion-policy.md +21 -21
  95. package/docs/design-system/icons.md +74 -74
  96. package/docs/design-system/installation.md +70 -70
  97. package/docs/design-system/launch-comparison-shadcn.md +98 -98
  98. package/docs/design-system/registry-and-cli.md +64 -64
  99. package/docs/design-system/release-policy.md +30 -30
  100. package/docs/design-system/roadmap.md +14 -14
  101. package/docs/design-system/support-matrix.md +23 -23
  102. package/docs/design-system/tabs.md +54 -54
  103. package/docs/design-system/template-gap-audit.md +32 -32
  104. package/docs/design-system/templates.md +59 -59
  105. package/docs/design-system/token-governance.md +72 -72
  106. package/package.json +98 -98
  107. package/registry/component-contract.json +40 -40
  108. package/registry/components/accordion.tsx +155 -155
  109. package/registry/components/alert-dialog.tsx +297 -297
  110. package/registry/components/alert.tsx +309 -293
  111. package/registry/components/app-header.tsx +151 -0
  112. package/registry/components/aspect-ratio.tsx +30 -30
  113. package/registry/components/attribute.tsx +489 -454
  114. package/registry/components/autocomplete.tsx +598 -598
  115. package/registry/components/avatar.tsx +385 -385
  116. package/registry/components/badge.tsx +630 -629
  117. package/registry/components/button-group.tsx +565 -565
  118. package/registry/components/button.tsx +128 -127
  119. package/registry/components/card.tsx +651 -638
  120. package/registry/components/carousel.tsx +296 -296
  121. package/registry/components/chart.tsx +203 -203
  122. package/registry/components/checkbox.tsx +247 -247
  123. package/registry/components/collapsible.tsx +109 -109
  124. package/registry/components/command.tsx +208 -208
  125. package/registry/components/context-menu.tsx +236 -236
  126. package/registry/components/date-picker.tsx +1289 -1289
  127. package/registry/components/expanded/ActivityFeed.tsx +227 -227
  128. package/registry/components/expanded/ActivityHeatmap.tsx +64 -64
  129. package/registry/components/expanded/Banner.tsx +179 -179
  130. package/registry/components/expanded/Breadcrumbs.tsx +135 -131
  131. package/registry/components/expanded/CatalogComponentsShowcase.tsx +205 -205
  132. package/registry/components/expanded/CatalogDivider.tsx +49 -49
  133. package/registry/components/expanded/EmptyState.tsx +155 -155
  134. package/registry/components/expanded/FileUpload.tsx +543 -543
  135. package/registry/components/expanded/OnboardingStepListItem.tsx +60 -60
  136. package/registry/components/expanded/PageHeader.tsx +209 -179
  137. package/registry/components/expanded/Slideout.tsx +108 -108
  138. package/registry/components/expanded/Steps.tsx +402 -402
  139. package/registry/components/expanded/Table.tsx +1109 -1092
  140. package/registry/components/expanded/Timeline.tsx +203 -203
  141. package/registry/components/expanded/activityFeed.css +248 -248
  142. package/registry/components/expanded/activityHeatmap.css +66 -66
  143. package/registry/components/expanded/banner.css +260 -260
  144. package/registry/components/expanded/breadcrumbs.css +157 -140
  145. package/registry/components/expanded/catalogComponentsShowcase.css +87 -87
  146. package/registry/components/expanded/divider.css +75 -75
  147. package/registry/components/expanded/emptyState.css +111 -111
  148. package/registry/components/expanded/fileUpload.css +457 -457
  149. package/registry/components/expanded/onboardingStepListItem.css +135 -135
  150. package/registry/components/expanded/pageHeader.css +284 -248
  151. package/registry/components/expanded/slideout.css +276 -276
  152. package/registry/components/expanded/steps.css +356 -356
  153. package/registry/components/expanded/table.css +655 -606
  154. package/registry/components/expanded/timeline.css +286 -286
  155. package/registry/components/field.tsx +283 -283
  156. package/registry/components/hover-card.tsx +48 -48
  157. package/registry/components/input-content.ts +107 -107
  158. package/registry/components/input-group.tsx +130 -130
  159. package/registry/components/input-otp.tsx +584 -584
  160. package/registry/components/input.tsx +992 -990
  161. package/registry/components/item.tsx +189 -189
  162. package/registry/components/kbd.tsx +246 -246
  163. package/registry/components/label.tsx +78 -78
  164. package/registry/components/menu.tsx +1091 -978
  165. package/registry/components/menubar.tsx +226 -226
  166. package/registry/components/modal.tsx +872 -872
  167. package/registry/components/native-select.tsx +205 -205
  168. package/registry/components/navigation-menu.tsx +171 -171
  169. package/registry/components/pagination.css +36 -36
  170. package/registry/components/pagination.tsx +560 -560
  171. package/registry/components/popover.tsx +338 -338
  172. package/registry/components/progress-slider.tsx +216 -216
  173. package/registry/components/radio-card.tsx +676 -676
  174. package/registry/components/radio-group.tsx +570 -570
  175. package/registry/components/resizable.tsx +108 -108
  176. package/registry/components/scroll-area.tsx +91 -91
  177. package/registry/components/segmented-control.tsx +87 -87
  178. package/registry/components/select-content.tsx +218 -218
  179. package/registry/components/select.tsx +937 -937
  180. package/registry/components/sheet.tsx +305 -305
  181. package/registry/components/sidebar.tsx +1535 -1433
  182. package/registry/components/skeleton.css +54 -54
  183. package/registry/components/skeleton.tsx +482 -482
  184. package/registry/components/slider.tsx +380 -380
  185. package/registry/components/social-button.tsx +387 -387
  186. package/registry/components/spinner.tsx +78 -78
  187. package/registry/components/table-elements.tsx +287 -128
  188. package/registry/components/tabs.css +246 -222
  189. package/registry/components/tabs.tsx +245 -241
  190. package/registry/components/tag.tsx +423 -423
  191. package/registry/components/textarea.tsx +610 -610
  192. package/registry/components/toast.tsx +136 -136
  193. package/registry/components/toggle.tsx +256 -256
  194. package/registry/components/toolbar.tsx +539 -539
  195. package/registry/components/tooltip.tsx +433 -433
  196. package/registry/examples/alert-demo.tsx +34 -34
  197. package/registry/examples/alert-dialog-demo.tsx +42 -42
  198. package/registry/examples/app-header-demo.tsx +40 -0
  199. package/registry/examples/aspect-ratio-demo.tsx +11 -11
  200. package/registry/examples/attribute-demo.tsx +65 -65
  201. package/registry/examples/autocomplete-demo.tsx +109 -109
  202. package/registry/examples/avatar-demo.tsx +132 -132
  203. package/registry/examples/badge-demo.tsx +69 -69
  204. package/registry/examples/button-demo.tsx +86 -86
  205. package/registry/examples/button-group-demo.tsx +63 -63
  206. package/registry/examples/card-demo.tsx +86 -86
  207. package/registry/examples/carousel-demo.tsx +43 -43
  208. package/registry/examples/chart-demo.tsx +18 -18
  209. package/registry/examples/checkbox-demo.tsx +62 -62
  210. package/registry/examples/collapsible-demo.tsx +16 -16
  211. package/registry/examples/collection-filter-bar-demo.tsx +135 -135
  212. package/registry/examples/command-demo.tsx +42 -42
  213. package/registry/examples/command-palette-demo.tsx +235 -235
  214. package/registry/examples/context-menu-demo.tsx +29 -29
  215. package/registry/examples/control-density-contract-demo.tsx +65 -65
  216. package/registry/examples/date-picker-demo.tsx +127 -127
  217. package/registry/examples/divider-demo.tsx +17 -17
  218. package/registry/examples/expanded/activity-heatmap-demo.tsx +29 -29
  219. package/registry/examples/expanded/banner-demo.tsx +48 -48
  220. package/registry/examples/expanded/breadcrumbs-demo.tsx +59 -59
  221. package/registry/examples/expanded/empty-state-demo.tsx +39 -39
  222. package/registry/examples/expanded/file-upload-demo.tsx +60 -60
  223. package/registry/examples/expanded/onboarding-step-demo.tsx +11 -11
  224. package/registry/examples/expanded/slideout-demo.tsx +15 -15
  225. package/registry/examples/expanded/steps-demo.tsx +29 -29
  226. package/registry/examples/expanded/tabs-demo.tsx +13 -13
  227. package/registry/examples/expanded/timeline-demo.tsx +18 -18
  228. package/registry/examples/field-demo.tsx +51 -51
  229. package/registry/examples/hover-card-demo.tsx +23 -23
  230. package/registry/examples/input-actions-demo.tsx +36 -36
  231. package/registry/examples/input-demo.tsx +87 -87
  232. package/registry/examples/input-group-demo.tsx +16 -16
  233. package/registry/examples/input-otp-demo.tsx +72 -72
  234. package/registry/examples/item-demo.tsx +46 -46
  235. package/registry/examples/kbd-demo.tsx +12 -12
  236. package/registry/examples/label-demo.tsx +20 -20
  237. package/registry/examples/menu-demo.tsx +122 -122
  238. package/registry/examples/menubar-demo.tsx +34 -34
  239. package/registry/examples/modal-demo.tsx +74 -74
  240. package/registry/examples/native-select-demo.tsx +16 -16
  241. package/registry/examples/navigation-menu-demo.tsx +29 -29
  242. package/registry/examples/pagination-demo.tsx +20 -20
  243. package/registry/examples/popover-demo.tsx +547 -547
  244. package/registry/examples/progress-demo.tsx +37 -37
  245. package/registry/examples/progress-slider-demo.tsx +29 -29
  246. package/registry/examples/radio-card-demo.tsx +51 -51
  247. package/registry/examples/radio-group-demo.tsx +62 -62
  248. package/registry/examples/resizable-demo.tsx +22 -22
  249. package/registry/examples/results-toolbar-demo.tsx +44 -44
  250. package/registry/examples/scroll-area-demo.tsx +15 -15
  251. package/registry/examples/segmented-control-demo.tsx +39 -39
  252. package/registry/examples/select-demo.tsx +87 -87
  253. package/registry/examples/sheet-demo.tsx +47 -47
  254. package/registry/examples/sidebar-demo.tsx +101 -101
  255. package/registry/examples/slider-demo.tsx +31 -31
  256. package/registry/examples/social-button-demo.tsx +61 -61
  257. package/registry/examples/spinner-demo.tsx +59 -59
  258. package/registry/examples/tabs-demo.tsx +13 -13
  259. package/registry/examples/tag-demo.tsx +29 -29
  260. package/registry/examples/textarea-demo.tsx +79 -79
  261. package/registry/examples/toast-demo.tsx +35 -35
  262. package/registry/examples/toggle-demo.tsx +59 -59
  263. package/registry/examples/tooltip-demo.tsx +115 -115
  264. package/registry/guidance/USAGE.md +27 -27
  265. package/registry/hooks/use-direction.ts +207 -207
  266. package/registry/index.json +387 -17
  267. package/registry/styles/globals.css +46 -0
  268. package/registry.json +24 -2
  269. package/schema/config.schema.json +51 -51
  270. package/schema/registry.schema.json +194 -194
  271. package/schema/tokens.schema.json +167 -167
  272. package/src/cli/command-line.js +194 -194
  273. package/src/cli/config-editors.js +9 -9
  274. package/src/cli/doctor.js +399 -399
  275. package/src/cli/file-transaction.js +302 -302
  276. package/src/cli/global-css.js +153 -153
  277. package/src/cli/index.js +1002 -1002
  278. package/src/cli/install-plan.js +592 -592
  279. package/src/cli/install-receipt.js +171 -171
  280. package/src/cli/jsonc.js +203 -203
  281. package/src/cli/package-install-state.js +254 -254
  282. package/src/cli/package-manager.js +238 -238
  283. package/src/cli/package-plan.js +185 -185
  284. package/src/cli/package-version.js +97 -97
  285. package/src/cli/registry-query.js +207 -207
  286. package/src/cli/reporting.js +55 -55
  287. package/src/cli/schema-validation.js +19 -19
  288. package/src/cli/source-scanner.js +686 -686
  289. package/src/cli/vite-config.js +478 -478
  290. package/tokens/banhaten.tokens.json +184 -0
@@ -1,638 +1,651 @@
1
- import * as React from "react"
2
- import { MoreHorizontalIcon } from "lucide-react"
3
- import { cva, type VariantProps } from "class-variance-authority"
4
-
5
- import { cn } from "@/lib/utils"
6
- import { Button, type ButtonProps } from "./button"
7
-
8
- type CardOrientation = "vertical" | "horizontal"
9
- type CardType = "leading-image" | "trailing-image" | "full-image"
10
- type CardBreakpoint = "desktop" | "mobile"
11
-
12
- const cardVariants = cva(
13
- [
14
- "group/card relative flex min-w-0 max-w-full overflow-hidden",
15
- "rounded-[var(--bh-card-radius)] bg-[var(--bh-card-bg)] text-start",
16
- "text-[var(--bh-content-default)] shadow-[inset_0_0_0_var(--bh-border-width-default)_var(--bh-card-border)]",
17
- "[--bh-card-bg:var(--bh-bg-raised)]",
18
- "[--bh-card-border:var(--bh-border-subtle)]",
19
- "[--bh-card-radius:var(--bh-radius-3xl-16)]",
20
- ],
21
- {
22
- variants: {
23
- orientation: {
24
- vertical: "flex-col",
25
- horizontal: "items-stretch",
26
- },
27
- type: {
28
- "leading-image": "",
29
- "trailing-image": "",
30
- "full-image": "",
31
- },
32
- breakpoint: {
33
- desktop: [
34
- "[--bh-card-content-padding:var(--bh-card-desktop-content-padding)]",
35
- "[--bh-card-horizontal-padding:var(--bh-card-desktop-horizontal-padding)]",
36
- "[--bh-card-media-height:var(--bh-card-desktop-media-height)]",
37
- "[--bh-card-full-height:var(--bh-card-desktop-full-height)]",
38
- ],
39
- mobile: [
40
- "[--bh-card-content-padding:var(--bh-card-mobile-content-padding)]",
41
- "[--bh-card-horizontal-padding:var(--bh-card-mobile-horizontal-padding)]",
42
- "[--bh-card-media-height:var(--bh-card-mobile-media-height)]",
43
- "[--bh-card-full-height:var(--bh-card-mobile-full-height)]",
44
- ],
45
- },
46
- },
47
- compoundVariants: [
48
- {
49
- orientation: "vertical",
50
- class: "w-[min(100%,var(--bh-card-vertical-width))]",
51
- },
52
- {
53
- orientation: "vertical",
54
- type: "full-image",
55
- class: "h-[var(--bh-card-full-height)]",
56
- },
57
- {
58
- orientation: "horizontal",
59
- breakpoint: "desktop",
60
- class:
61
- "min-h-[var(--bh-card-horizontal-min-height)] w-[min(100%,var(--bh-card-horizontal-width))] flex-wrap",
62
- },
63
- {
64
- orientation: "horizontal",
65
- breakpoint: "mobile",
66
- class: "w-[min(100%,var(--bh-card-vertical-width))] flex-col",
67
- },
68
- ],
69
- defaultVariants: {
70
- orientation: "vertical",
71
- type: "leading-image",
72
- breakpoint: "desktop",
73
- },
74
- }
75
- )
76
-
77
- type CardProps = Omit<React.ComponentProps<"article">, "title"> &
78
- VariantProps<typeof cardVariants> & {
79
- actions?: React.ReactNode
80
- description?: React.ReactNode
81
- footer?: React.ReactNode
82
- imageAlt?: string
83
- imageSrc?: string
84
- moreButtonLabel?: string
85
- onMoreClick?: React.MouseEventHandler<HTMLButtonElement>
86
- primaryActionLabel?: React.ReactNode
87
- primaryActionProps?: ButtonProps
88
- secondaryActionLabel?: React.ReactNode
89
- secondaryActionProps?: ButtonProps
90
- showDescription?: boolean
91
- showFooter?: boolean
92
- showImage?: boolean
93
- showMoreButton?: boolean
94
- showSubtitle?: boolean
95
- subtitle?: React.ReactNode
96
- title?: React.ReactNode
97
- }
98
-
99
- type CardMediaProps = React.ComponentProps<"div"> & {
100
- imageAlt?: string
101
- imageSrc?: string
102
- }
103
-
104
- type CardActionsProps = React.ComponentProps<"div"> & {
105
- primaryLabel?: React.ReactNode
106
- primaryProps?: ButtonProps
107
- secondaryLabel?: React.ReactNode
108
- secondaryProps?: ButtonProps
109
- }
110
-
111
- type CardFooterProps = React.ComponentProps<"div">
112
- type CardSurfaceProps = React.ComponentPropsWithoutRef<"article">
113
-
114
- const CardSurface = React.forwardRef<HTMLElement, CardSurfaceProps>(
115
- function CardSurface({ className, ...props }, ref) {
116
- return (
117
- <article
118
- data-slot="card-surface"
119
- ref={ref}
120
- className={cn(cardVariants(), className)}
121
- {...props}
122
- />
123
- )
124
- }
125
- )
126
-
127
- const Card = React.forwardRef<HTMLElement, CardProps>(function Card({
128
- actions,
129
- breakpoint = "desktop",
130
- className,
131
- description,
132
- footer,
133
- imageAlt = "",
134
- imageSrc,
135
- moreButtonLabel = "Open card menu",
136
- onMoreClick,
137
- orientation = "vertical",
138
- primaryActionLabel,
139
- primaryActionProps,
140
- secondaryActionLabel,
141
- secondaryActionProps,
142
- showDescription,
143
- showFooter,
144
- showImage,
145
- showMoreButton,
146
- showSubtitle,
147
- subtitle,
148
- title,
149
- type = "leading-image",
150
- ...props
151
- }, ref) {
152
- const cardOrientation = orientation ?? "vertical"
153
- const cardBreakpoint = breakpoint ?? "desktop"
154
- const cardType =
155
- cardOrientation === "horizontal" && type === "full-image"
156
- ? "leading-image"
157
- : type ?? "leading-image"
158
- const fullImage = cardOrientation === "vertical" && cardType === "full-image"
159
- const shouldShowDescription = showDescription ?? description !== undefined
160
- const shouldShowFooter =
161
- showFooter ??
162
- Boolean(footer || actions || primaryActionLabel || secondaryActionLabel)
163
- const shouldShowImage = showImage ?? Boolean(imageSrc)
164
- const shouldShowMoreButton = showMoreButton ?? Boolean(onMoreClick)
165
- const shouldShowSubtitle = showSubtitle ?? subtitle !== undefined
166
-
167
- const media = shouldShowImage ? (
168
- <CardMedia
169
- imageAlt={imageAlt}
170
- imageSrc={imageSrc}
171
- className={getCardMediaClassName(cardOrientation, cardBreakpoint)}
172
- />
173
- ) : null
174
-
175
- const body = (
176
- <CardBody
177
- actions={actions}
178
- breakpoint={cardBreakpoint}
179
- description={description}
180
- footer={footer}
181
- moreButtonLabel={moreButtonLabel}
182
- onMoreClick={onMoreClick}
183
- orientation={cardOrientation}
184
- primaryActionLabel={primaryActionLabel}
185
- primaryActionProps={primaryActionProps}
186
- secondaryActionLabel={secondaryActionLabel}
187
- secondaryActionProps={secondaryActionProps}
188
- showDescription={shouldShowDescription}
189
- showFooter={shouldShowFooter && !fullImage}
190
- showMoreButton={shouldShowMoreButton}
191
- showSubtitle={shouldShowSubtitle}
192
- subtitle={subtitle}
193
- title={title}
194
- />
195
- )
196
-
197
- return (
198
- <article
199
- data-slot="card"
200
- data-breakpoint={cardBreakpoint}
201
- data-orientation={cardOrientation}
202
- data-type={cardType}
203
- ref={ref}
204
- className={cn(
205
- cardVariants({
206
- orientation: cardOrientation,
207
- type: cardType,
208
- breakpoint: cardBreakpoint,
209
- }),
210
- className
211
- )}
212
- {...props}
213
- >
214
- {fullImage ? (
215
- <>
216
- <CardMedia
217
- imageAlt={imageAlt}
218
- imageSrc={imageSrc}
219
- className="absolute inset-0 size-full"
220
- />
221
- <CardFullImageContent
222
- breakpoint={cardBreakpoint}
223
- moreButtonLabel={moreButtonLabel}
224
- onMoreClick={onMoreClick}
225
- showMoreButton={shouldShowMoreButton}
226
- showSubtitle={shouldShowSubtitle}
227
- subtitle={subtitle}
228
- title={title}
229
- />
230
- </>
231
- ) : cardOrientation === "horizontal" &&
232
- cardBreakpoint === "desktop" &&
233
- cardType === "trailing-image" ? (
234
- <>
235
- {body}
236
- {media}
237
- </>
238
- ) : (
239
- <>
240
- {media}
241
- {body}
242
- </>
243
- )}
244
- </article>
245
- )
246
- })
247
-
248
- const CardMedia = React.forwardRef<HTMLDivElement, CardMediaProps>(
249
- function CardMedia({ children, className, imageAlt = "", imageSrc, ...props }, ref) {
250
- return (
251
- <div
252
- data-slot="card-media"
253
- ref={ref}
254
- className={cn(
255
- "relative min-h-0 shrink-0 overflow-hidden bg-[var(--bh-bg-neutral-subtle)]",
256
- className
257
- )}
258
- {...props}
259
- >
260
- {children ??
261
- (imageSrc ? (
262
- <img
263
- alt={imageAlt}
264
- className="absolute inset-0 size-full object-cover"
265
- src={imageSrc}
266
- />
267
- ) : (
268
- <CardImagePlaceholder />
269
- ))}
270
- </div>
271
- )
272
- }
273
- )
274
-
275
- const CardFooter = React.forwardRef<HTMLDivElement, CardFooterProps>(
276
- function CardFooter({ children, className, ...props }, ref) {
277
- return (
278
- <div
279
- data-slot="card-footer"
280
- ref={ref}
281
- className={cn("flex min-w-0 shrink-0 flex-col items-stretch", className)}
282
- {...props}
283
- >
284
- {children}
285
- </div>
286
- )
287
- }
288
- )
289
-
290
- const CardActions = React.forwardRef<HTMLDivElement, CardActionsProps>(
291
- function CardActions({
292
- children,
293
- className,
294
- primaryLabel,
295
- primaryProps,
296
- secondaryLabel,
297
- secondaryProps,
298
- ...props
299
- }, ref) {
300
- return (
301
- <div
302
- data-slot="card-actions"
303
- ref={ref}
304
- className={cn(
305
- "grid w-full max-w-[var(--bh-card-actions-max-width)] gap-[var(--bh-space-xl-12)]",
306
- primaryLabel && secondaryLabel ? "grid-cols-2" : "grid-cols-1",
307
- className
308
- )}
309
- {...props}
310
- >
311
- {children ?? (
312
- <>
313
- {primaryLabel ? (
314
- <Button {...primaryProps} className={cn("min-w-0", primaryProps?.className)}>
315
- {primaryLabel}
316
- </Button>
317
- ) : null}
318
- {secondaryLabel ? (
319
- <Button
320
- variant="soft"
321
- {...secondaryProps}
322
- className={cn("min-w-0", secondaryProps?.className)}
323
- >
324
- {secondaryLabel}
325
- </Button>
326
- ) : null}
327
- </>
328
- )}
329
- </div>
330
- )
331
- }
332
- )
333
-
334
- function CardBody({
335
- actions,
336
- breakpoint,
337
- description,
338
- footer,
339
- moreButtonLabel,
340
- onMoreClick,
341
- orientation,
342
- primaryActionLabel,
343
- primaryActionProps,
344
- secondaryActionLabel,
345
- secondaryActionProps,
346
- showDescription,
347
- showFooter,
348
- showMoreButton,
349
- showSubtitle,
350
- subtitle,
351
- title,
352
- }: {
353
- actions?: React.ReactNode
354
- breakpoint: CardBreakpoint
355
- description?: React.ReactNode
356
- footer?: React.ReactNode
357
- moreButtonLabel: string
358
- onMoreClick?: React.MouseEventHandler<HTMLButtonElement>
359
- orientation: CardOrientation
360
- primaryActionLabel?: React.ReactNode
361
- primaryActionProps?: ButtonProps
362
- secondaryActionLabel?: React.ReactNode
363
- secondaryActionProps?: ButtonProps
364
- showDescription: boolean
365
- showFooter: boolean
366
- showMoreButton: boolean
367
- showSubtitle: boolean
368
- subtitle?: React.ReactNode
369
- title?: React.ReactNode
370
- }) {
371
- const horizontal = orientation === "horizontal"
372
-
373
- return (
374
- <div
375
- data-slot="card-content"
376
- className={cn(
377
- "flex min-w-0 flex-col",
378
- horizontal
379
- ? "min-w-[min(100%,var(--bh-card-vertical-width))] flex-[1_1_var(--bh-card-vertical-width)] gap-[var(--bh-space-5xl-24)] p-[var(--bh-card-horizontal-padding)]"
380
- : "w-full gap-[var(--bh-space-5xl-24)] p-[var(--bh-card-content-padding)]"
381
- )}
382
- >
383
- <div
384
- data-slot="card-copy"
385
- className={cn(
386
- "flex min-w-0 flex-col",
387
- horizontal
388
- ? "gap-[var(--bh-space-xl-12)]"
389
- : "gap-[var(--bh-space-md-8)]"
390
- )}
391
- >
392
- <CardHeader
393
- moreButtonLabel={moreButtonLabel}
394
- onMoreClick={onMoreClick}
395
- onImage={false}
396
- showMoreButton={showMoreButton}
397
- showSubtitle={showSubtitle}
398
- subtitle={subtitle}
399
- title={title}
400
- subtitleClassName={getSubtitleClassName(breakpoint)}
401
- />
402
- {showDescription && description !== undefined ? (
403
- <p
404
- data-slot="card-description"
405
- dir="auto"
406
- className={cn(
407
- "min-w-0 break-words text-[var(--bh-content-subtle)]",
408
- getDescriptionClassName(orientation, breakpoint)
409
- )}
410
- >
411
- {description}
412
- </p>
413
- ) : null}
414
- </div>
415
-
416
- {showFooter ? (
417
- <CardFooter className={horizontal ? "mt-auto" : undefined}>
418
- {footer ??
419
- actions ?? (
420
- <CardActions
421
- primaryLabel={primaryActionLabel}
422
- primaryProps={primaryActionProps}
423
- secondaryLabel={secondaryActionLabel}
424
- secondaryProps={secondaryActionProps}
425
- />
426
- )}
427
- </CardFooter>
428
- ) : null}
429
- </div>
430
- )
431
- }
432
-
433
- function CardFullImageContent({
434
- breakpoint,
435
- moreButtonLabel,
436
- onMoreClick,
437
- showMoreButton,
438
- showSubtitle,
439
- subtitle,
440
- title,
441
- }: {
442
- breakpoint: CardBreakpoint
443
- moreButtonLabel: string
444
- onMoreClick?: React.MouseEventHandler<HTMLButtonElement>
445
- showMoreButton: boolean
446
- showSubtitle: boolean
447
- subtitle?: React.ReactNode
448
- title?: React.ReactNode
449
- }) {
450
- return (
451
- <div
452
- data-slot="card-overlay"
453
- className={[
454
- "absolute inset-x-0 bottom-0 flex min-w-0 flex-col",
455
- "bg-gradient-to-b from-transparent to-[var(--bh-card-media-overlay)]",
456
- "px-[var(--bh-card-content-padding)] pb-[var(--bh-card-content-padding)]",
457
- "pt-[var(--bh-space-6xl-32)] text-[var(--bh-content-on-color)]",
458
- ].join(" ")}
459
- >
460
- <CardHeader
461
- moreButtonLabel={moreButtonLabel}
462
- onMoreClick={onMoreClick}
463
- onImage
464
- showMoreButton={showMoreButton}
465
- showSubtitle={showSubtitle}
466
- subtitle={subtitle}
467
- subtitleClassName={getSubtitleClassName(breakpoint)}
468
- title={title}
469
- />
470
- </div>
471
- )
472
- }
473
-
474
- function CardHeader({
475
- moreButtonLabel,
476
- onImage,
477
- onMoreClick,
478
- showMoreButton,
479
- showSubtitle,
480
- subtitle,
481
- subtitleClassName,
482
- title,
483
- }: {
484
- moreButtonLabel: string
485
- onImage: boolean
486
- onMoreClick?: React.MouseEventHandler<HTMLButtonElement>
487
- showMoreButton: boolean
488
- showSubtitle: boolean
489
- subtitle: React.ReactNode
490
- subtitleClassName: string
491
- title: React.ReactNode
492
- }) {
493
- return (
494
- <div
495
- data-slot="card-header"
496
- className="flex min-w-0 items-start gap-[var(--bh-space-3xl-16)]"
497
- >
498
- <div className="flex min-w-0 flex-1 flex-col gap-[var(--bh-space-xxs-2)]">
499
- {title !== undefined ? (
500
- <h3
501
- data-slot="card-title"
502
- dir="auto"
503
- className={cn(
504
- "min-w-0 break-words text-[length:var(--bh-text-heading-sm-semibold-font-size)]",
505
- "font-[var(--bh-text-heading-sm-semibold-font-weight)]",
506
- "leading-[var(--bh-text-heading-sm-semibold-line-height)]",
507
- "tracking-[var(--bh-text-heading-sm-semibold-letter-spacing)]",
508
- onImage ? "text-[var(--bh-content-on-color)]" : "text-[var(--bh-content-default)]"
509
- )}
510
- >
511
- {title}
512
- </h3>
513
- ) : null}
514
- {showSubtitle && subtitle !== undefined ? (
515
- <p
516
- data-slot="card-subtitle"
517
- dir="auto"
518
- className={cn(
519
- "min-w-0 break-words",
520
- onImage
521
- ? "text-[var(--bh-content-on-color)]"
522
- : "text-[var(--bh-content-subtle)]",
523
- subtitleClassName
524
- )}
525
- >
526
- {subtitle}
527
- </p>
528
- ) : null}
529
- </div>
530
- {showMoreButton ? (
531
- <CardMoreButton
532
- aria-label={moreButtonLabel}
533
- onClick={onMoreClick}
534
- onImage={onImage}
535
- />
536
- ) : null}
537
- </div>
538
- )
539
- }
540
-
541
- function CardMoreButton({
542
- onImage,
543
- ...props
544
- }: React.ComponentProps<"button"> & { onImage: boolean }) {
545
- return (
546
- <button
547
- data-slot="card-more"
548
- type="button"
549
- className={cn(
550
- "inline-flex size-[var(--bh-card-more-size)] shrink-0 items-center justify-center",
551
- "rounded-[var(--bh-control-default)] outline-none",
552
- "transition-[background-color,color,box-shadow]",
553
- "focus-visible:shadow-[var(--elevation-button-focus)]",
554
- onImage
555
- ? "text-[var(--bh-content-on-color)] hover:bg-[var(--bh-interactive-ghost-hover)]"
556
- : "text-[var(--bh-content-subtle)] hover:bg-[var(--bh-interactive-ghost-hover)] hover:text-[var(--bh-content-default)]"
557
- )}
558
- {...props}
559
- >
560
- <MoreHorizontalIcon className="size-[var(--bh-card-more-icon-size)]" aria-hidden="true" />
561
- </button>
562
- )
563
- }
564
-
565
- function CardImagePlaceholder() {
566
- return (
567
- <div
568
- aria-hidden="true"
569
- data-slot="card-image-placeholder"
570
- className={[
571
- "absolute inset-0",
572
- "bg-[linear-gradient(135deg,var(--bh-bg-accent-sky-subtle),var(--bh-bg-accent-green-subtle))]",
573
- ].join(" ")}
574
- />
575
- )
576
- }
577
-
578
- function getCardMediaClassName(
579
- orientation: CardOrientation,
580
- breakpoint: CardBreakpoint
581
- ) {
582
- if (orientation === "horizontal" && breakpoint === "desktop") {
583
- return "min-h-[var(--bh-card-media-height)] w-[min(100%,var(--bh-card-horizontal-media-width))] shrink flex-[1_1_var(--bh-card-horizontal-media-width)]"
584
- }
585
-
586
- return "h-[var(--bh-card-media-height)] w-full"
587
- }
588
-
589
- function getSubtitleClassName(breakpoint: CardBreakpoint) {
590
- if (breakpoint === "mobile") {
591
- return [
592
- "text-[length:var(--bh-text-body-md-regular-font-size)]",
593
- "font-[var(--bh-text-body-md-regular-font-weight)]",
594
- "leading-[var(--bh-text-body-md-regular-line-height)]",
595
- "tracking-[var(--bh-text-body-md-regular-letter-spacing)]",
596
- ].join(" ")
597
- }
598
-
599
- return [
600
- "text-[length:var(--bh-text-body-lg-regular-font-size)]",
601
- "font-[var(--bh-text-body-lg-regular-font-weight)]",
602
- "leading-[var(--bh-text-body-lg-regular-line-height)]",
603
- "tracking-[var(--bh-text-body-lg-regular-letter-spacing)]",
604
- ].join(" ")
605
- }
606
-
607
- function getDescriptionClassName(
608
- orientation: CardOrientation,
609
- breakpoint: CardBreakpoint
610
- ) {
611
- if (orientation === "horizontal" && breakpoint === "desktop") {
612
- return getSubtitleClassName("desktop")
613
- }
614
-
615
- return [
616
- "text-[length:var(--bh-text-body-md-regular-font-size)]",
617
- "font-[var(--bh-text-body-md-regular-font-weight)]",
618
- "leading-[var(--bh-text-body-md-regular-line-height)]",
619
- "tracking-[var(--bh-text-body-md-regular-letter-spacing)]",
620
- ].join(" ")
621
- }
622
-
623
- export {
624
- Card,
625
- CardActions,
626
- CardFooter,
627
- CardMedia,
628
- CardSurface,
629
- cardVariants,
630
- type CardActionsProps,
631
- type CardBreakpoint,
632
- type CardFooterProps,
633
- type CardMediaProps,
634
- type CardOrientation,
635
- type CardProps,
636
- type CardSurfaceProps,
637
- type CardType,
638
- }
1
+ import * as React from "react"
2
+ import { MoreHorizontalIcon } from "lucide-react"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
+
5
+ import { cn } from "@/lib/utils"
6
+ import { Button, type ButtonProps } from "./button"
7
+
8
+ type CardOrientation = "vertical" | "horizontal"
9
+ type CardType = "leading-image" | "trailing-image" | "full-image"
10
+ type CardBreakpoint = "desktop" | "mobile"
11
+ type CardSize = "default" | "comfortable"
12
+
13
+ const cardVariants = cva(
14
+ [
15
+ "group/card relative flex min-w-0 max-w-full overflow-hidden",
16
+ "rounded-[var(--bh-card-radius)] bg-[var(--bh-card-bg)] text-start",
17
+ "text-[var(--bh-content-default)] shadow-[inset_0_0_0_var(--bh-border-width-default)_var(--bh-card-border)]",
18
+ "[--bh-card-bg:var(--bh-bg-raised)]",
19
+ "[--bh-card-border:var(--bh-border-subtle)]",
20
+ ],
21
+ {
22
+ variants: {
23
+ // comfortable is the app-shell panel: a smaller radius than the library cards.
24
+ size: {
25
+ default: "[--bh-card-radius:var(--bh-radius-3xl-16)]",
26
+ comfortable: "[--bh-card-radius:var(--bh-card-comfortable-radius)]",
27
+ },
28
+ orientation: {
29
+ vertical: "flex-col",
30
+ horizontal: "items-stretch",
31
+ },
32
+ type: {
33
+ "leading-image": "",
34
+ "trailing-image": "",
35
+ "full-image": "",
36
+ },
37
+ breakpoint: {
38
+ desktop: [
39
+ "[--bh-card-content-padding:var(--bh-card-desktop-content-padding)]",
40
+ "[--bh-card-horizontal-padding:var(--bh-card-desktop-horizontal-padding)]",
41
+ "[--bh-card-media-height:var(--bh-card-desktop-media-height)]",
42
+ "[--bh-card-full-height:var(--bh-card-desktop-full-height)]",
43
+ ],
44
+ mobile: [
45
+ "[--bh-card-content-padding:var(--bh-card-mobile-content-padding)]",
46
+ "[--bh-card-horizontal-padding:var(--bh-card-mobile-horizontal-padding)]",
47
+ "[--bh-card-media-height:var(--bh-card-mobile-media-height)]",
48
+ "[--bh-card-full-height:var(--bh-card-mobile-full-height)]",
49
+ ],
50
+ },
51
+ },
52
+ compoundVariants: [
53
+ {
54
+ orientation: "vertical",
55
+ class: "w-[min(100%,var(--bh-card-vertical-width))]",
56
+ },
57
+ {
58
+ orientation: "vertical",
59
+ type: "full-image",
60
+ class: "h-[var(--bh-card-full-height)]",
61
+ },
62
+ {
63
+ orientation: "horizontal",
64
+ breakpoint: "desktop",
65
+ class:
66
+ "min-h-[var(--bh-card-horizontal-min-height)] w-[min(100%,var(--bh-card-horizontal-width))] flex-wrap",
67
+ },
68
+ {
69
+ orientation: "horizontal",
70
+ breakpoint: "mobile",
71
+ class: "w-[min(100%,var(--bh-card-vertical-width))] flex-col",
72
+ },
73
+ ],
74
+ defaultVariants: {
75
+ size: "default",
76
+ orientation: "vertical",
77
+ type: "leading-image",
78
+ breakpoint: "desktop",
79
+ },
80
+ }
81
+ )
82
+
83
+ type CardProps = Omit<React.ComponentProps<"article">, "title"> &
84
+ VariantProps<typeof cardVariants> & {
85
+ actions?: React.ReactNode
86
+ description?: React.ReactNode
87
+ footer?: React.ReactNode
88
+ imageAlt?: string
89
+ imageSrc?: string
90
+ moreButtonLabel?: string
91
+ onMoreClick?: React.MouseEventHandler<HTMLButtonElement>
92
+ primaryActionLabel?: React.ReactNode
93
+ primaryActionProps?: ButtonProps
94
+ secondaryActionLabel?: React.ReactNode
95
+ secondaryActionProps?: ButtonProps
96
+ showDescription?: boolean
97
+ showFooter?: boolean
98
+ showImage?: boolean
99
+ showMoreButton?: boolean
100
+ showSubtitle?: boolean
101
+ subtitle?: React.ReactNode
102
+ title?: React.ReactNode
103
+ }
104
+
105
+ type CardMediaProps = React.ComponentProps<"div"> & {
106
+ imageAlt?: string
107
+ imageSrc?: string
108
+ }
109
+
110
+ type CardActionsProps = React.ComponentProps<"div"> & {
111
+ primaryLabel?: React.ReactNode
112
+ primaryProps?: ButtonProps
113
+ secondaryLabel?: React.ReactNode
114
+ secondaryProps?: ButtonProps
115
+ }
116
+
117
+ type CardFooterProps = React.ComponentProps<"div">
118
+ type CardSurfaceProps = React.ComponentPropsWithoutRef<"article"> & {
119
+ size?: CardSize
120
+ }
121
+
122
+ const CardSurface = React.forwardRef<HTMLElement, CardSurfaceProps>(
123
+ function CardSurface({ className, size = "default", ...props }, ref) {
124
+ return (
125
+ <article
126
+ data-slot="card-surface"
127
+ data-size={size}
128
+ ref={ref}
129
+ className={cn(cardVariants({ size }), className)}
130
+ {...props}
131
+ />
132
+ )
133
+ }
134
+ )
135
+
136
+ const Card = React.forwardRef<HTMLElement, CardProps>(function Card({
137
+ actions,
138
+ breakpoint = "desktop",
139
+ className,
140
+ description,
141
+ footer,
142
+ imageAlt = "",
143
+ imageSrc,
144
+ moreButtonLabel = "Open card menu",
145
+ onMoreClick,
146
+ orientation = "vertical",
147
+ primaryActionLabel,
148
+ primaryActionProps,
149
+ secondaryActionLabel,
150
+ secondaryActionProps,
151
+ showDescription,
152
+ showFooter,
153
+ showImage,
154
+ showMoreButton,
155
+ showSubtitle,
156
+ size = "default",
157
+ subtitle,
158
+ title,
159
+ type = "leading-image",
160
+ ...props
161
+ }, ref) {
162
+ const cardOrientation = orientation ?? "vertical"
163
+ const cardBreakpoint = breakpoint ?? "desktop"
164
+ const cardType =
165
+ cardOrientation === "horizontal" && type === "full-image"
166
+ ? "leading-image"
167
+ : type ?? "leading-image"
168
+ const fullImage = cardOrientation === "vertical" && cardType === "full-image"
169
+ const shouldShowDescription = showDescription ?? description !== undefined
170
+ const shouldShowFooter =
171
+ showFooter ??
172
+ Boolean(footer || actions || primaryActionLabel || secondaryActionLabel)
173
+ const shouldShowImage = showImage ?? Boolean(imageSrc)
174
+ const shouldShowMoreButton = showMoreButton ?? Boolean(onMoreClick)
175
+ const shouldShowSubtitle = showSubtitle ?? subtitle !== undefined
176
+
177
+ const media = shouldShowImage ? (
178
+ <CardMedia
179
+ imageAlt={imageAlt}
180
+ imageSrc={imageSrc}
181
+ className={getCardMediaClassName(cardOrientation, cardBreakpoint)}
182
+ />
183
+ ) : null
184
+
185
+ const body = (
186
+ <CardBody
187
+ actions={actions}
188
+ breakpoint={cardBreakpoint}
189
+ description={description}
190
+ footer={footer}
191
+ moreButtonLabel={moreButtonLabel}
192
+ onMoreClick={onMoreClick}
193
+ orientation={cardOrientation}
194
+ primaryActionLabel={primaryActionLabel}
195
+ primaryActionProps={primaryActionProps}
196
+ secondaryActionLabel={secondaryActionLabel}
197
+ secondaryActionProps={secondaryActionProps}
198
+ showDescription={shouldShowDescription}
199
+ showFooter={shouldShowFooter && !fullImage}
200
+ showMoreButton={shouldShowMoreButton}
201
+ showSubtitle={shouldShowSubtitle}
202
+ subtitle={subtitle}
203
+ title={title}
204
+ />
205
+ )
206
+
207
+ return (
208
+ <article
209
+ data-slot="card"
210
+ data-breakpoint={cardBreakpoint}
211
+ data-orientation={cardOrientation}
212
+ data-size={size ?? "default"}
213
+ data-type={cardType}
214
+ ref={ref}
215
+ className={cn(
216
+ cardVariants({
217
+ size,
218
+ orientation: cardOrientation,
219
+ type: cardType,
220
+ breakpoint: cardBreakpoint,
221
+ }),
222
+ className
223
+ )}
224
+ {...props}
225
+ >
226
+ {fullImage ? (
227
+ <>
228
+ <CardMedia
229
+ imageAlt={imageAlt}
230
+ imageSrc={imageSrc}
231
+ className="absolute inset-0 size-full"
232
+ />
233
+ <CardFullImageContent
234
+ breakpoint={cardBreakpoint}
235
+ moreButtonLabel={moreButtonLabel}
236
+ onMoreClick={onMoreClick}
237
+ showMoreButton={shouldShowMoreButton}
238
+ showSubtitle={shouldShowSubtitle}
239
+ subtitle={subtitle}
240
+ title={title}
241
+ />
242
+ </>
243
+ ) : cardOrientation === "horizontal" &&
244
+ cardBreakpoint === "desktop" &&
245
+ cardType === "trailing-image" ? (
246
+ <>
247
+ {body}
248
+ {media}
249
+ </>
250
+ ) : (
251
+ <>
252
+ {media}
253
+ {body}
254
+ </>
255
+ )}
256
+ </article>
257
+ )
258
+ })
259
+
260
+ const CardMedia = React.forwardRef<HTMLDivElement, CardMediaProps>(
261
+ function CardMedia({ children, className, imageAlt = "", imageSrc, ...props }, ref) {
262
+ return (
263
+ <div
264
+ data-slot="card-media"
265
+ ref={ref}
266
+ className={cn(
267
+ "relative min-h-0 shrink-0 overflow-hidden bg-[var(--bh-bg-neutral-subtle)]",
268
+ className
269
+ )}
270
+ {...props}
271
+ >
272
+ {children ??
273
+ (imageSrc ? (
274
+ <img
275
+ alt={imageAlt}
276
+ className="absolute inset-0 size-full object-cover"
277
+ src={imageSrc}
278
+ />
279
+ ) : (
280
+ <CardImagePlaceholder />
281
+ ))}
282
+ </div>
283
+ )
284
+ }
285
+ )
286
+
287
+ const CardFooter = React.forwardRef<HTMLDivElement, CardFooterProps>(
288
+ function CardFooter({ children, className, ...props }, ref) {
289
+ return (
290
+ <div
291
+ data-slot="card-footer"
292
+ ref={ref}
293
+ className={cn("flex min-w-0 shrink-0 flex-col items-stretch", className)}
294
+ {...props}
295
+ >
296
+ {children}
297
+ </div>
298
+ )
299
+ }
300
+ )
301
+
302
+ const CardActions = React.forwardRef<HTMLDivElement, CardActionsProps>(
303
+ function CardActions({
304
+ children,
305
+ className,
306
+ primaryLabel,
307
+ primaryProps,
308
+ secondaryLabel,
309
+ secondaryProps,
310
+ ...props
311
+ }, ref) {
312
+ return (
313
+ <div
314
+ data-slot="card-actions"
315
+ ref={ref}
316
+ className={cn(
317
+ "grid w-full max-w-[var(--bh-card-actions-max-width)] gap-[var(--bh-space-xl-12)]",
318
+ primaryLabel && secondaryLabel ? "grid-cols-2" : "grid-cols-1",
319
+ className
320
+ )}
321
+ {...props}
322
+ >
323
+ {children ?? (
324
+ <>
325
+ {primaryLabel ? (
326
+ <Button {...primaryProps} className={cn("min-w-0", primaryProps?.className)}>
327
+ {primaryLabel}
328
+ </Button>
329
+ ) : null}
330
+ {secondaryLabel ? (
331
+ <Button
332
+ variant="soft"
333
+ {...secondaryProps}
334
+ className={cn("min-w-0", secondaryProps?.className)}
335
+ >
336
+ {secondaryLabel}
337
+ </Button>
338
+ ) : null}
339
+ </>
340
+ )}
341
+ </div>
342
+ )
343
+ }
344
+ )
345
+
346
+ function CardBody({
347
+ actions,
348
+ breakpoint,
349
+ description,
350
+ footer,
351
+ moreButtonLabel,
352
+ onMoreClick,
353
+ orientation,
354
+ primaryActionLabel,
355
+ primaryActionProps,
356
+ secondaryActionLabel,
357
+ secondaryActionProps,
358
+ showDescription,
359
+ showFooter,
360
+ showMoreButton,
361
+ showSubtitle,
362
+ subtitle,
363
+ title,
364
+ }: {
365
+ actions?: React.ReactNode
366
+ breakpoint: CardBreakpoint
367
+ description?: React.ReactNode
368
+ footer?: React.ReactNode
369
+ moreButtonLabel: string
370
+ onMoreClick?: React.MouseEventHandler<HTMLButtonElement>
371
+ orientation: CardOrientation
372
+ primaryActionLabel?: React.ReactNode
373
+ primaryActionProps?: ButtonProps
374
+ secondaryActionLabel?: React.ReactNode
375
+ secondaryActionProps?: ButtonProps
376
+ showDescription: boolean
377
+ showFooter: boolean
378
+ showMoreButton: boolean
379
+ showSubtitle: boolean
380
+ subtitle?: React.ReactNode
381
+ title?: React.ReactNode
382
+ }) {
383
+ const horizontal = orientation === "horizontal"
384
+
385
+ return (
386
+ <div
387
+ data-slot="card-content"
388
+ className={cn(
389
+ "flex min-w-0 flex-col",
390
+ horizontal
391
+ ? "min-w-[min(100%,var(--bh-card-vertical-width))] flex-[1_1_var(--bh-card-vertical-width)] gap-[var(--bh-space-5xl-24)] p-[var(--bh-card-horizontal-padding)]"
392
+ : "w-full gap-[var(--bh-space-5xl-24)] p-[var(--bh-card-content-padding)]"
393
+ )}
394
+ >
395
+ <div
396
+ data-slot="card-copy"
397
+ className={cn(
398
+ "flex min-w-0 flex-col",
399
+ horizontal
400
+ ? "gap-[var(--bh-space-xl-12)]"
401
+ : "gap-[var(--bh-space-md-8)]"
402
+ )}
403
+ >
404
+ <CardHeader
405
+ moreButtonLabel={moreButtonLabel}
406
+ onMoreClick={onMoreClick}
407
+ onImage={false}
408
+ showMoreButton={showMoreButton}
409
+ showSubtitle={showSubtitle}
410
+ subtitle={subtitle}
411
+ title={title}
412
+ subtitleClassName={getSubtitleClassName(breakpoint)}
413
+ />
414
+ {showDescription && description !== undefined ? (
415
+ <p
416
+ data-slot="card-description"
417
+ dir="auto"
418
+ className={cn(
419
+ "min-w-0 break-words text-[var(--bh-content-subtle)]",
420
+ getDescriptionClassName(orientation, breakpoint)
421
+ )}
422
+ >
423
+ {description}
424
+ </p>
425
+ ) : null}
426
+ </div>
427
+
428
+ {showFooter ? (
429
+ <CardFooter className={horizontal ? "mt-auto" : undefined}>
430
+ {footer ??
431
+ actions ?? (
432
+ <CardActions
433
+ primaryLabel={primaryActionLabel}
434
+ primaryProps={primaryActionProps}
435
+ secondaryLabel={secondaryActionLabel}
436
+ secondaryProps={secondaryActionProps}
437
+ />
438
+ )}
439
+ </CardFooter>
440
+ ) : null}
441
+ </div>
442
+ )
443
+ }
444
+
445
+ function CardFullImageContent({
446
+ breakpoint,
447
+ moreButtonLabel,
448
+ onMoreClick,
449
+ showMoreButton,
450
+ showSubtitle,
451
+ subtitle,
452
+ title,
453
+ }: {
454
+ breakpoint: CardBreakpoint
455
+ moreButtonLabel: string
456
+ onMoreClick?: React.MouseEventHandler<HTMLButtonElement>
457
+ showMoreButton: boolean
458
+ showSubtitle: boolean
459
+ subtitle?: React.ReactNode
460
+ title?: React.ReactNode
461
+ }) {
462
+ return (
463
+ <div
464
+ data-slot="card-overlay"
465
+ className={[
466
+ "absolute inset-x-0 bottom-0 flex min-w-0 flex-col",
467
+ "bg-gradient-to-b from-transparent to-[var(--bh-card-media-overlay)]",
468
+ "px-[var(--bh-card-content-padding)] pb-[var(--bh-card-content-padding)]",
469
+ "pt-[var(--bh-space-6xl-32)] text-[var(--bh-content-on-color)]",
470
+ ].join(" ")}
471
+ >
472
+ <CardHeader
473
+ moreButtonLabel={moreButtonLabel}
474
+ onMoreClick={onMoreClick}
475
+ onImage
476
+ showMoreButton={showMoreButton}
477
+ showSubtitle={showSubtitle}
478
+ subtitle={subtitle}
479
+ subtitleClassName={getSubtitleClassName(breakpoint)}
480
+ title={title}
481
+ />
482
+ </div>
483
+ )
484
+ }
485
+
486
+ function CardHeader({
487
+ moreButtonLabel,
488
+ onImage,
489
+ onMoreClick,
490
+ showMoreButton,
491
+ showSubtitle,
492
+ subtitle,
493
+ subtitleClassName,
494
+ title,
495
+ }: {
496
+ moreButtonLabel: string
497
+ onImage: boolean
498
+ onMoreClick?: React.MouseEventHandler<HTMLButtonElement>
499
+ showMoreButton: boolean
500
+ showSubtitle: boolean
501
+ subtitle: React.ReactNode
502
+ subtitleClassName: string
503
+ title: React.ReactNode
504
+ }) {
505
+ return (
506
+ <div
507
+ data-slot="card-header"
508
+ className="flex min-w-0 items-start gap-[var(--bh-space-3xl-16)]"
509
+ >
510
+ <div className="flex min-w-0 flex-1 flex-col gap-[var(--bh-space-xxs-2)]">
511
+ {title !== undefined ? (
512
+ <h3
513
+ data-slot="card-title"
514
+ dir="auto"
515
+ className={cn(
516
+ "min-w-0 break-words text-[length:var(--bh-text-heading-sm-semibold-font-size)]",
517
+ "font-[var(--bh-text-heading-sm-semibold-font-weight)]",
518
+ "leading-[var(--bh-text-heading-sm-semibold-line-height)]",
519
+ "tracking-[var(--bh-text-heading-sm-semibold-letter-spacing)]",
520
+ onImage ? "text-[var(--bh-content-on-color)]" : "text-[var(--bh-content-default)]"
521
+ )}
522
+ >
523
+ {title}
524
+ </h3>
525
+ ) : null}
526
+ {showSubtitle && subtitle !== undefined ? (
527
+ <p
528
+ data-slot="card-subtitle"
529
+ dir="auto"
530
+ className={cn(
531
+ "min-w-0 break-words",
532
+ onImage
533
+ ? "text-[var(--bh-content-on-color)]"
534
+ : "text-[var(--bh-content-subtle)]",
535
+ subtitleClassName
536
+ )}
537
+ >
538
+ {subtitle}
539
+ </p>
540
+ ) : null}
541
+ </div>
542
+ {showMoreButton ? (
543
+ <CardMoreButton
544
+ aria-label={moreButtonLabel}
545
+ onClick={onMoreClick}
546
+ onImage={onImage}
547
+ />
548
+ ) : null}
549
+ </div>
550
+ )
551
+ }
552
+
553
+ function CardMoreButton({
554
+ onImage,
555
+ ...props
556
+ }: React.ComponentProps<"button"> & { onImage: boolean }) {
557
+ return (
558
+ <button
559
+ data-slot="card-more"
560
+ type="button"
561
+ className={cn(
562
+ "inline-flex size-[var(--bh-card-more-size)] shrink-0 items-center justify-center",
563
+ "rounded-[var(--bh-control-default)] outline-none",
564
+ "transition-[background-color,color,box-shadow]",
565
+ "focus-visible:shadow-[var(--elevation-button-focus)]",
566
+ onImage
567
+ ? "text-[var(--bh-content-on-color)] hover:bg-[var(--bh-interactive-ghost-hover)]"
568
+ : "text-[var(--bh-content-subtle)] hover:bg-[var(--bh-interactive-ghost-hover)] hover:text-[var(--bh-content-default)]"
569
+ )}
570
+ {...props}
571
+ >
572
+ <MoreHorizontalIcon className="size-[var(--bh-card-more-icon-size)]" aria-hidden="true" />
573
+ </button>
574
+ )
575
+ }
576
+
577
+ function CardImagePlaceholder() {
578
+ return (
579
+ <div
580
+ aria-hidden="true"
581
+ data-slot="card-image-placeholder"
582
+ className={[
583
+ "absolute inset-0",
584
+ "bg-[linear-gradient(135deg,var(--bh-bg-accent-sky-subtle),var(--bh-bg-accent-green-subtle))]",
585
+ ].join(" ")}
586
+ />
587
+ )
588
+ }
589
+
590
+ function getCardMediaClassName(
591
+ orientation: CardOrientation,
592
+ breakpoint: CardBreakpoint
593
+ ) {
594
+ if (orientation === "horizontal" && breakpoint === "desktop") {
595
+ return "min-h-[var(--bh-card-media-height)] w-[min(100%,var(--bh-card-horizontal-media-width))] shrink flex-[1_1_var(--bh-card-horizontal-media-width)]"
596
+ }
597
+
598
+ return "h-[var(--bh-card-media-height)] w-full"
599
+ }
600
+
601
+ function getSubtitleClassName(breakpoint: CardBreakpoint) {
602
+ if (breakpoint === "mobile") {
603
+ return [
604
+ "text-[length:var(--bh-text-body-md-regular-font-size)]",
605
+ "font-[var(--bh-text-body-md-regular-font-weight)]",
606
+ "leading-[var(--bh-text-body-md-regular-line-height)]",
607
+ "tracking-[var(--bh-text-body-md-regular-letter-spacing)]",
608
+ ].join(" ")
609
+ }
610
+
611
+ return [
612
+ "text-[length:var(--bh-text-body-lg-regular-font-size)]",
613
+ "font-[var(--bh-text-body-lg-regular-font-weight)]",
614
+ "leading-[var(--bh-text-body-lg-regular-line-height)]",
615
+ "tracking-[var(--bh-text-body-lg-regular-letter-spacing)]",
616
+ ].join(" ")
617
+ }
618
+
619
+ function getDescriptionClassName(
620
+ orientation: CardOrientation,
621
+ breakpoint: CardBreakpoint
622
+ ) {
623
+ if (orientation === "horizontal" && breakpoint === "desktop") {
624
+ return getSubtitleClassName("desktop")
625
+ }
626
+
627
+ return [
628
+ "text-[length:var(--bh-text-body-md-regular-font-size)]",
629
+ "font-[var(--bh-text-body-md-regular-font-weight)]",
630
+ "leading-[var(--bh-text-body-md-regular-line-height)]",
631
+ "tracking-[var(--bh-text-body-md-regular-letter-spacing)]",
632
+ ].join(" ")
633
+ }
634
+
635
+ export {
636
+ Card,
637
+ CardActions,
638
+ CardFooter,
639
+ CardMedia,
640
+ CardSurface,
641
+ cardVariants,
642
+ type CardActionsProps,
643
+ type CardBreakpoint,
644
+ type CardFooterProps,
645
+ type CardMediaProps,
646
+ type CardOrientation,
647
+ type CardProps,
648
+ type CardSize,
649
+ type CardSurfaceProps,
650
+ type CardType,
651
+ }