Skip to content

Commit

Permalink
Merge pull request #873 from gympass/ACS-100
Browse files Browse the repository at this point in the history
🚀 Feat: ad aria label to right button
  • Loading branch information
alvim-wh authored Feb 6, 2025
2 parents d3904da + 2d61b86 commit 98a43ad
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/yoga/src/Button/web/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Button = forwardRef(
secondary = false,
icon: Icon,
isLoading = false,
'aria-label': ariaLabel,
...props
},
ref,
Expand All @@ -49,6 +50,7 @@ const Button = forwardRef(
small={small}
secondary={secondary}
isLoading={isLoading}
aria-label={ariaLabel}
{...finalProps}
>
{Icon && <Icon role="img" />}
Expand All @@ -65,7 +67,6 @@ const Button = forwardRef(
);

Button.propTypes = {
ariaLabel: string,
children: node,
disabled: bool,
full: bool,
Expand All @@ -77,6 +78,7 @@ Button.propTypes = {
/** an Icon from yoga-icons package */
icon: oneOfType([node, func]),
href: string,
'aria-label': string,
};

Button.displayName = 'Button';
Expand Down
18 changes: 18 additions & 0 deletions packages/yoga/src/Heading/web/Heading.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ describe('<Heading />', () => {
expect(container).toMatchSnapshot();
});

it('should have aria-label', () => {
const { getByLabelText } = render(
<ThemeProvider>
<Heading noPadding>
<Title>Gympass</Title>
<BackButton onClick={onClick} />
<RightButton
icon={Upload2}
onClick={onClick}
aria-label="labelAriaText"
/>
</Heading>
</ThemeProvider>,
);

expect(getByLabelText('labelAriaText')).toBeTruthy();
});

it('should override the background color', () => {
const { container } = render(
<ThemeProvider>
Expand Down
11 changes: 9 additions & 2 deletions packages/yoga/src/Heading/web/RightButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ const ButtonIcon = styled(Button)`
}};
`;

const RightButton = ({ onClick, icon, ...props }) => (
<ButtonIcon onClick={onClick} secondary padding="xxxsmall" {...props}>
const RightButton = ({ onClick, icon, 'aria-label': ariaLabel, ...props }) => (
<ButtonIcon
onClick={onClick}
secondary
padding="xxxsmall"
aria-label={ariaLabel}
{...props}
>
<Box
flex={1}
display="flex"
Expand All @@ -77,6 +83,7 @@ const RightButton = ({ onClick, icon, ...props }) => (
RightButton.propTypes = {
onClick: PropTypes.func.isRequired,
icon: PropTypes.elementType.isRequired,
'aria-label': PropTypes.string,
};

RightButton.displayName = 'Heading.RightButton';
Expand Down

0 comments on commit 98a43ad

Please sign in to comment.