Skip to content

Commit

Permalink
Remove loader when downloading the file (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 authored Jun 6, 2024
1 parent 02fa336 commit 7868898
Show file tree
Hide file tree
Showing 3 changed files with 4,595 additions and 4,518 deletions.
17 changes: 16 additions & 1 deletion ui-src/context/useFigma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ export const useFigma = (): UseFigmaHook => {
setDownloading(true);

const file = await parse(pluginMessage.data);
const blob = await file.export();

download(blob, `${pluginMessage.data.name}.zip`);

setExporting(false);
setDownloading(false);

file.export();
break;
}
case 'CUSTOM_FONTS': {
Expand Down Expand Up @@ -109,6 +114,16 @@ export const useFigma = (): UseFigmaHook => {
}
};

const download = (blob: Blob, name: string) => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');

a.href = url;
a.download = name;

a.click();
};

const reload = () => {
setLoading(true);
postMessage('reload');
Expand Down
Loading

0 comments on commit 7868898

Please sign in to comment.