Skip to content

Commit

Permalink
프로덕션 배포 (#368)
Browse files Browse the repository at this point in the history
* chore: 간단한 UI 개선사항 반영 (#359)

* chore: background-size 지정

* chore: color 추가

* 아바타 컴포넌트 구현 (#350)

* feat: add Avatar and AvatarGroup component

* style: edit Avatar styles

* fix: 텍스트가 영역을 넘어가지 않도록 수정 (#367)

---------

Co-authored-by: Eunsu(Evan) Kim <[email protected]>
  • Loading branch information
100Gyeon and eunsukimme authored Aug 28, 2023
1 parent 43978aa commit 495b349
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/components/avatar/Avatar.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Meta, StoryObj } from '@storybook/react';

import Avatar from './Avatar';

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta: Meta<typeof Avatar> = {
title: 'Avatar',
component: Avatar,
tags: ['autodocs'],
};

export default meta;
type Story = StoryObj<typeof Avatar>;

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Default: Story = {
args: {
src: 'https://mui.com/static/images/avatar/1.jpg',
alt: 'Avatar',
},
};

export const CustomStyles: Story = {
args: {
src: 'https://mui.com/static/images/avatar/1.jpg',
alt: 'Avatar',
sx: {
width: '48px',
height: '48px',
},
},
};
29 changes: 29 additions & 0 deletions src/components/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CSSProperties } from 'react';
import { styled } from 'stitches.config';

interface AvatarProps {
src: string;
alt: string;
sx?: CSSProperties;
}

export default function Avatar({ src, alt, sx }: AvatarProps) {
return (
<SContainer style={sx}>
<SImage src={src} alt={alt} />
</SContainer>
);
}

const SContainer = styled('div', {
width: '32px',
height: '32px',
borderRadius: '50%',
overflow: 'hidden',
flexType: 'center',
});
const SImage = styled('img', {
width: '100%',
height: '100%',
objectFit: 'cover',
});
37 changes: 37 additions & 0 deletions src/components/avatar/AvatarGroup.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { Meta, StoryObj } from '@storybook/react';

import AvatarGroup from './AvatarGroup';
import Avatar from './Avatar';

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta: Meta<typeof AvatarGroup> = {
title: 'AvatarGroup',
component: AvatarGroup,
tags: ['autodocs'],
};

export default meta;
type Story = StoryObj<typeof AvatarGroup>;

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Default: Story = {
args: {
children: [
<Avatar
src="https://mui.com/static/images/avatar/1.jpg"
alt="sample iamge"
sx={{ width: '48px', height: '48px' }}
/>,
<Avatar
src="https://mui.com/static/images/avatar/2.jpg"
alt="sample iamge"
sx={{ width: '48px', height: '48px' }}
/>,
<Avatar
src="https://mui.com/static/images/avatar/3.jpg"
alt="sample iamge"
sx={{ width: '48px', height: '48px' }}
/>,
],
},
};
24 changes: 24 additions & 0 deletions src/components/avatar/AvatarGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Children, PropsWithChildren } from 'react';
import { styled } from 'stitches.config';

export default function AvatarGroup({ children }: PropsWithChildren) {
return (
<SContainer>
{Children.map(children, (child, index) => (
<SAvatarWrapper key={index} style={{ transform: `translateX(-${33 * index}%)` }}>
{child}
</SAvatarWrapper>
))}
</SContainer>
);
}

const SContainer = styled('div', {
display: 'flex',
alignItems: 'center',
});
const SAvatarWrapper = styled('div', {
'& > div': {
border: '3px solid $black100',
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ const SDetailText = styled('p', {
fontAg: '16_medium_150',
color: '$white100',
boxSizing: 'border-box',
wordBreak: 'break-word',
});

const SEmptyText = styled('p', {
Expand Down

0 comments on commit 495b349

Please sign in to comment.