-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
480 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@utima/ui": minor | ||
--- | ||
|
||
Added Breadcrumb component, performance optimizations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/ui/src/components/breadcrumb/Breadcrumb.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Slash } from 'lucide-react'; | ||
|
||
import * as Breadcrumb from './index'; | ||
import * as Dropdown from '../dropdown/index'; | ||
|
||
const meta: Meta<typeof Breadcrumb.Root> = { | ||
component: Breadcrumb.Root, | ||
tags: ['autodocs'], | ||
title: 'Components/Breadcrumb', | ||
args: { | ||
children: ( | ||
<Breadcrumb.List> | ||
<Breadcrumb.Item> | ||
<Breadcrumb.Link href='/'>Home</Breadcrumb.Link> | ||
</Breadcrumb.Item> | ||
<Breadcrumb.Separator /> | ||
<Breadcrumb.Item> | ||
<Dropdown.Root> | ||
<Dropdown.Trigger className='flex items-center gap-1'> | ||
<Breadcrumb.Ellipsis className='h-4 w-4' /> | ||
<span className='sr-only'>Toggle menu</span> | ||
</Dropdown.Trigger> | ||
<Dropdown.Content align='start'> | ||
<Dropdown.Item>Documentation</Dropdown.Item> | ||
<Dropdown.Item>Themes</Dropdown.Item> | ||
<Dropdown.Item>GitHub</Dropdown.Item> | ||
</Dropdown.Content> | ||
</Dropdown.Root> | ||
</Breadcrumb.Item> | ||
<Breadcrumb.Separator> | ||
<Slash /> | ||
</Breadcrumb.Separator> | ||
<Breadcrumb.Item> | ||
<Breadcrumb.Link href='/docs/components'>Components</Breadcrumb.Link> | ||
</Breadcrumb.Item> | ||
<Breadcrumb.Separator /> | ||
<Breadcrumb.Item> | ||
<Breadcrumb.Page>Breadcrumb</Breadcrumb.Page> | ||
</Breadcrumb.Item> | ||
</Breadcrumb.List> | ||
), | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Breadcrumb.Root>; | ||
|
||
export const Basic: Story = { | ||
args: {}, | ||
}; |
19 changes: 19 additions & 0 deletions
19
packages/ui/src/components/breadcrumb/Breadcrumb.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { twOverrides } from '@/overrides'; | ||
|
||
import { globalDef } from '../global.styles'; | ||
|
||
export const breadcrumbDef = twOverrides( | ||
{ | ||
breadcrumb: '', | ||
ellipsis: { | ||
wrapper: `${globalDef.ringVisible} flex h-9 w-9 items-center justify-center`, | ||
icon: 'size-4', | ||
}, | ||
item: 'inline-flex items-center gap-1.5', | ||
link: `${globalDef.ringVisible} rounded-radius transition-colors hover:text-foreground`, | ||
list: 'flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-fg sm:gap-2.5', | ||
page: 'font-normal text-foreground', | ||
separator: '[&>svg]:size-3.5', | ||
}, | ||
'breadcrumb', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { type ComponentPropsWithoutRef, type ReactNode, memo } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { breadcrumbDef } from './Breadcrumb.styles'; | ||
|
||
interface BreadcrumbProps extends ComponentPropsWithoutRef<'nav'> { | ||
separator?: ReactNode; | ||
} | ||
|
||
export const Breadcrumb = memo(function Breadcrumb({ | ||
className, | ||
...props | ||
}: BreadcrumbProps) { | ||
return ( | ||
<nav | ||
aria-label='breadcrumb' | ||
className={cn(breadcrumbDef.breadcrumb, className)} | ||
{...props} | ||
/> | ||
); | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/ui/src/components/breadcrumb/BreadcrumbEllipsis.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { MoreHorizontal } from 'lucide-react'; | ||
import { memo, type ComponentPropsWithoutRef } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { breadcrumbDef } from './Breadcrumb.styles'; | ||
|
||
export const BreadcrumbEllipsis = memo(function BreadcrumbEllipsis({ | ||
className, | ||
children, | ||
...props | ||
}: ComponentPropsWithoutRef<'span'>) { | ||
return ( | ||
<span | ||
role='presentation' | ||
aria-hidden='true' | ||
className={cn(breadcrumbDef.ellipsis.wrapper, className)} | ||
{...props} | ||
> | ||
<MoreHorizontal className={breadcrumbDef.ellipsis.icon} /> | ||
<span className='sr-only'>More</span> | ||
</span> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { memo, type ComponentPropsWithoutRef } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { breadcrumbDef } from './Breadcrumb.styles'; | ||
|
||
export const BreadcrumbItem = memo(function BreadcrumbItem({ | ||
className, | ||
...props | ||
}: ComponentPropsWithoutRef<'li'>) { | ||
return <li className={cn(breadcrumbDef.item, className)} {...props} />; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Slot } from '@radix-ui/react-slot'; | ||
import { memo, type ComponentPropsWithoutRef } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { breadcrumbDef } from './Breadcrumb.styles'; | ||
|
||
interface BreadcrumbLinkProps extends ComponentPropsWithoutRef<'a'> { | ||
asChild?: boolean; | ||
} | ||
|
||
export const BreadcrumbLink = memo(function BreadcrumbLink({ | ||
asChild, | ||
className, | ||
...props | ||
}: BreadcrumbLinkProps) { | ||
const Comp = asChild ? Slot : 'a'; | ||
|
||
return <Comp className={cn(breadcrumbDef.link, className)} {...props} />; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { memo, type ComponentPropsWithoutRef } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { breadcrumbDef } from './Breadcrumb.styles'; | ||
|
||
export const BreadcrumbList = memo(function BreadcrumbList({ | ||
className, | ||
...props | ||
}: ComponentPropsWithoutRef<'ol'>) { | ||
return <ol className={cn(breadcrumbDef.list, className)} {...props} />; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { memo, type ComponentPropsWithoutRef } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { breadcrumbDef } from './Breadcrumb.styles'; | ||
|
||
export const BreadcrumbPage = memo(function BreadcrumbPage({ | ||
className, | ||
...props | ||
}: ComponentPropsWithoutRef<'span'>) { | ||
return ( | ||
<span | ||
role='link' | ||
aria-disabled='true' | ||
aria-current='page' | ||
className={cn(breadcrumbDef.page, className)} | ||
{...props} | ||
/> | ||
); | ||
}); |
23 changes: 23 additions & 0 deletions
23
packages/ui/src/components/breadcrumb/BreadcrumbSeparator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ChevronRight } from 'lucide-react'; | ||
import { memo, type ComponentPropsWithoutRef } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { breadcrumbDef } from './Breadcrumb.styles'; | ||
|
||
export const BreadcrumbSeparator = memo(function BreadcrumbSeparator({ | ||
className, | ||
children, | ||
...props | ||
}: ComponentPropsWithoutRef<'li'>) { | ||
return ( | ||
<li | ||
role='presentation' | ||
aria-hidden='true' | ||
className={cn(breadcrumbDef.separator, className)} | ||
{...props} | ||
> | ||
{children ?? <ChevronRight />} | ||
</li> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export { Breadcrumb as Root } from './Breadcrumb'; | ||
export { BreadcrumbLink as Link } from './BreadcrumbLink'; | ||
export { BreadcrumbEllipsis as Ellipsis } from './BreadcrumbEllipsis'; | ||
export { BreadcrumbItem as Item } from './BreadcrumbItem'; | ||
export { BreadcrumbList as List } from './BreadcrumbList'; | ||
export { BreadcrumbPage as Page } from './BreadcrumbPage'; | ||
export { BreadcrumbSeparator as Separator } from './BreadcrumbSeparator'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.