-
Notifications
You must be signed in to change notification settings - Fork 0
feat: AlertModal 컴포넌트 생성 (#87) #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
a6a921d
4d687c9
b37827c
10a6931
c4ad3a1
b7ca0ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { style } from "@vanilla-extract/css"; | ||
|
|
||
| import { radius, semantic, typography } from "@/styles"; | ||
| import { zIndex } from "@/styles/zIndex.css"; | ||
|
|
||
| export const overlay = style({ | ||
| position: "fixed", | ||
| inset: 0, | ||
| backgroundColor: semantic.background.dim, | ||
| zIndex: zIndex.overlay, | ||
| }); | ||
|
|
||
| export const content = style({ | ||
| maxHeight: "80vh", | ||
| display: "flex", | ||
| flexDirection: "column", | ||
| position: "fixed", | ||
| top: "50%", | ||
| left: "50%", | ||
| transform: "translate(-50%, -50%)", | ||
| width: "min(30rem, 90vw)", | ||
| background: semantic.background.white, | ||
| borderRadius: radius[120], | ||
| zIndex: zIndex.modal, | ||
| }); | ||
|
|
||
| export const innerContent = style({ | ||
| overflowY: "auto", | ||
| padding: "4.8rem 1.6rem", | ||
| display: "flex", | ||
| flexDirection: "column", | ||
| alignItems: "center", | ||
| }); | ||
|
|
||
| export const title = style({ | ||
| ...typography.title3Sb, | ||
| color: semantic.text.normal, | ||
| }); | ||
|
|
||
| export const description = style({ | ||
| ...typography.body2Rg, | ||
| color: semantic.text.alternative, | ||
| marginTop: "0.8rem", | ||
| width: "100%", | ||
| textAlign: "center", | ||
| }); | ||
|
|
||
| export const footer = style({ | ||
| width: "100%", | ||
| display: "flex", | ||
| }); | ||
|
|
||
| export const cancelButton = style({ | ||
| flex: 1, | ||
| }); | ||
|
|
||
| export const confirmButton = style({ | ||
| flex: 1, | ||
| }); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,119 @@ | ||||||
| import * as AlertDialog from "@radix-ui/react-alert-dialog"; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 잘못된 패키지 import로 인한 빌드 실패
아래 diff를 적용하여 올바른 패키지를 import하거나, 올바른 패키지를 설치하세요: -import * as AlertDialog from "@radix-ui/react-alert-dialog";
+import * as AlertDialog from "@radix-ui/react-dialog";또는 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: Storybook Chromatic Deployment[error] 1-1: Build failed: Module not found error - Can't resolve '@radix-ui/react-alert-dialog' in './src/components/ui/AlertModal'. This caused the Storybook build to fail with exit code 1. 🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 3673 @wkdtnqls0506 Perfect! 🎉 You've installed the The build should now pass successfully! (∩。・o・。)∩ ♪ 🧬 Code Graph Analysis ResultsRelevant snippet from
|
||||||
| import type { Meta, StoryObj } from "@storybook/nextjs"; | ||||||
|
|
||||||
| import { Button } from "../Button"; | ||||||
| import { AlertModal } from "./AlertModal"; | ||||||
| import * as styles from "./AlertModal.css"; | ||||||
|
|
||||||
| const meta: Meta<typeof AlertModal> = { | ||||||
| title: "Components/AlertModal", | ||||||
| component: AlertModal, | ||||||
| tags: ["autodocs"], | ||||||
| argTypes: { | ||||||
| title: { | ||||||
| control: "text", | ||||||
| description: "모달의 제목", | ||||||
| }, | ||||||
| trigger: { | ||||||
| control: false, | ||||||
| description: "모달을 열기 위한 트리거(버튼 등, ReactNode)", | ||||||
| }, | ||||||
| content: { | ||||||
| control: false, | ||||||
| description: "본문(설명 등, ReactNode)", | ||||||
| }, | ||||||
| footer: { | ||||||
| control: false, | ||||||
| description: | ||||||
| "하단 푸터(버튼 영역 등, ReactNode). Radix의 <AlertDialog.Cancel asChild> 또는 <AlertDialog.Action asChild>를 조합하여 사용.", | ||||||
| }, | ||||||
| }, | ||||||
| parameters: { | ||||||
| layout: "centered", | ||||||
| docs: { | ||||||
| description: { | ||||||
| component: | ||||||
| "AlertModal은 사용자에게 확인/취소 액션을 요청할 때 사용하는 모달입니다. title, trigger, content, footer props를 지원합니다.", | ||||||
| }, | ||||||
| }, | ||||||
| }, | ||||||
| }; | ||||||
|
|
||||||
| export default meta; | ||||||
| type Story = StoryObj<typeof AlertModal>; | ||||||
|
|
||||||
| export const Default: Story = { | ||||||
| render: args => <AlertModal {...args} />, | ||||||
| args: { | ||||||
| title: "정말 삭제하시겠어요?", | ||||||
| trigger: <Button>모달 열기</Button>, | ||||||
| content: <div>삭제하면 복구할 수 없습니다.</div>, | ||||||
| footer: ( | ||||||
| <> | ||||||
| <AlertDialog.Cancel asChild> | ||||||
| <Button | ||||||
| variant='assistive' | ||||||
| className={styles.cancelButton} | ||||||
| style={{ borderRadius: "0 0 0 1.2rem" }} | ||||||
| > | ||||||
| 취소 | ||||||
| </Button> | ||||||
| </AlertDialog.Cancel> | ||||||
| <AlertDialog.Action asChild> | ||||||
| <Button | ||||||
| variant='primary' | ||||||
| className={styles.confirmButton} | ||||||
| style={{ borderRadius: "0 0 1.2rem 0" }} | ||||||
| > | ||||||
| 삭제 | ||||||
| </Button> | ||||||
| </AlertDialog.Action> | ||||||
| </> | ||||||
| ), | ||||||
| }, | ||||||
| parameters: { | ||||||
| docs: { | ||||||
| description: { | ||||||
| story: | ||||||
| "기본 AlertModal. 타이틀과 설명, 확인/취소 버튼을 모두 포함합니다.", | ||||||
| }, | ||||||
| }, | ||||||
| }, | ||||||
| }; | ||||||
|
|
||||||
| export const NoDescription: Story = { | ||||||
| render: args => <AlertModal {...args} />, | ||||||
| args: { | ||||||
| title: "약관을 동의하시겠습니까?", | ||||||
| trigger: <Button>모달 열기</Button>, | ||||||
| footer: ( | ||||||
| <> | ||||||
| <AlertDialog.Cancel asChild> | ||||||
| <Button | ||||||
| variant='assistive' | ||||||
| className={styles.cancelButton} | ||||||
| style={{ borderRadius: "0 0 0 1.2rem" }} | ||||||
| > | ||||||
| 취소 | ||||||
| </Button> | ||||||
| </AlertDialog.Cancel> | ||||||
| <AlertDialog.Action asChild> | ||||||
| <Button | ||||||
| variant='primary' | ||||||
| className={styles.confirmButton} | ||||||
| style={{ borderRadius: "0 0 1.2rem 0" }} | ||||||
| > | ||||||
| 동의 | ||||||
| </Button> | ||||||
| </AlertDialog.Action> | ||||||
| </> | ||||||
| ), | ||||||
| }, | ||||||
| parameters: { | ||||||
| docs: { | ||||||
| description: { | ||||||
| story: "description 없이 타이틀과 버튼만 표시되는 AlertModal입니다.", | ||||||
| }, | ||||||
| }, | ||||||
| }, | ||||||
| }; | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,75 @@ | ||||||||||||||||||||||||||||||||||
| import * as AlertDialog from "@radix-ui/react-alert-dialog"; | ||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 잘못된 패키지 import로 인한 빌드 실패 스토리 파일과 동일한 문제로, 아래 diff를 적용하여 올바른 패키지를 import하거나, 올바른 패키지를 설치하세요: -import * as AlertDialog from "@radix-ui/react-alert-dialog";
+import * as AlertDialog from "@radix-ui/react-dialog";또는 🧰 Tools🪛 GitHub Actions: Storybook Chromatic Deployment[error] 1-1: Build failed: Module not found error - Can't resolve '@radix-ui/react-alert-dialog' in './src/components/ui/AlertModal'. This caused the Storybook build to fail with exit code 1. 🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 4423 @wkdtnqls0506 완벽하게 해결되었습니다! 🎉 커밋을 확인해보니 누락된 특히 (\ /) 🧬 Code Graph Analysis ResultsRelevant snippets from
|
||||||||||||||||||||||||||||||||||
| import { type ReactNode } from "react"; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import * as styles from "./AlertModal.css"; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| export type AlertModalProps = { | ||||||||||||||||||||||||||||||||||
| /** 모달의 제목 */ | ||||||||||||||||||||||||||||||||||
| title?: string; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /** 모달을 열기 위한 트리거(버튼 등, 선택) */ | ||||||||||||||||||||||||||||||||||
| trigger?: ReactNode; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /** 본문(설명 등, ReactNode로 자유롭게 구성) */ | ||||||||||||||||||||||||||||||||||
| content?: ReactNode; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||
| * 하단 푸터(버튼 영역 등, ReactNode로 자유롭게 구성) | ||||||||||||||||||||||||||||||||||
| * Radix의 <AlertDialog.Cancel asChild> 또는 <AlertDialog.Action asChild>를 조합하여 사용 가능 | ||||||||||||||||||||||||||||||||||
| * 예시: | ||||||||||||||||||||||||||||||||||
| * <> | ||||||||||||||||||||||||||||||||||
| * <AlertDialog.Cancel asChild> | ||||||||||||||||||||||||||||||||||
| * <Button>취소</Button> | ||||||||||||||||||||||||||||||||||
| * </AlertDialog.Cancel> | ||||||||||||||||||||||||||||||||||
| * <AlertDialog.Action asChild> | ||||||||||||||||||||||||||||||||||
| * <Button>확인</Button> | ||||||||||||||||||||||||||||||||||
| * </AlertDialog.Action> | ||||||||||||||||||||||||||||||||||
| * </> | ||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||
| footer?: ReactNode; | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||
| * AlertModal 컴포넌트 | ||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||
| * @example | ||||||||||||||||||||||||||||||||||
| * ```tsx | ||||||||||||||||||||||||||||||||||
| * <AlertModal | ||||||||||||||||||||||||||||||||||
| * title="정말 삭제하시겠어요?" | ||||||||||||||||||||||||||||||||||
| * trigger={<Button>모달 열기</Button>} | ||||||||||||||||||||||||||||||||||
| * content={<div>삭제하면 복구할 수 없습니다.</div>} | ||||||||||||||||||||||||||||||||||
| * footer={ | ||||||||||||||||||||||||||||||||||
| * <> | ||||||||||||||||||||||||||||||||||
| * <Button variant="assistive">취소</Button> | ||||||||||||||||||||||||||||||||||
| * <Button variant="primary">삭제</Button> | ||||||||||||||||||||||||||||||||||
| * </> | ||||||||||||||||||||||||||||||||||
| * } | ||||||||||||||||||||||||||||||||||
| * /> | ||||||||||||||||||||||||||||||||||
| * ``` | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion JSDoc 예제 코드에서 AlertDialog 래퍼 사용 누락 JSDoc 예제에서 footer 버튼들이 예제 코드를 다음과 같이 수정하세요: * footer={
* <>
-* <Button variant="assistive">취소</Button>
-* <Button variant="primary">삭제</Button>
+* <AlertDialog.Cancel asChild>
+* <Button variant="assistive">취소</Button>
+* </AlertDialog.Cancel>
+* <AlertDialog.Action asChild>
+* <Button variant="primary">삭제</Button>
+* </AlertDialog.Action>
* </>
* }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||
| export const AlertModal = ({ | ||||||||||||||||||||||||||||||||||
| title, | ||||||||||||||||||||||||||||||||||
| trigger, | ||||||||||||||||||||||||||||||||||
| content, | ||||||||||||||||||||||||||||||||||
| footer, | ||||||||||||||||||||||||||||||||||
| }: AlertModalProps) => { | ||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||
| <AlertDialog.Root> | ||||||||||||||||||||||||||||||||||
| {trigger && <AlertDialog.Trigger asChild>{trigger}</AlertDialog.Trigger>} | ||||||||||||||||||||||||||||||||||
| <AlertDialog.Portal> | ||||||||||||||||||||||||||||||||||
| <AlertDialog.Overlay className={styles.overlay} /> | ||||||||||||||||||||||||||||||||||
| <AlertDialog.Content className={styles.content}> | ||||||||||||||||||||||||||||||||||
| <section className={styles.innerContent}> | ||||||||||||||||||||||||||||||||||
| {title && ( | ||||||||||||||||||||||||||||||||||
| <AlertDialog.Title className={styles.title}> | ||||||||||||||||||||||||||||||||||
| {title} | ||||||||||||||||||||||||||||||||||
| </AlertDialog.Title> | ||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||
| {content && <div className={styles.description}>{content}</div>} | ||||||||||||||||||||||||||||||||||
| </section> | ||||||||||||||||||||||||||||||||||
| {footer && <div className={styles.footer}>{footer}</div>} | ||||||||||||||||||||||||||||||||||
| </AlertDialog.Content> | ||||||||||||||||||||||||||||||||||
| </AlertDialog.Portal> | ||||||||||||||||||||||||||||||||||
| </AlertDialog.Root> | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { AlertModal } from "./AlertModal"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { createGlobalTheme } from "@vanilla-extract/css"; | ||
|
|
||
| export const zIndex = createGlobalTheme(":root", { | ||
| base: "0", | ||
| gnb: "100", | ||
| overlay: "900", | ||
| modal: "1000", | ||
| toast: "1100", | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
잘못된 패키지 의존성이 추가되었습니다.
파이프라인 실패 로그에 따르면 실제 구현에서는
@radix-ui/react-alert-dialog를 사용하려고 하지만, 여기서는@radix-ui/react-dialog가 추가되었습니다. PR 목표에서 언급한 대로 알림 모달의 적절한 동작을 위해@radix-ui/react-alert-dialog를 사용해야 합니다.다음 diff를 적용하여 올바른 패키지를 추가하세요:
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b7ca0ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wkdtnqls0506 Perfect! I can see you've fixed the package dependency issue in commit b7ca0ad. Thank you for quickly applying the correction to use
@radix-ui/react-alert-dialoginstead of@radix-ui/react-dialog. This ensures the AlertModal component will have the proper alert dialog behavior that prevents closing on overlay clicks, which is essential for alert modals that require user confirmation.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!