feat: add download btn to img preview dialog
This commit is contained in:
@@ -4,6 +4,7 @@ import { DialogTitle } from "@radix-ui/react-dialog"
|
|||||||
import { useQuery as useConvexQuery } from "convex/react"
|
import { useQuery as useConvexQuery } from "convex/react"
|
||||||
import { atom, useAtom, useAtomValue, useSetAtom } from "jotai"
|
import { atom, useAtom, useAtomValue, useSetAtom } from "jotai"
|
||||||
import {
|
import {
|
||||||
|
DownloadIcon,
|
||||||
Maximize2Icon,
|
Maximize2Icon,
|
||||||
Minimize2Icon,
|
Minimize2Icon,
|
||||||
XIcon,
|
XIcon,
|
||||||
@@ -86,7 +87,7 @@ function PreviewContent({
|
|||||||
<DialogHeader className="border-b border-b-border p-4 flex flex-row items-center justify-between">
|
<DialogHeader className="border-b border-b-border p-4 flex flex-row items-center justify-between">
|
||||||
<DialogTitle>{file.name}</DialogTitle>
|
<DialogTitle>{file.name}</DialogTitle>
|
||||||
<div className="flex flex-row items-center space-x-2">
|
<div className="flex flex-row items-center space-x-2">
|
||||||
<Toolbar />
|
<Toolbar fileUrl={fileUrl} file={file} />
|
||||||
<Button variant="ghost" size="icon" asChild>
|
<Button variant="ghost" size="icon" asChild>
|
||||||
<DialogClose>
|
<DialogClose>
|
||||||
<XIcon />
|
<XIcon />
|
||||||
@@ -102,7 +103,7 @@ function PreviewContent({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Toolbar() {
|
function Toolbar({ fileUrl, file }: { fileUrl: string; file: Doc<"files"> }) {
|
||||||
const setZoomLevel = useSetAtom(zoomLevelAtom)
|
const setZoomLevel = useSetAtom(zoomLevelAtom)
|
||||||
const zoomInterval = useRef<ReturnType<typeof setInterval> | null>(null)
|
const zoomInterval = useRef<ReturnType<typeof setInterval> | null>(null)
|
||||||
|
|
||||||
@@ -154,6 +155,17 @@ function Toolbar() {
|
|||||||
>
|
>
|
||||||
<ZoomOutIcon />
|
<ZoomOutIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button asChild>
|
||||||
|
<a
|
||||||
|
href={fileUrl}
|
||||||
|
download={file.name}
|
||||||
|
target="_blank"
|
||||||
|
className="flex flex-row items-center"
|
||||||
|
>
|
||||||
|
<DownloadIcon />
|
||||||
|
<span className="sr-only md:not-sr-only">Download</span>
|
||||||
|
</a>
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user