banhaten 0.1.2 → 0.2.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 +45 -0
- package/CONTRIBUTING.md +44 -0
- package/README.md +145 -328
- package/SECURITY.md +15 -0
- package/banhaten.config.example.json +1 -3
- package/docs/design-system/README.md +20 -0
- package/docs/design-system/adoption-quality-remediation.md +87 -0
- package/docs/design-system/agent-usage.md +13 -0
- package/docs/design-system/appearance-presets.md +189 -0
- package/docs/design-system/appearances/default.md +94 -0
- package/docs/design-system/appearances/rounded.md +95 -0
- package/docs/design-system/appearances/sharp.md +95 -0
- package/docs/design-system/component-docs-pattern.md +81 -0
- package/docs/design-system/component-showcase-consistency-report.md +217 -0
- package/docs/design-system/component-token-consistency-audit.md +173 -0
- package/docs/design-system/components/README.md +75 -0
- package/docs/design-system/components/accordion.md +67 -0
- package/docs/design-system/components/activity-feed.md +106 -0
- package/docs/design-system/components/alert-dialog.md +87 -0
- package/docs/design-system/components/alert.md +111 -0
- package/docs/design-system/components/aspect-ratio.md +59 -0
- package/docs/design-system/components/attribute.md +103 -0
- package/docs/design-system/components/autocomplete.md +93 -0
- package/docs/design-system/components/avatar.md +70 -0
- package/docs/design-system/components/badge.md +72 -0
- package/docs/design-system/components/banner.md +99 -0
- package/docs/design-system/components/breadcrumbs.md +188 -0
- package/docs/design-system/components/button-group.md +117 -0
- package/docs/design-system/components/button.md +95 -0
- package/docs/design-system/components/card.md +95 -0
- package/docs/design-system/components/carousel.md +61 -0
- package/docs/design-system/components/catalog-components.md +59 -0
- package/docs/design-system/components/chart.md +58 -0
- package/docs/design-system/components/checkbox.md +68 -0
- package/docs/design-system/components/collapsible.md +63 -0
- package/docs/design-system/components/command.md +75 -0
- package/docs/design-system/components/context-menu.md +59 -0
- package/docs/design-system/components/date-picker.md +97 -0
- package/docs/design-system/components/divider.md +117 -0
- package/docs/design-system/components/empty-state.md +72 -0
- package/docs/design-system/components/field.md +86 -0
- package/docs/design-system/components/file-upload.md +199 -0
- package/docs/design-system/components/hover-card.md +61 -0
- package/docs/design-system/components/icons.md +48 -0
- package/docs/design-system/components/input-group.md +73 -0
- package/docs/design-system/components/input-otp.md +73 -0
- package/docs/design-system/components/input.md +84 -0
- package/docs/design-system/components/item.md +72 -0
- package/docs/design-system/components/kbd.md +62 -0
- package/docs/design-system/components/label.md +64 -0
- package/docs/design-system/components/menu.md +76 -0
- package/docs/design-system/components/menubar.md +60 -0
- package/docs/design-system/components/modal.md +119 -0
- package/docs/design-system/components/native-select.md +70 -0
- package/docs/design-system/components/navigation-menu.md +63 -0
- package/docs/design-system/components/onboarding-step-list-item.md +94 -0
- package/docs/design-system/components/page-header.md +98 -0
- package/docs/design-system/components/pagination.md +71 -0
- package/docs/design-system/components/popover.md +77 -0
- package/docs/design-system/components/progress-slider.md +66 -0
- package/docs/design-system/components/progress.md +92 -0
- package/docs/design-system/components/radio-card.md +65 -0
- package/docs/design-system/components/radio-group.md +72 -0
- package/docs/design-system/components/resizable.md +57 -0
- package/docs/design-system/components/scroll-area.md +60 -0
- package/docs/design-system/components/segmented-control.md +71 -0
- package/docs/design-system/components/select.md +87 -0
- package/docs/design-system/components/sheet.md +82 -0
- package/docs/design-system/components/sidebar.md +83 -0
- package/docs/design-system/components/skeleton.md +91 -0
- package/docs/design-system/components/slideout.md +77 -0
- package/docs/design-system/components/slider.md +81 -0
- package/docs/design-system/components/social-button.md +65 -0
- package/docs/design-system/components/spinner.md +77 -0
- package/docs/design-system/components/steps.md +77 -0
- package/docs/design-system/components/table.md +411 -0
- package/docs/design-system/components/tabs.md +69 -0
- package/docs/design-system/components/tag.md +95 -0
- package/docs/design-system/components/textarea.md +64 -0
- package/docs/design-system/components/timeline.md +95 -0
- package/docs/design-system/components/toast.md +73 -0
- package/docs/design-system/components/toggle.md +96 -0
- package/docs/design-system/components/toolbar.md +105 -0
- package/docs/design-system/components/tooltip.md +107 -0
- package/docs/design-system/components/typography.md +18 -0
- package/docs/design-system/density-and-elevation.md +44 -0
- package/docs/design-system/design-system-test-missing-items.md +368 -0
- package/docs/design-system/direction-and-localization.md +23 -0
- package/docs/design-system/form-recipes.md +73 -0
- package/docs/design-system/gap-promotion-policy.md +21 -0
- package/docs/design-system/gap-promotion-report.md +166 -0
- package/docs/design-system/icons.md +69 -0
- package/docs/design-system/installation.md +68 -0
- package/docs/design-system/launch-comparison-shadcn.md +98 -0
- package/docs/design-system/registry-and-cli.md +64 -0
- package/docs/design-system/release-policy.md +30 -0
- package/docs/design-system/roadmap.md +14 -0
- package/docs/design-system/support-matrix.md +23 -0
- package/docs/design-system/tabs.md +53 -0
- package/docs/design-system/token-governance.md +60 -0
- package/package.json +97 -65
- package/registry/component-contract.json +40 -0
- package/registry/components/alert-dialog.tsx +297 -0
- package/registry/components/alert.tsx +86 -65
- package/registry/components/aspect-ratio.tsx +30 -0
- package/registry/components/autocomplete.tsx +23 -9
- package/registry/components/avatar.tsx +7 -7
- package/registry/components/badge.tsx +1 -1
- package/registry/components/button-group.tsx +321 -4
- package/registry/components/button.tsx +38 -17
- package/registry/components/card.tsx +68 -59
- package/registry/components/carousel.tsx +282 -0
- package/registry/components/chart.tsx +203 -0
- package/registry/components/checkbox.tsx +3 -3
- package/registry/components/collapsible.tsx +69 -0
- package/registry/components/command.tsx +174 -0
- package/registry/components/context-menu.tsx +236 -0
- package/registry/components/date-picker.tsx +246 -105
- package/registry/components/expanded/ActivityFeed.tsx +6 -15
- package/registry/components/expanded/Banner.tsx +3 -3
- package/registry/components/expanded/Breadcrumbs.tsx +5 -5
- package/registry/components/expanded/CatalogComponentsShowcase.tsx +13 -13
- package/registry/components/expanded/CatalogDivider.tsx +1 -1
- package/registry/components/expanded/EmptyState.tsx +1 -1
- package/registry/components/expanded/FileUpload.tsx +9 -2
- package/registry/components/expanded/OnboardingStepListItem.tsx +2 -4
- package/registry/components/expanded/PageHeader.tsx +14 -14
- package/registry/components/expanded/Slideout.tsx +15 -415
- package/registry/components/expanded/Steps.tsx +4 -4
- package/registry/components/expanded/Table.tsx +116 -69
- package/registry/components/expanded/Timeline.tsx +3 -3
- package/registry/components/expanded/activityFeed.css +1 -1
- package/registry/components/expanded/breadcrumbs.css +139 -139
- package/registry/components/expanded/catalogComponentsShowcase.css +83 -83
- package/registry/components/expanded/divider.css +1 -1
- package/registry/components/expanded/emptyState.css +1 -1
- package/registry/components/expanded/fileUpload.css +6 -6
- package/registry/components/expanded/slideout.css +9 -685
- package/registry/components/expanded/steps.css +274 -274
- package/registry/components/expanded/table.css +2 -2
- package/registry/components/expanded/timeline.css +264 -264
- package/registry/components/field.tsx +230 -0
- package/registry/components/hover-card.tsx +48 -0
- package/registry/components/input-content.ts +1 -0
- package/registry/components/input-group.tsx +130 -0
- package/registry/components/input-otp.tsx +13 -3
- package/registry/components/input.tsx +70 -45
- package/registry/components/item.tsx +189 -0
- package/registry/components/kbd.tsx +151 -0
- package/registry/components/label.tsx +78 -0
- package/registry/components/menu.tsx +34 -246
- package/registry/components/menubar.tsx +226 -0
- package/registry/components/modal.tsx +216 -143
- package/registry/components/native-select.tsx +205 -0
- package/registry/components/navigation-menu.tsx +171 -0
- package/registry/components/pagination.tsx +80 -58
- package/registry/components/popover.tsx +162 -664
- package/registry/components/radio-card.tsx +116 -87
- package/registry/components/radio-group.tsx +1 -1
- package/registry/components/resizable.tsx +74 -0
- package/registry/components/scroll-area.tsx +67 -0
- package/registry/components/segmented-control.tsx +87 -0
- package/registry/components/select-content.tsx +2 -2
- package/registry/components/select.tsx +54 -20
- package/registry/components/sheet.tsx +305 -0
- package/registry/components/sidebar.tsx +352 -0
- package/registry/components/skeleton.css +0 -3
- package/registry/components/social-button.tsx +116 -30
- package/registry/components/spinner.tsx +18 -55
- package/registry/components/{expanded/tabs.css → tabs.css} +127 -106
- package/registry/components/tabs.tsx +246 -0
- package/registry/components/tag.tsx +2 -2
- package/registry/components/textarea.tsx +4 -4
- package/registry/components/toast.tsx +136 -0
- package/registry/components/toggle.tsx +2 -2
- package/registry/components/toolbar.tsx +89 -17
- package/registry/components/tooltip.tsx +1 -1
- package/registry/examples/alert-demo.tsx +25 -5
- package/registry/examples/alert-dialog-demo.tsx +42 -0
- package/registry/examples/aspect-ratio-demo.tsx +11 -0
- package/registry/examples/attribute-demo.tsx +1 -1
- package/registry/examples/autocomplete-demo.tsx +3 -3
- package/registry/examples/avatar-demo.tsx +7 -7
- package/registry/examples/badge-demo.tsx +1 -1
- package/registry/examples/button-demo.tsx +6 -6
- package/registry/examples/button-group-demo.tsx +23 -2
- package/registry/examples/card-demo.tsx +46 -8
- package/registry/examples/carousel-demo.tsx +43 -0
- package/registry/examples/chart-demo.tsx +33 -0
- package/registry/examples/checkbox-demo.tsx +5 -5
- package/registry/examples/collapsible-demo.tsx +16 -0
- package/registry/examples/collection-filter-bar-demo.tsx +135 -0
- package/registry/examples/command-demo.tsx +42 -0
- package/registry/examples/{expanded/command-bar-demo.tsx → command-palette-demo.tsx} +5 -15
- package/registry/examples/context-menu-demo.tsx +29 -0
- package/registry/examples/control-density-contract-demo.tsx +61 -0
- package/registry/examples/date-picker-demo.tsx +12 -12
- package/registry/examples/divider-demo.tsx +3 -3
- package/registry/examples/expanded/banner-demo.tsx +1 -1
- package/registry/examples/expanded/breadcrumbs-demo.tsx +1 -1
- package/registry/examples/expanded/empty-state-demo.tsx +1 -1
- package/registry/examples/expanded/file-upload-demo.tsx +1 -1
- package/registry/examples/expanded/onboarding-step-demo.tsx +1 -1
- package/registry/examples/expanded/slideout-demo.tsx +2 -2
- package/registry/examples/expanded/steps-demo.tsx +1 -1
- package/registry/examples/expanded/tabs-demo.tsx +2 -2
- package/registry/examples/expanded/timeline-demo.tsx +1 -1
- package/registry/examples/field-demo.tsx +51 -0
- package/registry/examples/hover-card-demo.tsx +23 -0
- package/registry/examples/input-demo.tsx +6 -6
- package/registry/examples/input-group-demo.tsx +16 -0
- package/registry/examples/input-otp-demo.tsx +4 -4
- package/registry/examples/item-demo.tsx +46 -0
- package/registry/examples/kbd-demo.tsx +11 -0
- package/registry/examples/label-demo.tsx +20 -0
- package/registry/examples/menu-demo.tsx +1 -1
- package/registry/examples/menubar-demo.tsx +34 -0
- package/registry/examples/modal-demo.tsx +67 -9
- package/registry/examples/native-select-demo.tsx +16 -0
- package/registry/examples/navigation-menu-demo.tsx +29 -0
- package/registry/examples/pagination-demo.tsx +6 -3
- package/registry/examples/popover-demo.tsx +19 -19
- package/registry/examples/progress-demo.tsx +1 -1
- package/registry/examples/progress-slider-demo.tsx +1 -1
- package/registry/examples/radio-card-demo.tsx +4 -4
- package/registry/examples/radio-group-demo.tsx +2 -2
- package/registry/examples/resizable-demo.tsx +22 -0
- package/registry/examples/results-toolbar-demo.tsx +44 -0
- package/registry/examples/scroll-area-demo.tsx +15 -0
- package/registry/examples/segmented-control-demo.tsx +39 -0
- package/registry/examples/select-demo.tsx +1 -1
- package/registry/examples/sheet-demo.tsx +47 -0
- package/registry/examples/sidebar-demo.tsx +55 -0
- package/registry/examples/slider-demo.tsx +3 -3
- package/registry/examples/social-button-demo.tsx +18 -8
- package/registry/examples/spinner-demo.tsx +13 -13
- package/registry/examples/tabs-demo.tsx +13 -0
- package/registry/examples/tag-demo.tsx +1 -1
- package/registry/examples/textarea-demo.tsx +4 -4
- package/registry/examples/toast-demo.tsx +35 -0
- package/registry/examples/toggle-demo.tsx +6 -6
- package/registry/examples/tooltip-demo.tsx +4 -4
- package/registry/guidance/USAGE.md +27 -0
- package/registry/hooks/use-direction.ts +193 -13
- package/registry/index.json +6010 -432
- package/registry/styles/globals.css +3112 -4690
- package/registry.json +1582 -0
- package/schema/config.schema.json +51 -0
- package/schema/registry.schema.json +190 -0
- package/schema/tokens.schema.json +163 -0
- package/src/cli/command-line.js +194 -0
- package/src/cli/config-editors.js +9 -0
- package/src/cli/doctor.js +399 -0
- package/src/cli/file-transaction.js +295 -0
- package/src/cli/global-css.js +153 -0
- package/src/cli/index.js +639 -1391
- package/src/cli/install-plan.js +592 -0
- package/src/cli/install-receipt.js +171 -0
- package/src/cli/jsonc.js +203 -0
- package/src/cli/package-install-state.js +254 -0
- package/src/cli/package-manager.js +238 -0
- package/src/cli/package-plan.js +185 -0
- package/src/cli/package-version.js +97 -0
- package/src/cli/registry-query.js +207 -0
- package/src/cli/reporting.js +55 -0
- package/src/cli/schema-validation.js +19 -0
- package/src/cli/source-scanner.js +686 -0
- package/src/cli/vite-config.js +478 -0
- package/tokens/banhaten.tokens.json +4313 -310
- 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 +0 -744
- 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/expanded/BannerBoard.tsx +0 -225
- package/registry/components/expanded/CatalogTag.tsx +0 -85
- package/registry/components/expanded/CommandBar.tsx +0 -386
- package/registry/components/expanded/IconExplorer.tsx +0 -612
- package/registry/components/expanded/Tabs.tsx +0 -86
- package/registry/components/expanded/TimelineShowcase.tsx +0 -158
- package/registry/components/expanded/commandBar.css +0 -470
- package/registry/components/expanded/iconExplorer.css +0 -764
- package/registry/components/expanded/iconPacks.ts +0 -866
- package/registry/components/expanded/tag.css +0 -148
- package/registry/examples/expanded/icons-demo.tsx +0 -5
- 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
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
5
|
+
import { PanelLeftIcon } from "lucide-react"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
|
|
9
|
+
type SidebarContextValue = {
|
|
10
|
+
collapsed: boolean
|
|
11
|
+
dir?: "ltr" | "rtl"
|
|
12
|
+
setCollapsed: (collapsed: boolean) => void
|
|
13
|
+
toggle: () => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type SidebarProviderProps = React.ComponentProps<"div"> & {
|
|
17
|
+
collapsed?: boolean
|
|
18
|
+
defaultCollapsed?: boolean
|
|
19
|
+
dir?: "ltr" | "rtl"
|
|
20
|
+
onCollapsedChange?: (collapsed: boolean) => void
|
|
21
|
+
}
|
|
22
|
+
type SidebarProps = React.ComponentProps<"aside"> & {
|
|
23
|
+
side?: "start" | "end"
|
|
24
|
+
}
|
|
25
|
+
type SidebarSectionProps = React.ComponentProps<"div">
|
|
26
|
+
type SidebarGroupLabelProps = React.ComponentProps<"div">
|
|
27
|
+
type SidebarMenuProps = React.ComponentProps<"ul">
|
|
28
|
+
type SidebarMenuItemProps = React.ComponentProps<"li">
|
|
29
|
+
type SidebarMenuButtonProps = React.ComponentProps<"button"> & {
|
|
30
|
+
active?: boolean
|
|
31
|
+
asChild?: boolean
|
|
32
|
+
icon?: React.ReactNode
|
|
33
|
+
}
|
|
34
|
+
type SidebarToggleProps = React.ComponentProps<"button">
|
|
35
|
+
type SidebarTriggerProps = SidebarToggleProps
|
|
36
|
+
type SidebarRailProps = React.ComponentProps<"button">
|
|
37
|
+
type SidebarInsetProps = React.ComponentProps<"main">
|
|
38
|
+
|
|
39
|
+
const SidebarContext = React.createContext<SidebarContextValue | null>(null)
|
|
40
|
+
|
|
41
|
+
function SidebarProvider({
|
|
42
|
+
children,
|
|
43
|
+
className,
|
|
44
|
+
collapsed,
|
|
45
|
+
defaultCollapsed = false,
|
|
46
|
+
dir,
|
|
47
|
+
onCollapsedChange,
|
|
48
|
+
...props
|
|
49
|
+
}: SidebarProviderProps) {
|
|
50
|
+
const [uncontrolledCollapsed, setUncontrolledCollapsed] =
|
|
51
|
+
React.useState(defaultCollapsed)
|
|
52
|
+
const isControlled = collapsed !== undefined
|
|
53
|
+
const resolvedCollapsed = collapsed ?? uncontrolledCollapsed
|
|
54
|
+
|
|
55
|
+
const setCollapsed = React.useCallback(
|
|
56
|
+
(nextCollapsed: boolean) => {
|
|
57
|
+
if (!isControlled) {
|
|
58
|
+
setUncontrolledCollapsed(nextCollapsed)
|
|
59
|
+
}
|
|
60
|
+
onCollapsedChange?.(nextCollapsed)
|
|
61
|
+
},
|
|
62
|
+
[isControlled, onCollapsedChange]
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
const context = React.useMemo<SidebarContextValue>(
|
|
66
|
+
() => ({
|
|
67
|
+
collapsed: resolvedCollapsed,
|
|
68
|
+
dir,
|
|
69
|
+
setCollapsed,
|
|
70
|
+
toggle: () => setCollapsed(!resolvedCollapsed),
|
|
71
|
+
}),
|
|
72
|
+
[dir, resolvedCollapsed, setCollapsed]
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<SidebarContext.Provider value={context}>
|
|
77
|
+
<div
|
|
78
|
+
data-collapsed={resolvedCollapsed ? "true" : undefined}
|
|
79
|
+
data-slot="sidebar-provider"
|
|
80
|
+
dir={dir}
|
|
81
|
+
className={cn("min-w-0", className)}
|
|
82
|
+
{...props}
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</div>
|
|
86
|
+
</SidebarContext.Provider>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const Sidebar = React.forwardRef<HTMLElement, SidebarProps>(function Sidebar(
|
|
91
|
+
{ className, side = "start", ...props },
|
|
92
|
+
ref
|
|
93
|
+
) {
|
|
94
|
+
const { collapsed, dir } = useSidebarContext()
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<aside
|
|
98
|
+
data-collapsed={collapsed ? "true" : undefined}
|
|
99
|
+
data-side={side}
|
|
100
|
+
data-slot="sidebar"
|
|
101
|
+
dir={dir}
|
|
102
|
+
ref={ref}
|
|
103
|
+
className={cn(
|
|
104
|
+
"group/sidebar flex h-full min-h-[var(--bh-space-19xl-384)] w-[var(--bh-sidebar-width)] max-w-full shrink-0 flex-col overflow-hidden bg-[var(--bh-sidebar-bg)] text-[var(--bh-content-default)] shadow-[var(--shadow-sidebar)] transition-[width,background-color]",
|
|
105
|
+
"data-[collapsed=true]:w-[var(--bh-sidebar-width-collapsed)] data-[collapsed=true]:bg-[var(--bh-sidebar-bg-collapsed)]",
|
|
106
|
+
side === "end" && "ms-auto",
|
|
107
|
+
className
|
|
108
|
+
)}
|
|
109
|
+
{...props}
|
|
110
|
+
/>
|
|
111
|
+
)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
function SidebarHeader({ className, ...props }: SidebarSectionProps) {
|
|
115
|
+
return (
|
|
116
|
+
<div
|
|
117
|
+
data-slot="sidebar-header"
|
|
118
|
+
className={cn(
|
|
119
|
+
"flex min-h-[var(--bh-sidebar-item-height)] shrink-0 items-center gap-[var(--bh-sidebar-item-gap)] px-[var(--bh-sidebar-padding)] py-[var(--bh-space-xl-12)]",
|
|
120
|
+
className
|
|
121
|
+
)}
|
|
122
|
+
{...props}
|
|
123
|
+
/>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function SidebarBody({ className, ...props }: SidebarSectionProps) {
|
|
128
|
+
return (
|
|
129
|
+
<div
|
|
130
|
+
data-slot="sidebar-body"
|
|
131
|
+
className={cn(
|
|
132
|
+
"min-h-0 flex-1 overflow-auto px-[var(--bh-sidebar-padding)] py-[var(--bh-space-xl-12)]",
|
|
133
|
+
className
|
|
134
|
+
)}
|
|
135
|
+
{...props}
|
|
136
|
+
/>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function SidebarFooter({ className, ...props }: SidebarSectionProps) {
|
|
141
|
+
return (
|
|
142
|
+
<div
|
|
143
|
+
data-slot="sidebar-footer"
|
|
144
|
+
className={cn(
|
|
145
|
+
"shrink-0 border-t border-[var(--bh-sidebar-border)] px-[var(--bh-sidebar-padding)] py-[var(--bh-space-xl-12)]",
|
|
146
|
+
className
|
|
147
|
+
)}
|
|
148
|
+
{...props}
|
|
149
|
+
/>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function SidebarGroup({ className, ...props }: SidebarSectionProps) {
|
|
154
|
+
return (
|
|
155
|
+
<div
|
|
156
|
+
data-slot="sidebar-group"
|
|
157
|
+
className={cn("grid gap-[var(--bh-space-md-8)]", className)}
|
|
158
|
+
{...props}
|
|
159
|
+
/>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function SidebarGroupLabel({ className, ...props }: SidebarGroupLabelProps) {
|
|
164
|
+
const { collapsed } = useSidebarContext()
|
|
165
|
+
|
|
166
|
+
if (collapsed) return null
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div
|
|
170
|
+
data-slot="sidebar-group-label"
|
|
171
|
+
dir="auto"
|
|
172
|
+
className={cn(
|
|
173
|
+
"px-[var(--bh-sidebar-item-padding-x)] text-[length:var(--bh-text-body-xs-medium-font-size)] font-[var(--bh-text-body-xs-medium-font-weight)] uppercase leading-[var(--bh-text-body-xs-medium-line-height)] tracking-[var(--bh-text-body-xs-medium-letter-spacing)] text-[var(--bh-content-muted)]",
|
|
174
|
+
className
|
|
175
|
+
)}
|
|
176
|
+
{...props}
|
|
177
|
+
/>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function SidebarMenu({ className, ...props }: SidebarMenuProps) {
|
|
182
|
+
return (
|
|
183
|
+
<ul
|
|
184
|
+
data-slot="sidebar-menu"
|
|
185
|
+
className={cn("m-0 grid list-none gap-[var(--bh-space-xs-4)] p-0", className)}
|
|
186
|
+
{...props}
|
|
187
|
+
/>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function SidebarMenuItem({ className, ...props }: SidebarMenuItemProps) {
|
|
192
|
+
return (
|
|
193
|
+
<li
|
|
194
|
+
data-slot="sidebar-menu-item"
|
|
195
|
+
className={cn("min-w-0", className)}
|
|
196
|
+
{...props}
|
|
197
|
+
/>
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const SidebarMenuButton = React.forwardRef<
|
|
202
|
+
HTMLButtonElement,
|
|
203
|
+
SidebarMenuButtonProps
|
|
204
|
+
>(function SidebarMenuButton(
|
|
205
|
+
{ active = false, asChild = false, children, className, icon, ...props },
|
|
206
|
+
ref
|
|
207
|
+
) {
|
|
208
|
+
const { collapsed } = useSidebarContext()
|
|
209
|
+
const Comp = asChild ? Slot : "button"
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<Comp
|
|
213
|
+
aria-current={active ? "page" : undefined}
|
|
214
|
+
data-active={active ? "true" : undefined}
|
|
215
|
+
data-slot="sidebar-menu-button"
|
|
216
|
+
ref={ref}
|
|
217
|
+
className={cn(
|
|
218
|
+
"flex h-[var(--bh-sidebar-item-height)] w-full min-w-0 items-center gap-[var(--bh-sidebar-item-gap)] rounded-[var(--bh-radius-lg-8)] px-[var(--bh-sidebar-item-padding-x)] 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-sidebar-item-content)] outline-none transition-[background-color,box-shadow,color]",
|
|
219
|
+
"hover:bg-[var(--bh-sidebar-item-bg-hover)] focus-visible:shadow-[var(--shadow-button-focus)] data-[active=true]:bg-[var(--bh-sidebar-item-bg-active)] data-[active=true]:text-[var(--bh-sidebar-item-content-active)]",
|
|
220
|
+
collapsed && "justify-center px-[var(--bh-space-md-8)]",
|
|
221
|
+
className
|
|
222
|
+
)}
|
|
223
|
+
{...props}
|
|
224
|
+
>
|
|
225
|
+
{icon ? (
|
|
226
|
+
<span
|
|
227
|
+
aria-hidden="true"
|
|
228
|
+
data-slot="sidebar-menu-icon"
|
|
229
|
+
className="inline-flex size-[var(--bh-sidebar-icon-size)] shrink-0 items-center justify-center"
|
|
230
|
+
>
|
|
231
|
+
{icon}
|
|
232
|
+
</span>
|
|
233
|
+
) : null}
|
|
234
|
+
{collapsed ? null : (
|
|
235
|
+
<span data-slot="sidebar-menu-label" dir="auto" className="min-w-0 flex-1 truncate">
|
|
236
|
+
{children}
|
|
237
|
+
</span>
|
|
238
|
+
)}
|
|
239
|
+
</Comp>
|
|
240
|
+
)
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
const SidebarToggle = React.forwardRef<HTMLButtonElement, SidebarToggleProps>(
|
|
244
|
+
function SidebarToggle({ children, className, onClick, type = "button", ...props }, ref) {
|
|
245
|
+
const { collapsed, toggle } = useSidebarContext()
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<button
|
|
249
|
+
aria-label={collapsed ? "Expand sidebar" : "Collapse sidebar"}
|
|
250
|
+
aria-pressed={collapsed}
|
|
251
|
+
data-slot="sidebar-toggle"
|
|
252
|
+
ref={ref}
|
|
253
|
+
type={type}
|
|
254
|
+
className={cn(
|
|
255
|
+
"inline-flex size-[var(--bh-sidebar-item-height)] items-center justify-center rounded-[var(--bh-radius-lg-8)] text-[var(--bh-content-subtle)] outline-none transition-[background-color,box-shadow,color] hover:bg-[var(--bh-interactive-ghost-hover)] focus-visible:shadow-[var(--shadow-button-focus)]",
|
|
256
|
+
className
|
|
257
|
+
)}
|
|
258
|
+
onClick={(event) => {
|
|
259
|
+
onClick?.(event)
|
|
260
|
+
if (!event.defaultPrevented) toggle()
|
|
261
|
+
}}
|
|
262
|
+
{...props}
|
|
263
|
+
>
|
|
264
|
+
{children ?? (
|
|
265
|
+
<PanelLeftIcon
|
|
266
|
+
aria-hidden="true"
|
|
267
|
+
className="size-[var(--bh-space-5xl-24)] rtl:-scale-x-100"
|
|
268
|
+
strokeWidth="var(--bh-icon-stroke-200)"
|
|
269
|
+
/>
|
|
270
|
+
)}
|
|
271
|
+
</button>
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
const SidebarTrigger = SidebarToggle
|
|
277
|
+
|
|
278
|
+
const SidebarRail = React.forwardRef<HTMLButtonElement, SidebarRailProps>(
|
|
279
|
+
function SidebarRail({ className, onClick, type = "button", ...props }, ref) {
|
|
280
|
+
const { toggle } = useSidebarContext()
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<button
|
|
284
|
+
aria-label="Toggle sidebar"
|
|
285
|
+
data-slot="sidebar-rail"
|
|
286
|
+
ref={ref}
|
|
287
|
+
type={type}
|
|
288
|
+
className={cn(
|
|
289
|
+
"absolute inset-y-0 end-[calc(var(--bh-sidebar-rail-width)*-1)] hidden w-[var(--bh-sidebar-rail-width)] cursor-ew-resize bg-transparent outline-none lg:block",
|
|
290
|
+
className
|
|
291
|
+
)}
|
|
292
|
+
onClick={(event) => {
|
|
293
|
+
onClick?.(event)
|
|
294
|
+
if (!event.defaultPrevented) toggle()
|
|
295
|
+
}}
|
|
296
|
+
{...props}
|
|
297
|
+
/>
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
const SidebarInset = React.forwardRef<HTMLElement, SidebarInsetProps>(
|
|
303
|
+
function SidebarInset({ className, ...props }, ref) {
|
|
304
|
+
return (
|
|
305
|
+
<main
|
|
306
|
+
data-slot="sidebar-inset"
|
|
307
|
+
ref={ref}
|
|
308
|
+
className={cn("min-w-0 flex-1", className)}
|
|
309
|
+
{...props}
|
|
310
|
+
/>
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
function useSidebarContext() {
|
|
316
|
+
const context = React.useContext(SidebarContext)
|
|
317
|
+
if (!context) {
|
|
318
|
+
throw new Error("Sidebar components must be used within SidebarProvider")
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return context
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export {
|
|
325
|
+
Sidebar,
|
|
326
|
+
SidebarBody,
|
|
327
|
+
SidebarFooter,
|
|
328
|
+
SidebarGroup,
|
|
329
|
+
SidebarGroupLabel,
|
|
330
|
+
SidebarHeader,
|
|
331
|
+
SidebarInset,
|
|
332
|
+
SidebarMenu,
|
|
333
|
+
SidebarMenuButton,
|
|
334
|
+
SidebarMenuItem,
|
|
335
|
+
SidebarProvider,
|
|
336
|
+
SidebarRail,
|
|
337
|
+
SidebarTrigger,
|
|
338
|
+
SidebarToggle,
|
|
339
|
+
}
|
|
340
|
+
export type {
|
|
341
|
+
SidebarGroupLabelProps,
|
|
342
|
+
SidebarInsetProps,
|
|
343
|
+
SidebarMenuButtonProps,
|
|
344
|
+
SidebarMenuItemProps,
|
|
345
|
+
SidebarMenuProps,
|
|
346
|
+
SidebarProps,
|
|
347
|
+
SidebarProviderProps,
|
|
348
|
+
SidebarRailProps,
|
|
349
|
+
SidebarTriggerProps,
|
|
350
|
+
SidebarSectionProps,
|
|
351
|
+
SidebarToggleProps,
|
|
352
|
+
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
[data-slot="skeleton"] {
|
|
2
2
|
--bh-skeleton-bg: var(--bh-bg-muted);
|
|
3
3
|
--bh-skeleton-highlight: var(--bh-bg-raised-subtle);
|
|
4
|
-
--bh-skeleton-duration: 1.4s;
|
|
5
4
|
--bh-skeleton-radius: var(--bh-radius-md-6);
|
|
6
|
-
--bh-skeleton-shimmer-width: 62%;
|
|
7
|
-
--bh-skeleton-width: 100%;
|
|
8
5
|
--bh-skeleton-height: var(--bh-space-4xl-20);
|
|
9
6
|
}
|
|
10
7
|
|
|
@@ -3,15 +3,11 @@ import { Slot } from "@radix-ui/react-slot"
|
|
|
3
3
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
4
|
import {
|
|
5
5
|
AppleIcon,
|
|
6
|
-
ChromeIcon,
|
|
7
|
-
FacebookIcon,
|
|
8
|
-
LinkedinIcon,
|
|
9
6
|
MessageCircleIcon,
|
|
10
|
-
TwitterIcon,
|
|
11
|
-
type LucideIcon,
|
|
12
7
|
} from "lucide-react"
|
|
13
8
|
|
|
14
9
|
import { cn } from "@/lib/utils"
|
|
10
|
+
import { useResolvedDirection } from "@/hooks/use-direction"
|
|
15
11
|
|
|
16
12
|
type SocialPlatform =
|
|
17
13
|
| "apple"
|
|
@@ -23,10 +19,15 @@ type SocialPlatform =
|
|
|
23
19
|
|
|
24
20
|
type SocialButtonVariant = "solid" | "outline"
|
|
25
21
|
type SocialButtonSize = "default" | "icon"
|
|
22
|
+
type SocialButtonMessages = Record<SocialPlatform, string>
|
|
23
|
+
type SocialButtonIconComponent = React.ComponentType<
|
|
24
|
+
React.SVGProps<SVGSVGElement> & {
|
|
25
|
+
strokeWidth?: number | string
|
|
26
|
+
}
|
|
27
|
+
>
|
|
26
28
|
|
|
27
29
|
type SocialPlatformConfig = {
|
|
28
30
|
label: string
|
|
29
|
-
labelAr: string
|
|
30
31
|
solidBg: string
|
|
31
32
|
solidHover: string
|
|
32
33
|
solidBorder: string
|
|
@@ -43,7 +44,6 @@ type SocialPlatformConfig = {
|
|
|
43
44
|
const socialPlatformConfig: Record<SocialPlatform, SocialPlatformConfig> = {
|
|
44
45
|
apple: {
|
|
45
46
|
label: "Sign in with Apple",
|
|
46
|
-
labelAr: "تسجيل الدخول بأبل",
|
|
47
47
|
solidBg: "var(--bh-social-apple-bg)",
|
|
48
48
|
solidHover: "var(--bh-social-apple-hover)",
|
|
49
49
|
solidBorder: "var(--bh-social-apple-border)",
|
|
@@ -55,7 +55,6 @@ const socialPlatformConfig: Record<SocialPlatform, SocialPlatformConfig> = {
|
|
|
55
55
|
},
|
|
56
56
|
facebook: {
|
|
57
57
|
label: "Sign in with Facebook",
|
|
58
|
-
labelAr: "تسجيل الدخول بفيسبوك",
|
|
59
58
|
solidBg: "var(--bh-social-facebook-bg)",
|
|
60
59
|
solidHover: "var(--bh-social-facebook-hover)",
|
|
61
60
|
solidBorder: "transparent",
|
|
@@ -66,7 +65,6 @@ const socialPlatformConfig: Record<SocialPlatform, SocialPlatformConfig> = {
|
|
|
66
65
|
},
|
|
67
66
|
google: {
|
|
68
67
|
label: "Sign in with Google",
|
|
69
|
-
labelAr: "تسجيل الدخول بجوجل",
|
|
70
68
|
solidBg: "var(--bh-social-google-bg)",
|
|
71
69
|
solidHover: "var(--bh-social-google-hover)",
|
|
72
70
|
solidBorder: "var(--bh-social-google-border)",
|
|
@@ -77,7 +75,6 @@ const socialPlatformConfig: Record<SocialPlatform, SocialPlatformConfig> = {
|
|
|
77
75
|
},
|
|
78
76
|
linkedin: {
|
|
79
77
|
label: "Sign in with LinkedIn",
|
|
80
|
-
labelAr: "تسجيل الدخول باستخدام لينكد إن",
|
|
81
78
|
solidBg: "var(--bh-social-linkedin-bg)",
|
|
82
79
|
solidHover: "var(--bh-social-linkedin-hover)",
|
|
83
80
|
solidBorder: "transparent",
|
|
@@ -88,7 +85,6 @@ const socialPlatformConfig: Record<SocialPlatform, SocialPlatformConfig> = {
|
|
|
88
85
|
},
|
|
89
86
|
twitter: {
|
|
90
87
|
label: "Sign in with Twitter",
|
|
91
|
-
labelAr: "تسجيل الدخول باستخدام تويتر",
|
|
92
88
|
solidBg: "var(--bh-social-twitter-bg)",
|
|
93
89
|
solidHover: "var(--bh-social-twitter-hover)",
|
|
94
90
|
solidBorder: "var(--bh-social-twitter-border)",
|
|
@@ -100,7 +96,6 @@ const socialPlatformConfig: Record<SocialPlatform, SocialPlatformConfig> = {
|
|
|
100
96
|
},
|
|
101
97
|
whatsapp: {
|
|
102
98
|
label: "Sign in with WhatsApp",
|
|
103
|
-
labelAr: "تسجيل الدخول باستخدام واتساب",
|
|
104
99
|
solidBg: "var(--bh-social-whatsapp-bg)",
|
|
105
100
|
solidHover: "var(--bh-social-whatsapp-hover)",
|
|
106
101
|
solidBorder: "transparent",
|
|
@@ -111,6 +106,15 @@ const socialPlatformConfig: Record<SocialPlatform, SocialPlatformConfig> = {
|
|
|
111
106
|
},
|
|
112
107
|
}
|
|
113
108
|
|
|
109
|
+
const arabicSocialButtonMessages: SocialButtonMessages = {
|
|
110
|
+
apple: "تسجيل الدخول بأبل",
|
|
111
|
+
facebook: "تسجيل الدخول بفيسبوك",
|
|
112
|
+
google: "تسجيل الدخول بجوجل",
|
|
113
|
+
linkedin: "تسجيل الدخول باستخدام لينكد إن",
|
|
114
|
+
twitter: "تسجيل الدخول باستخدام تويتر",
|
|
115
|
+
whatsapp: "تسجيل الدخول باستخدام واتساب",
|
|
116
|
+
}
|
|
117
|
+
|
|
114
118
|
const socialButtonVariants = cva(
|
|
115
119
|
"group/social-button relative inline-flex items-center justify-center whitespace-nowrap rounded-[var(--bh-social-button-radius)] bg-[var(--bh-social-button-bg)] text-[var(--bh-social-button-fg)] shadow-[var(--shadow-social-button)] outline-none transition-[background-color,box-shadow,color] [--bh-social-button-current-border:var(--bh-social-button-border)] [--shadow-social-button:inset_0px_0px_0px_var(--bh-border-width-default)_var(--bh-social-button-current-border,var(--bh-social-button-border,transparent)),var(--shadow-component-default)] rtl:[--bh-social-button-width:var(--bh-social-button-width-rtl)] hover:bg-[var(--bh-social-button-bg-hover)] focus-visible:[--bh-social-button-current-border:var(--bh-social-button-focus-border)] focus-visible:shadow-[var(--shadow-social-button-focus)] disabled:pointer-events-none disabled:opacity-[var(--bh-opacity-50)] [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
116
120
|
{
|
|
@@ -138,6 +142,7 @@ type SocialButtonProps = Omit<React.ComponentProps<"button">, "children"> &
|
|
|
138
142
|
asChild?: boolean
|
|
139
143
|
children?: React.ReactNode
|
|
140
144
|
label?: string
|
|
145
|
+
messages?: Partial<SocialButtonMessages>
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
const SocialButton = React.forwardRef<HTMLButtonElement, SocialButtonProps>(function SocialButton({
|
|
@@ -146,6 +151,7 @@ const SocialButton = React.forwardRef<HTMLButtonElement, SocialButtonProps>(func
|
|
|
146
151
|
variant = "solid",
|
|
147
152
|
size = "default",
|
|
148
153
|
label,
|
|
154
|
+
messages,
|
|
149
155
|
asChild = false,
|
|
150
156
|
children,
|
|
151
157
|
dir,
|
|
@@ -154,12 +160,25 @@ const SocialButton = React.forwardRef<HTMLButtonElement, SocialButtonProps>(func
|
|
|
154
160
|
"aria-label": ariaLabel,
|
|
155
161
|
...props
|
|
156
162
|
}, ref) {
|
|
163
|
+
const rootRef = React.useRef<HTMLButtonElement | null>(null)
|
|
164
|
+
const resolvedDirection = useResolvedDirection(
|
|
165
|
+
dir === "ltr" || dir === "rtl" ? dir : undefined,
|
|
166
|
+
rootRef
|
|
167
|
+
)
|
|
168
|
+
const setRootRef = React.useCallback(
|
|
169
|
+
(node: HTMLButtonElement | null) => {
|
|
170
|
+
rootRef.current = node
|
|
171
|
+
if (typeof ref === "function") ref(node)
|
|
172
|
+
else if (ref) ref.current = node
|
|
173
|
+
},
|
|
174
|
+
[ref]
|
|
175
|
+
)
|
|
157
176
|
const config = socialPlatformConfig[platform]
|
|
158
177
|
const selectedVariant = variant || "solid"
|
|
159
178
|
const selectedSize = size || "default"
|
|
160
179
|
const isIcon = selectedSize === "icon"
|
|
161
|
-
const defaultLabel =
|
|
162
|
-
const visibleLabel = label
|
|
180
|
+
const defaultLabel = messages?.[platform] ?? config.label
|
|
181
|
+
const visibleLabel = label ?? (isSimpleLabel(children) ? children : defaultLabel)
|
|
163
182
|
const accessibleLabel =
|
|
164
183
|
typeof visibleLabel === "string" || typeof visibleLabel === "number"
|
|
165
184
|
? String(visibleLabel)
|
|
@@ -192,8 +211,8 @@ const SocialButton = React.forwardRef<HTMLButtonElement, SocialButtonProps>(func
|
|
|
192
211
|
data-size={selectedSize}
|
|
193
212
|
data-slot="social-button"
|
|
194
213
|
data-variant={selectedVariant}
|
|
195
|
-
dir={
|
|
196
|
-
ref={
|
|
214
|
+
dir={resolvedDirection}
|
|
215
|
+
ref={setRootRef}
|
|
197
216
|
className={cn(
|
|
198
217
|
socialButtonVariants({
|
|
199
218
|
variant: selectedVariant,
|
|
@@ -216,13 +235,6 @@ function isSimpleLabel(
|
|
|
216
235
|
return typeof value === "string" || typeof value === "number"
|
|
217
236
|
}
|
|
218
237
|
|
|
219
|
-
function getDefaultLabel(
|
|
220
|
-
config: SocialPlatformConfig,
|
|
221
|
-
dir: React.HTMLAttributes<HTMLElement>["dir"]
|
|
222
|
-
) {
|
|
223
|
-
return dir === "rtl" ? config.labelAr : config.label
|
|
224
|
-
}
|
|
225
|
-
|
|
226
238
|
function getSocialButtonVars(
|
|
227
239
|
config: SocialPlatformConfig,
|
|
228
240
|
variant: SocialButtonVariant,
|
|
@@ -270,23 +282,97 @@ function SocialButtonIcon({
|
|
|
270
282
|
className="size-[var(--bh-social-button-icon-size)]"
|
|
271
283
|
data-slot="social-button-icon"
|
|
272
284
|
focusable="false"
|
|
273
|
-
strokeWidth={
|
|
285
|
+
strokeWidth={
|
|
286
|
+
platform === "apple"
|
|
287
|
+
? "var(--bh-icon-stroke-200)"
|
|
288
|
+
: "var(--bh-icon-stroke-225)"
|
|
289
|
+
}
|
|
274
290
|
style={{ color: "var(--bh-social-button-icon)" }}
|
|
275
291
|
/>
|
|
276
292
|
)
|
|
277
293
|
}
|
|
278
294
|
|
|
279
|
-
|
|
295
|
+
function FacebookBrandIcon({
|
|
296
|
+
strokeWidth: _strokeWidth,
|
|
297
|
+
...props
|
|
298
|
+
}: React.SVGProps<SVGSVGElement> & {
|
|
299
|
+
strokeWidth?: number | string
|
|
300
|
+
}) {
|
|
301
|
+
return (
|
|
302
|
+
<svg viewBox="0 0 24 24" fill="none" {...props}>
|
|
303
|
+
<path
|
|
304
|
+
d="M13.5 21v-7h2.35l.45-3h-2.8V9.06c0-.82.4-1.62 1.68-1.62h1.27V4.89S15.3 4.7 14.2 4.7c-2.3 0-3.8 1.39-3.8 3.9V11H7.84v3h2.56v7h3.1Z"
|
|
305
|
+
fill="currentColor"
|
|
306
|
+
/>
|
|
307
|
+
</svg>
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function GoogleBrandIcon({
|
|
312
|
+
strokeWidth: _strokeWidth,
|
|
313
|
+
...props
|
|
314
|
+
}: React.SVGProps<SVGSVGElement> & {
|
|
315
|
+
strokeWidth?: number | string
|
|
316
|
+
}) {
|
|
317
|
+
return (
|
|
318
|
+
<svg viewBox="0 0 24 24" fill="none" {...props}>
|
|
319
|
+
<path
|
|
320
|
+
d="M12 4.75a7.25 7.25 0 1 0 5.13 12.37 6.85 6.85 0 0 0 1.87-4.72H12v2.6h4.09a3.96 3.96 0 1 1-1.08-4.1l1.84-1.84A7.2 7.2 0 0 0 12 4.75Z"
|
|
321
|
+
fill="currentColor"
|
|
322
|
+
/>
|
|
323
|
+
</svg>
|
|
324
|
+
)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function LinkedinBrandIcon({
|
|
328
|
+
strokeWidth: _strokeWidth,
|
|
329
|
+
...props
|
|
330
|
+
}: React.SVGProps<SVGSVGElement> & {
|
|
331
|
+
strokeWidth?: number | string
|
|
332
|
+
}) {
|
|
333
|
+
return (
|
|
334
|
+
<svg viewBox="0 0 24 24" fill="none" {...props}>
|
|
335
|
+
<path
|
|
336
|
+
d="M6.7 8.9H3.9V20h2.8V8.9ZM5.3 4A1.65 1.65 0 1 0 5.3 7.3 1.65 1.65 0 0 0 5.3 4Zm14.8 9.85c0-3.05-1.63-4.47-3.8-4.47a3.28 3.28 0 0 0-2.98 1.64h-.04V8.9h-2.69V20h2.8v-5.5c0-1.45.28-2.85 2.07-2.85 1.76 0 1.78 1.65 1.78 2.94V20h2.86v-6.15Z"
|
|
337
|
+
fill="currentColor"
|
|
338
|
+
/>
|
|
339
|
+
</svg>
|
|
340
|
+
)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function TwitterBrandIcon({
|
|
344
|
+
strokeWidth: _strokeWidth,
|
|
345
|
+
...props
|
|
346
|
+
}: React.SVGProps<SVGSVGElement> & {
|
|
347
|
+
strokeWidth?: number | string
|
|
348
|
+
}) {
|
|
349
|
+
return (
|
|
350
|
+
<svg viewBox="0 0 24 24" fill="none" {...props}>
|
|
351
|
+
<path
|
|
352
|
+
d="m15.3 10.9 5.1-5.9h-1.2l-4.43 5.14L11.23 5H7.15l5.35 7.79L7.15 19h1.2l4.68-5.43L16.77 19h4.08l-5.55-8.1Zm-1.66 1.92-.54-.78-4.31-6.15h1.86l3.49 4.98.54.78 4.52 6.46h-1.86l-3.7-5.29Z"
|
|
353
|
+
fill="currentColor"
|
|
354
|
+
/>
|
|
355
|
+
</svg>
|
|
356
|
+
)
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const socialButtonIcons: Record<SocialPlatform, SocialButtonIconComponent> = {
|
|
280
360
|
apple: AppleIcon,
|
|
281
|
-
facebook:
|
|
282
|
-
google:
|
|
283
|
-
linkedin:
|
|
284
|
-
twitter:
|
|
361
|
+
facebook: FacebookBrandIcon,
|
|
362
|
+
google: GoogleBrandIcon,
|
|
363
|
+
linkedin: LinkedinBrandIcon,
|
|
364
|
+
twitter: TwitterBrandIcon,
|
|
285
365
|
whatsapp: MessageCircleIcon,
|
|
286
366
|
}
|
|
287
367
|
|
|
288
|
-
export {
|
|
368
|
+
export {
|
|
369
|
+
arabicSocialButtonMessages,
|
|
370
|
+
SocialButton,
|
|
371
|
+
socialButtonVariants,
|
|
372
|
+
socialPlatformConfig,
|
|
373
|
+
}
|
|
289
374
|
export type {
|
|
375
|
+
SocialButtonMessages,
|
|
290
376
|
SocialButtonProps,
|
|
291
377
|
SocialButtonSize,
|
|
292
378
|
SocialButtonVariant,
|