Skip to content

Commit

Permalink
chore(breadcrumb): change active color item
Browse files Browse the repository at this point in the history
  • Loading branch information
mleralec committed Dec 27, 2023
1 parent 2aac9e5 commit 0626f2c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 46 deletions.
12 changes: 0 additions & 12 deletions docs/pages/components/breadcrumb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,6 @@ 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
45 changes: 17 additions & 28 deletions packages/Breadcrumb/src/Item.styles.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
import styled, { css, th } from '@xstyled/styled-components'
import { shouldForwardProp } from '@welcome-ui/system'
import styled, { th } from '@xstyled/styled-components'

interface ItemProps {
isActive: boolean
}

export const Item = styled.aBox.withConfig({ shouldForwardProp })<ItemProps>(
({ isActive }) => css`
${th('breadcrumbs.item.default')};
align-items: center;
transition: medium;
direction: initial;
export const Item = styled.aBox`
${th('breadcrumbs.item.default')};
align-items: center;
transition: medium;
direction: initial;
${!isActive &&
css`
&:hover {
${th('breadcrumbs.item.hover')};
}
`};
&:hover {
${th('breadcrumbs.item.hover')};
}
&[aria-disabled='true'] {
pointer-events: none;
cursor: default;
}
&[aria-current='page'] {
${th('breadcrumbs.item.active')};
}
${isActive &&
css`
${th('breadcrumbs.item.active')};
`}
`
)
&[aria-disabled='true'] {
pointer-events: none;
cursor: default;
}
`

export const Separator = styled.span`
${th('breadcrumbs.separator')};
Expand Down
9 changes: 5 additions & 4 deletions packages/Breadcrumb/src/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import * as S from './Item.styles'

export interface ItemOptions {
children: React.ReactNode
disabled?: boolean
separator?: string | React.ReactNode
isActive?: boolean
to?: string
}

export type ItemProps = CreateWuiProps<'a', ItemOptions>
Expand All @@ -17,7 +17,9 @@ export type ItemProps = CreateWuiProps<'a', ItemOptions>
* @name Breadcrumb.Item
*/
export const Item = forwardRef<'a', ItemProps>(
({ children, dataTestId, disabled, isActive, separator, ...rest }, ref) => {
({ children, dataTestId, isActive, separator, ...rest }, ref) => {
const isClickable = rest.href || rest.to

return (
<Box
aria-label="breadcrumb"
Expand All @@ -30,8 +32,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}
aria-disabled={!isClickable}
{...rest}
ref={ref}
>
Expand Down
1 change: 0 additions & 1 deletion packages/Breadcrumb/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const BreadcrumbComponent = forwardRef<'div', BreadcrumbProps>(
key: `breadcrumb-${index}`,
separator: isLastChild ? undefined : separator,
isActive,
as: !!isActive && 'span',
...child.props,
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/Core/src/theme/breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const getBreadcrumbs = (theme: WuiTheme): ThemeBreadcrumbs => {
color: colors['dark-700'],
},
active: {
color: colors['dark-900'],
color: colors['dark-700'],
},
},
separator: {
Expand Down

0 comments on commit 0626f2c

Please sign in to comment.