|
1 | | -import * as React from "react" |
2 | | -import { Slot } from "@radix-ui/react-slot" |
3 | | -import { ChevronRight, MoreHorizontal } from "lucide-react" |
| 1 | +import { Slot } from '@radix-ui/react-slot'; |
| 2 | +import { ChevronRight, MoreHorizontal } from 'lucide-react'; |
4 | 3 |
|
5 | | -import { cn } from "@/lib/utils" |
| 4 | +import { cn } from '@/lib/utils'; |
| 5 | +import type { ComponentProps } from 'react'; |
6 | 6 |
|
7 | | -function Breadcrumb({ ...props }: React.ComponentProps<"nav">) { |
8 | | - return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} /> |
| 7 | +function Breadcrumb({ ...props }: ComponentProps<'nav'>) { |
| 8 | + return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />; |
9 | 9 | } |
10 | 10 |
|
11 | | -function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) { |
12 | | - return ( |
13 | | - <ol |
14 | | - data-slot="breadcrumb-list" |
15 | | - className={cn( |
16 | | - "text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5", |
17 | | - className |
18 | | - )} |
19 | | - {...props} |
20 | | - /> |
21 | | - ) |
| 11 | +function BreadcrumbList({ className, ...props }: ComponentProps<'ol'>) { |
| 12 | + return ( |
| 13 | + <ol |
| 14 | + data-slot="breadcrumb-list" |
| 15 | + className={cn( |
| 16 | + 'flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground sm:gap-2.5', |
| 17 | + className, |
| 18 | + )} |
| 19 | + {...props} |
| 20 | + /> |
| 21 | + ); |
22 | 22 | } |
23 | 23 |
|
24 | | -function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) { |
25 | | - return ( |
26 | | - <li |
27 | | - data-slot="breadcrumb-item" |
28 | | - className={cn("inline-flex items-center gap-1.5", className)} |
29 | | - {...props} |
30 | | - /> |
31 | | - ) |
| 24 | +function BreadcrumbItem({ className, ...props }: ComponentProps<'li'>) { |
| 25 | + return <li data-slot="breadcrumb-item" className={cn('inline-flex items-center gap-1.5', className)} {...props} />; |
32 | 26 | } |
33 | 27 |
|
34 | 28 | function BreadcrumbLink({ |
35 | | - asChild, |
36 | | - className, |
37 | | - ...props |
38 | | -}: React.ComponentProps<"a"> & { |
39 | | - asChild?: boolean |
| 29 | + asChild, |
| 30 | + className, |
| 31 | + ...props |
| 32 | +}: ComponentProps<'a'> & { |
| 33 | + asChild?: boolean; |
40 | 34 | }) { |
41 | | - const Comp = asChild ? Slot : "a" |
| 35 | + const Comp = asChild ? Slot : 'a'; |
42 | 36 |
|
43 | | - return ( |
44 | | - <Comp |
45 | | - data-slot="breadcrumb-link" |
46 | | - className={cn("hover:text-foreground transition-colors", className)} |
47 | | - {...props} |
48 | | - /> |
49 | | - ) |
| 37 | + return ( |
| 38 | + <Comp |
| 39 | + data-slot="breadcrumb-link" |
| 40 | + className={cn('transition-colors hover:text-foreground', className)} |
| 41 | + {...props} |
| 42 | + /> |
| 43 | + ); |
50 | 44 | } |
51 | 45 |
|
52 | | -function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) { |
53 | | - return ( |
54 | | - <span |
55 | | - data-slot="breadcrumb-page" |
56 | | - role="link" |
57 | | - aria-disabled="true" |
58 | | - aria-current="page" |
59 | | - className={cn("text-foreground font-normal", className)} |
60 | | - {...props} |
61 | | - /> |
62 | | - ) |
| 46 | +function BreadcrumbPage({ className, ...props }: ComponentProps<'span'>) { |
| 47 | + return ( |
| 48 | + <span |
| 49 | + data-slot="breadcrumb-page" |
| 50 | + role="link" |
| 51 | + aria-disabled="true" |
| 52 | + aria-current="page" |
| 53 | + className={cn('font-normal text-foreground', className)} |
| 54 | + {...props} |
| 55 | + /> |
| 56 | + ); |
63 | 57 | } |
64 | 58 |
|
65 | | -function BreadcrumbSeparator({ |
66 | | - children, |
67 | | - className, |
68 | | - ...props |
69 | | -}: React.ComponentProps<"li">) { |
70 | | - return ( |
71 | | - <li |
72 | | - data-slot="breadcrumb-separator" |
73 | | - role="presentation" |
74 | | - aria-hidden="true" |
75 | | - className={cn("[&>svg]:size-3.5", className)} |
76 | | - {...props} |
77 | | - > |
78 | | - {children ?? <ChevronRight />} |
79 | | - </li> |
80 | | - ) |
| 59 | +function BreadcrumbSeparator({ children, className, ...props }: ComponentProps<'li'>) { |
| 60 | + return ( |
| 61 | + <li |
| 62 | + data-slot="breadcrumb-separator" |
| 63 | + role="presentation" |
| 64 | + aria-hidden="true" |
| 65 | + className={cn('[&>svg]:size-3.5', className)} |
| 66 | + {...props} |
| 67 | + > |
| 68 | + {children ?? <ChevronRight />} |
| 69 | + </li> |
| 70 | + ); |
81 | 71 | } |
82 | 72 |
|
83 | | -function BreadcrumbEllipsis({ |
84 | | - className, |
85 | | - ...props |
86 | | -}: React.ComponentProps<"span">) { |
87 | | - return ( |
88 | | - <span |
89 | | - data-slot="breadcrumb-ellipsis" |
90 | | - role="presentation" |
91 | | - aria-hidden="true" |
92 | | - className={cn("flex size-9 items-center justify-center", className)} |
93 | | - {...props} |
94 | | - > |
95 | | - <MoreHorizontal className="size-4" /> |
96 | | - <span className="sr-only">More</span> |
97 | | - </span> |
98 | | - ) |
| 73 | +function BreadcrumbEllipsis({ className, ...props }: ComponentProps<'span'>) { |
| 74 | + return ( |
| 75 | + <span |
| 76 | + data-slot="breadcrumb-ellipsis" |
| 77 | + role="presentation" |
| 78 | + aria-hidden="true" |
| 79 | + className={cn('flex size-9 items-center justify-center', className)} |
| 80 | + {...props} |
| 81 | + > |
| 82 | + <MoreHorizontal className="size-4" /> |
| 83 | + <span className="sr-only">More</span> |
| 84 | + </span> |
| 85 | + ); |
99 | 86 | } |
100 | 87 |
|
101 | 88 | export { |
102 | | - Breadcrumb, |
103 | | - BreadcrumbList, |
104 | | - BreadcrumbItem, |
105 | | - BreadcrumbLink, |
106 | | - BreadcrumbPage, |
107 | | - BreadcrumbSeparator, |
108 | | - BreadcrumbEllipsis, |
109 | | -} |
| 89 | + Breadcrumb, |
| 90 | + BreadcrumbEllipsis, |
| 91 | + BreadcrumbItem, |
| 92 | + BreadcrumbLink, |
| 93 | + BreadcrumbList, |
| 94 | + BreadcrumbPage, |
| 95 | + BreadcrumbSeparator, |
| 96 | +}; |
0 commit comments