image export fix

This commit is contained in:
Guy Ben-Aharon
2024-08-22 21:45:48 +03:00
parent 1e7987c957
commit f8c27a9e97
3 changed files with 29 additions and 11 deletions
@@ -49,7 +49,9 @@ export const ExportImageProvider: React.FC<React.PropsWithChildren> = ({
const exportImage: ExportImageContext['exportImage'] = useCallback(
async (type) => {
showLoader();
showLoader({
animated: false,
});
setNodes((nodes) =>
nodes.map((node) => ({ ...node, selected: false }))
@@ -2,7 +2,7 @@ import { createContext } from 'react';
import { emptyFn } from '@/lib/utils';
export interface FullScreenLoaderContext {
showLoader: () => void;
showLoader: (options?: { animated?: boolean }) => void;
hideLoader: () => void;
}
@@ -1,20 +1,30 @@
import React from 'react';
import { fullScreenLoaderContext } from './full-screen-spinner-context';
import {
FullScreenLoaderContext,
fullScreenLoaderContext,
} from './full-screen-spinner-context';
import { Dialog, DialogContent } from '@/components/dialog/dialog';
import { Spinner } from '@/components/spinner/spinner';
import { Hourglass } from 'lucide-react';
export const FullScreenLoaderProvider: React.FC<React.PropsWithChildren> = ({
children,
}) => {
const [open, setOpen] = React.useState(false);
const [animated, setAnimated] = React.useState(true);
const hideLoader = React.useCallback(() => {
setOpen(false);
}, []);
const hideLoader: FullScreenLoaderContext['hideLoader'] =
React.useCallback(() => {
setOpen(false);
}, []);
const showLoader = React.useCallback(() => {
setOpen(true);
}, []);
const showLoader: FullScreenLoaderContext['showLoader'] = React.useCallback(
(options) => {
setAnimated(options?.animated ?? true);
setOpen(true);
},
[]
);
return (
<fullScreenLoaderContext.Provider
@@ -25,8 +35,14 @@ export const FullScreenLoaderProvider: React.FC<React.PropsWithChildren> = ({
>
{children}
<Dialog open={open}>
<DialogContent className="shadow-none bg-transparent border-none outline-none">
<Spinner className="text-black" size={'large'} />
<DialogContent className="shadow-none bg-transparent border-none outline-none justify-center">
<div className="bg-white w-fit p-3 rounded-xl">
{animated ? (
<Spinner size={'large'} />
) : (
<Hourglass className="size-12" />
)}
</div>
</DialogContent>
</Dialog>
</fullScreenLoaderContext.Provider>