From 8263a84e40d2fb1eb262393cc87cf0c580a970f3 Mon Sep 17 00:00:00 2001 From: Richard Roberson Date: Sat, 18 Jan 2025 05:38:13 -0700 Subject: [PATCH] Working --- src/app/globals.css | 4 ++++ src/app/layout.tsx | 10 +++++++++- src/app/page.tsx | 14 +++++--------- src/app/pdf/[id]/page.tsx | 30 ++++++++++++----------------- src/components/DocumentList.tsx | 16 ++++++++-------- src/components/PDFUploader.tsx | 10 +++++----- src/components/PDFViewer.tsx | 34 +++++++++++++++++++++++++++++++-- src/context/PDFContext.tsx | 2 +- tailwind.config.ts | 2 ++ 9 files changed, 78 insertions(+), 44 deletions(-) diff --git a/src/app/globals.css b/src/app/globals.css index ae1b8dd..697735e 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -7,6 +7,8 @@ --foreground: #171717; --base: #f5f5f5; --offbase: #dbdbdb; + --accent: #ef4444; + --muted: #737373; } @media (prefers-color-scheme: dark) { @@ -15,6 +17,8 @@ --foreground: #ededed; --base: #333333; --offbase: #4a4a4a; + --accent: #f87171; + --muted: #a3a3a3; } } diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 60c9e34..6d67d8a 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -28,7 +28,15 @@ export default function RootLayout({ - {children} + +
+
+
+ {children} +
+
+
+
); diff --git a/src/app/page.tsx b/src/app/page.tsx index b23fa9f..6c78312 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -5,15 +5,11 @@ import { DocumentList } from '@/components/DocumentList'; export default function Home() { return ( -
-
-
-

PDF Reader

-
- - -
-
+
+

OpenReader WebUI

+
+ +
); diff --git a/src/app/pdf/[id]/page.tsx b/src/app/pdf/[id]/page.tsx index 0e5d6b9..3c5c2d9 100644 --- a/src/app/pdf/[id]/page.tsx +++ b/src/app/pdf/[id]/page.tsx @@ -9,7 +9,7 @@ export default function PDFViewerPage() { const { id } = useParams(); const { getDocument } = usePDF(); const router = useRouter(); - + const document = getDocument(id as string); if (!document) { @@ -17,13 +17,13 @@ export default function PDFViewerPage() {
-

Document not found. Please select a document from the home page.

+

Document not found. Please select a document from the home page.

- - + Back to Documents @@ -36,28 +36,22 @@ export default function PDFViewerPage() { } return ( -
-
-
- +
+
+ - + Documents -
-
-
-

{document.name}

-
-
- -
+

{document.name}

-
+ + ); } diff --git a/src/components/DocumentList.tsx b/src/components/DocumentList.tsx index a1c26c2..4e553db 100644 --- a/src/components/DocumentList.tsx +++ b/src/components/DocumentList.tsx @@ -6,7 +6,7 @@ export function DocumentList() { if (documents.length === 0) { return ( -
+
No documents uploaded yet
); @@ -14,32 +14,32 @@ export function DocumentList() { return (
-

Your Documents

-
+

Your Documents

+
{documents.map((doc) => (
- +
-

{doc.name}

-

+

{doc.name}

+

{(doc.size / 1024 / 1024).toFixed(2)} MB

diff --git a/src/context/PDFContext.tsx b/src/context/PDFContext.tsx index 0c158af..97096b7 100644 --- a/src/context/PDFContext.tsx +++ b/src/context/PDFContext.tsx @@ -43,7 +43,7 @@ export function PDFProvider({ children }: { children: ReactNode }) { reader.onloadend = () => { const base64Data = reader.result as string; const newDoc: PDFDocument = { - id: `${file.name}-${Date.now()}`, + id: `${file.name.replace(/[^a-zA-Z0-9]/g, '-').replace(/-+/g, '-')}-${Date.now()}`, name: file.name, size: file.size, lastModified: file.lastModified, diff --git a/tailwind.config.ts b/tailwind.config.ts index 10bca83..555205d 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -13,6 +13,8 @@ export default { foreground: "var(--foreground)", base: "var(--base)", offbase: "var(--offbase)", + accent: "var(--accent)", + muted: "var(--muted)", }, }, },