Skip to content

Commit

Permalink
No bug: Set width/height on user avatars (#1432)
Browse files Browse the repository at this point in the history
It prevents the surrounding UI from jumping while the image is loading.
Relatedly, we're also making the alt= attribute empty to prevent
(rather meaningless) text from appearing during loading.
  • Loading branch information
mathjazz committed Oct 17, 2019
1 parent efc811f commit 01fd682
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
17 changes: 14 additions & 3 deletions frontend/src/core/user/components/UserMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@ export class UserMenuBase extends React.Component<Props, State> {
onClick={ this.toggleVisibility }
>
{ user.isAuthenticated ?
<img src={ user.gravatarURLSmall } alt="User avatar" /> :
<div className="menu-icon fa fa-bars" />
<img
src={ user.gravatarURLSmall }
alt=""
height="44"
width="44"
/>
:
<div className="menu-icon fa fa-bars" />
}
</div>

Expand All @@ -89,7 +95,12 @@ export class UserMenuBase extends React.Component<Props, State> {
<React.Fragment>
<li className="details">
<a href={ `/contributors/${user.username}/` }>
<img src={ user.gravatarURLBig } alt="User avatar" />
<img
src={ user.gravatarURLBig }
alt=""
height="88"
width="88"
/>
<p className="name">{ user.nameOrEmail }</p>
<p className="email">{ user.email }</p>
</a>
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/modules/history/components/Translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ export class TranslationBase extends React.Component<InternalProps, State> {
const { translation } = this.props;

if (!translation.uid) {
return <img src='/static/img/anon.jpg' alt='User avatar' />;
return <img
src='/static/img/logo.svg'
alt=''
height='44'
width='44'
/>;
}

return <a
Expand All @@ -137,7 +142,12 @@ export class TranslationBase extends React.Component<InternalProps, State> {
rel='noopener noreferrer'
onClick={ (e: SyntheticMouseEvent<>) => e.stopPropagation() }
>
<img src={ translation.user_gravatar_url_small } alt='User avatar' />
<img
src={ translation.user_gravatar_url_small }
alt=''
height='44'
width='44'
/>
</a>
}

Expand Down

0 comments on commit 01fd682

Please sign in to comment.