banhaten 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +139 -100
- package/CONTRIBUTING.md +46 -44
- package/README.md +192 -190
- package/SECURITY.md +15 -15
- package/banhaten.config.example.json +11 -11
- package/docs/design-spacing.md +13 -0
- package/docs/design-system/README.md +22 -20
- package/docs/design-system/adoption-quality-remediation.md +87 -87
- package/docs/design-system/agent-usage.md +13 -13
- package/docs/design-system/appearance-presets.md +189 -189
- package/docs/design-system/appearances/default.md +94 -94
- package/docs/design-system/appearances/rounded.md +95 -95
- package/docs/design-system/appearances/sharp.md +95 -95
- package/docs/design-system/component-docs-pattern.md +81 -81
- package/docs/design-system/component-implementation-ownership-audit.md +245 -245
- package/docs/design-system/component-quality-audit-2026-08-20.md +225 -225
- package/docs/design-system/component-showcase-consistency-report.md +219 -219
- package/docs/design-system/component-token-consistency-audit.md +173 -173
- package/docs/design-system/components/README.md +90 -76
- package/docs/design-system/components/accordion.md +53 -53
- package/docs/design-system/components/activity-feed.md +94 -94
- package/docs/design-system/components/activity-heatmap.md +57 -57
- package/docs/design-system/components/agent-input.md +85 -0
- package/docs/design-system/components/alert-dialog.md +72 -72
- package/docs/design-system/components/alert.md +97 -97
- package/docs/design-system/components/approval-card.md +134 -0
- package/docs/design-system/components/aspect-ratio.md +45 -45
- package/docs/design-system/components/attribute.md +88 -88
- package/docs/design-system/components/autocomplete.md +75 -75
- package/docs/design-system/components/avatar.md +54 -54
- package/docs/design-system/components/badge.md +54 -54
- package/docs/design-system/components/banner.md +87 -87
- package/docs/design-system/components/breadcrumbs.md +176 -175
- package/docs/design-system/components/button-group.md +98 -98
- package/docs/design-system/components/button.md +83 -80
- package/docs/design-system/components/card.md +88 -88
- package/docs/design-system/components/carousel.md +46 -46
- package/docs/design-system/components/catalog-components.md +47 -47
- package/docs/design-system/components/chart.md +95 -24
- package/docs/design-system/components/checkbox.md +54 -54
- package/docs/design-system/components/collapsible.md +67 -53
- package/docs/design-system/components/command.md +62 -62
- package/docs/design-system/components/context-menu.md +46 -46
- package/docs/design-system/components/date-picker.md +81 -81
- package/docs/design-system/components/divider.md +102 -102
- package/docs/design-system/components/empty-state.md +56 -56
- package/docs/design-system/components/field.md +70 -70
- package/docs/design-system/components/file-upload.md +187 -187
- package/docs/design-system/components/hover-card.md +48 -48
- package/docs/design-system/components/icons.md +48 -48
- package/docs/design-system/components/inline-citations.md +93 -0
- package/docs/design-system/components/input-group.md +58 -58
- package/docs/design-system/components/input-otp.md +56 -56
- package/docs/design-system/components/input.md +114 -60
- package/docs/design-system/components/item.md +59 -59
- package/docs/design-system/components/kbd.md +51 -49
- package/docs/design-system/components/label.md +49 -49
- package/docs/design-system/components/menu.md +71 -61
- package/docs/design-system/components/menubar.md +47 -47
- package/docs/design-system/components/modal.md +105 -105
- package/docs/design-system/components/native-select.md +54 -54
- package/docs/design-system/components/navigation-menu.md +50 -50
- package/docs/design-system/components/onboarding-step-list-item.md +82 -82
- package/docs/design-system/components/page-header.md +93 -86
- package/docs/design-system/components/pagination.md +57 -57
- package/docs/design-system/components/popover.md +60 -60
- package/docs/design-system/components/progress-slider.md +50 -50
- package/docs/design-system/components/progress.md +76 -76
- package/docs/design-system/components/radio-card.md +51 -51
- package/docs/design-system/components/radio-group.md +57 -57
- package/docs/design-system/components/resizable.md +44 -44
- package/docs/design-system/components/rolling-count.md +61 -0
- package/docs/design-system/components/scroll-area.md +51 -51
- package/docs/design-system/components/segmented-control.md +54 -54
- package/docs/design-system/components/select.md +68 -62
- package/docs/design-system/components/sheet.md +67 -67
- package/docs/design-system/components/shimmer-text.md +67 -0
- package/docs/design-system/components/sidebar.md +110 -99
- package/docs/design-system/components/skeleton.md +75 -75
- package/docs/design-system/components/slideout.md +65 -65
- package/docs/design-system/components/slider.md +63 -63
- package/docs/design-system/components/social-button.md +50 -50
- package/docs/design-system/components/spinner.md +62 -62
- package/docs/design-system/components/steps.md +65 -65
- package/docs/design-system/components/streaming-text.md +82 -0
- package/docs/design-system/components/table.md +419 -414
- package/docs/design-system/components/tabs.md +59 -55
- package/docs/design-system/components/tag.md +80 -80
- package/docs/design-system/components/task-list.md +95 -0
- package/docs/design-system/components/textarea.md +50 -50
- package/docs/design-system/components/thinking-reasoning.md +72 -0
- package/docs/design-system/components/thinking-state.md +67 -0
- package/docs/design-system/components/timeline.md +83 -83
- package/docs/design-system/components/toast.md +58 -58
- package/docs/design-system/components/toggle.md +81 -81
- package/docs/design-system/components/toolbar.md +92 -87
- package/docs/design-system/components/tooltip.md +94 -92
- package/docs/design-system/components/typography.md +18 -18
- package/docs/design-system/density-and-elevation.md +65 -65
- package/docs/design-system/design-system-test-missing-items.md +368 -368
- package/docs/design-system/direction-and-localization.md +23 -23
- package/docs/design-system/form-recipes.md +73 -73
- package/docs/design-system/gap-promotion-policy.md +21 -21
- package/docs/design-system/icons.md +74 -74
- package/docs/design-system/installation.md +70 -68
- package/docs/design-system/launch-comparison-shadcn.md +98 -98
- package/docs/design-system/registry-and-cli.md +64 -64
- package/docs/design-system/release-policy.md +30 -30
- package/docs/design-system/roadmap.md +14 -14
- package/docs/design-system/support-matrix.md +23 -23
- package/docs/design-system/tabs.md +54 -53
- package/docs/design-system/template-gap-audit.md +32 -0
- package/docs/design-system/templates.md +59 -0
- package/docs/design-system/token-governance.md +72 -59
- package/package.json +98 -98
- package/registry/component-contract.json +40 -40
- package/registry/components/accordion.tsx +155 -155
- package/registry/components/agent-input-parts.tsx +552 -0
- package/registry/components/agent-input-state.ts +156 -0
- package/registry/components/agent-input.css +307 -0
- package/registry/components/agent-input.tsx +382 -0
- package/registry/components/alert-dialog.tsx +297 -297
- package/registry/components/alert.tsx +293 -293
- package/registry/components/approval-card.css +409 -0
- package/registry/components/approval-card.tsx +401 -0
- package/registry/components/approval-frame.tsx +108 -0
- package/registry/components/approval-questions.tsx +559 -0
- package/registry/components/aspect-ratio.tsx +30 -30
- package/registry/components/attribute.tsx +454 -454
- package/registry/components/autocomplete.tsx +598 -651
- package/registry/components/avatar.tsx +385 -385
- package/registry/components/badge.tsx +629 -629
- package/registry/components/button-group.tsx +565 -565
- package/registry/components/button.tsx +127 -123
- package/registry/components/card.tsx +638 -638
- package/registry/components/carousel.tsx +296 -296
- package/registry/components/chart-block-data.ts +177 -0
- package/registry/components/chart-block.css +171 -0
- package/registry/components/chart-block.tsx +260 -0
- package/registry/components/chart-interactions.ts +123 -0
- package/registry/components/chart-options.cartesian.ts +162 -0
- package/registry/components/chart-options.paint.ts +99 -0
- package/registry/components/chart-options.parts.ts +72 -0
- package/registry/components/chart-options.radial.ts +109 -0
- package/registry/components/chart-options.ts +44 -0
- package/registry/components/chart-options.types.ts +67 -0
- package/registry/components/chart.tsx +203 -203
- package/registry/components/checkbox.tsx +247 -247
- package/registry/components/collapsible.tsx +109 -69
- package/registry/components/command.tsx +208 -208
- package/registry/components/context-menu.tsx +236 -236
- package/registry/components/data-chart.tsx +40 -0
- package/registry/components/date-picker.tsx +1289 -1289
- package/registry/components/echart-theme.ts +246 -0
- package/registry/components/echart.css +49 -0
- package/registry/components/echart.tsx +178 -0
- package/registry/components/expanded/ActivityFeed.tsx +227 -227
- package/registry/components/expanded/ActivityHeatmap.tsx +64 -64
- package/registry/components/expanded/Banner.tsx +179 -179
- package/registry/components/expanded/Breadcrumbs.tsx +131 -131
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +205 -205
- package/registry/components/expanded/CatalogDivider.tsx +49 -49
- package/registry/components/expanded/EmptyState.tsx +155 -155
- package/registry/components/expanded/FileUpload.tsx +543 -543
- package/registry/components/expanded/OnboardingStepListItem.tsx +60 -60
- package/registry/components/expanded/PageHeader.tsx +179 -166
- package/registry/components/expanded/Slideout.tsx +108 -108
- package/registry/components/expanded/Steps.tsx +402 -402
- package/registry/components/expanded/Table.tsx +1092 -1071
- package/registry/components/expanded/Timeline.tsx +203 -203
- package/registry/components/expanded/activityFeed.css +248 -248
- package/registry/components/expanded/activityHeatmap.css +66 -66
- package/registry/components/expanded/banner.css +260 -260
- package/registry/components/expanded/breadcrumbs.css +140 -140
- package/registry/components/expanded/catalogComponentsShowcase.css +87 -87
- package/registry/components/expanded/divider.css +75 -75
- package/registry/components/expanded/emptyState.css +111 -111
- package/registry/components/expanded/fileUpload.css +457 -457
- package/registry/components/expanded/onboardingStepListItem.css +135 -135
- package/registry/components/expanded/pageHeader.css +248 -290
- package/registry/components/expanded/slideout.css +276 -276
- package/registry/components/expanded/steps.css +356 -356
- package/registry/components/expanded/table.css +606 -606
- package/registry/components/expanded/timeline.css +286 -286
- package/registry/components/field.tsx +283 -283
- package/registry/components/hover-card.tsx +48 -48
- package/registry/components/inline-citations.css +126 -0
- package/registry/components/inline-citations.tsx +292 -0
- package/registry/components/input-content.ts +107 -107
- package/registry/components/input-group.tsx +130 -130
- package/registry/components/input-otp.tsx +584 -584
- package/registry/components/input.tsx +990 -979
- package/registry/components/item.tsx +189 -189
- package/registry/components/kbd.tsx +246 -245
- package/registry/components/label.tsx +78 -78
- package/registry/components/menu.tsx +978 -986
- package/registry/components/menubar.tsx +226 -226
- package/registry/components/modal.tsx +872 -872
- package/registry/components/native-select.tsx +205 -205
- package/registry/components/navigation-menu.tsx +171 -171
- package/registry/components/pagination.css +36 -36
- package/registry/components/pagination.tsx +560 -560
- package/registry/components/popover.tsx +338 -338
- package/registry/components/progress-slider.tsx +216 -216
- package/registry/components/radio-card.tsx +676 -676
- package/registry/components/radio-group.tsx +570 -570
- package/registry/components/resizable.tsx +108 -108
- package/registry/components/rolling-count.css +37 -0
- package/registry/components/rolling-count.tsx +110 -0
- package/registry/components/scroll-area.tsx +91 -91
- package/registry/components/segmented-control.tsx +87 -87
- package/registry/components/select-content.tsx +218 -218
- package/registry/components/select.tsx +937 -932
- package/registry/components/sheet.tsx +305 -305
- package/registry/components/shimmer-text.css +69 -0
- package/registry/components/shimmer-text.tsx +43 -0
- package/registry/components/sidebar.tsx +1433 -1230
- package/registry/components/skeleton.css +54 -54
- package/registry/components/skeleton.tsx +482 -482
- package/registry/components/slider.tsx +380 -380
- package/registry/components/social-button.tsx +387 -387
- package/registry/components/spinner.tsx +78 -78
- package/registry/components/streaming-text.css +45 -0
- package/registry/components/streaming-text.tsx +165 -0
- package/registry/components/table-elements.tsx +128 -128
- package/registry/components/tabs.css +222 -218
- package/registry/components/tabs.tsx +241 -241
- package/registry/components/tag.tsx +423 -423
- package/registry/components/task-list.css +328 -0
- package/registry/components/task-list.tsx +429 -0
- package/registry/components/textarea.tsx +610 -610
- package/registry/components/thinking-reasoning.css +178 -0
- package/registry/components/thinking-reasoning.tsx +253 -0
- package/registry/components/thinking-state.css +8 -0
- package/registry/components/thinking-state.tsx +46 -0
- package/registry/components/toast.tsx +136 -136
- package/registry/components/toggle.tsx +256 -256
- package/registry/components/toolbar.tsx +539 -539
- package/registry/components/tooltip.tsx +433 -431
- package/registry/examples/agent-input-demo.tsx +90 -0
- package/registry/examples/alert-demo.tsx +34 -34
- package/registry/examples/alert-dialog-demo.tsx +42 -42
- package/registry/examples/approval-card-demo.tsx +83 -0
- package/registry/examples/aspect-ratio-demo.tsx +11 -11
- package/registry/examples/attribute-demo.tsx +65 -65
- package/registry/examples/autocomplete-demo.tsx +109 -109
- package/registry/examples/avatar-demo.tsx +132 -132
- package/registry/examples/badge-demo.tsx +69 -69
- package/registry/examples/button-demo.tsx +86 -83
- package/registry/examples/button-group-demo.tsx +63 -63
- package/registry/examples/card-demo.tsx +86 -86
- package/registry/examples/carousel-demo.tsx +43 -43
- package/registry/examples/chart-block-demo.tsx +5 -0
- package/registry/examples/chart-demo.tsx +18 -33
- package/registry/examples/checkbox-demo.tsx +62 -62
- package/registry/examples/collapsible-demo.tsx +16 -16
- package/registry/examples/collection-filter-bar-demo.tsx +135 -135
- package/registry/examples/command-demo.tsx +42 -42
- package/registry/examples/command-palette-demo.tsx +235 -235
- package/registry/examples/context-menu-demo.tsx +29 -29
- package/registry/examples/control-density-contract-demo.tsx +65 -61
- package/registry/examples/date-picker-demo.tsx +127 -127
- package/registry/examples/divider-demo.tsx +17 -17
- package/registry/examples/expanded/activity-heatmap-demo.tsx +29 -29
- package/registry/examples/expanded/banner-demo.tsx +48 -48
- package/registry/examples/expanded/breadcrumbs-demo.tsx +59 -59
- package/registry/examples/expanded/empty-state-demo.tsx +39 -39
- package/registry/examples/expanded/file-upload-demo.tsx +60 -60
- package/registry/examples/expanded/onboarding-step-demo.tsx +11 -11
- package/registry/examples/expanded/slideout-demo.tsx +15 -15
- package/registry/examples/expanded/steps-demo.tsx +29 -29
- package/registry/examples/expanded/tabs-demo.tsx +13 -13
- package/registry/examples/expanded/timeline-demo.tsx +18 -18
- package/registry/examples/field-demo.tsx +51 -51
- package/registry/examples/hover-card-demo.tsx +23 -23
- package/registry/examples/inline-citations-demo.tsx +31 -0
- package/registry/examples/input-actions-demo.tsx +36 -0
- package/registry/examples/input-demo.tsx +87 -87
- package/registry/examples/input-group-demo.tsx +16 -16
- package/registry/examples/input-otp-demo.tsx +72 -72
- package/registry/examples/item-demo.tsx +46 -46
- package/registry/examples/kbd-demo.tsx +12 -12
- package/registry/examples/label-demo.tsx +20 -20
- package/registry/examples/menu-demo.tsx +122 -122
- package/registry/examples/menubar-demo.tsx +34 -34
- package/registry/examples/modal-demo.tsx +74 -74
- package/registry/examples/native-select-demo.tsx +16 -16
- package/registry/examples/navigation-menu-demo.tsx +29 -29
- package/registry/examples/pagination-demo.tsx +20 -20
- package/registry/examples/popover-demo.tsx +547 -546
- package/registry/examples/progress-demo.tsx +37 -37
- package/registry/examples/progress-slider-demo.tsx +29 -29
- package/registry/examples/radio-card-demo.tsx +51 -51
- package/registry/examples/radio-group-demo.tsx +62 -62
- package/registry/examples/resizable-demo.tsx +22 -22
- package/registry/examples/results-toolbar-demo.tsx +44 -44
- package/registry/examples/rolling-count-demo.tsx +39 -0
- package/registry/examples/scroll-area-demo.tsx +15 -15
- package/registry/examples/segmented-control-demo.tsx +39 -39
- package/registry/examples/select-demo.tsx +87 -87
- package/registry/examples/sheet-demo.tsx +47 -47
- package/registry/examples/shimmer-text-demo.tsx +20 -0
- package/registry/examples/sidebar-demo.tsx +101 -101
- package/registry/examples/slider-demo.tsx +31 -31
- package/registry/examples/social-button-demo.tsx +61 -61
- package/registry/examples/spinner-demo.tsx +59 -59
- package/registry/examples/streaming-text-demo.tsx +28 -0
- package/registry/examples/tabs-demo.tsx +13 -13
- package/registry/examples/tag-demo.tsx +29 -29
- package/registry/examples/task-list-demo.tsx +74 -0
- package/registry/examples/textarea-demo.tsx +79 -79
- package/registry/examples/thinking-reasoning-demo.tsx +74 -0
- package/registry/examples/thinking-state-demo.tsx +13 -0
- package/registry/examples/toast-demo.tsx +35 -35
- package/registry/examples/toggle-demo.tsx +59 -59
- package/registry/examples/tooltip-demo.tsx +115 -115
- package/registry/guidance/USAGE.md +27 -27
- package/registry/guidance/charts.LICENSE.txt +24 -0
- package/registry/hooks/use-controllable-state.ts +33 -0
- package/registry/hooks/use-direction.ts +207 -207
- package/registry/hooks/use-listbox-navigation.ts +73 -0
- package/registry/hooks/use-motion-end.ts +55 -0
- package/registry/hooks/use-reduced-motion.ts +28 -0
- package/registry/index.json +1403 -155
- package/registry/styles/globals.css +946 -1088
- package/registry.json +361 -8
- package/schema/config.schema.json +51 -51
- package/schema/registry.schema.json +194 -190
- package/schema/tokens.schema.json +167 -163
- package/src/cli/command-line.js +194 -194
- package/src/cli/config-editors.js +9 -9
- package/src/cli/doctor.js +399 -399
- package/src/cli/file-transaction.js +302 -295
- package/src/cli/global-css.js +153 -153
- package/src/cli/index.js +1002 -1009
- package/src/cli/install-plan.js +592 -592
- package/src/cli/install-receipt.js +171 -171
- package/src/cli/jsonc.js +203 -203
- package/src/cli/package-install-state.js +254 -254
- package/src/cli/package-manager.js +238 -238
- package/src/cli/package-plan.js +185 -185
- package/src/cli/package-version.js +97 -97
- package/src/cli/registry-query.js +207 -207
- package/src/cli/reporting.js +55 -55
- package/src/cli/schema-validation.js +19 -19
- package/src/cli/source-scanner.js +686 -686
- package/src/cli/vite-config.js +478 -478
- package/tokens/banhaten.tokens.json +306 -192
|
@@ -1,638 +1,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
|
-
|
|
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(--
|
|
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
|
+
|
|
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
|
+
}
|