Skip to content

Commit

Permalink
fix: add aria-label
Browse files Browse the repository at this point in the history
  • Loading branch information
ogonkov committed May 31, 2024
1 parent 07bebeb commit 4739880
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/components/AvatarStack/AvatarStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {block} from '../utils/cn';

import {AvatarStackItem} from './AvatarStackItem';
import {AvatarStackMoreButton} from './AvatarStackMoreButton';
import i18n from './i18n';
import type {AvatarStackProps} from './types';

import './AvatarStack.scss';
Expand Down Expand Up @@ -50,7 +51,11 @@ const AvatarStackComponent = ({
{renderMoreButton ? (
renderMoreButton({count: moreItems})
) : (
<Avatar text={`+${moreItems}`} size={size} />
<Avatar
text={`+${moreItems}`}
aria-label={i18n('more', {count: moreItems})}
size={size}
/>
)}
</AvatarStackItem>
) : null}
Expand Down
8 changes: 7 additions & 1 deletion src/components/AvatarStack/AvatarStackMoreButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type {AvatarSize} from '../Avatar';
import {Avatar, DEFAULT_AVATAR_SIZE} from '../Avatar';
import {block} from '../utils/cn';

import i18n from './i18n';

const b = block('avatar-stack');

type Props = Pick<React.HTMLProps<HTMLButtonElement>, 'className' | 'onClick' | 'aria-label'> & {
Expand All @@ -15,7 +17,11 @@ export const AvatarStackMoreButton = React.forwardRef<HTMLButtonElement, Props>(
({className, size = DEFAULT_AVATAR_SIZE, onClick, count, 'aria-label': ariaLabel}, ref) => {
return (
<button ref={ref} className={b('more-button', {size}, className)} onClick={onClick}>
<Avatar text={`+${count}`} size={size} aria-label={ariaLabel} />
<Avatar
text={`+${count}`}
size={size}
aria-label={ariaLabel || i18n('more', {count})}
/>
</button>
);
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarStack/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More"
"more": ["and {{count}} more", "and {{count}} more", "and {{count}} more"]
}
2 changes: 1 addition & 1 deletion src/components/AvatarStack/i18n/ru.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "Больше"
"more": ["И eщё {{count}}", "И eщё {{count}}", "И eщё {{count}}"]
}

0 comments on commit 4739880

Please sign in to comment.