Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2169: Rename blog prop to url in PostAvatar, deal with optional value #2176

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/web/src/components/Posts/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ const PostComponent = ({ postUrl }: Props) => {
{!desktop && (
<>
<div className={classes.authorAvatarContainer}>
<PostAvatar name={post.feed.author} blog={post.feed.link} />
<PostAvatar name={post.feed.author} url={post.feed.link} />
</div>
<div className={classes.authorNameContainer}>
<h1 className={classes.author}>
Expand Down
22 changes: 15 additions & 7 deletions src/web/src/components/Posts/PostAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { makeStyles } from '@material-ui/core/styles';
type AvatarProps = {
name: string;
img?: string;
blog?: string;
url?: string;
};

const useStyles = makeStyles((theme: Theme) =>
Expand Down Expand Up @@ -39,7 +39,7 @@ const useStyles = makeStyles((theme: Theme) =>
})
);

const PostAvatar = ({ name, img, blog = '' }: AvatarProps) => {
const PostAvatar = ({ name, img, url }: AvatarProps) => {
const classes = useStyles();

if (img) {
Expand All @@ -58,11 +58,19 @@ const PostAvatar = ({ name, img, blog = '' }: AvatarProps) => {
)
.join('');
return (
<a href={blog} className={classes.link}>
<Avatar className={classes.avatar}>
<p className={classes.text}>{initials}</p>
</Avatar>
</a>
<div>
{url?.length ? (
<a href={url} className={classes.link}>
<Avatar className={classes.avatar}>
<p className={classes.text}>{initials}</p>
</Avatar>
</a>
) : (
<Avatar className={classes.avatar}>
<p className={classes.text}>{initials}</p>
</Avatar>
)}
</div>
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/web/src/components/Posts/PostInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const PostDesktopInfo = ({ authorName, postDate, blogUrl, postUrl }: Props) => {
return (
<ListSubheader className={classes.root}>
<div className={classes.authorAvatarContainer}>
<PostAvatar name={authorName} blog={blogUrl} />
<PostAvatar name={authorName} url={blogUrl} />
</div>
<div className={classes.authorNameContainer}>
<p className={classes.author}>
Expand Down
2 changes: 1 addition & 1 deletion src/web/src/components/SignUp/Forms/GitHubAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const GitHubAccount = connect<{}, SignUpForm>((props) => {
<div className={classes.avatarPreview}>
<PostAvatar
name={values.github.username || values.displayName}
blog={values.github.avatarUrl}
url={values.github.avatarUrl}
img={values.github?.avatarUrl}
/>
<h2 className={classes.username}>{values.github.username}</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/web/src/components/SignUp/Forms/Review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const Review = connect<{}, SignUpForm>((props) => {
<h1 className={classes.titlePage}>Review your Information</h1>
<div className={classes.contentContainer}>
<div className={classes.avatar}>
<PostAvatar name={displayName} blog={blogUrl} img={github.avatarUrl} />
<PostAvatar name={displayName} url={blogUrl} img={github.avatarUrl} />
<h2>{displayName}</h2>
</div>
<div className={classes.senecaBlogInfo}>
Expand Down