Simplify PDF embed
This commit is contained in:
19
web/src/components/PDF/PDF.tsx
Normal file
19
web/src/components/PDF/PDF.tsx
Normal file
@ -0,0 +1,19 @@
|
||||
interface PDFProps {
|
||||
url: string
|
||||
form?: boolean
|
||||
}
|
||||
|
||||
const PDF = ({ url, form = false }: PDFProps) => (
|
||||
<embed
|
||||
src={url}
|
||||
title="PDF"
|
||||
type="application/pdf"
|
||||
style={{
|
||||
width: 'calc(100vw - 1rem)',
|
||||
height: `calc(100vh - ${form ? '8.5rem' : '6rem'})`,
|
||||
}}
|
||||
className="rounded-xl"
|
||||
/>
|
||||
)
|
||||
|
||||
export default PDF
|
@ -102,7 +102,7 @@ const PortraitForm = ({ portrait }: PortraitFormProps) => {
|
||||
return (
|
||||
<div className="mx-auto w-fit space-y-2">
|
||||
<img
|
||||
className="aspect-portrait max-w-2xl rounded-xl object-cover"
|
||||
className="aspect-portrait max-w-80 sm:max-w-sm md:max-w-md lg:max-w-lg xl:max-w-xl 2xl:max-w-2xl rounded-xl object-cover"
|
||||
src={portrait?.fileId}
|
||||
alt={`${process.env.FIRST_NAME} Portrait`}
|
||||
/>
|
||||
|
@ -1,26 +1,11 @@
|
||||
import { useState } from 'react'
|
||||
|
||||
import { Resume as ResumeType } from 'types/graphql'
|
||||
|
||||
import PDF from 'src/components/PDF/PDF'
|
||||
|
||||
interface ResumeProps {
|
||||
resume?: ResumeType
|
||||
}
|
||||
|
||||
const Resume = ({ resume }: ResumeProps) => {
|
||||
const [fileId] = useState<string>(resume?.fileId)
|
||||
|
||||
return (
|
||||
<object
|
||||
data={fileId}
|
||||
type="application/pdf"
|
||||
aria-label="Resume PDF"
|
||||
style={{
|
||||
width: 'calc(100vw - 1rem)',
|
||||
height: 'calc(100vh - 6rem)',
|
||||
}}
|
||||
className="rounded-xl"
|
||||
/>
|
||||
)
|
||||
}
|
||||
const Resume = ({ resume }: ResumeProps) => <PDF url={resume?.fileId} />
|
||||
|
||||
export default Resume
|
||||
|
@ -14,6 +14,7 @@ import type {
|
||||
import { TypedDocumentNode, useMutation } from '@redwoodjs/web'
|
||||
import { toast } from '@redwoodjs/web/toast'
|
||||
|
||||
import PDF from 'src/components/PDF/PDF'
|
||||
import Uploader from 'src/components/Uploader/Uploader'
|
||||
import { deleteFile, handleBeforeUnload } from 'src/lib/tus'
|
||||
|
||||
@ -100,16 +101,7 @@ const ResumeForm = ({ resume }: ResumeFormProps) => {
|
||||
if (resume?.fileId)
|
||||
return (
|
||||
<div className="mx-auto w-fit space-y-2">
|
||||
<object
|
||||
data={resume?.fileId}
|
||||
type="application/pdf"
|
||||
aria-label="Resume PDF"
|
||||
style={{
|
||||
width: 'calc(100vw - 1rem)',
|
||||
height: 'calc(100vh - 10rem)',
|
||||
}}
|
||||
className="rounded-xl"
|
||||
/>
|
||||
<PDF form url={resume?.fileId} />
|
||||
<div className="flex justify-center">
|
||||
<button
|
||||
type="button"
|
||||
@ -143,16 +135,7 @@ const ResumeForm = ({ resume }: ResumeFormProps) => {
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<object
|
||||
data={fileId}
|
||||
type="application/pdf"
|
||||
aria-label="Resume PDF"
|
||||
style={{
|
||||
width: 'calc(100vw - 1rem)',
|
||||
height: 'calc(100vh - 10rem)',
|
||||
}}
|
||||
className="rounded-xl"
|
||||
/>
|
||||
<PDF form url={fileId} />
|
||||
)}
|
||||
{fileId && (
|
||||
<div className="flex justify-center space-x-2">
|
||||
|
@ -97,7 +97,7 @@ const TitlesForm = ({ titles }: TitlesFormProps) => {
|
||||
<nav className="my-2 flex justify-center space-x-2">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm"
|
||||
className="btn btn-sm uppercase"
|
||||
onClick={() => setPreview(!preview)}
|
||||
>
|
||||
{preview ? 'Hide' : 'Show'} Preview
|
||||
|
Reference in New Issue
Block a user