| 23 | |
| 24 | /** A preview + download button for a file */ |
| 25 | export function FileInner({ resource }: ResourcePageProps) { |
| 26 | function handleDownload() { |
| 27 | window.open(downloadUrl); |
| 28 | } |
| 29 | |
| 30 | const [downloadUrl] = useString(resource, properties.file.downloadUrl); |
| 31 | const [bytes] = useNumber(resource, properties.file.filesize); |
| 32 | |
| 33 | const fileSizeString = bytes ? ` (${niceBytes(bytes)})` : ''; |
| 34 | |
| 35 | return ( |
| 36 | <div> |
| 37 | <ValueForm resource={resource} propertyURL={properties.description} /> |
| 38 | <Button onClick={handleDownload}>Download{fileSizeString}</Button> |
| 39 | <div> |
| 40 | <FilePreview resource={resource} /> |
| 41 | </div> |
| 42 | </div> |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | function FilePreview({ resource }: ResourcePageProps) { |
| 47 | const [url] = useString(resource, properties.file.downloadUrl); |