Profile redesign: Add alt to avatar and header (#38532)

This commit is contained in:
Echo 2026-04-02 16:47:11 +02:00 committed by GitHub
parent f90f1e3b75
commit 59299c69ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 12 additions and 3 deletions

View File

@ -37,6 +37,7 @@ export interface BaseApiAccountJSON {
acct: string; acct: string;
avatar: string; avatar: string;
avatar_static: string; avatar_static: string;
avatar_description: string;
bot: boolean; bot: boolean;
created_at: string; created_at: string;
discoverable?: boolean; discoverable?: boolean;
@ -50,6 +51,7 @@ export interface BaseApiAccountJSON {
group: boolean; group: boolean;
header: string; header: string;
header_static: string; header_static: string;
header_description: string;
id: string; id: string;
last_status_at: string; last_status_at: string;
locked: boolean; locked: boolean;

View File

@ -13,6 +13,7 @@ interface Props {
account: account:
| Pick<Account, 'id' | 'acct' | 'avatar' | 'avatar_static'> | Pick<Account, 'id' | 'acct' | 'avatar' | 'avatar_static'>
| undefined; // FIXME: remove `undefined` once we know for sure its always there | undefined; // FIXME: remove `undefined` once we know for sure its always there
alt?: string;
size?: number; size?: number;
style?: React.CSSProperties; style?: React.CSSProperties;
inline?: boolean; inline?: boolean;
@ -25,6 +26,7 @@ interface Props {
export const Avatar: React.FC<Props> = ({ export const Avatar: React.FC<Props> = ({
account, account,
alt = '',
animate = autoPlayGif, animate = autoPlayGif,
size = 20, size = 20,
inline = false, inline = false,
@ -65,7 +67,7 @@ export const Avatar: React.FC<Props> = ({
style={style} style={style}
> >
{src && !error && ( {src && !error && (
<img src={src} alt='' onLoad={handleLoad} onError={handleError} /> <img src={src} alt={alt} onLoad={handleLoad} onError={handleError} />
)} )}
{counter && ( {counter && (

View File

@ -72,7 +72,7 @@ export const AccountHeader: React.FC<{
modalType: 'IMAGE', modalType: 'IMAGE',
modalProps: { modalProps: {
src: account.avatar, src: account.avatar,
alt: '', alt: account.avatar_description,
}, },
}), }),
); );
@ -120,7 +120,7 @@ export const AccountHeader: React.FC<{
{!suspendedOrHidden && ( {!suspendedOrHidden && (
<img <img
src={autoPlayGif ? account.header : account.header_static} src={autoPlayGif ? account.header : account.header_static}
alt='' alt={account.header_description}
className='parallax' className='parallax'
/> />
)} )}
@ -147,6 +147,7 @@ export const AccountHeader: React.FC<{
> >
<Avatar <Avatar
account={suspendedOrHidden ? undefined : account} account={suspendedOrHidden ? undefined : account}
alt={account.avatar_description}
size={80} size={80}
/> />
</a> </a>

View File

@ -62,6 +62,7 @@ export const accountDefaultValues: AccountShape = {
acct: '', acct: '',
avatar: '', avatar: '',
avatar_static: '', avatar_static: '',
avatar_description: '',
bot: false, bot: false,
created_at: '', created_at: '',
discoverable: false, discoverable: false,
@ -78,6 +79,7 @@ export const accountDefaultValues: AccountShape = {
group: false, group: false,
header: '', header: '',
header_static: '', header_static: '',
header_description: '',
id: '', id: '',
last_status_at: '', last_status_at: '',
locked: false, locked: false,

View File

@ -25,6 +25,7 @@ export const accountFactory: FactoryFunction<ApiAccountJSON> = ({
acct: 'testuser', acct: 'testuser',
avatar: '/avatars/original/missing.png', avatar: '/avatars/original/missing.png',
avatar_static: '/avatars/original/missing.png', avatar_static: '/avatars/original/missing.png',
avatar_description: '',
username: 'testuser', username: 'testuser',
display_name: 'Test User', display_name: 'Test User',
bot: false, bot: false,
@ -42,6 +43,7 @@ export const accountFactory: FactoryFunction<ApiAccountJSON> = ({
group: false, group: false,
header: '/header.png', header: '/header.png',
header_static: '/header_static.png', header_static: '/header_static.png',
header_description: '',
indexable: true, indexable: true,
last_status_at: '2023-01-01', last_status_at: '2023-01-01',
locked: false, locked: false,