From 49f38efdbe3718055d2c84847d7dab92ae359be9 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Tue, 1 Jul 2025 20:26:25 +0000 Subject: feat: Add a proper reader mode --- apps/web/app/reader/[bookmarkId]/page.tsx | 312 ++++++++++++++++++++++++++++++ 1 file changed, 312 insertions(+) create mode 100644 apps/web/app/reader/[bookmarkId]/page.tsx (limited to 'apps/web/app/reader') diff --git a/apps/web/app/reader/[bookmarkId]/page.tsx b/apps/web/app/reader/[bookmarkId]/page.tsx new file mode 100644 index 00000000..7c2b0c9e --- /dev/null +++ b/apps/web/app/reader/[bookmarkId]/page.tsx @@ -0,0 +1,312 @@ +"use client"; + +import { Suspense, useState } from "react"; +import { useRouter } from "next/navigation"; +import HighlightCard from "@/components/dashboard/highlights/HighlightCard"; +import ReaderView from "@/components/dashboard/preview/ReaderView"; +import { Button } from "@/components/ui/button"; +import { FullPageSpinner } from "@/components/ui/full-page-spinner"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { Separator } from "@/components/ui/separator"; +import { Slider } from "@/components/ui/slider"; +import { + HighlighterIcon as Highlight, + Minus, + Plus, + Printer, + Settings, + Type, + X, +} from "lucide-react"; + +import { api } from "@karakeep/shared-react/trpc"; +import { BookmarkTypes } from "@karakeep/shared/types/bookmarks"; +import { getBookmarkTitle } from "@karakeep/shared/utils/bookmarkUtils"; + +export default function ReaderViewPage({ + params, +}: { + params: { bookmarkId: string }; +}) { + const bookmarkId = params.bookmarkId; + const { data: highlights } = api.highlights.getForBookmark.useQuery({ + bookmarkId, + }); + const { data: bookmark } = api.bookmarks.getBookmark.useQuery({ + bookmarkId, + }); + + const router = useRouter(); + const [fontSize, setFontSize] = useState([18]); + const [lineHeight, setLineHeight] = useState([1.6]); + const [fontFamily, setFontFamily] = useState("serif"); + const [showHighlights, setShowHighlights] = useState(false); + const [showSettings, setShowSettings] = useState(false); + + const fontFamilies = { + serif: "ui-serif, Georgia, Cambria, serif", + sans: "ui-sans-serif, system-ui, sans-serif", + mono: "ui-monospace, Menlo, Monaco, monospace", + }; + + const onClose = () => { + if (window.history.length > 1) { + router.back(); + } else { + router.push("/dashboard"); + } + }; + + const handlePrint = () => { + window.print(); + }; + + return ( +
+ {/* Header */} +
+
+
+ + Reader View +
+ +
+ + + + + + + +
+
+ +

Reading Settings

+
+ +
+
+ + +
+ +
+
+ + + {fontSize[0]}px + +
+
+ + + +
+
+ +
+
+ + + {lineHeight[0]} + +
+ +
+
+
+
+
+ + +
+
+
+ +
+ {/* Mobile backdrop */} + {showHighlights && ( + +
+
+ + +
+
+ {highlights.highlights.map((highlight) => ( + + ))} +
+
+ + + )} + + + ); +} -- cgit v1.2.3-70-g09d2