Show QR codes are toasts

This commit is contained in:
Ananth Venkatesh 2024-02-16 21:44:32 +00:00
parent bcf0a38b4e
commit 0205590b9f
3 changed files with 20 additions and 17 deletions

View file

@ -14,7 +14,6 @@ import generateHash from '@/app/utils/hash'
import { Suspense } from 'react' import { Suspense } from 'react'
import { loadDocument } from '@/app/db/loaders' import { loadDocument } from '@/app/db/loaders'
import { useSuspenseQuery } from '@tanstack/react-query' import { useSuspenseQuery } from '@tanstack/react-query'
import QRCode from 'qrcode.react'
const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] }) const zillaSlab = Zilla_Slab({ subsets: ['latin'], weight: ['500'] })
@ -49,20 +48,15 @@ const DocumentViewer = ({ slug }: Readonly<{ slug: string }>) => {
return ( return (
<div className='max-w-4xl lg:max-w-6xl mx-auto'> <div className='max-w-4xl lg:max-w-6xl mx-auto'>
<div> <h1
<div className='mr-8 mb-4 mt-4 hidden md:inline'> className={`
<QRCode value={citation ?? `eeXiv:${generateHash(slug)}`} /> text-slate-800 text-5xl mb-4
</div> ${zillaSlab.className}
<h1 text-wrap break-words hyphens-auto
className={` `}
text-slate-800 text-5xl mb-4 >
${zillaSlab.className} {title}
text-wrap break-words hyphens-auto </h1>
`}
>
{title}
</h1>
</div>
<p className={`text-slate-800 mt-2`}> <p className={`text-slate-800 mt-2`}>
<Authors authors={authors} /> <Authors authors={authors} />
</p> </p>

View file

@ -7,6 +7,7 @@ import { useSuspenseQuery } from '@tanstack/react-query'
import { epoch2date } from '@/app/utils/epoch2datestring' import { epoch2date } from '@/app/utils/epoch2datestring'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import generateHash from '@/app/utils/hash' import generateHash from '@/app/utils/hash'
import QRCode from 'qrcode.react'
const VersionChooser = ({ const VersionChooser = ({
doc, doc,
@ -51,9 +52,17 @@ const VersionChooser = ({
} }
const handleCopy = () => { const handleCopy = () => {
const id = doc.citation ? doc.citation : generateHash(slug) const id = doc.citation ? doc.citation.slice(6) : generateHash(slug)
navigator.clipboard.writeText(`eeXiv:${id}`) navigator.clipboard.writeText(`eeXiv:${id}`)
notifyCopied('Citation') notifyCopied('Citation')
toast.info((
<div className='p-4'>
<QRCode value={doc.citation ?? `eeXiv:${generateHash(slug)}`} />
</div>
), {
autoClose: false,
closeOnClick: true,
})
} }
return ( return (

View file

@ -77,7 +77,7 @@ export default function Page() {
let invalid = false let invalid = false
if (search.toLowerCase().startsWith('eexiv')) { if (search.toLowerCase().startsWith('eexiv:')) {
const id = search.slice(6) const id = search.slice(6)
if (id.length !== 12) { if (id.length !== 12) {