mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 06:27:19 +01:00
45 lines
781 B
TypeScript
45 lines
781 B
TypeScript
import React from 'react'
|
|
|
|
export default function Preview({
|
|
pdfIsLoading,
|
|
pdfError,
|
|
pdfUrl,
|
|
}: {
|
|
pdfIsLoading: boolean
|
|
pdfError: string
|
|
pdfUrl: string
|
|
}) {
|
|
if (pdfIsLoading) {
|
|
return <div>Lade…</div>
|
|
}
|
|
|
|
const errorStyles = {
|
|
padding: '6px 12px',
|
|
color: 'white',
|
|
backgroundColor: '#d81e1e',
|
|
borderRadius: '3px',
|
|
}
|
|
|
|
if (pdfError) {
|
|
return (
|
|
<div style={errorStyles}>
|
|
<span role="img" aria-label="Crying Man">
|
|
😢
|
|
</span>{' '}
|
|
{pdfError}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (!pdfUrl) {
|
|
return <div>Knopf drücken dann gibts hier was zu sehen!</div>
|
|
}
|
|
|
|
const styles = {
|
|
width: '700px',
|
|
height: '1050px',
|
|
}
|
|
|
|
return <embed src={pdfUrl} style={styles} type="application/pdf" />
|
|
}
|