Update loading indicators with animation and unmount completion option

Updated the global loading and top loading bar indicators. For the global loading indicator, added zoom-in and fade-in animations. As for the top loading bar indicator, introduced an option to control whether to complete its progress once it's unmounted.
This commit is contained in:
giancarlo
2024-06-04 02:00:23 +07:00
parent bf7e3185de
commit 86e4bdcc7a
2 changed files with 14 additions and 14 deletions

View File

@@ -5,7 +5,11 @@ import { createRef, useEffect, useRef } from 'react';
import type { LoadingBarRef } from 'react-top-loading-bar';
import LoadingBar from 'react-top-loading-bar';
export function TopLoadingBarIndicator() {
export function TopLoadingBarIndicator({
completeOnUnmount = true,
}: {
completeOnUnmount?: boolean;
}) {
const ref = createRef<LoadingBarRef>();
const runningRef = useRef(false);
@@ -20,10 +24,12 @@ export function TopLoadingBarIndicator() {
runningRef.current = true;
return () => {
loadingBarRef.complete();
if (completeOnUnmount) {
loadingBarRef.complete();
}
runningRef.current = false;
};
}, [ref]);
}, [completeOnUnmount, ref]);
return (
<LoadingBar