Skip to content

Commit 38c4d4b

Browse files
authored
Merge pull request #36 from prgrms-web-devcourse-final-project/feat/toast#26
[feat] toast 구현
2 parents 93b8299 + 2c3f478 commit 38c4d4b

File tree

15 files changed

+181
-32
lines changed

15 files changed

+181
-32
lines changed

package-lock.json

Lines changed: 28 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"gsap": "^3.13.0",
2323
"next": "15.5.3",
2424
"react": "19.1.0",
25-
"react-dom": "19.1.0"
25+
"react-dom": "19.1.0",
26+
"react-hot-toast": "^2.6.0"
2627
},
2728
"devDependencies": {
2829
"@eslint/eslintrc": "^3",

src/app/design-system/page.tsx

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
import Button from '@/shared/components/button/Button';
44
import TextButton from '@/shared/components/button/TextButton';
5-
import ConfirmPop from '@/shared/components/ModalPop/ConfirmPop';
6-
import ModalLayout from '@/shared/components/ModalPop/ModalLayout';
5+
import ConfirmPop from '@/shared/components/modalPop/ConfirmPop';
6+
import ModalLayout from '@/shared/components/modalPop/ModalLayout';
77
import { useState } from 'react';
8+
import { customToast } from '@/shared/components/toast/CustomToastUtils';
89

910
function Page() {
1011
const [isModalOpen, setModalOpen] = useState(false);
1112
const [isConfirmOpen, setConfirmOpen] = useState(false);
1213

1314
return (
14-
<div className="p-6 space-y-6">
15+
<div className="p-6 space-y-6 bg-primary">
1516
{/* 페이지 제목 */}
1617
<h1 className="text-2xl font-bold border-b pb-2">Design System</h1>
1718

@@ -21,29 +22,29 @@ function Page() {
2122

2223
{/* Input */}
2324
<div className="flex flex-col gap-2 space-y-2">
24-
<h3 className="text-xl font-medium border-b pb-1">Input</h3>
25+
<h3 className="text-lg font-medium border-b pb-1">Input</h3>
2526
{/* 여기 컴포넌트 삽입 */}
2627
</div>
2728

2829
{/* checkbox */}
2930
<div className="space-y-2">
30-
<h3 className="text-xl font-medium border-b pb-1">checkbox</h3>
31+
<h3 className="text-lg font-medium border-b pb-1">checkbox</h3>
3132
{/* 여기 컴포넌트 삽입 */}
3233
</div>
3334

3435
{/* select */}
3536
<div className="space-y-2">
36-
<h3 className="text-xl font-medium border-b pb-1">select</h3>
37+
<h3 className="text-lg font-medium border-b pb-1">select</h3>
3738
{/* 여기 컴포넌트 삽입 */}
3839
</div>
3940
</div>
4041

4142
{/* Button */}
4243
<div className="space-y-3">
43-
<h2 className="text-2xl font-semibold border-b pb-1">Button</h2>
44+
<h2 className="text-2xl font-semibold pb-1">Button</h2>
4445

4546
<div className="space-y-2">
46-
<h3 className="text-xl font-medium border-b pb-1">Button</h3>
47+
<h3 className="text-lg font-medium border-b pb-1">Button</h3>
4748
<Button type="button">버튼</Button>
4849
<Button color="purple" type="button">
4950
Button
@@ -66,15 +67,36 @@ function Page() {
6667

6768
{/* popup */}
6869
<div className="space-y-3">
69-
<h2 className="text-2xl font-semibold border-b pb-1">popup</h2>
70+
<h2 className="text-2xl font-semibold pb-1">popup</h2>
7071

7172
<div className="space-y-2">
72-
<h3 className="text-xl font-medium border-b pb-1">toast</h3>
73-
{/* 여기 컴포넌트 삽입 */}
73+
<h3 className="text-lg font-medium border-b pb-1">toast</h3>
74+
<div className="flex gap-2">
75+
<button
76+
className="px-4 py-2 bg-green-300 text-black rounded"
77+
onClick={() => customToast.success('성공 메시지')}
78+
>
79+
Success Toast
80+
</button>
81+
82+
<button
83+
className="px-4 py-2 bg-yellow-100 text-black rounded"
84+
onClick={() => customToast.info('정보 메시지')}
85+
>
86+
Info Toast
87+
</button>
88+
89+
<button
90+
className="px-4 py-2 bg-red-200 text-black rounded"
91+
onClick={() => customToast.error('오류 메시지')}
92+
>
93+
Error Toast
94+
</button>
95+
</div>
7496
</div>
7597

7698
<div className="space-y-2">
77-
<h3 className="text-xl font-medium border-b pb-1">popup</h3>
99+
<h3 className="text-lg font-medium border-b pb-1">popup</h3>
78100
{/* 모달 열기 버튼 */}
79101
<button
80102
onClick={() => setModalOpen(true)}
@@ -94,7 +116,11 @@ function Page() {
94116
onClose={() => setModalOpen(false)}
95117
title="제목"
96118
description="설명"
97-
buttons={<>{/* 여기다가 버튼 컴포넌트 넣으면 됨 */}</>}
119+
buttons={
120+
<>
121+
<Button type="button">버튼</Button>
122+
</>
123+
}
98124
>
99125
<div>모달팝업 내용</div>
100126
</ModalLayout>

src/app/layout.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Metadata } from 'next';
22
import '@/shared/styles/global.css';
3+
import { Toaster } from 'react-hot-toast';
34
export const metadata: Metadata = {
45
title: 'SSOUL',
56
description: '칵테일을 좋아하는 사람들을 위한 서비스',
@@ -15,6 +16,16 @@ export default function RootLayout({
1516
<body>
1617
{children}
1718
<div id="modal-root"></div>
19+
<Toaster
20+
position="top-center"
21+
toastOptions={{
22+
duration: 2000,
23+
style: {
24+
minWidth: '340px',
25+
background: 'transparent',
26+
},
27+
}}
28+
/>
1829
</body>
1930
</html>
2031
);
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 9 additions & 0 deletions
Loading
Lines changed: 11 additions & 0 deletions
Loading
Lines changed: 9 additions & 0 deletions
Loading

src/shared/components/ModalPop/ConfirmPop.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Button from '../button/Button';
12
import ModalLayout from './ModalLayout';
23

34
interface Props {
@@ -19,8 +20,12 @@ function ConfirmPop({ ref, open, onClose, title, description, children }: Props)
1920
description={description}
2021
buttons={
2122
<>
22-
<button>취소</button>
23-
<button>확인</button>
23+
<Button type="button" size="sm">
24+
취소
25+
</Button>
26+
<Button type="button" size="sm" color="purple">
27+
확인
28+
</Button>
2429
</>
2530
}
2631
>

src/shared/components/ModalPop/ModalLayout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ function ModalLayout({
4646
<div className="fixed inset-0 bg-black/80 flex-center " onClick={onClose} aria-hidden="true">
4747
<div
4848
className={tw(
49-
'relative p-8 rounded-lg bg-bg-pop shadow-[0_4px_9px_0_rgba(255,255,255,0.25)]',
50-
size === 'sm' && 'p-5 w-[18.75rem]',
51-
size === 'md' && 'w-[31.25rem]'
49+
'relative w-[calc(100%-1.5rem)] p-8 rounded-lg bg-bg-pop shadow-[0_4px_9px_0_rgba(255,255,255,0.25)]',
50+
size === 'sm' && 'p-5 max-w-[18.75rem]',
51+
size === 'md' && 'max-w-[31.25rem]'
5252
)}
5353
ref={ref}
5454
aria-modal="true"

0 commit comments

Comments
 (0)