Skip to content

Commit bd97f0c

Browse files
authored
Merge pull request #37 from YAPP-Github/feat/#36
[FEAT] 공통 buttom sheet 컴포넌트 구현
2 parents 7b98e0b + d50b8cd commit bd97f0c

3 files changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type { Meta, StoryObj } from '@storybook/nextjs-vite';
2+
import { useState } from 'react';
3+
4+
import BottomSheet from './BottomSheet';
5+
6+
const meta: Meta<typeof BottomSheet> = {
7+
title: 'Shared/UI/BottomSheet',
8+
component: BottomSheet,
9+
parameters: {
10+
layout: 'fullscreen',
11+
},
12+
tags: ['autodocs'],
13+
};
14+
15+
export default meta;
16+
type Story = StoryObj<typeof BottomSheet>;
17+
18+
const BottomSheetWithHooks = () => {
19+
const [isOpen, setIsOpen] = useState(false);
20+
21+
return (
22+
<div className='flex h-screen w-full items-center justify-center bg-gray-100 p-4'>
23+
<button
24+
className='rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700'
25+
onClick={() => setIsOpen(true)}
26+
>
27+
Open BottomSheet
28+
</button>
29+
{isOpen && (
30+
<BottomSheet onClose={() => setIsOpen(false)}>
31+
<div className='px-5'>
32+
<h2 className='text-title-2 text-text-primary mb-2'>
33+
Bottom Sheet Title
34+
</h2>
35+
<p className='text-body-2 text-text-secondary'>
36+
Here is some content inside the bottom sheet. You can put anything
37+
here.
38+
</p>
39+
<div className='mt-4 flex flex-col gap-2'>
40+
<button className='bg-primary-default w-full rounded py-3 font-medium text-white'>
41+
Confirm
42+
</button>
43+
<button
44+
className='text-text-secondary w-full rounded bg-gray-100 py-3 font-medium'
45+
onClick={() => setIsOpen(false)}
46+
>
47+
Cancel
48+
</button>
49+
</div>
50+
</div>
51+
</BottomSheet>
52+
)}
53+
</div>
54+
);
55+
};
56+
57+
export const Default: Story = {
58+
render: () => <BottomSheetWithHooks />,
59+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { PropsWithChildren } from 'react';
2+
3+
import Icon from '../icon/Icon';
4+
5+
interface BottomSheetProps extends PropsWithChildren {
6+
onClose: () => void;
7+
}
8+
9+
export default function BottomSheet({ onClose, children }: BottomSheetProps) {
10+
return (
11+
<div className='bg-gray-0 flex w-full flex-col rounded-t-xl pb-5 shadow-lg'>
12+
<div className='flex w-full justify-end pt-4 pr-5'>
13+
<button
14+
type='button'
15+
onClick={onClose}
16+
className='text-text-primary flex h-6 w-6 items-center justify-center active:scale-95'
17+
aria-label='닫기'
18+
>
19+
<Icon name='ic_menu_close' size={24} />
20+
</button>
21+
</div>
22+
{children}
23+
</div>
24+
);
25+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as BottomSheet } from './BottomSheet';

0 commit comments

Comments
 (0)