From fba73099f53d70c6c61c4f5e2173026829e986ce Mon Sep 17 00:00:00 2001 From: Kevin Monisit Date: Thu, 16 Jan 2025 10:32:32 -0500 Subject: [PATCH] Huge note revamp; added markdown and note insertion into board --- app/components/NotesEditor.tsx | 111 +++ .../middlePanel/dashboard/ScheduleBoard.tsx | 94 +-- .../dashboard/components/NotesBox.tsx | 17 + .../components/ui/Container/Container.tsx | 4 + .../courseInfoDisplay/SemesterInfo.tsx | 4 +- .../components/NotesArea.tsx | 54 -- lib/defaultSettings.json | 6 +- lib/hooks/stores/useNotesStore.ts | 24 +- lib/hooks/stores/useSettingsStore.ts | 1 + package.json | 2 + pnpm-lock.yaml | 700 ++++++++++++++++++ tailwind.config.ts | 2 +- types/models.d.ts | 12 +- 13 files changed, 917 insertions(+), 114 deletions(-) create mode 100644 app/components/NotesEditor.tsx create mode 100644 app/features/middlePanel/dashboard/components/NotesBox.tsx delete mode 100644 app/features/rightPanel/courseInfoDisplay/components/NotesArea.tsx diff --git a/app/components/NotesEditor.tsx b/app/components/NotesEditor.tsx new file mode 100644 index 00000000..e9b9963f --- /dev/null +++ b/app/components/NotesEditor.tsx @@ -0,0 +1,111 @@ +import { useEffect, useRef, useState } from 'react'; +import Markdown from 'react-markdown'; +import { useNotesStore } from '@/lib/hooks/stores/useNotesStore'; + +interface NotesEditorProps { + id: string | number; + showDisplayOption?: boolean; + className?: string; + title?: string; +} + +export default function NotesEditor({ + id, + showDisplayOption = false, + title, +}: NotesEditorProps) { + const { notes, setNote } = useNotesStore(); + const [isEditing, setIsEditing] = useState(false); + const [editValue, setEditValue] = useState(notes[id]?.note || ''); + const [displayNextToSemester, setDisplayNextToSemester] = useState( + notes[id]?.displayNextToSemester || false + ); + const textAreaRef = useRef(null); + + useEffect(() => { + if (textAreaRef.current) { + textAreaRef.current.style.height = 'auto'; + textAreaRef.current.style.height = + textAreaRef.current.scrollHeight + 'px'; + } + }, [editValue, isEditing]); + + const handleSave = () => { + setNote(id, { + note: editValue, + displayNextToSemester, + }); + setIsEditing(false); + }; + + return ( +
+
+ {title &&

{title}

} + {!title &&

Notes:

} + +
+ + {showDisplayOption && ( +
+ { + setDisplayNextToSemester(e.target.checked); + setNote(id, { + note: editValue, + displayNextToSemester: e.target.checked, + }); + }} + className='mr-2' + /> + +
+ )} + + {isEditing ? ( +
+