Skip to content

Commit 4ec4501

Browse files
authored
Merge pull request #41 from geulDa/feat/#13/popup
✨Feat : 팝업 컴포넌트 구현
2 parents f76882b + 0886fdd commit 4ec4501

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

src/shared/common/Overlay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ interface OverlayProps {
44
className?: string;
55
}
66

7-
const Overlay = ({ onClick, opacity = 40, className }: OverlayProps) => {
7+
const Overlay = ({ onClick, opacity = 30, className }: OverlayProps) => {
88
return (
99
<div
1010
onClick={onClick}

src/shared/common/Popup.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { useState } from 'react';
2+
import { cn } from '@/shared/lib';
3+
4+
interface PopupProps {
5+
text: string;
6+
onClose?: () => void;
7+
}
8+
9+
export default function Popup({ text, onClose }: PopupProps) {
10+
const [visible, setVisible] = useState(true);
11+
const handleClose = () => {
12+
setVisible(false);
13+
onClose?.();
14+
};
15+
16+
if (!visible) return null;
17+
18+
return (
19+
<div
20+
className={cn(
21+
'px-[1.6rem] py-[1.5rem] w-[26.2rem] h-[12rem]',
22+
'bg-white border border-gray-200 rounded-[0.8rem]',
23+
'flex flex-col items-center justify-center gap-[1.4rem]',
24+
)}
25+
>
26+
<p className='text-title-sm text-gray-500'>{text}</p>
27+
<button className='text-title-md text-blue-400' onClick={handleClose}>
28+
확인
29+
</button>
30+
</div>
31+
);
32+
}

src/shared/common/PopupSet.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { useState } from 'react';
2+
import { cn } from '@/shared/lib';
3+
import Popup from '@/shared/common/Popup';
4+
import Overlay from '@/shared/common/Overlay';
5+
6+
interface PopupSetProps {
7+
text: string;
8+
onClose?: () => void;
9+
}
10+
11+
export default function PopupSet({ text, onClose }: PopupSetProps) {
12+
const [isOpen, setIsOpen] = useState(true);
13+
14+
const handleClose = () => {
15+
setIsOpen(false);
16+
onClose?.();
17+
};
18+
19+
if (!isOpen) return null;
20+
21+
return (
22+
<>
23+
<Overlay />
24+
{/* 중앙 고정 */}
25+
<div
26+
className={cn(
27+
'fixed inset-0 z-[50]',
28+
'flex items-center justify-center',
29+
)}
30+
>
31+
<Popup text={text} onClose={handleClose} />
32+
</div>
33+
</>
34+
);
35+
}

0 commit comments

Comments
 (0)