Skip to content

Commit

Permalink
ui: Avatar 초기 프로필 이미지 관련 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
choyeon2e committed Jul 23, 2023
1 parent ae3ae1d commit 7d9cbf5
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 37 deletions.
22 changes: 0 additions & 22 deletions src/assets/image/ProfileImage.tsx

This file was deleted.

9 changes: 9 additions & 0 deletions src/assets/image/kitty_profile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/image/monkey_profile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions src/components/atoms/Avatar/Avatar.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ type Story = StoryObj<typeof meta>;
export const Xsmall: Story = {
args: {
variant: "xsmall",
color: "purple"
color: "purple",
imageUrl: "kitty",
}
};

export const Small: Story = {
args: {
variant: "small",
color: "purple"
color: "purple",
imageUrl: "kitty",
}
};

export const Medium: Story = {
args: {
variant: "medium",
color: "purple"
color: "purple",
imageUrl: "kitty",
}
};
48 changes: 36 additions & 12 deletions src/components/atoms/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import styled from "@emotion/styled";
import ProfileImage from "@assets/image/ProfileImage";
import { theme } from '@styles/theme';
import Kitty from "../../../assets/image/kitty_profile.svg";
import Monkey from "../../../assets/image/monkey_profile.svg"

type AvatarVariant =
| "xsmall"
| "small"
| "medium"
type AvatarVariant = "xsmall" | "small" | "medium";

type ColorVariant =
| "purple"
| "light"
type ColorVariant = "purple" | "light";

type ProfileVariant = "kitty" | "monkey";

type AvatarShapeType = {
[key in AvatarVariant]: {
Expand All @@ -24,11 +22,19 @@ type AvatarColorType = {
}
}

type ProfileImgType = {
[key in ProfileVariant]: {
imageUrl: string;
}
}

interface AvatarProps{
variant: AvatarVariant;
color: ColorVariant;
imageUrl: ProfileVariant;
}


const AVATAR_SIZE_TYPE: AvatarShapeType = {
xsmall: {
size: 36,
Expand All @@ -53,16 +59,24 @@ const AVATAR_COLOR_TYPE: AvatarColorType = {
}
}

const PROFILE_IMAGE_TYPE: ProfileImgType = {
kitty: {
imageUrl: Kitty,
},
monkey: {
imageUrl: Monkey,
},
}

export const Avatar = ({
variant,
color
}: AvatarProps) => {
color,
imageUrl
}: AvatarProps,) => {
return (
<Wrapper>
<AvatarCircle variant={variant} color={color}>
<ProfileImage
size={AVATAR_SIZE_TYPE[variant].profileSize}
<ProfileImages variant={variant} imageUrl={imageUrl}
/>
</AvatarCircle>
</Wrapper>
Expand All @@ -83,4 +97,14 @@ const AvatarCircle = styled.div<{
display: flex;
justify-content: center;
align-items: center;
`

const ProfileImages = styled.image<{
variant: AvatarVariant;
imageUrl: ProfileVariant;
}>`
width: ${({ variant }) => `${AVATAR_SIZE_TYPE[variant].profileSize}px`};
height: ${({ variant }) => `${AVATAR_SIZE_TYPE[variant].profileSize}px`};
background-image: url(${({ imageUrl }) => `${PROFILE_IMAGE_TYPE[imageUrl].imageUrl}`});
background-size: cover;
`

0 comments on commit 7d9cbf5

Please sign in to comment.