Skip to content

Commit

Permalink
feat(breadcrumb): using TextLink as breadcrumb items
Browse files Browse the repository at this point in the history
  • Loading branch information
Powerplex committed Aug 20, 2024
1 parent 0a6cec2 commit f590e53
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
8 changes: 6 additions & 2 deletions packages/components/breadcrumb/src/Breadcrumb.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export const Default: StoryFn = _args => (
<Breadcrumb.Separator />

<Breadcrumb.Item>
<Breadcrumb.Link href="/docs/components">Components</Breadcrumb.Link>
<Breadcrumb.Link href="/?path=/docs/experimental-breadcrumb--docs">
Components
</Breadcrumb.Link>
</Breadcrumb.Item>

<Breadcrumb.Separator />
Expand All @@ -44,7 +46,9 @@ export const CustomSeparator: StoryFn = _args => (
</Breadcrumb.Separator>

<Breadcrumb.Item>
<Breadcrumb.Link href="/docs/components">Components</Breadcrumb.Link>
<Breadcrumb.Link href="/?path=/docs/experimental-breadcrumb--docs">
Components
</Breadcrumb.Link>
</Breadcrumb.Item>

<Breadcrumb.Separator>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/breadcrumb/src/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const Breadcrumb = forwardRef<HTMLOListElement, BreadcrumbProps>(
data-spark-component="breadcrumb"
ref={ref}
aria-label={ariaLabel}
className={cx('text-caption', className)}
className={cx('text-caption text-neutral', className)}
>
<ol className={cx('flex flex-wrap items-center gap-sm break-words')} {...rest} />
</nav>
Expand Down
21 changes: 18 additions & 3 deletions packages/components/breadcrumb/src/BreadcrumbLink.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
import { Slot } from '@spark-ui/slot'
import { TextLink } from '@spark-ui/text-link'
import { ComponentPropsWithoutRef, forwardRef } from 'react'

export interface LinkProps extends ComponentPropsWithoutRef<'a'> {
export interface LinkProps extends ComponentPropsWithoutRef<typeof TextLink> {
asChild?: boolean
className?: string
href?: string
}

export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
({ asChild = false, className, href, ...rest }, ref) => {
const Component = asChild ? Slot : 'a'
(
{
asChild = false,
className,
bold = true,
intent = 'current',
underline = true,
href,
...rest
},
ref
) => {
const Component = asChild ? Slot : TextLink

return (
<Component
data-spark-component="breadcrumb-link"
href={href}
ref={ref}
className={className}
bold={bold}
intent={intent}
underline={underline}
{...rest}
/>
)
Expand Down

0 comments on commit f590e53

Please sign in to comment.