@@ -4,71 +4,90 @@ import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
44import Image from 'next/image' ;
55import Link from 'next/link' ;
66import type { BreadcrumbOption } from './Breadcrumb' ;
7+ import { getBreadcrumbTextStyles } from './Breadcrumb' ;
78import { Button } from './Button' ;
89import { SvgChevronDown } from '@/components/icons/SvgChevronDown' ;
910import { cn , getGuildAcronym } from '@/utils/util' ;
1011
1112interface BreadcrumbDropdownProps {
1213 readonly highlight ?: boolean | undefined ;
14+ readonly href ?: string | undefined ;
1315 readonly icon ?: React . ReactNode ;
1416 readonly isLast : boolean ;
1517 readonly label : string ;
1618 readonly options : readonly BreadcrumbOption [ ] ;
1719}
1820
19- export function BreadcrumbDropdown ( { label, icon, options, isLast, highlight } : BreadcrumbDropdownProps ) {
21+ export function BreadcrumbDropdown ( { label, icon, href, options, isLast, highlight } : BreadcrumbDropdownProps ) {
22+ const textStyles = getBreadcrumbTextStyles ( isLast , highlight ) ;
23+ const content = (
24+ < >
25+ { icon }
26+ { label }
27+ </ >
28+ ) ;
29+
2030 return (
21- < DropdownMenu . Root >
22- < DropdownMenu . Trigger asChild >
23- < Button
31+ < div className = "flex items-center gap-1" >
32+ { href ? (
33+ < Link
2434 className = { cn (
25- 'flex items-center gap-1 hover:text-primary dark:hover:text-primary-dark px-0 ' ,
26- isLast ? 'text-primary dark:text-primary-dark font-medium' : 'text-secondary dark:text-secondary-dark' ,
27- highlight && 'italic ' ,
35+ 'flex items-center gap-2 hover:text-primary dark:hover:text-primary-dark' ,
36+ textStyles ,
37+ isLast && 'pointer-events-none ' ,
2838 ) }
39+ href = { href }
40+ prefetch
2941 >
30- { icon }
31- { label }
32- < SvgChevronDown />
33- </ Button >
34- </ DropdownMenu . Trigger >
42+ { content }
43+ </ Link >
44+ ) : (
45+ < span className = { cn ( 'flex items-center gap-2' , textStyles ) } > { content } </ span >
46+ ) }
47+ < DropdownMenu . Root >
48+ < DropdownMenu . Trigger asChild >
49+ < Button className = { cn ( 'flex items-center hover:text-primary dark:hover:text-primary-dark px-0' , textStyles ) } >
50+ < SvgChevronDown />
51+ </ Button >
52+ </ DropdownMenu . Trigger >
3553
36- < DropdownMenu . Portal >
37- < DropdownMenu . Content
38- className = "min-w-[220px] bg-card dark:bg-card-dark border border-on-secondary dark:border-on-secondary-dark rounded-lg p-1 shadow-lg z-50"
39- sideOffset = { 5 }
40- >
41- { options . map ( ( option , optionIndex ) => {
42- const iconUrl =
43- option . icon && option . id ? `https://cdn.discordapp.com/icons/${ option . id } /${ option . icon } .png` : null ;
54+ < DropdownMenu . Portal >
55+ < DropdownMenu . Content
56+ className = "min-w-[220px] bg-card dark:bg-card-dark border border-on-secondary dark:border-on-secondary-dark rounded-lg p-1 shadow-lg z-50"
57+ sideOffset = { 5 }
58+ >
59+ { options . map ( ( option , optionIndex ) => {
60+ const iconUrl =
61+ option . icon && option . id ? `https://cdn.discordapp.com/icons/${ option . id } /${ option . icon } .png` : null ;
4462
45- return (
46- < DropdownMenu . Item asChild key = { optionIndex } >
47- < Link
48- className = "flex items-center gap-2 px-3 py-2 text-base text-secondary dark:text-secondary-dark hover:text-primary dark:hover:text-primary-dark hover:bg-on-tertiary dark:hover:bg-on-tertiary-dark rounded-md outline-none cursor-pointer"
49- href = { option . href }
50- prefetch
51- >
52- { iconUrl ? (
53- < Image
54- alt = { `${ option . label } icon` }
55- className = "flex h-6 w-6 items-center justify-center rounded-full"
56- height = { 24 }
57- src = { iconUrl }
58- width = { 24 }
59- />
60- ) : (
61- < span className = "flex h-6 w-6 items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-full bg-on-tertiary text-xs dark:bg-on-tertiary-dark" >
62- { getGuildAcronym ( option . label ) }
63- </ span >
64- ) }
65- { option . label }
66- </ Link >
67- </ DropdownMenu . Item >
68- ) ;
69- } ) }
70- </ DropdownMenu . Content >
71- </ DropdownMenu . Portal >
72- </ DropdownMenu . Root >
63+ return (
64+ < DropdownMenu . Item asChild key = { optionIndex } >
65+ < Link
66+ className = "flex items-center gap-2 px-3 py-2 text-base text-secondary dark:text-secondary-dark hover:text-primary dark:hover:text-primary-dark hover:bg-on-tertiary dark:hover:bg-on-tertiary-dark rounded-md outline-none cursor-pointer"
67+ href = { option . href }
68+ prefetch
69+ >
70+ { iconUrl ? (
71+ < Image
72+ alt = { `${ option . label } icon` }
73+ className = "flex h-6 w-6 items-center justify-center rounded-full"
74+ height = { 24 }
75+ src = { iconUrl }
76+ width = { 24 }
77+ />
78+ ) : (
79+ < span className = "flex h-6 w-6 items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-full bg-on-tertiary text-xs dark:bg-on-tertiary-dark" >
80+ { getGuildAcronym ( option . label ) }
81+ </ span >
82+ ) }
83+ { option . label }
84+ </ Link >
85+ </ DropdownMenu . Item >
86+ ) ;
87+ } ) }
88+ </ DropdownMenu . Content >
89+ </ DropdownMenu . Portal >
90+ </ DropdownMenu . Root >
91+ </ div >
7392 ) ;
7493}
0 commit comments