Skip to content

Commit 8b5f76a

Browse files
committed
feat: 취소 시 내용 초기화
1 parent 80de211 commit 8b5f76a

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

app/(with-sidebar)/write/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import Editor from '@/components/write/Editor';
2-
import SaveButton from '@/components/write/SaveButton';
32

43
const Page = () => {
54
return (
65
<div className="bg-background flex min-h-screen flex-col gap-8">
76
<Editor />
8-
<SaveButton />
97
</div>
108
);
119
};

components/write/Editor.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dynamic from 'next/dynamic';
44
import { useState } from 'react';
55
import type { MDEditorProps } from '@uiw/react-md-editor';
6+
import SaveButton from '@/components/write/SaveButton';
67

78
const MDEditor = dynamic<MDEditorProps>(() => import('@uiw/react-md-editor'), {
89
ssr: false,
@@ -11,10 +12,16 @@ const MDEditor = dynamic<MDEditorProps>(() => import('@uiw/react-md-editor'), {
1112
const Editor = () => {
1213
const [value, setValue] = useState<string>('');
1314

15+
const onClickCancel = () => {
16+
setValue('');
17+
};
18+
19+
const onClickSave = () => {};
20+
1421
return (
1522
<div
1623
data-color-mode="light"
17-
className="mx-auto mt-8 w-full max-w-5xl rounded-2xl px-4 [&_.w-md-editor]:border-0! [&_.w-md-editor]:bg-transparent! [&_.w-md-editor]:shadow-none [&_.w-md-editor-text]:bg-transparent! [&_.w-md-editor-toolbar]:bg-transparent! [&_.wmde-markdown]:bg-transparent!"
24+
className="mx-auto mt-8 flex w-full max-w-5xl flex-col gap-8 rounded-2xl px-4 [&_.w-md-editor]:border-0! [&_.w-md-editor]:bg-transparent! [&_.w-md-editor]:shadow-none [&_.w-md-editor-text]:bg-transparent! [&_.w-md-editor-toolbar]:bg-transparent! [&_.wmde-markdown]:bg-transparent!"
1825
>
1926
<MDEditor
2027
value={value}
@@ -30,6 +37,7 @@ const Editor = () => {
3037
return cmd;
3138
}}
3239
/>
40+
<SaveButton onClickCancel={onClickCancel} onClickSave={onClickSave} />
3341
</div>
3442
);
3543
};

components/write/SaveButton.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
const SaveButton = () => {
1+
type ButtonsProps = {
2+
onClickCancel: () => void;
3+
onClickSave: () => void;
4+
};
5+
6+
const SaveButton = ({ onClickCancel, onClickSave }: ButtonsProps) => {
27
return (
38
<div className="mx-auto flex h-10 w-3xs gap-6">
49
<button
10+
onClick={onClickSave}
511
type="button"
612
className="bg-primary flex-1 rounded-xl py-4 text-center text-base leading-0 font-semibold text-white shadow-sm transition hover:bg-violet-500 active:bg-violet-700 disabled:cursor-not-allowed disabled:opacity-60"
713
>
814
저장
915
</button>
1016

1117
<button
18+
onClick={onClickCancel}
1219
type="button"
1320
className="flex-1 rounded-xl border border-slate-300 bg-none py-4 text-center text-base leading-0 font-semibold text-slate-700 transition hover:bg-slate-200 active:bg-slate-300 disabled:cursor-not-allowed disabled:opacity-60"
1421
>

0 commit comments

Comments
 (0)