Skip to content

Commit

Permalink
feat(bar): added aria hidden and disabled flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jingcai86 committed Apr 19, 2024
1 parent d90a326 commit d3bc823
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
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

0 comments on commit d3bc823

Please sign in to comment.