feat: add image zoom options (#984)
This commit is contained in:
@@ -10,6 +10,7 @@ import { Button } from '@/Components/Button/Button'
|
||||
import { Icon } from '@/Components/Icon'
|
||||
import { FilePreviewInfoPanel } from './FilePreviewInfoPanel'
|
||||
import { isFileTypePreviewable } from './isFilePreviewable'
|
||||
import { PreviewComponent } from './PreviewComponent'
|
||||
|
||||
type Props = {
|
||||
application: WebApplication
|
||||
@@ -17,22 +18,6 @@ type Props = {
|
||||
onDismiss: () => void
|
||||
}
|
||||
|
||||
const getPreviewComponentForFile = (file: SNFile, objectUrl: string) => {
|
||||
if (file.mimeType.startsWith('image/')) {
|
||||
return <img src={objectUrl} />
|
||||
}
|
||||
|
||||
if (file.mimeType.startsWith('video/')) {
|
||||
return <video className="w-full h-full" src={objectUrl} controls />
|
||||
}
|
||||
|
||||
if (file.mimeType.startsWith('audio/')) {
|
||||
return <audio src={objectUrl} controls />
|
||||
}
|
||||
|
||||
return <object className="w-full h-full" data={objectUrl} />
|
||||
}
|
||||
|
||||
export const FilePreviewModal: FunctionComponent<Props> = ({ application, file, onDismiss }) => {
|
||||
const [objectUrl, setObjectUrl] = useState<string>()
|
||||
const [isFilePreviewable, setIsFilePreviewable] = useState(false)
|
||||
@@ -132,9 +117,9 @@ export const FilePreviewModal: FunctionComponent<Props> = ({ application, file,
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-grow min-h-0 overflow-auto">
|
||||
<div className="flex flex-grow items-center justify-center">
|
||||
<div className="flex flex-grow items-center justify-center relative">
|
||||
{objectUrl ? (
|
||||
getPreviewComponentForFile(file, objectUrl)
|
||||
<PreviewComponent file={file} objectUrl={objectUrl} />
|
||||
) : isLoadingFile ? (
|
||||
<div className="sk-spinner w-5 h-5 spinner-info"></div>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user