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: ad aria label to right button #873

Merged
merged 4 commits into from
Feb 6, 2025
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
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,
nataliosilveiraext marked this conversation as resolved.
Show resolved Hide resolved
};

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
9 changes: 0 additions & 9 deletions packages/yoga/src/Menu/web/__snapshots__/Menu.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ exports[`<Menu /> should match snapshot Menu with a onMouseHover props false 1`]

<div>
<button
aria-disabled="false"
aria-expanded="false"
aria-haspopup="menu"
class="c0"
Expand Down Expand Up @@ -180,7 +179,6 @@ exports[`<Menu /> should match snapshot Menu with an align props end 1`] = `
<div>
<div>
<button
aria-disabled="false"
aria-expanded="false"
aria-haspopup="menu"
class="c0"
Expand Down Expand Up @@ -281,7 +279,6 @@ exports[`<Menu /> should match snapshot Menu with an align props start 1`] = `
<div>
<div>
<button
aria-disabled="false"
aria-expanded="false"
aria-haspopup="menu"
class="c0"
Expand Down Expand Up @@ -382,7 +379,6 @@ exports[`<Menu /> should match snapshot Menu.Item with active 1`] = `
<div>
<div>
<button
aria-disabled="false"
aria-expanded="false"
aria-haspopup="menu"
class="c0"
Expand Down Expand Up @@ -483,7 +479,6 @@ exports[`<Menu /> should match snapshot Menu.Item with disabled 1`] = `
<div>
<div>
<button
aria-disabled="false"
aria-expanded="false"
aria-haspopup="menu"
class="c0"
Expand Down Expand Up @@ -584,7 +579,6 @@ exports[`<Menu /> should match snapshot Menu.Item with disabled and icon 1`] = `
<div>
<div>
<button
aria-disabled="false"
aria-expanded="false"
aria-haspopup="menu"
class="c0"
Expand Down Expand Up @@ -685,7 +679,6 @@ exports[`<Menu /> should match snapshot Menu.Item with icon 1`] = `
<div>
<div>
<button
aria-disabled="false"
aria-expanded="false"
aria-haspopup="menu"
class="c0"
Expand Down Expand Up @@ -786,7 +779,6 @@ exports[`<Menu /> should match snapshot Menu.Item with link 1`] = `
<div>
<div>
<button
aria-disabled="false"
aria-expanded="false"
aria-haspopup="menu"
class="c0"
Expand Down Expand Up @@ -887,7 +879,6 @@ exports[`<Menu /> should match snapshot in default Menu 1`] = `
<div>
<div>
<button
aria-disabled="false"
aria-expanded="false"
aria-haspopup="menu"
class="c0"
Expand Down
Loading