diff --git a/src/app/notes/page.tsx b/src/app/notes/page.tsx new file mode 100644 index 0000000..b6043e6 --- /dev/null +++ b/src/app/notes/page.tsx @@ -0,0 +1,36 @@ +import React, { useState } from 'react'; +import Sidebar from '@/components/Sidebar'; +import NoteList from '@/components/NoteList'; +import AddNoteButton from '@/components/AddNoteButton'; +import Modal from '@/components/Modal'; +import NoteForm from '@/components/NoteForm'; + +function NotesPage() { + const [notes, setNotes] = useState([]); + const [isModalOpen, setIsModalOpen] = useState(false); + + const handleAddNote = (title: string, content: string) => { + setNotes([...notes, { title, date: new Date().toLocaleDateString() }]); + setIsModalOpen(false); + }; + + return ( +
+ + +
+

Notes

+
+ + setIsModalOpen(true)} /> +
+
+ + setIsModalOpen(false)}> + + +
+ ); +} + +export default NotesPage; diff --git a/src/components/AddNoteButton.tsx b/src/components/AddNoteButton.tsx new file mode 100644 index 0000000..d332d69 --- /dev/null +++ b/src/components/AddNoteButton.tsx @@ -0,0 +1,17 @@ +import React from 'react'; + +interface AddNoteButtonProps { + onClick: () => void; +} + +function AddNoteButton({ onClick }: AddNoteButtonProps) { + return ( + + ); +} + +export default AddNoteButton; diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx new file mode 100644 index 0000000..bd2c305 --- /dev/null +++ b/src/components/Modal.tsx @@ -0,0 +1,22 @@ +import React, { ReactNode } from 'react'; + +interface ModalProps { + isOpen: boolean; + onClose: () => void; + children: ReactNode; +} + +function Modal({ isOpen, onClose, children }: ModalProps) { + if (!isOpen) return null; + + return ( +
+
e.stopPropagation()}> + × + {children} +
+
+ ); +} + +export default Modal; diff --git a/src/components/NoteForm.tsx b/src/components/NoteForm.tsx new file mode 100644 index 0000000..82342c5 --- /dev/null +++ b/src/components/NoteForm.tsx @@ -0,0 +1,37 @@ +import React, { useState } from 'react'; + +interface NoteFormProps { + onSubmit: (title: string, content: string) => void; +} + +function NoteForm({ onSubmit }: NoteFormProps) { + const [title, setTitle] = useState(''); + const [content, setContent] = useState(''); + + const handleSubmit = (event: React.FormEvent) => { + event.preventDefault(); + onSubmit(title, content); + setTitle(''); + setContent(''); + }; + + return ( +
+
+ + setTitle(e.target.value)} className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" required /> +
+
+ + +
+
+ +
+
+ ); +} + +export default NoteForm; diff --git a/src/components/NoteItem.tsx b/src/components/NoteItem.tsx new file mode 100644 index 0000000..deed52a --- /dev/null +++ b/src/components/NoteItem.tsx @@ -0,0 +1,17 @@ +import React from 'react'; + +interface NoteItemProps { + title: string; + date: string; +} + +function NoteItem({ title, date }: NoteItemProps) { + return ( +
+
{title}
+
{date}
+
+ ); +} + +export default NoteItem; diff --git a/src/components/NoteList.tsx b/src/components/NoteList.tsx new file mode 100644 index 0000000..674b7ae --- /dev/null +++ b/src/components/NoteList.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import NoteItem from '@/components/NoteItem'; + +interface Note { + title: string; + date: string; +} + +interface NoteListProps { + notes: Note[]; +} + +function NoteList({ notes }: NoteListProps) { + return ( +
+ {notes.map((note, index) => ( + + ))} +
+ ); +} + +export default NoteList; diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx new file mode 100644 index 0000000..68823e4 --- /dev/null +++ b/src/components/Sidebar.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import Link from 'next/link'; + +interface SidebarProps { + activeItem: string; +} + +function Sidebar({ activeItem }: SidebarProps) { + return ( +
+
+
+ {/* User's initial, could be dynamically generated */} + O +
+ Gram Liu +
+
+ {/* Menu Items */} + Home + Physics + Chemistry +
+
+ ); +} + +export default Sidebar;