Skip to content

Commit

Permalink
fix(accessibility): add right title/alt (#7094)
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustinMauroy authored Oct 8, 2024
1 parent c6e97a1 commit 5b77c34
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions apps/site/components/Common/AvatarGroup/Avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ import styles from './index.module.css';
export type AvatarProps = {
src: string;
alt: string;
fallback: string;
};

const Avatar: FC<AvatarProps> = ({ src, alt }) => (
const Avatar: FC<AvatarProps> = ({ src, alt, fallback }) => (
<RadixAvatar.Root className={styles.avatarRoot}>
<RadixAvatar.Image
loading="lazy"
src={src}
alt={alt}
title={alt}
className={styles.avatar}
/>
<RadixAvatar.Fallback delayMs={500} className={styles.avatar}>
{alt}
{fallback}
</RadixAvatar.Fallback>
</RadixAvatar.Root>
);
Expand Down
5 changes: 3 additions & 2 deletions apps/site/components/Common/AvatarGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getAcronymFromString } from '@/util/stringUtils';
import styles from './index.module.css';

type AvatarGroupProps = {
avatars: Array<ComponentProps<typeof Avatar>>;
avatars: Array<Omit<ComponentProps<typeof Avatar>, 'fallback'>>;
limit?: number;
isExpandable?: boolean;
};
Expand All @@ -33,7 +33,8 @@ const AvatarGroup: FC<AvatarGroupProps> = ({
{renderAvatars.map((avatar, index) => (
<Avatar
src={avatar.src}
alt={getAcronymFromString(avatar.alt)}
alt={avatar.alt}
fallback={getAcronymFromString(avatar.alt)}
key={index}
/>
))}
Expand Down
3 changes: 1 addition & 2 deletions apps/site/components/withMetaBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useClientContext } from '@/hooks/react-client';
import useMediaQuery from '@/hooks/react-client/useMediaQuery';
import { DEFAULT_DATE_FORMAT } from '@/next.calendar.constants.mjs';
import { getGitHubBlobUrl, getGitHubAvatarUrl } from '@/util/gitHubUtils';
import { getAcronymFromString } from '@/util/stringUtils';

const WithMetaBar: FC = () => {
const { headings, readingTime, frontmatter, filename } = useClientContext();
Expand All @@ -23,7 +22,7 @@ const WithMetaBar: FC = () => {
frontmatter.authors?.split(',').map(author => author.trim()) ?? [];
const avatars = usernames.map(username => ({
src: getGitHubAvatarUrl(username),
alt: getAcronymFromString(username),
alt: username,
}));

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

0 comments on commit 5b77c34

Please sign in to comment.