feat: 공용 Alert 다이얼로그 비주얼 추가
Co-Authored-By: Claude Opus 5
@3988eac196e24f05fe6c3d00a973ebfa906cb29d
+++ components/ui/alert.tsx
... | ... | @@ -0,0 +1,39 @@ |
| 1 | +import type { ReactNode } from "react"; | |
| 2 | + | |
| 3 | +type AlertVariant = "info" | "danger"; | |
| 4 | + | |
| 5 | +const TITLE_TONE_CLASSES: Record<AlertVariant, string> = { | |
| 6 | + info: "text-foreground", | |
| 7 | + danger: "text-danger", | |
| 8 | +}; | |
| 9 | + | |
| 10 | +interface AlertProps { | |
| 11 | + variant?: AlertVariant; | |
| 12 | + title: string; | |
| 13 | + children?: ReactNode; | |
| 14 | + actions?: ReactNode; | |
| 15 | +} | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * 확인/경고 다이얼로그 비주얼(scrim 오버레이 + 패널). | |
| 19 | + * 열림/닫힘 여부는 호출부(feature)가 마운트/언마운트로 제어하고, 포커스 트랩도 | |
| 20 | + * 호출부 책임이다. 이 컴포넌트는 상태를 가지지 않는다. | |
| 21 | + */ | |
| 22 | +export function Alert({ variant = "info", title, children, actions }: AlertProps) { | |
| 23 | + return ( | |
| 24 | + <div className="fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4"> | |
| 25 | + <div | |
| 26 | + role="alertdialog" | |
| 27 | + aria-modal="true" | |
| 28 | + aria-label={title} | |
| 29 | + className="w-full max-w-sm animate-dialog-in rounded-xl bg-surface p-6 shadow-dialog" | |
| 30 | + > | |
| 31 | + <h2 className={`text-title-lg ${TITLE_TONE_CLASSES[variant]}`}>{title}</h2> | |
| 32 | + {children && ( | |
| 33 | + <div className="mt-2 text-body-md text-foreground-muted">{children}</div> | |
| 34 | + )} | |
| 35 | + {actions && <div className="mt-6 flex justify-end gap-2">{actions}</div>} | |
| 36 | + </div> | |
| 37 | + </div> | |
| 38 | + ); | |
| 39 | +} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?