Skip to content

Commit

Permalink
Make avatars consistently circular
Browse files Browse the repository at this point in the history
Summary: The avatar shown in merge conflict source commit was not circular, because it was missing that style. The only other user of this <AvatarImg> had its own styles, which should really belong in the AvatarImg itself.

Reviewed By: sggutier

Differential Revision: D57290584

fbshipit-source-id: c0db2195923c465c116b3f73efea3f3ed260f9ec
  • Loading branch information
evangrayk authored and facebook-github-bot committed May 13, 2024
1 parent a75d0c3 commit 958c434
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
18 changes: 12 additions & 6 deletions addons/isl/src/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {DetailedHTMLProps} from 'react';
import serverAPI from './ClientToServerAPI';
import {t} from './i18n';
import {atomFamilyWeak, lazyAtom} from './jotaiUtils';
import {colors, radius} from './tokens.stylex';
import * as stylex from '@stylexjs/stylex';
import {useAtomValue} from 'jotai';

Expand All @@ -30,13 +31,15 @@ const avatarUrl = atomFamilyWeak((author: string) => {
export function AvatarImg({
url,
username,
xstyle,
...rest
}: {url?: string; username: string} & DetailedHTMLProps<
}: {url?: string; username: string; xstyle?: stylex.StyleXStyles} & DetailedHTMLProps<
React.ImgHTMLAttributes<HTMLImageElement>,
HTMLImageElement
>) {
return url == null ? null : (
<img
{...stylex.props(styles.circle, xstyle)}
src={url}
width={14}
height={14}
Expand All @@ -47,18 +50,21 @@ export function AvatarImg({
}

const styles = stylex.create({
empty: {
content: '',
circle: {
width: 14,
height: 14,
border: '2px solid',
borderRadius: radius.full,
borderColor: colors.fg,
},
empty: {
content: '',
backgroundColor: 'var(--foreground)',
borderRadius: '50%',
border: '1px solid var(--foreground)',
},
});

export function BlankAvatar() {
return <div {...stylex.props(styles.empty)} />;
return <div {...stylex.props(styles.circle, styles.empty)} />;
}

export function Avatar({
Expand Down
9 changes: 1 addition & 8 deletions addons/isl/src/codeReview/DiffComments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ const styles = stylex.create({
flexShrink: 0,
},
avatar: {
borderRadius: radius.full,
border: '2px solid',
borderColor: colors.fg,
marginBlock: spacing.half,
},
byline: {
Expand All @@ -101,11 +98,7 @@ function Comment({comment, isTopLevel}: {comment: DiffComment; isTopLevel?: bool
return (
<Row xstyle={styles.comment}>
<Column {...stylex.props(styles.left)}>
<AvatarImg
username={comment.author}
url={comment.authorAvatarUri}
{...stylex.props(styles.avatar)}
/>
<AvatarImg username={comment.author} url={comment.authorAvatarUri} xstyle={styles.avatar} />
</Column>
<Column xstyle={styles.commentInfo}>
<b {...stylex.props(styles.author)}>{comment.author}</b>
Expand Down

0 comments on commit 958c434

Please sign in to comment.