Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(breadcrumb): items without link must be disabled #2372

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/pages/components/breadcrumb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ By default we removed clickable the last child. You can change this by set to fa
</Breadcrumb>
```

## Item disable

You can disable an item.

```jsx
<Breadcrumb>
<Breadcrumb.Item disabled>Introduction</Breadcrumb.Item>
<Breadcrumb.Item href="/">Components</Breadcrumb.Item>
<Breadcrumb.Item href="/">Breadcrumb</Breadcrumb.Item>
</Breadcrumb>
```

## Properties

### Breadcrumb
Expand Down
5 changes: 5 additions & 0 deletions packages/Breadcrumb/src/Item.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export const Item = styled.aBox.withConfig({ shouldForwardProp })<ItemProps>(
}
`};

&[aria-disabled='true'] {
pointer-events: none;
cursor: default;
}

${isActive &&
css`
${th('breadcrumbs.item.active')};
Expand Down
4 changes: 3 additions & 1 deletion packages/Breadcrumb/src/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as S from './Item.styles'

export interface ItemOptions {
children: React.ReactNode
disabled?: boolean
separator?: string | React.ReactNode
isActive?: boolean
}
Expand All @@ -16,7 +17,7 @@ export type ItemProps = CreateWuiProps<'a', ItemOptions>
* @name Breadcrumb.Item
*/
export const Item = forwardRef<'a', ItemProps>(
({ children, dataTestId, isActive, separator, ...rest }, ref) => {
({ children, dataTestId, disabled, isActive, separator, ...rest }, ref) => {
return (
<Box
aria-label="breadcrumb"
Expand All @@ -29,6 +30,7 @@ export const Item = forwardRef<'a', ItemProps>(
{separator && <S.Separator role="presentation">{separator}</S.Separator>}
<S.Item
aria-current={isActive ? 'page' : undefined}
aria-disabled={disabled}
isActive={isActive}
{...rest}
ref={ref}
Expand Down