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(bar): added aria hidden and disabled flag #2566

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions packages/bar/src/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ const InnerBar = <RawDatum extends BarDatum>({
barAriaLabel,
barAriaLabelledBy,
barAriaDescribedBy,
barAriaHidden,
barAriaDisabled,

initialHiddenIds,

Expand Down Expand Up @@ -257,6 +259,8 @@ const InnerBar = <RawDatum extends BarDatum>({
ariaLabel: barAriaLabel,
ariaLabelledBy: barAriaLabelledBy,
ariaDescribedBy: barAriaDescribedBy,
ariaHidden: barAriaHidden,
ariaDisabled: barAriaDisabled,
}),
[
borderRadius,
Expand All @@ -274,6 +278,8 @@ const InnerBar = <RawDatum extends BarDatum>({
barAriaLabel,
barAriaLabelledBy,
barAriaDescribedBy,
barAriaHidden,
barAriaDisabled,
]
)

Expand Down
4 changes: 4 additions & 0 deletions packages/bar/src/BarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const BarItem = <RawDatum extends BarDatum>({
ariaLabel,
ariaLabelledBy,
ariaDescribedBy,
ariaDisabled,
ariaHidden,
}: BarItemProps<RawDatum>) => {
const theme = useTheme()
const { showTooltipFromEvent, showTooltipAt, hideTooltip } = useTooltip()
Expand Down Expand Up @@ -93,6 +95,8 @@ export const BarItem = <RawDatum extends BarDatum>({
aria-label={ariaLabel ? ariaLabel(data) : undefined}
aria-labelledby={ariaLabelledBy ? ariaLabelledBy(data) : undefined}
aria-describedby={ariaDescribedBy ? ariaDescribedBy(data) : undefined}
aria-disabled={ariaDisabled ? ariaDisabled(data) : undefined}
aria-hidden={ariaHidden ? ariaHidden(data) : undefined}
onMouseEnter={isInteractive ? handleMouseEnter : undefined}
onMouseMove={isInteractive ? handleTooltip : undefined}
onMouseLeave={isInteractive ? handleMouseLeave : undefined}
Expand Down
6 changes: 6 additions & 0 deletions packages/bar/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ export interface BarItemProps<RawDatum extends BarDatum>
ariaLabel?: BarSvgProps<RawDatum>['barAriaLabel']
ariaLabelledBy?: BarSvgProps<RawDatum>['barAriaLabelledBy']
ariaDescribedBy?: BarSvgProps<RawDatum>['barAriaDescribedBy']
ariaHidden?: BarSvgProps<RawDatum>['barAriaHidden']
ariaDisabled?: BarSvgProps<RawDatum>['barAriaDisabled']
}

export type RenderBarProps<RawDatum extends BarDatum> = Omit<
Expand All @@ -185,6 +187,8 @@ export type RenderBarProps<RawDatum extends BarDatum> = Omit<
| 'ariaLabel'
| 'ariaLabelledBy'
| 'ariaDescribedBy'
| 'ariaHidden'
| 'ariaDisabled'
> & {
borderColor: string
labelColor: string
Expand Down Expand Up @@ -293,6 +297,8 @@ export type BarSvgProps<RawDatum extends BarDatum> = Partial<BarCommonProps<RawD
barAriaDescribedBy?: (
data: ComputedDatum<RawDatum>
) => React.AriaAttributes['aria-describedby']
barAriaHidden?: (data: ComputedDatum<RawDatum>) => React.AriaAttributes['aria-hidden']
barAriaDisabled?: (data: ComputedDatum<RawDatum>) => React.AriaAttributes['aria-disabled']
}>

export type BarCanvasProps<RawDatum extends BarDatum> = Partial<BarCommonProps<RawDatum>> &
Expand Down
16 changes: 16 additions & 0 deletions website/src/data/components/bar/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,22 @@ const props: ChartProperty[] = [
help: '[aria-describedby](https://www.w3.org/TR/wai-aria/#aria-describedby) for bar items.',
type: '(data) => string',
},
{
key: 'barAriaHidden',
flavors: ['svg'],
required: false,
group: 'Accessibility',
help: '[aria-hidden](https://www.w3.org/TR/wai-aria/#aria-hidden) for bar items.',
type: '(data) => boolean',
},
{
key: 'barAriaDisabled',
flavors: ['svg'],
required: false,
group: 'Accessibility',
help: '[aria-disabled](https://www.w3.org/TR/wai-aria/#aria-disabled) for bar items.',
type: '(data) => boolean',
},
]

export const groups = groupProperties(props)
Loading