Skip to content

Commit

Permalink
ui: avatar 컴포넌트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
choyeon2e committed Jul 20, 2023
1 parent 8ea0608 commit ae3ae1d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
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 @@ -12,18 +12,21 @@ type Story = StoryObj<typeof meta>;

export const Xsmall: Story = {
args: {
variant: "xsmall"
variant: "xsmall",
color: "purple"
}
};

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

export const Medium: Story = {
args: {
variant: "medium"
variant: "medium",
color: "purple"
}
};
32 changes: 27 additions & 5 deletions src/components/atoms/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import styled from "@emotion/styled";
import ProfileImage from "@assets/image/ProfileImage";
import { theme } from '@styles/theme';

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

type ColorVariant =
| "purple"
| "light"

type AvatarShapeType = {
[key in AvatarVariant]: {
Expand All @@ -14,8 +18,15 @@ type AvatarShapeType = {
}
}

interface ButtonProps{
type AvatarColorType = {
[key in ColorVariant]: {
color: string;
}
}

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

const AVATAR_SIZE_TYPE: AvatarShapeType = {
Expand All @@ -33,13 +44,23 @@ const AVATAR_SIZE_TYPE: AvatarShapeType = {
}
}

const AVATAR_COLOR_TYPE: AvatarColorType = {
purple: {
color: "#D4B2FF"
},
light: {
color: `${theme.palette.purple_100}`
}
}


export const Avatar = ({
variant
}: ButtonProps) => {
variant,
color
}: AvatarProps) => {
return (
<Wrapper>
<AvatarCircle variant={variant}>
<AvatarCircle variant={variant} color={color}>
<ProfileImage
size={AVATAR_SIZE_TYPE[variant].profileSize}
/>
Expand All @@ -53,10 +74,11 @@ const Wrapper = styled.div`

const AvatarCircle = styled.div<{
variant: AvatarVariant;
color: ColorVariant;
}>`
width: ${({ variant }) => `${AVATAR_SIZE_TYPE[variant].size}px`};
height: ${({ variant }) => `${AVATAR_SIZE_TYPE[variant].size}px`};
background-color: #D4B2FF;
background-color: ${({color})=> `${AVATAR_COLOR_TYPE[color].color}`};
border-radius: 50%;
display: flex;
justify-content: center;
Expand Down

0 comments on commit ae3ae1d

Please sign in to comment.