diff --git a/froncik/components/Images.tsx b/froncik/components/Images.tsx index 49c4a4b..73f864d 100644 --- a/froncik/components/Images.tsx +++ b/froncik/components/Images.tsx @@ -8,6 +8,7 @@ import {TemplatesContext} from "./teplatesStore"; export default function Images({id, fields}: { id: number, fields: Record }) { const [images, loadImages] = useState(undefined) + const [updatingImages, setUpdatingImages] = useState(false); const ctx = useContext(TemplatesContext) const debouncedQuery = useCallback(_.debounce((fun) => @@ -18,21 +19,30 @@ export default function Images({id, fields}: { id: number, fields: Record { debouncedQuery( - () => API.labels.previewImages(id, fields) - .then((x) => { - x.json().then(x => loadImages(x.images)) - }) + () => { + setUpdatingImages(true) + API.labels.previewImages(id, fields) + .then((x) => { + x.json().then(x => loadImages(x.images)) + }) + .finally(() => setUpdatingImages(false)) + } ) }, [id, fields]) return images ? - (images.length == 1 ? : { - images.map(image => - - - - ) - }) + <> +
+ {images.length == 1 ? : { + images.map(image => + + + + ) + }} +
+ {updatingImages && } + :
Loading...
} diff --git a/froncik/public/preloader.svg b/froncik/public/preloader.svg new file mode 100644 index 0000000..49f065b --- /dev/null +++ b/froncik/public/preloader.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/froncik/styles/globals.css b/froncik/styles/globals.css index 4c97c93..7b84c9f 100644 --- a/froncik/styles/globals.css +++ b/froncik/styles/globals.css @@ -10,3 +10,17 @@ body.loading, body.loading * { width: 100%; text-align: right; } + +.preview-preloader { + height: 100%; + width: 100%; + position: absolute; +} + +.updating-images { + -webkit-filter: blur(2px); + -moz-filter: blur(2px); + -o-filter: blur(2px); + -ms-filter: blur(2px); + filter: blur(2px); +} \ No newline at end of file