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

Feat: user profile Avatar 공통 컴포넌트 구현 #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 15 additions & 1 deletion src/Menu/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import UserListItemCard from "@/common/components/UserListItemCard";
import UserProfileAvatar from "@/common/components/UserProfileAvatar";
import { css } from "@emotion/react";
import styled from "@emotion/styled";
import { Blockquote, Card, Checkbox, Flex, Heading, Radio, Text } from "@radix-ui/themes";
import {
Blockquote,
Card,
Checkbox,
Flex,
Heading,
Radio,
Text,
} from "@radix-ui/themes";
import { version } from "react";
import { Link } from "react-router";

Expand All @@ -10,6 +19,7 @@ export default function MenuPage() {
<>
{version}
<Card variant="surface">menu</Card>

<Checkbox defaultChecked />
<Heading size="6" css={css({ color: "red" })}>
heading
Expand Down Expand Up @@ -50,6 +60,10 @@ export default function MenuPage() {
<UserListItemCard>유저4</UserListItemCard>
</Flex>
</UserListContainer>

{/* fallback이 보여지는 케이스 -> 이미지 로딩 실패시 */}
<UserProfileAvatar size="9" />
<UserProfileAvatar src="https://picsum.photos/id/237/200/300" size="9" />
</>
);
}
Expand Down
20 changes: 20 additions & 0 deletions src/common/components/UserProfileAvatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Avatar, type AvatarProps } from "@radix-ui/themes";

type UserProfileAvatarProps = Omit<
AvatarProps,
"radius" | "variant" | "color" | "fallback"
>;
Comment on lines +3 to +6
Copy link
Member

Choose a reason for hiding this comment

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

연서언니가 달아준 제 pr 코리 내용에서의 이점과 결론처럼 interface 사용하는건 어떤가용?

Suggested change
type UserProfileAvatarProps = Omit<
AvatarProps,
"radius" | "variant" | "color" | "fallback"
>;
interface UserProfileAvatarProps extends Omit<
AvatarProps,
"radius" | "variant" | "color" | "fallback"
>{};

이것도 강제할 필요까지는 없겠지만 컨벤션 얘기할 때 한 번 얘기하고 가면 좋겠네요 ㅎㅎ


const UserProfileAvatar = ({ ...props }: UserProfileAvatarProps) => {
Copy link
Member

@seobbang seobbang Jan 24, 2025

Choose a reason for hiding this comment

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

여긴 다른 prop이 없어서 이렇게 해도 괜찮을 것 같네용
개인 취향이니 참고만 해주셔요!

Suggested change
const UserProfileAvatar = ({ ...props }: UserProfileAvatarProps) => {
const UserProfileAvatar = (props: UserProfileAvatarProps) => {

return (
<Avatar
radius="full"
variant="soft"
color="gray"
fallback={<>fallback image</>}
{...props}
/>
);
};

export default UserProfileAvatar;