From b6d4f49fd9bfd40ad0ff216b3fd93658e5aa17af Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Tue, 23 Dec 2025 03:47:17 +0100 Subject: [PATCH] feat: Add note viewing dialog and implement grid/list view toggle for notes. --- k-notes-frontend/src/components/note-card.tsx | 32 ++++++--- .../src/components/note-view-dialog.tsx | 65 +++++++++++++++++++ k-notes-frontend/src/pages/dashboard.tsx | 39 +++++++++-- 3 files changed, 124 insertions(+), 12 deletions(-) create mode 100644 k-notes-frontend/src/components/note-view-dialog.tsx diff --git a/k-notes-frontend/src/components/note-card.tsx b/k-notes-frontend/src/components/note-card.tsx index ed58714..58a9dea 100644 --- a/k-notes-frontend/src/components/note-card.tsx +++ b/k-notes-frontend/src/components/note-card.tsx @@ -12,6 +12,7 @@ import ReactMarkdown from "react-markdown"; import { getNoteColor } from "@/lib/constants"; import clsx from "clsx"; import { VersionHistoryDialog } from "./version-history-dialog"; +import { NoteViewDialog } from "./note-view-dialog"; interface NoteCardProps { note: Note; @@ -22,9 +23,11 @@ export function NoteCard({ note }: NoteCardProps) { const { mutate: updateNote } = useUpdateNote(); const [editing, setEditing] = useState(false); const [historyOpen, setHistoryOpen] = useState(false); + const [viewOpen, setViewOpen] = useState(false); // Archive toggle - const toggleArchive = () => { + const toggleArchive = (e: React.MouseEvent) => { + e.stopPropagation(); updateNote({ id: note.id, is_archived: !note.is_archived @@ -32,14 +35,16 @@ export function NoteCard({ note }: NoteCardProps) { }; // Pin toggle - const togglePin = () => { + const togglePin = (e: React.MouseEvent) => { + e.stopPropagation(); updateNote({ id: note.id, is_pinned: !note.is_pinned }); }; - const handleDelete = () => { + const handleDelete = (e: React.MouseEvent) => { + e.stopPropagation(); if (confirm("Are you sure?")) { deleteNote(note.id); } @@ -66,11 +71,14 @@ export function NoteCard({ note }: NoteCardProps) { return ( <> - + )} + onClick={() => setViewOpen(true)} + >
{note.title} @@ -94,10 +102,10 @@ export function NoteCard({ note }: NoteCardProps) { ))}
- - + + + + ); +} diff --git a/k-notes-frontend/src/pages/dashboard.tsx b/k-notes-frontend/src/pages/dashboard.tsx index b1b7f2d..3e6b99b 100644 --- a/k-notes-frontend/src/pages/dashboard.tsx +++ b/k-notes-frontend/src/pages/dashboard.tsx @@ -3,13 +3,18 @@ import { useNotes, useSearchNotes } from "@/hooks/use-notes"; import { CreateNoteDialog } from "@/components/create-note-dialog"; import { NoteCard } from "@/components/note-card"; import { Input } from "@/components/ui/input"; -import { Search } from "lucide-react"; +import { Search, LayoutGrid, List } from "lucide-react"; import { useLocation } from "react-router-dom"; +import { Button } from "@/components/ui/button"; +import clsx from "clsx"; export default function DashboardPage() { const location = useLocation(); const isArchive = location.pathname === "/archive"; + // View mode state + const [viewMode, setViewMode] = useState<"grid" | "list">("grid"); + // Search state const [searchQuery, setSearchQuery] = useState(""); @@ -36,7 +41,29 @@ export default function DashboardPage() { />
- {!isArchive && } +
+
+ + +
+ {!isArchive && } +
{/* Title */} @@ -65,8 +92,12 @@ export default function DashboardPage() { )} - {/* Notes Grid */} -
+ {/* Notes Grid/List */} +
{/* Pinned Notes First (if not searching and not archive) */} {!searchQuery && !isArchive && displayNotes?.filter((n: any) => n.is_pinned).map((note: any) => (