Files
probo/packages/helpers/src/dom.ts
Jonathan 25b330f948 Load fileUrl on demand for evidence
Fix #168

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
2025-07-15 16:48:04 +02:00

23 lines
656 B
TypeScript

export function withViewTransition(fn: () => void) {
if (!document.startViewTransition) {
fn();
return;
}
document.startViewTransition(fn);
}
export function downloadFile(url: string | undefined | null, filename: string) {
if (!url) {
alert("Cannot download this file, fileUrl is not provided");
return;
}
const link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("hidden", "hidden");
link.setAttribute("download", filename);
link.style.display = "none";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}