Skip to content

Commit 5b77c34

Browse files
fix(accessibility): add right title/alt (#7094)
1 parent c6e97a1 commit 5b77c34

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

apps/site/components/Common/AvatarGroup/Avatar/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ import styles from './index.module.css';
66
export type AvatarProps = {
77
src: string;
88
alt: string;
9+
fallback: string;
910
};
1011

11-
const Avatar: FC<AvatarProps> = ({ src, alt }) => (
12+
const Avatar: FC<AvatarProps> = ({ src, alt, fallback }) => (
1213
<RadixAvatar.Root className={styles.avatarRoot}>
1314
<RadixAvatar.Image
1415
loading="lazy"
1516
src={src}
1617
alt={alt}
18+
title={alt}
1719
className={styles.avatar}
1820
/>
1921
<RadixAvatar.Fallback delayMs={500} className={styles.avatar}>
20-
{alt}
22+
{fallback}
2123
</RadixAvatar.Fallback>
2224
</RadixAvatar.Root>
2325
);

apps/site/components/Common/AvatarGroup/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getAcronymFromString } from '@/util/stringUtils';
1111
import styles from './index.module.css';
1212

1313
type AvatarGroupProps = {
14-
avatars: Array<ComponentProps<typeof Avatar>>;
14+
avatars: Array<Omit<ComponentProps<typeof Avatar>, 'fallback'>>;
1515
limit?: number;
1616
isExpandable?: boolean;
1717
};
@@ -33,7 +33,8 @@ const AvatarGroup: FC<AvatarGroupProps> = ({
3333
{renderAvatars.map((avatar, index) => (
3434
<Avatar
3535
src={avatar.src}
36-
alt={getAcronymFromString(avatar.alt)}
36+
alt={avatar.alt}
37+
fallback={getAcronymFromString(avatar.alt)}
3738
key={index}
3839
/>
3940
))}

apps/site/components/withMetaBar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { useClientContext } from '@/hooks/react-client';
1010
import useMediaQuery from '@/hooks/react-client/useMediaQuery';
1111
import { DEFAULT_DATE_FORMAT } from '@/next.calendar.constants.mjs';
1212
import { getGitHubBlobUrl, getGitHubAvatarUrl } from '@/util/gitHubUtils';
13-
import { getAcronymFromString } from '@/util/stringUtils';
1413

1514
const WithMetaBar: FC = () => {
1615
const { headings, readingTime, frontmatter, filename } = useClientContext();
@@ -23,7 +22,7 @@ const WithMetaBar: FC = () => {
2322
frontmatter.authors?.split(',').map(author => author.trim()) ?? [];
2423
const avatars = usernames.map(username => ({
2524
src: getGitHubAvatarUrl(username),
26-
alt: getAcronymFromString(username),
25+
alt: username,
2726
}));
2827

2928
// Doing that because on mobile list on top of page and on desktop list on the right side

0 commit comments

Comments
 (0)