From 9445a624ad7811f1969c7433e2d7eb636a6f00d6 Mon Sep 17 00:00:00 2001 From: Team 1280 Programming Laptop <59985235+Team1280Programming@users.noreply.github.com> Date: Wed, 14 Feb 2024 16:38:54 -0800 Subject: [PATCH] Add document version chooser --- .../document/view/[slug]/DocumentViewer.tsx | 33 +++------- .../document/view/[slug]/VersionChooser.tsx | 62 +++++++++++++++++++ src/app/globals.css | 5 ++ 3 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 src/app/document/view/[slug]/VersionChooser.tsx diff --git a/src/app/document/view/[slug]/DocumentViewer.tsx b/src/app/document/view/[slug]/DocumentViewer.tsx index 4ecb327..e79fea9 100644 --- a/src/app/document/view/[slug]/DocumentViewer.tsx +++ b/src/app/document/view/[slug]/DocumentViewer.tsx @@ -1,4 +1,4 @@ -import { DocumentType, documents } from '@/app/db/data' +import { documents } from '@/app/db/data' import { Zilla_Slab } from 'next/font/google' import { epoch2datestring } from '@/app/utils/epoch2datestring' import { @@ -11,11 +11,14 @@ import { import { ItemBadge, Status } from '@/app/components/Badges' import Link from 'next/link' import { notFound } from 'next/navigation' +import VersionChooser from './VersionChooser' const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] }) -export default function DocumentViewer({ slug }: Readonly<{ slug: string }>) { - const { manifest, abstract, file, citation } = documents[slug] +const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => { + const doc = documents[slug] + const { manifest, abstract, file, citation } = doc + if (!manifest) return notFound() const { title, @@ -51,7 +54,7 @@ export default function DocumentViewer({ slug }: Readonly<{ slug: string }>) {

- + Revision {latest} @@ -78,25 +81,9 @@ export default function DocumentViewer({ slug }: Readonly<{ slug: string }>) { Cite as: {citation ? <>{citation} : <>eeXiv:{slug}}

- - - +
) } + +export default DocumentViewer diff --git a/src/app/document/view/[slug]/VersionChooser.tsx b/src/app/document/view/[slug]/VersionChooser.tsx new file mode 100644 index 0000000..918e1ee --- /dev/null +++ b/src/app/document/view/[slug]/VersionChooser.tsx @@ -0,0 +1,62 @@ +'use client' +import { useState } from 'react' +import { Document } from '@/app/db/data' +import Link from 'next/link' + +const VersionChooser = ({ + doc, + slug, +}: Readonly<{ doc: Document; slug: string }>) => { + const { file } = doc + const { + title, + authors, + topics, + dates, + references, + code, + type, + latest, + reviewers, + status, + } = doc.manifest + + const fileEnding = file === 'other' ? '' : `.${file}` + const [selectedRevision, setSelectedRevision] = useState(latest) // Initialize the selected revision with the latest revision + + return ( +
+ + + + +
+ ) +} + +export default VersionChooser diff --git a/src/app/globals.css b/src/app/globals.css index 678f2a8..3e7e485 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -20,6 +20,11 @@ a:hover { text-decoration: underline; } +option { + @apply font-sans; + @apply p-4; +} + .button-default { @apply bg-blue-600 text-slate-100 hover:bg-blue-400 font-semibold rounded py-2 px-4 my-2 shadow-sm shadow-slate-400; }