From 1aadcd74204f391380cc8ebf3c1aab8c214e1d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=84=EC=A1=B0?= Date: Wed, 28 Aug 2024 12:42:31 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20WorkSpaceCreateModal=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EA=B5=AC=ED=98=84=20-=20S11P21S0?= =?UTF-8?q?02-74?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WorkSpaceCreateForm.tsx | 78 +++++++++++++++++++ .../WorkSpaceCreateModal/index.stories.tsx | 18 +++++ .../components/WorkSpaceCreateModal/index.tsx | 25 ++++++ 3 files changed, 121 insertions(+) create mode 100644 frontend/src/components/WorkSpaceCreateModal/WorkSpaceCreateForm.tsx create mode 100644 frontend/src/components/WorkSpaceCreateModal/index.stories.tsx create mode 100644 frontend/src/components/WorkSpaceCreateModal/index.tsx diff --git a/frontend/src/components/WorkSpaceCreateModal/WorkSpaceCreateForm.tsx b/frontend/src/components/WorkSpaceCreateModal/WorkSpaceCreateForm.tsx new file mode 100644 index 0000000..86a65fb --- /dev/null +++ b/frontend/src/components/WorkSpaceCreateModal/WorkSpaceCreateForm.tsx @@ -0,0 +1,78 @@ +import { zodResolver } from '@hookform/resolvers/zod'; +import { useForm } from 'react-hook-form'; +import { z } from 'zod'; +import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'; +import { Input } from '../ui/input'; +import { Button } from '../ui/button'; + +const formSchema = z.object({ + workspaceName: z.string().max(50).min(1, { + message: '이름을 입력해주세요.', + }), + workspaceDescription: z.string().max(200).optional(), +}); + +export type WorkSpaceCreateFormValues = z.infer; + +const defaultValues: Partial = { + workspaceName: '', + workspaceDescription: '', +}; + +export default function WorkSpaceCreateForm({ onSubmit }: { onSubmit: (data: WorkSpaceCreateFormValues) => void }) { + const form = useForm({ + resolver: zodResolver(formSchema), + defaultValues, + }); + + return ( +
+ + ( + + 워크스페이스 이름 + + + + + + )} + /> + ( + + 워크스페이스 설명 + + + + + + )} + /> + + + + ); +} diff --git a/frontend/src/components/WorkSpaceCreateModal/index.stories.tsx b/frontend/src/components/WorkSpaceCreateModal/index.stories.tsx new file mode 100644 index 0000000..691c782 --- /dev/null +++ b/frontend/src/components/WorkSpaceCreateModal/index.stories.tsx @@ -0,0 +1,18 @@ +import '@/index.css'; +import WorkSpaceCreateModal from '.'; + +export default { + title: 'Modal/WorkSpaceCreateModal', + component: WorkSpaceCreateModal, +}; + +export const Default = () => ( + { + console.log('close'); + }} + onSubmit={(data) => { + console.log(data); + }} + /> +); diff --git a/frontend/src/components/WorkSpaceCreateModal/index.tsx b/frontend/src/components/WorkSpaceCreateModal/index.tsx new file mode 100644 index 0000000..d9259b9 --- /dev/null +++ b/frontend/src/components/WorkSpaceCreateModal/index.tsx @@ -0,0 +1,25 @@ +import WorkSpaceCreateForm, { WorkSpaceCreateFormValues } from './WorkSpaceCreateForm'; +import XIcon from '@/assets/icons/x.svg?react'; + +export default function WorkSpaceCreateModal({ + onClose, + onSubmit, +}: { + onClose: () => void; + onSubmit: (data: WorkSpaceCreateFormValues) => void; +}) { + return ( +
+
+

새 워크스페이스

+ +
+ +
+ ); +}