banhaten 0.1.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/LICENSE +21 -0
- package/README.md +361 -0
- package/banhaten.config.example.json +13 -0
- package/package.json +59 -0
- package/registry/assets/activity-feed-avatar.png +0 -0
- package/registry/assets/avatars/avatar-01.jpg +0 -0
- package/registry/assets/avatars/avatar-02.jpg +0 -0
- package/registry/assets/avatars/avatar-03.jpg +0 -0
- package/registry/assets/avatars/avatar-04.jpg +0 -0
- package/registry/assets/avatars/avatar-05.jpg +0 -0
- package/registry/assets/avatars/avatar-06.jpg +0 -0
- package/registry/assets/avatars/avatar-07.jpg +0 -0
- package/registry/assets/avatars/avatar-08.jpg +0 -0
- package/registry/assets/avatars/avatar-09.jpg +0 -0
- package/registry/assets/avatars/avatar-10.jpg +0 -0
- package/registry/assets/avatars/avatar-11.jpg +0 -0
- package/registry/assets/avatars/avatar-12.jpg +0 -0
- package/registry/assets/avatars/avatar-13.jpg +0 -0
- package/registry/assets/avatars/avatar-14.jpg +0 -0
- package/registry/assets/avatars/avatar-15.jpg +0 -0
- package/registry/assets/avatars/avatar-16.jpg +0 -0
- package/registry/assets/avatars/avatar-17.jpg +0 -0
- package/registry/assets/avatars/avatar-18.jpg +0 -0
- package/registry/assets/avatars/avatar-19.jpg +0 -0
- package/registry/assets/avatars/avatar-20.jpg +0 -0
- package/registry/assets/avatars/avatar-21.jpg +0 -0
- package/registry/assets/avatars/avatar-22.jpg +0 -0
- package/registry/assets/avatars/avatar-23.jpg +0 -0
- package/registry/assets/avatars/avatar-24.jpg +0 -0
- package/registry/assets/avatars/avatar-25.jpg +0 -0
- package/registry/assets/avatars/avatar-26.jpg +0 -0
- package/registry/assets/avatars/avatar-27.jpg +0 -0
- package/registry/assets/avatars/avatar-28.jpg +0 -0
- package/registry/assets/avatars/avatar-29.jpg +0 -0
- package/registry/assets/avatars/avatar-30.jpg +0 -0
- package/registry/assets/avatars/avatar-31.jpg +0 -0
- package/registry/assets/avatars/avatar-32.jpg +0 -0
- package/registry/assets/avatars/avatar-33.jpg +0 -0
- package/registry/assets/avatars/avatar-34.jpg +0 -0
- package/registry/assets/avatars/avatar-35.jpg +0 -0
- package/registry/assets/image-assets.json +744 -0
- package/registry/assets/images/art-01.jpg +0 -0
- package/registry/assets/images/art-02.jpg +0 -0
- package/registry/assets/images/art-03.jpg +0 -0
- package/registry/assets/images/art-04.jpg +0 -0
- package/registry/assets/images/art-05.jpg +0 -0
- package/registry/assets/images/art-06.jpg +0 -0
- package/registry/assets/images/art-07.jpg +0 -0
- package/registry/assets/images/art-08.jpg +0 -0
- package/registry/assets/images/art-09.jpg +0 -0
- package/registry/assets/images/art-10.jpg +0 -0
- package/registry/assets/images/art-11.jpg +0 -0
- package/registry/assets/images/art-12.jpg +0 -0
- package/registry/assets/images/art-13.jpg +0 -0
- package/registry/assets/images/art-14.jpg +0 -0
- package/registry/assets/images/art-15.jpg +0 -0
- package/registry/assets/images/art-16.jpg +0 -0
- package/registry/assets/images/art-17.jpg +0 -0
- package/registry/assets/images/art-18.jpg +0 -0
- package/registry/assets/images/art-19.jpg +0 -0
- package/registry/assets/images/art-20.jpg +0 -0
- package/registry/assets/images/art-21.jpg +0 -0
- package/registry/assets/images/art-22.jpg +0 -0
- package/registry/assets/images/art-23.jpg +0 -0
- package/registry/assets/images/art-24.jpg +0 -0
- package/registry/assets/images/art-25.jpg +0 -0
- package/registry/assets/images/art-26.jpg +0 -0
- package/registry/assets/images/art-27.jpg +0 -0
- package/registry/assets/images/nature-01.jpg +0 -0
- package/registry/assets/images/nature-02.jpg +0 -0
- package/registry/assets/images/nature-03.jpg +0 -0
- package/registry/assets/images/nature-04.jpg +0 -0
- package/registry/assets/images/nature-05.jpg +0 -0
- package/registry/assets/images/nature-06.jpg +0 -0
- package/registry/assets/images/nature-07.jpg +0 -0
- package/registry/assets/images/nature-08.jpg +0 -0
- package/registry/assets/images/nature-09.jpg +0 -0
- package/registry/assets/images/nature-10.jpg +0 -0
- package/registry/assets/images/nature-11.jpg +0 -0
- package/registry/assets/images/nature-12.jpg +0 -0
- package/registry/assets/images/nature-13.jpg +0 -0
- package/registry/assets/images/nature-14.jpg +0 -0
- package/registry/assets/images/nature-15.jpg +0 -0
- package/registry/assets/images/nature-16.jpg +0 -0
- package/registry/assets/images/nature-17.jpg +0 -0
- package/registry/assets/images/nature-18.jpg +0 -0
- package/registry/assets/images/nature-19.jpg +0 -0
- package/registry/assets/images/nature-20.jpg +0 -0
- package/registry/components/accordion.tsx +119 -0
- package/registry/components/alert.tsx +282 -0
- package/registry/components/attribute.tsx +452 -0
- package/registry/components/avatar.tsx +142 -0
- package/registry/components/badge.tsx +567 -0
- package/registry/components/button-group.tsx +246 -0
- package/registry/components/button.tsx +102 -0
- package/registry/components/card.tsx +613 -0
- package/registry/components/checkbox.tsx +244 -0
- package/registry/components/date-picker.tsx +1143 -0
- package/registry/components/divider.tsx +82 -0
- package/registry/components/expanded/ActivityFeed.tsx +226 -0
- package/registry/components/expanded/Banner.tsx +145 -0
- package/registry/components/expanded/BannerBoard.tsx +225 -0
- package/registry/components/expanded/Breadcrumbs.tsx +156 -0
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +211 -0
- package/registry/components/expanded/CatalogDivider.tsx +48 -0
- package/registry/components/expanded/CatalogTag.tsx +92 -0
- package/registry/components/expanded/CommandBar.tsx +406 -0
- package/registry/components/expanded/FileUpload.tsx +231 -0
- package/registry/components/expanded/IconExplorer.tsx +612 -0
- package/registry/components/expanded/OnboardingStepListItem.tsx +67 -0
- package/registry/components/expanded/PageHeader.tsx +184 -0
- package/registry/components/expanded/Slideout.tsx +514 -0
- package/registry/components/expanded/Steps.tsx +266 -0
- package/registry/components/expanded/Table.tsx +1014 -0
- package/registry/components/expanded/Tabs.tsx +86 -0
- package/registry/components/expanded/Timeline.tsx +235 -0
- package/registry/components/expanded/TimelineShowcase.tsx +158 -0
- package/registry/components/expanded/activityFeed.css +292 -0
- package/registry/components/expanded/banner.css +312 -0
- package/registry/components/expanded/breadcrumbs.css +140 -0
- package/registry/components/expanded/catalogComponentsShowcase.css +87 -0
- package/registry/components/expanded/commandBar.css +473 -0
- package/registry/components/expanded/divider.css +75 -0
- package/registry/components/expanded/fileUpload.css +228 -0
- package/registry/components/expanded/iconExplorer.css +764 -0
- package/registry/components/expanded/iconPacks.ts +866 -0
- package/registry/components/expanded/onboardingStepListItem.css +126 -0
- package/registry/components/expanded/pageHeader.css +287 -0
- package/registry/components/expanded/slideout.css +955 -0
- package/registry/components/expanded/steps.css +329 -0
- package/registry/components/expanded/table.css +607 -0
- package/registry/components/expanded/tabs.css +197 -0
- package/registry/components/expanded/tag.css +148 -0
- package/registry/components/expanded/timeline.css +282 -0
- package/registry/components/input-content.ts +106 -0
- package/registry/components/input.tsx +866 -0
- package/registry/components/menu.tsx +758 -0
- package/registry/components/modal.tsx +799 -0
- package/registry/components/pagination.tsx +543 -0
- package/registry/components/progress-slider.tsx +216 -0
- package/registry/components/progress.tsx +367 -0
- package/registry/components/radio-card.tsx +654 -0
- package/registry/components/radio-group.tsx +570 -0
- package/registry/components/select-content.tsx +313 -0
- package/registry/components/select.tsx +871 -0
- package/registry/components/slider.tsx +380 -0
- package/registry/components/social-button.tsx +360 -0
- package/registry/components/spinner.tsx +31 -0
- package/registry/components/tag.tsx +423 -0
- package/registry/components/textarea.tsx +625 -0
- package/registry/components/toggle.tsx +272 -0
- package/registry/components/toolbar.tsx +467 -0
- package/registry/components/tooltip.tsx +427 -0
- package/registry/examples/accordion-demo.tsx +34 -0
- package/registry/examples/alert-demo.tsx +14 -0
- package/registry/examples/attribute-demo.tsx +65 -0
- package/registry/examples/avatar-demo.tsx +74 -0
- package/registry/examples/badge-demo.tsx +53 -0
- package/registry/examples/button-demo.tsx +83 -0
- package/registry/examples/button-group-demo.tsx +42 -0
- package/registry/examples/card-demo.tsx +48 -0
- package/registry/examples/checkbox-demo.tsx +67 -0
- package/registry/examples/date-picker-demo.tsx +74 -0
- package/registry/examples/divider-demo.tsx +17 -0
- package/registry/examples/expanded/activity-feed-demo.tsx +22 -0
- package/registry/examples/expanded/banner-demo.tsx +23 -0
- package/registry/examples/expanded/catalog-components-demo.tsx +5 -0
- package/registry/examples/expanded/command-bar-demo.tsx +10 -0
- package/registry/examples/expanded/icons-demo.tsx +5 -0
- package/registry/examples/expanded/onboarding-step-demo.tsx +11 -0
- package/registry/examples/expanded/page-header-demo.tsx +19 -0
- package/registry/examples/expanded/slideout-demo.tsx +15 -0
- package/registry/examples/expanded/steps-demo.tsx +18 -0
- package/registry/examples/expanded/tabs-demo.tsx +13 -0
- package/registry/examples/expanded/timeline-demo.tsx +18 -0
- package/registry/examples/input-demo.tsx +87 -0
- package/registry/examples/menu-demo.tsx +109 -0
- package/registry/examples/modal-demo.tsx +16 -0
- package/registry/examples/pagination-demo.tsx +17 -0
- package/registry/examples/progress-demo.tsx +37 -0
- package/registry/examples/progress-slider-demo.tsx +29 -0
- package/registry/examples/radio-card-demo.tsx +51 -0
- package/registry/examples/radio-group-demo.tsx +62 -0
- package/registry/examples/select-demo.tsx +73 -0
- package/registry/examples/slider-demo.tsx +31 -0
- package/registry/examples/social-button-demo.tsx +51 -0
- package/registry/examples/tag-demo.tsx +29 -0
- package/registry/examples/textarea-demo.tsx +79 -0
- package/registry/examples/toggle-demo.tsx +59 -0
- package/registry/examples/toolbar-demo.tsx +80 -0
- package/registry/examples/tooltip-demo.tsx +115 -0
- package/registry/hooks/use-direction.ts +27 -0
- package/registry/index.json +1213 -0
- package/registry/styles/globals.css +4600 -0
- package/registry/utils/cn.ts +6 -0
- package/src/cli/index.js +826 -0
- package/tokens/Color mode.zip +0 -0
- package/tokens/Numbers.zip +0 -0
- package/tokens/Radius.zip +0 -0
- package/tokens/Theme.zip +0 -0
- package/tokens/banhaten.tokens.json +5525 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion"
|
|
5
|
+
import { ChevronDownIcon } from "lucide-react"
|
|
6
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
7
|
+
|
|
8
|
+
import { cn } from "@/lib/utils"
|
|
9
|
+
|
|
10
|
+
const accordionVariants = cva("w-full", {
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default:
|
|
14
|
+
"[&>[data-slot=accordion-item]]:border-b-[var(--bh-space-xxxs-1)] [&>[data-slot=accordion-item]]:border-[var(--bh-border-subtle)] [&>[data-slot=accordion-item]:last-child]:border-b-0",
|
|
15
|
+
bordered:
|
|
16
|
+
"rounded-[var(--bh-radius-md-6)] border border-[var(--bh-border-subtle)] bg-[var(--bh-bg-raised)] [&>[data-slot=accordion-item]]:border-b-[var(--bh-space-xxxs-1)] [&>[data-slot=accordion-item]]:border-[var(--bh-border-subtle)] [&>[data-slot=accordion-item]:last-child]:border-b-0 [&_[data-slot=accordion-content]>div]:px-[var(--bh-space-3xl-16)] [&_[data-slot=accordion-trigger]]:px-[var(--bh-space-3xl-16)]",
|
|
17
|
+
cards:
|
|
18
|
+
"flex flex-col gap-[var(--bh-space-md-8)] [&>[data-slot=accordion-item]]:rounded-[var(--bh-radius-md-6)] [&>[data-slot=accordion-item]]:border [&>[data-slot=accordion-item]]:border-[var(--bh-border-subtle)] [&>[data-slot=accordion-item]]:bg-[var(--bh-bg-raised)] [&>[data-slot=accordion-item]]:shadow-[var(--shadow-accordion-item)] [&_[data-slot=accordion-content]>div]:px-[var(--bh-space-3xl-16)] [&_[data-slot=accordion-trigger]]:px-[var(--bh-space-3xl-16)]",
|
|
19
|
+
soft: "rounded-[var(--bh-radius-md-6)] bg-[var(--bh-bg-neutral-subtle)] p-[var(--bh-space-xs-4)] [&>[data-slot=accordion-item]]:rounded-[var(--bh-radius-xs-2)] [&_[data-slot=accordion-content]>div]:px-[var(--bh-space-xl-12)] [&_[data-slot=accordion-trigger]]:px-[var(--bh-space-xl-12)]",
|
|
20
|
+
},
|
|
21
|
+
size: {
|
|
22
|
+
sm: "[&_[data-slot=accordion-content]>div]:pb-[var(--bh-space-xl-12)] [&_[data-slot=accordion-content]]:text-[length:var(--bh-text-body-xs-regular-font-size)] [&_[data-slot=accordion-content]]:leading-[var(--bh-text-body-xs-regular-line-height)] [&_[data-slot=accordion-trigger]]:py-[var(--bh-space-xl-12)] [&_[data-slot=accordion-trigger]]:text-[length:var(--bh-text-body-xs-medium-font-size)] [&_[data-slot=accordion-trigger]]:leading-[var(--bh-text-body-xs-medium-line-height)]",
|
|
23
|
+
default: "",
|
|
24
|
+
lg: "[&_[data-slot=accordion-content]>div]:pb-[var(--bh-space-4xl-20)] [&_[data-slot=accordion-content]]:text-[length:var(--bh-text-body-md-regular-font-size)] [&_[data-slot=accordion-content]]:leading-[var(--bh-text-body-md-regular-line-height)] [&_[data-slot=accordion-trigger]]:py-[var(--bh-space-4xl-20)] [&_[data-slot=accordion-trigger]]:text-[length:var(--bh-text-body-md-medium-font-size)] [&_[data-slot=accordion-trigger]]:leading-[var(--bh-text-body-md-medium-line-height)]",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
variant: "default",
|
|
29
|
+
size: "default",
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
function Accordion({
|
|
34
|
+
className,
|
|
35
|
+
variant,
|
|
36
|
+
size,
|
|
37
|
+
...props
|
|
38
|
+
}: React.ComponentProps<typeof AccordionPrimitive.Root> &
|
|
39
|
+
VariantProps<typeof accordionVariants>) {
|
|
40
|
+
return (
|
|
41
|
+
<AccordionPrimitive.Root
|
|
42
|
+
data-slot="accordion"
|
|
43
|
+
data-size={size ?? "default"}
|
|
44
|
+
data-variant={variant ?? "default"}
|
|
45
|
+
className={cn(accordionVariants({ variant, size }), className)}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function AccordionItem({
|
|
52
|
+
className,
|
|
53
|
+
...props
|
|
54
|
+
}: React.ComponentProps<typeof AccordionPrimitive.Item>) {
|
|
55
|
+
return (
|
|
56
|
+
<AccordionPrimitive.Item
|
|
57
|
+
data-slot="accordion-item"
|
|
58
|
+
className={cn(
|
|
59
|
+
"overflow-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-[var(--bh-opacity-50)]",
|
|
60
|
+
className
|
|
61
|
+
)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function AccordionTrigger({
|
|
68
|
+
className,
|
|
69
|
+
children,
|
|
70
|
+
...props
|
|
71
|
+
}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
|
|
72
|
+
return (
|
|
73
|
+
<AccordionPrimitive.Header className="flex">
|
|
74
|
+
<AccordionPrimitive.Trigger
|
|
75
|
+
data-slot="accordion-trigger"
|
|
76
|
+
className={cn(
|
|
77
|
+
"flex flex-1 items-start justify-between gap-[var(--bh-space-3xl-16)] rounded-[var(--bh-radius-md-6)] py-[var(--bh-space-3xl-16)] text-start text-[length:var(--bh-text-body-sm-medium-font-size)] font-[var(--bh-text-body-sm-medium-font-weight)] leading-[var(--bh-text-body-sm-medium-line-height)] tracking-[var(--bh-text-body-sm-medium-letter-spacing)] text-[var(--bh-content-default)] outline-none transition-[background-color,color,box-shadow] hover:text-[var(--bh-content-default)] focus-visible:shadow-[var(--shadow-button-focus)] disabled:pointer-events-none disabled:opacity-[var(--bh-opacity-50)] data-[disabled]:pointer-events-none data-[disabled]:opacity-[var(--bh-opacity-50)] [&[data-state=open]>svg]:rotate-180 [&_svg]:size-[var(--bh-space-3xl-16)]",
|
|
78
|
+
className
|
|
79
|
+
)}
|
|
80
|
+
{...props}
|
|
81
|
+
>
|
|
82
|
+
<span dir="auto" className="min-w-0">
|
|
83
|
+
{children}
|
|
84
|
+
</span>
|
|
85
|
+
<ChevronDownIcon
|
|
86
|
+
aria-hidden="true"
|
|
87
|
+
data-slot="accordion-chevron"
|
|
88
|
+
className="pointer-events-none mt-[var(--bh-space-xxs-2)] shrink-0 text-[var(--bh-content-muted)] transition-transform duration-[var(--bh-duration-default)]"
|
|
89
|
+
/>
|
|
90
|
+
</AccordionPrimitive.Trigger>
|
|
91
|
+
</AccordionPrimitive.Header>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function AccordionContent({
|
|
96
|
+
className,
|
|
97
|
+
children,
|
|
98
|
+
...props
|
|
99
|
+
}: React.ComponentProps<typeof AccordionPrimitive.Content>) {
|
|
100
|
+
return (
|
|
101
|
+
<AccordionPrimitive.Content
|
|
102
|
+
data-slot="accordion-content"
|
|
103
|
+
className="overflow-hidden text-[length:var(--bh-text-body-sm-regular-font-size)] font-[var(--bh-text-body-sm-regular-font-weight)] leading-[var(--bh-text-body-sm-regular-line-height)] tracking-[var(--bh-text-body-sm-regular-letter-spacing)] text-[var(--bh-content-subtle)] data-[state=closed]:animate-[accordion-up_var(--bh-duration-accordion)_var(--bh-easing-out)] data-[state=open]:animate-[accordion-down_var(--bh-duration-accordion)_var(--bh-easing-out)]"
|
|
104
|
+
{...props}
|
|
105
|
+
>
|
|
106
|
+
<div dir="auto" className={cn("pt-0 pb-[var(--bh-space-3xl-16)]", className)}>
|
|
107
|
+
{children}
|
|
108
|
+
</div>
|
|
109
|
+
</AccordionPrimitive.Content>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
Accordion,
|
|
115
|
+
AccordionItem,
|
|
116
|
+
AccordionTrigger,
|
|
117
|
+
AccordionContent,
|
|
118
|
+
accordionVariants,
|
|
119
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
|
|
6
|
+
const alertVariants = cva(
|
|
7
|
+
[
|
|
8
|
+
"ds-alert relative flex min-w-0 max-w-full overflow-hidden",
|
|
9
|
+
"bg-[var(--alert-bg)] text-[var(--alert-title)] shadow-[inset_0_0_0_var(--bh-border-width-default)_var(--alert-border)]",
|
|
10
|
+
"font-[var(--bh-font-family)] tracking-[var(--bh-text-base-letter-spacing)]",
|
|
11
|
+
],
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
status: {
|
|
15
|
+
danger:
|
|
16
|
+
"[--alert-bg:var(--bh-bg-danger-subtle)] [--alert-border:var(--bh-border-danger-subtle)] [--alert-title:var(--bh-content-danger-strong)] [--alert-description:var(--bh-content-danger-default)] [--alert-icon:var(--bh-content-danger-default)]",
|
|
17
|
+
success:
|
|
18
|
+
"[--alert-bg:var(--bh-bg-success-subtle)] [--alert-border:var(--bh-border-success-subtle)] [--alert-title:var(--bh-content-success-strong)] [--alert-description:var(--bh-content-success-default)] [--alert-icon:var(--bh-content-success-default)]",
|
|
19
|
+
warning:
|
|
20
|
+
"[--alert-bg:var(--bh-bg-warning-subtle)] [--alert-border:var(--bh-border-warning-subtle)] [--alert-title:var(--bh-content-warning-strong)] [--alert-description:var(--bh-content-warning-default)] [--alert-icon:var(--bh-content-warning-default)]",
|
|
21
|
+
info:
|
|
22
|
+
"[--alert-bg:var(--bh-bg-info-subtle)] [--alert-border:var(--bh-border-info-subtle)] [--alert-title:var(--bh-content-brand-strong)] [--alert-description:var(--bh-content-brand-default)] [--alert-icon:var(--bh-content-brand-default)]",
|
|
23
|
+
neutral:
|
|
24
|
+
"[--alert-bg:var(--bh-bg-neutral-subtle)] [--alert-border:var(--bh-border-subtle)] [--alert-title:var(--bh-content-default)] [--alert-description:var(--bh-content-default)] [--alert-icon:var(--bh-content-default)]",
|
|
25
|
+
},
|
|
26
|
+
isExpandable: {
|
|
27
|
+
false:
|
|
28
|
+
"h-[var(--bh-alert-compact-height)] w-[var(--bh-alert-compact-width)] items-center gap-[var(--bh-space-xl-12)] rounded-[var(--bh-alert-compact-radius)] p-[var(--bh-alert-compact-padding)]",
|
|
29
|
+
true:
|
|
30
|
+
"h-[var(--bh-alert-expanded-height)] w-[var(--bh-alert-expanded-width)] items-start gap-[var(--bh-space-xl-12)] rounded-[var(--bh-alert-expanded-radius)] px-[var(--bh-alert-expanded-padding-x)] py-[var(--bh-alert-expanded-padding-y)]",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
status: "danger",
|
|
35
|
+
isExpandable: false,
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
type AlertStatus = "danger" | "success" | "warning" | "info" | "neutral"
|
|
41
|
+
type AlertDirection = "ltr" | "rtl"
|
|
42
|
+
|
|
43
|
+
type AlertAction = {
|
|
44
|
+
label: React.ReactNode
|
|
45
|
+
onClick?: () => void
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type AlertProps = Omit<
|
|
49
|
+
React.ComponentPropsWithoutRef<"section">,
|
|
50
|
+
"dir" | "title"
|
|
51
|
+
> &
|
|
52
|
+
Omit<VariantProps<typeof alertVariants>, "status"> & {
|
|
53
|
+
actions?: AlertAction[]
|
|
54
|
+
closeLabel?: string
|
|
55
|
+
description?: React.ReactNode
|
|
56
|
+
dir?: AlertDirection
|
|
57
|
+
onClose?: () => void
|
|
58
|
+
showActions?: boolean
|
|
59
|
+
showCloseButton?: boolean
|
|
60
|
+
status?: AlertStatus
|
|
61
|
+
title?: React.ReactNode
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const defaultActions: Record<AlertDirection, AlertAction[]> = {
|
|
65
|
+
ltr: [{ label: "Action" }, { label: "Action" }],
|
|
66
|
+
rtl: [
|
|
67
|
+
{ label: "\u0632\u0631 \u0627\u0644\u0631\u0627\u0628\u0637" },
|
|
68
|
+
{ label: "\u0632\u0631 \u0627\u0644\u0631\u0627\u0628\u0637" },
|
|
69
|
+
],
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const defaultCopy = {
|
|
73
|
+
ltr: {
|
|
74
|
+
title: "Alert title",
|
|
75
|
+
description:
|
|
76
|
+
"Lorem ipsum dolor sit amet consectetur. Libero feugiat velit risus egestas blandit eget curabitur.",
|
|
77
|
+
},
|
|
78
|
+
rtl: {
|
|
79
|
+
title:
|
|
80
|
+
"\u0623\u062f\u062e\u0644 \u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u062a\u0646\u0628\u064a\u0647 \u0627\u0644\u062e\u0627\u0635 \u0628\u0643 \u0647\u0646\u0627!",
|
|
81
|
+
description:
|
|
82
|
+
"\u0623\u062f\u062e\u0644 \u0648\u0635\u0641 \u0627\u0644\u062a\u0646\u0628\u064a\u0647 \u0647\u0646\u0627\u060c \u0633\u064a\u0628\u062f\u0648 \u0623\u0641\u0636\u0644 \u0643\u0633\u0637\u0631\u064a\u0646 \u0645\u0646 \u0627\u0644\u0646\u0635.",
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const Alert = React.forwardRef<HTMLElement, AlertProps>(function Alert(
|
|
87
|
+
{
|
|
88
|
+
actions,
|
|
89
|
+
children,
|
|
90
|
+
className,
|
|
91
|
+
closeLabel,
|
|
92
|
+
description,
|
|
93
|
+
dir = "ltr",
|
|
94
|
+
isExpandable = false,
|
|
95
|
+
onClose,
|
|
96
|
+
showActions = true,
|
|
97
|
+
showCloseButton = true,
|
|
98
|
+
status = "danger",
|
|
99
|
+
title,
|
|
100
|
+
...props
|
|
101
|
+
},
|
|
102
|
+
ref
|
|
103
|
+
) {
|
|
104
|
+
const expanded = Boolean(isExpandable)
|
|
105
|
+
const resolvedStatus = status ?? "danger"
|
|
106
|
+
const copy = defaultCopy[dir]
|
|
107
|
+
const renderedTitle = title ?? children ?? copy.title
|
|
108
|
+
const renderedDescription = description ?? copy.description
|
|
109
|
+
const actionItems = actions ?? defaultActions[dir]
|
|
110
|
+
const visibleActions = showActions ? actionItems.slice(0, expanded ? 2 : 1) : []
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<section
|
|
114
|
+
data-slot="alert"
|
|
115
|
+
data-status={resolvedStatus}
|
|
116
|
+
data-expandable={expanded ? "true" : "false"}
|
|
117
|
+
dir={dir}
|
|
118
|
+
ref={ref}
|
|
119
|
+
className={cn(
|
|
120
|
+
alertVariants({ status: resolvedStatus, isExpandable: expanded }),
|
|
121
|
+
expanded && dir === "rtl" && "h-[var(--bh-alert-expanded-rtl-height)]",
|
|
122
|
+
expanded &&
|
|
123
|
+
dir === "ltr" &&
|
|
124
|
+
resolvedStatus === "neutral" &&
|
|
125
|
+
"[--alert-border:var(--bh-border-default)]",
|
|
126
|
+
className
|
|
127
|
+
)}
|
|
128
|
+
{...props}
|
|
129
|
+
>
|
|
130
|
+
<div
|
|
131
|
+
data-slot="alert-main"
|
|
132
|
+
className={cn(
|
|
133
|
+
"flex flex-[1_0_0] min-w-0",
|
|
134
|
+
expanded
|
|
135
|
+
? "items-start gap-[var(--bh-space-xl-12)]"
|
|
136
|
+
: "items-center gap-[var(--bh-space-md-8)]"
|
|
137
|
+
)}
|
|
138
|
+
>
|
|
139
|
+
<span
|
|
140
|
+
data-slot="alert-icon"
|
|
141
|
+
className="inline-flex size-[var(--bh-alert-icon-size)] shrink-0 items-center justify-center text-[var(--alert-icon)]"
|
|
142
|
+
>
|
|
143
|
+
<AlertStatusIcon status={resolvedStatus} />
|
|
144
|
+
</span>
|
|
145
|
+
<div
|
|
146
|
+
data-slot="alert-copy"
|
|
147
|
+
className={cn(
|
|
148
|
+
"flex flex-[1_0_0] min-w-0 text-start",
|
|
149
|
+
expanded && "flex-col justify-center gap-[var(--bh-space-xl-12)]",
|
|
150
|
+
dir === "rtl" && "text-right"
|
|
151
|
+
)}
|
|
152
|
+
>
|
|
153
|
+
<div
|
|
154
|
+
data-slot="alert-info"
|
|
155
|
+
className={cn(
|
|
156
|
+
"flex w-full min-w-0 flex-[1_0_0] flex-col justify-center gap-[var(--bh-space-xs-4)]",
|
|
157
|
+
dir === "rtl" && "items-end text-right"
|
|
158
|
+
)}
|
|
159
|
+
>
|
|
160
|
+
<p
|
|
161
|
+
data-slot="alert-title"
|
|
162
|
+
dir="auto"
|
|
163
|
+
className={cn(
|
|
164
|
+
"m-0 min-w-0 w-full break-words text-[length:var(--bh-text-body-md-medium-font-size)] font-[var(--bh-font-weight-medium)] leading-[var(--bh-text-body-md-medium-line-height)] tracking-[var(--bh-text-body-md-medium-letter-spacing)] text-[var(--alert-title)]",
|
|
165
|
+
dir === "rtl" && "[direction:rtl] text-right leading-[var(--bh-text-body-sm-regular-line-height)]"
|
|
166
|
+
)}
|
|
167
|
+
>
|
|
168
|
+
{renderedTitle}
|
|
169
|
+
</p>
|
|
170
|
+
{expanded && (
|
|
171
|
+
<p
|
|
172
|
+
data-slot="alert-description"
|
|
173
|
+
dir="auto"
|
|
174
|
+
className="m-0 w-full break-words text-[length:var(--bh-text-body-sm-regular-font-size)] font-[var(--bh-font-weight-regular)] leading-[var(--bh-text-body-sm-regular-line-height)] tracking-[var(--bh-text-body-sm-regular-letter-spacing)] text-[var(--alert-description)] opacity-[var(--bh-opacity-80)]"
|
|
175
|
+
>
|
|
176
|
+
{renderedDescription}
|
|
177
|
+
</p>
|
|
178
|
+
)}
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
{expanded && visibleActions.length > 0 && (
|
|
182
|
+
<AlertActions actions={visibleActions} />
|
|
183
|
+
)}
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
{!expanded && visibleActions.length > 0 && (
|
|
188
|
+
<AlertActions actions={visibleActions} />
|
|
189
|
+
)}
|
|
190
|
+
|
|
191
|
+
{showCloseButton && (
|
|
192
|
+
<button
|
|
193
|
+
data-slot="alert-close"
|
|
194
|
+
aria-label={closeLabel}
|
|
195
|
+
className="inline-flex size-[var(--bh-alert-icon-size)] shrink-0 cursor-pointer items-center justify-center rounded-[var(--bh-radius-full)] border-0 bg-transparent p-0 text-[var(--bh-content-subtle)] outline-none focus-visible:shadow-[var(--shadow-button-focus)]"
|
|
196
|
+
onClick={onClose}
|
|
197
|
+
type="button"
|
|
198
|
+
>
|
|
199
|
+
<CloseIcon />
|
|
200
|
+
</button>
|
|
201
|
+
)}
|
|
202
|
+
</section>
|
|
203
|
+
)
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
function AlertActions({ actions }: { actions: AlertAction[] }) {
|
|
207
|
+
return (
|
|
208
|
+
<div
|
|
209
|
+
data-slot="alert-actions"
|
|
210
|
+
className="flex shrink-0 items-center gap-[var(--bh-space-3xl-16)]"
|
|
211
|
+
>
|
|
212
|
+
{actions.map((action, index) => (
|
|
213
|
+
<button
|
|
214
|
+
data-slot="alert-action"
|
|
215
|
+
className="inline-flex shrink-0 cursor-pointer items-center justify-center gap-[var(--bh-space-xxs-2)] border-0 bg-transparent p-0 text-start text-[length:var(--bh-text-body-md-underline-font-size)] font-[var(--bh-text-body-md-underline-font-weight)] leading-[var(--bh-text-body-md-underline-line-height)] tracking-[var(--bh-text-body-md-underline-letter-spacing)] text-[var(--bh-content-default)] underline outline-none [text-underline-position:from-font] focus-visible:shadow-[var(--shadow-button-focus)]"
|
|
216
|
+
key={index}
|
|
217
|
+
onClick={action.onClick}
|
|
218
|
+
type="button"
|
|
219
|
+
>
|
|
220
|
+
{action.label}
|
|
221
|
+
</button>
|
|
222
|
+
))}
|
|
223
|
+
</div>
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function AlertStatusIcon({ status }: { status: AlertStatus }) {
|
|
228
|
+
if (status === "success") {
|
|
229
|
+
return (
|
|
230
|
+
<svg aria-hidden="true" className="size-[var(--bh-alert-icon-size)] fill-current" viewBox="0 0 16.6667 16.6667">
|
|
231
|
+
<path d="M8.33333 16.6667C12.9357 16.6667 16.6667 12.9357 16.6667 8.33333C16.6667 3.73096 12.9357 0 8.33333 0C3.73096 0 0 3.73096 0 8.33333C0 12.9357 3.73096 16.6667 8.33333 16.6667ZM12.8809 6.21426L7.5 11.5952L3.99407 8.08925L5.17259 6.91075L7.5 9.23817L11.7024 5.03574L12.8809 6.21426Z" />
|
|
232
|
+
</svg>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (status === "warning") {
|
|
237
|
+
return (
|
|
238
|
+
<svg aria-hidden="true" className="size-[var(--bh-alert-icon-size)] fill-current" viewBox="0 0 17.544 15.4168">
|
|
239
|
+
<path d="M9.49356 0.416809L17.4321 14.1668C17.6623 14.5654 17.5257 15.0751 17.1271 15.3052C17.0005 15.3783 16.8567 15.4168 16.7105 15.4168H0.833333C0.3731 15.4168 0 15.0438 0 14.5835C0 14.4372 0.0385084 14.2935 0.11165 14.1668L8.05022 0.416809C8.28031 0.0182258 8.78997 -0.118333 9.18856 0.111784C9.31522 0.184926 9.42047 0.290126 9.49356 0.416809ZM7.93856 11.2502V12.9168H9.60522V11.2502H7.93856ZM7.93856 5.41681V9.5835H9.60522V5.41681H7.93856Z" />
|
|
240
|
+
</svg>
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (status === "info") {
|
|
245
|
+
return (
|
|
246
|
+
<svg aria-hidden="true" className="size-[var(--bh-alert-icon-size)] fill-current" viewBox="0 0 16.6667 16.6667">
|
|
247
|
+
<path d="M8.33333 16.6667C3.73096 16.6667 0 12.9357 0 8.33333C0 3.73096 3.73096 0 8.33333 0C12.9357 0 16.6667 3.73096 16.6667 8.33333C16.6667 12.9357 12.9357 16.6667 8.33333 16.6667ZM8.33333 6.25C9.02367 6.25 9.58333 5.69036 9.58333 5C9.58333 4.30964 9.02367 3.75 8.33333 3.75C7.643 3.75 7.08333 4.30964 7.08333 5C7.08333 5.69036 7.643 6.25 8.33333 6.25ZM10 10.8333H9.16667V7.08333H6.66667V8.75H7.5V10.8333H6.66667V12.5H10V10.8333Z" />
|
|
248
|
+
</svg>
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (status === "neutral") {
|
|
253
|
+
return (
|
|
254
|
+
<svg aria-hidden="true" className="size-[var(--bh-alert-icon-size)] fill-current" viewBox="0 0 15.851 15.0752">
|
|
255
|
+
<path d="M7.92545 12.0833L3.02726 15.0752L4.35901 9.49217L0 5.75819L5.72128 5.29952L7.92545 0L10.1297 5.29952L15.851 5.75819L11.492 9.49217L12.8237 15.0752L7.92545 12.0833Z" />
|
|
256
|
+
</svg>
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<svg aria-hidden="true" className="size-[var(--bh-alert-icon-size)] fill-current" viewBox="0 0 16.6667 16.6667">
|
|
262
|
+
<path d="M8.33333 16.6667C3.73096 16.6667 0 12.9357 0 8.33333C0 3.73096 3.73096 0 8.33333 0C12.9357 0 16.6667 3.73096 16.6667 8.33333C16.6667 12.9357 12.9357 16.6667 8.33333 16.6667ZM7.5 10.8333V12.5H9.16667V10.8333H7.5ZM7.5 4.16667V9.16667H9.16667V4.16667H7.5Z" />
|
|
263
|
+
</svg>
|
|
264
|
+
)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function CloseIcon() {
|
|
268
|
+
return (
|
|
269
|
+
<svg aria-hidden="true" className="size-[var(--bh-alert-icon-size)] fill-current" viewBox="0 0 16 16">
|
|
270
|
+
<path d="M8.00004 7.05723L11.2999 3.75739L12.2427 4.7002L8.94284 8.00003L12.2427 11.2998L11.2999 12.2427L8.00004 8.94283L4.70021 12.2427L3.75739 11.2998L7.05723 8.00003L3.75739 4.7002L4.70021 3.75739L8.00004 7.05723Z" />
|
|
271
|
+
</svg>
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export {
|
|
276
|
+
Alert,
|
|
277
|
+
alertVariants,
|
|
278
|
+
type AlertAction,
|
|
279
|
+
type AlertDirection,
|
|
280
|
+
type AlertProps,
|
|
281
|
+
type AlertStatus,
|
|
282
|
+
}
|