Skip to content

Commit

Permalink
Refactor victory-accessible-group to a function component (#2777)
Browse files Browse the repository at this point in the history
  • Loading branch information
KenanYusuf authored Feb 6, 2024
1 parent d8be277 commit 3f2da66
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-dogs-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"victory-core": patch
---

Refactor victory-accessible-group to a function component
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,34 @@ export interface VictoryAccessibleGroupProps {
tabIndex?: number;
}

export class VictoryAccessibleGroup extends React.Component<VictoryAccessibleGroupProps> {
static displayName = "VictoryAccessibleGroup";
export const VictoryAccessibleGroup = ({
desc,
children,
tabIndex,
className = "VictoryAccessibleGroup",
...props
}: VictoryAccessibleGroupProps) => {
const descId =
desc && (props["aria-describedby"] || desc.split(" ").join("-"));

static defaultProps = {
className: "VictoryAccessibleGroup",
};

render() {
const { desc, children, className, tabIndex } = this.props;
const descId =
desc && (this.props["aria-describedby"] || desc.split(" ").join("-"));

return desc ? (
<g
aria-label={this.props["aria-label"]}
aria-describedby={descId}
className={className}
tabIndex={tabIndex}
>
<desc id={descId}>{desc}</desc>
{children}
</g>
) : (
<g
aria-label={this.props["aria-label"]}
aria-describedby={this.props["aria-describedby"]}
className={className}
tabIndex={tabIndex}
>
{children}
</g>
);
}
}
return desc ? (
<g
aria-label={props["aria-label"]}
aria-describedby={descId}
className={className}
tabIndex={tabIndex}
>
<desc id={descId}>{desc}</desc>
{children}
</g>
) : (
<g
aria-label={props["aria-label"]}
aria-describedby={props["aria-describedby"]}
className={className}
tabIndex={tabIndex}
>
{children}
</g>
);
};

0 comments on commit 3f2da66

Please sign in to comment.