Skip to content
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
12 changes: 12 additions & 0 deletions packages/view/src/components/@common/Author/Author.const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const AVATAR_STYLE = {
width: 30,
height: 30,
minWidth: 30,
minHeight: 30,
} as const;

export const TOOLTIP_STYLE = {
".MuiTooltip-tooltip": {
bgcolor: "#3c4048",
},
} as const;
Comment on lines +1 to +12

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

legacy를 잘 파악하셨네요 😸

78 changes: 56 additions & 22 deletions packages/view/src/components/@common/Author/Author.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,68 @@ import type { AuthorInfo } from "types";

import { GITHUB_URL } from "../../../constants/constants";

import { AVATAR_STYLE, TOOLTIP_STYLE } from "./Author.const";

const isGitHubUser = (src: string): boolean => {
return src.startsWith(GITHUB_URL);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사소한 부분이지만 의미가 더 명확하게 변경되어서 좋은 것 같습니다ㅎㅎ

};

const getGitHubProfileUrl = (username: string): string => {
return `${GITHUB_URL}/${username}`;
};

const ClickableAvatar = ({ name, src }: AuthorInfo) => {
return (
<a
href={getGitHubProfileUrl(name)}
target="_blank"
rel="noopener noreferrer"
style={{ textDecoration: "none" }}
>
<Avatar
alt={name}
src={src}
sx={{ ...AVATAR_STYLE, cursor: "pointer" }}
/>
</a>
);
};

const StaticAvatar = ({ name, src }: AuthorInfo) => {
return (
<Avatar
alt={name}
src={src}
sx={AVATAR_STYLE}
/>
);
};

const AvatarComponent = ({ name, src }: AuthorInfo) => {
return isGitHubUser(src) ? (
<ClickableAvatar
name={name}
src={src}
/>
) : (
<StaticAvatar
name={name}
src={src}
/>
);
};

const Author = ({ name, src }: AuthorInfo) => {
const isUser = src.includes(GITHUB_URL);
return (
<Tooltip
title={name}
placement="top-start"
PopperProps={{ sx: { ".MuiTooltip-tooltip": { bgcolor: "#3c4048" } } }}
PopperProps={{ sx: TOOLTIP_STYLE }}
>
{isUser ? (
<a
href={`${GITHUB_URL}/${name}`}
target="_blank"
rel="noopener noreferrer"
style={{ textDecoration: "none" }}
>
<Avatar
alt={name}
src={src}
sx={{ width: 30, height: 30, minWidth: 30, minHeight: 30, cursor: "pointer" }}
/>
</a>
) : (
<Avatar
alt={name}
src={src}
sx={{ width: 30, height: 30, minWidth: 30, minHeight: 30 }}
/>
)}
<AvatarComponent
name={name}
src={src}
/>
</Tooltip>
);
};
Expand Down
Loading