Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hanyugeon committed Nov 7, 2023
2 parents a3501da + 12b35a6 commit 0450b41
Show file tree
Hide file tree
Showing 54 changed files with 3,392 additions and 1,913 deletions.
11 changes: 11 additions & 0 deletions .storybook/preview.ts → .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React from 'react';

import type { Preview } from '@storybook/react';
import '@/styles/global.css';

import ToastProvider from '../src/ui/Base/Toast/ToastProvider';

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
Expand All @@ -15,6 +19,13 @@ const preview: Preview = {
},
layout: 'fullscreen',
},
decorators: [
Story => (
<ToastProvider>
<Story />
</ToastProvider>
),
],
};

export default preview;
2 changes: 1 addition & 1 deletion public/icons/arrow-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/arrow-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions public/icons/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions public/icons/check-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions public/icons/comments.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export { default as IconCheck } from './check.svg';
export { default as IconComments } from './comments.svg';
export { default as IconDelete } from './delete.svg';
export { default as IconMembers } from './members.svg';
export { default as IconPlus } from './plus.svg';

// 카카오
export { default as IconKakao } from './kakao.svg';
4 changes: 2 additions & 2 deletions public/icons/members.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/icons/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions public/icons/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/constants/dataUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const DATA_URL = {
placeholder:
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjWL9+/X8ABysDDapsaG4AAAAASUVORK5CYII=', // data url for placeholder color (#AFAFAF)
};
21 changes: 21 additions & 0 deletions src/stories/Base/Avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Meta, StoryObj } from '@storybook/react';

import Avatar from '@/ui/Base/Avatar';

const meta: Meta<typeof Avatar> = {
title: 'Base/Avatar',
component: Avatar,
tags: ['autodocs'],
};

export default meta;

type Story = StoryObj<typeof Avatar>;

export const Default: Story = {
args: {},
};

export const WithSrc: Story = {
args: { src: '/icons/logo.svg', name: 'dadok', size: 'large' },
};
43 changes: 43 additions & 0 deletions src/stories/Base/Bookshelf/Bookshelf.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import Bookshelf from '@/ui/Bookshelf';
import { Meta, StoryObj } from '@storybook/react';

const meta: Meta<typeof Bookshelf> = {
title: 'Bookshelf/Bookshelf',
component: Bookshelf,
tags: ['autodocs'],
};

export default meta;

type Story = StoryObj<typeof Bookshelf>;

// TODO: 스토리북에서 이미지를 불러올 때 발생하는 CORS 이슈 해결
export const Default: Story = {
args: {
bookshelfId: 9,
bookshelfName: '백민종님의 책장',
books: [
{
bookId: 3,
title: '리액트를 다루는 기술',
imageUrl: '/images/book-cover/book1.jpeg',
},
{
bookId: 11,
title: '모던 자바스크립트 Deep Dive',
imageUrl: '/images/book-cover/book2.jpeg',
},
{
bookId: 22,
title: '이펙티브 타입스크립트',
imageUrl: '/images/book-cover/book3.jpeg',
},
{
bookId: 23,
title: '리팩터링 2판',
imageUrl: '/images/book-cover/book4.jpeg',
},
],
likeCount: 3,
},
};
48 changes: 8 additions & 40 deletions src/stories/Base/BottomNavigation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,21 @@ export default meta;
type Story = StoryObj<typeof BottomNavigation>;

export const Default: Story = {
parameters: {
nextjs: {
navigation: {
pathname: '/bookarchive',
},
},
},
render: () => {
return <BottomNavigation />;
},
args: { pathname: '/bookarchive' },
render: args => <BottomNavigation {...args} />,
};

export const Search: Story = {
parameters: {
nextjs: {
navigation: {
pathname: '/book/search',
},
},
},
render: () => {
return <BottomNavigation />;
},
args: { pathname: '/book/search' },
render: args => <BottomNavigation {...args} />,
};

export const Group: Story = {
parameters: {
nextjs: {
navigation: {
pathname: '/group',
},
},
},
render: () => {
return <BottomNavigation />;
},
args: { pathname: '/group' },
render: args => <BottomNavigation {...args} />,
};

export const Profile: Story = {
parameters: {
nextjs: {
navigation: {
pathname: '/profile/me',
},
},
},
render: () => {
return <BottomNavigation />;
},
args: { pathname: '/profile/me' },
render: args => <BottomNavigation {...args} />,
};
19 changes: 19 additions & 0 deletions src/stories/Base/FloatingButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Meta, StoryObj } from '@storybook/react';
import FloatingButton from '@/ui/Base/FloatingButton';

const meta: Meta<typeof FloatingButton> = {
title: 'Base/FloatingButton',
component: FloatingButton,
tags: ['autodocs'],
};

export default meta;

type Story = StoryObj<typeof FloatingButton>;

export const Default: Story = {
args: {
position: 'bottom-right',
},
render: args => <FloatingButton {...args} />,
};
62 changes: 62 additions & 0 deletions src/stories/Base/Toast.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Meta, StoryObj } from '@storybook/react';

import Button from '@/ui/Base/Button';
import useToast from '@/ui/Base/Toast/useToast';
import ToastItem from '@/ui/Base/Toast/ToastItem';

const meta: Meta<typeof ToastItem> = {
title: 'Base/Toast',
component: ToastItem,
tags: ['autodocs'],
};

export default meta;

type Story = StoryObj<typeof ToastItem>;

const NormalToast = () => {
const toast = useToast();
const handleButtonClick = () =>
toast.show({
type: 'normal',
message: '5초 동안 보여지는 토스트 메세지에요.',
duration: 5000,
});

return <Button onClick={handleButtonClick}>토스트 띄우기</Button>;
};

const SuccessToast = () => {
const toast = useToast();
const handleButtonClick = () =>
toast.show({ type: 'success', message: '링크가 복사되었어요' });

return <Button onClick={handleButtonClick}>링크 복사하기</Button>;
};

const ErrorToast = () => {
const toast = useToast();
const handleButtonClick = () =>
toast.show({ type: 'error', message: '잠시 후 다시 시도해주세요' });

return <Button onClick={handleButtonClick}>재시도</Button>;
};

export const Default: Story = {
args: {
message: '토스트 예시',
},
render: args => <ToastItem {...args} />,
};

export const Normal: Story = {
render: NormalToast,
};

export const Success: Story = {
render: SuccessToast,
};

export const Error: Story = {
render: ErrorToast,
};
Loading

0 comments on commit 0450b41

Please sign in to comment.