Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Modal = ({ isOpen, onClose, children, size = 'large', className }:
<div
ref={modalRef}
className={cn(
'relative z-50 w-full rounded-lg bg-white p-5 shadow-xl',
'relative z-50 w-full rounded-lg bg-white shadow-xl',
sizeClasses[size],
className,
)}
Expand Down
8 changes: 6 additions & 2 deletions src/components/common/AddButton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { cn } from '@/utils/cn';
import { CiCirclePlus } from 'react-icons/ci';

interface PlusButtonProps {
Expand All @@ -9,14 +10,17 @@ interface PlusButtonProps {
export default function AddButton({ className, onClick, label }: PlusButtonProps) {
return (
<button
className={`cursor-pointer ${className}`}
className={cn(
'cursor-pointer rounded-full p-2 transition-colors hover:bg-gray-200/70',
className,
)}
onClick={onClick}
aria-label={label}
name="add-button"
type="button"
title={label}
>
<CiCirclePlus size={30} />
<CiCirclePlus className="h-[20px] w-[20px] text-gray-500 hover:text-blue-500" />
</button>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ export default function LexicalMarkdownEditor({
};

return (
<div className="sm:h-[80%] h-[87%] w-full">
<div className="h-full w-full">
<LexicalComposer initialConfig={initialConfig}>
<div className="h-full flex flex-col relative">
<ToolbarPlugin />
<RichTextPlugin
contentEditable={
<ContentEditable
className={`flex-1 p-4 outline-none resize-none border border-gray-300 overflow-y-auto focus:border-blue-500 focus:ring-1 focus:ring-blue-500 ${
className={`flex-1 p-4 outline-none resize-none border rounded-b-lg border-gray-300 overflow-y-auto focus:border-blue-500 focus:ring-1 focus:ring-blue-500 ${
isMobile ? 'pb-20' : ''
}`}
onClick={handleContentEditableClick}
Expand Down
83 changes: 46 additions & 37 deletions src/components/memo-editor/MemoCreateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import CategoryModal from '@/components/category/CategoryModal';
import AddButton from '@/components/common/AddButton';
import CrossButton from '@/components/common/CrossButton';
import InputField from '@/components/common/InputField';
import LexicalMarkdownEditor from '@/components/memo-editor/LexicalMarkdownEditor/LexicalMarkdownEditor';
import MemoEditorSkeleton from '@/components/memo-editor/MemoEditorSkeleton';
import { Modal } from '@/components/Modal';
Expand Down Expand Up @@ -59,49 +58,59 @@ export default function MemoCreateModal({ onClose }: MemoCreateModalProps) {
aria-label="메모 생성"
aria-labelledby="memo-create-modal"
size="large"
className="max-w-4xl relative sm:h-[85%] h-full"
className="max-w-5xl w-full relative flex flex-col rounded-lg bg-white shadow-xl sm:h-[85vh] h-full border border-gray-100"
>
{isLoading ? (
<MemoEditorSkeleton />
) : (
<>
<div className="absolute top-1 right-1">
<CrossButton onClick={submitMemo} label="Close editor" />
<div className="flex h-full flex-col">
<div className="modal-header flex flex-shrink-0 items-center justify-end gap-2 border-gray-200 px-4 py-2">
<CrossButton onClick={submitMemo} label="Close editor" className="p-1.5" />
</div>
<div className="mb-2 mt-2">
<InputField
placeholder="제목"
name="title"
value={memoData.title}
variant="title"
onChange={handleChange}
/>
</div>
<div className="mb-4 relative">
<InputField
placeholder="카테고리"
name="category"
value={memoData.category}
onChange={handleChange}
/>
<AddButton
onClick={openCategoryModal}
className="absolute -top-1 right-0"
label="카테고리 추가"
/>
{isOpenCategoryModal && (
<div className="absolute top-4 right-1 z-51">
<CategoryModal onClose={() => setIsOpenCategoryModal(false)} />
<div className="modal-main flex flex-grow flex-col overflow-y-hidden pb-4 pl-4 pr-4">
<div className="flex flex-col gap-2">
<input
placeholder="제목을 입력하세요"
name="title"
value={memoData.title}
onChange={handleChange}
className="w-full bg-transparent px-2 py-1 text-3xl font-bold tracking-tight text-gray-900 focus:outline-none border-b-2 border-transparent focus:border-blue-500 placeholder:text-gray-400 transition-colors"
autoFocus
/>
<div className="flex items-center gap-2 px-2 py-1">
<span className="text-xs font-medium text-gray-500">Category:</span>
<div className="relative flex-1 max-w-[200px]">
<div className="absolute left-2 top-1/2 transform -translate-y-1/2 text-gray-400">
#
</div>
<input
placeholder="카테고리 추가"
name="category"
value={memoData.category}
onChange={handleChange}
className="w-full rounded-md border border-gray-200 bg-gray-50 px-6 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 placeholder:text-gray-400"
/>
<div className="absolute right-0 top-1/2 transform -translate-y-1/2">
<AddButton onClick={openCategoryModal} label="카테고리 추가" className="p-1" />
</div>
</div>
</div>
)}
{isOpenCategoryModal && (
<div className="absolute top-16 right-4 z-50">
<CategoryModal onClose={() => setIsOpenCategoryModal(false)} />
</div>
)}
</div>
<div className="h-full flex-grow pt-4">
<LexicalMarkdownEditor
placeholder="마크다운으로 메모를 작성해보세요..."
value={memoData.content}
onChange={newValue => setMemoData(prev => ({ ...prev, content: newValue || '' }))}
autoFocus={false}
/>
</div>
</div>
<LexicalMarkdownEditor
autoFocus
placeholder="내용을 입력하세요..."
value={memoData.content}
onChange={newValue => setMemoData(prev => ({ ...prev, content: newValue || '' }))}
/>
</>
</div>
)}
</Modal>
);
Expand Down
100 changes: 57 additions & 43 deletions src/components/memo-editor/MemoUpdateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import AddButton from '@/components/common/AddButton';
import CrossButton from '@/components/common/CrossButton';
import DeleteButton from '@/components/common/DeleteButton';
import InputField from '@/components/common/InputField';
import LexicalMarkdownEditor from '@/components/memo-editor/LexicalMarkdownEditor/LexicalMarkdownEditor';
import MemoEditorSkeleton from '@/components/memo-editor/MemoEditorSkeleton';
import { Modal } from '@/components/Modal';
Expand All @@ -22,7 +21,7 @@ export default function MemoUpdateModal({ onClose, id }: MemoUpdateModalProps) {
const { data: memo, isLoading, isError, isFetching } = useGetMemoById(id);
const { updateMemo } = useUpdateMemo();
const { deleteMemo } = useDeleteMemo();

const [memoData, setMemoData] = useState<{
id?: string;
title?: string;
Expand Down Expand Up @@ -93,61 +92,76 @@ export default function MemoUpdateModal({ onClose, id }: MemoUpdateModalProps) {
aria-label="메모 수정"
aria-labelledby="memo-update-modal"
size="large"
className="max-w-4xl relative sm:h-[85%] h-full"
className="max-w-5xl w-full relative flex flex-col rounded-lg bg-white shadow-xl sm:h-[85vh] h-full border border-gray-100"
>
{isError ? (
<div className="flex flex-col items-center justify-center h-full space-y-4">
<div className="text-red-500 text-center">메모를 불러오는 중 오류가 발생했습니다.</div>
<div className="flex h-full flex-col items-center justify-center space-y-4 p-6">
<div className="text-center text-red-600 font-medium">
메모를 불러오는 중 오류가 발생했습니다.
</div>
<button
onClick={() => handleUpdateMemo()}
className="px-4 py-2 bg-gray-700 text-white rounded"
className="rounded-md bg-gray-800 px-4 py-2 text-white text-sm transition-colors hover:bg-gray-900 focus:ring-2 focus:ring-gray-300 focus:outline-none"
>
다시 시도
</button>
<div className="absolute top-1 right-1">
<CrossButton onClick={handleClose} label="Close editor" />
<div className="absolute top-2 right-2">
<CrossButton onClick={handleClose} label="Close editor" className="p-1.5" />
</div>
</div>
) : isLoading || isFetching ? (
<MemoEditorSkeleton />
) : (
<>
<DeleteButton
onClick={handleDeleteMemo}
label="Delete memo"
className="absolute top-1 right-12"
/>
<div className="absolute top-1 right-1">
<CrossButton onClick={handleClose} label="Close editor" />
<div className="flex h-full flex-col">
<div className="modal-header flex flex-shrink-0 items-center justify-end gap-2 px-4 py-2">
<DeleteButton onClick={handleDeleteMemo} label="Delete memo" className="p-1.5" />
<CrossButton onClick={handleClose} label="Close editor" className="p-1.5" />
</div>
<div className="mb-2 mt-2">
<InputField
placeholder="제목"
name="title"
value={displayMemoData.title}
variant="title"
onChange={handleChange}
/>
<div className="modal-main flex flex-grow flex-col overflow-y-hidden pb-4 pl-4 pr-4">
<div className="flex flex-col gap-2">
<input
placeholder="제목을 입력하세요"
name="title"
value={displayMemoData.title}
onChange={handleChange}
className="w-full bg-transparent px-2 py-1 text-3xl font-bold tracking-tight text-gray-900 focus:outline-none border-b-2 border-transparent focus:border-blue-500 placeholder:text-gray-400 transition-colors"
autoFocus
/>
<div className="flex items-center gap-2 px-2 py-1">
<span className="text-xs font-medium text-gray-500">Category:</span>
<div className="relative flex-1 max-w-[200px]">
<div className="absolute left-2 top-1/2 transform -translate-y-1/2 text-gray-400">
#
</div>
<input
placeholder="카테고리 추가 or 변경"
name="category"
value={displayMemoData.category}
onChange={handleChange}
className="w-full rounded-md border border-gray-200 bg-gray-50 px-6 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 placeholder:text-gray-400"
/>
<div className="absolute right-0 top-1/2 transform -translate-y-1/2">
<AddButton
onClick={() => {
/* TODO: Implement category selection */
}}
label="카테고리 추가 or 변경"
className="p-1"
/>
</div>
</div>
</div>
</div>
<div className="h-full flex-grow pt-4">
<LexicalMarkdownEditor
value={displayMemoData.content}
onChange={handleMemoContentChange}
autoFocus={false}
placeholder="마크다운으로 메모를 작성해보세요..."
/>
</div>
</div>
<div className="mb-4 relative">
<InputField
placeholder="카테고리"
name="category"
value={displayMemoData.category}
onChange={handleChange}
/>
<AddButton
onClick={() => {}}
className="absolute -top-1 right-0"
label="카테고리 추가"
/>
</div>
<LexicalMarkdownEditor
value={displayMemoData.content}
onChange={handleMemoContentChange}
autoFocus={true}
/>
</>
</div>
)}
</Modal>
);
Expand Down