Portal/rsconcept/frontend/src/components/ui/Loader.tsx

43 lines
872 B
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
'use client';
import { ThreeCircles, ThreeDots } from 'react-loader-spinner';
import { useConceptOptions } from '@/context/ConceptOptionsContext';
2024-06-07 20:17:03 +03:00
interface LoaderProps {
/** Scale of the loader from 1 to 10. */
scale?: number;
/** Show a circular loader. */
2024-06-07 20:17:03 +03:00
circular?: boolean;
}
/**
* Displays animated loader.
*/
function Loader({ scale = 5, circular }: LoaderProps) {
2024-06-07 20:17:03 +03:00
const { colors } = useConceptOptions();
2024-12-11 14:59:04 +03:00
if (circular) {
return (
<ThreeCircles
color={colors.bgPrimary}
height={scale * 20}
width={scale * 20}
wrapperClass='flex justify-center'
/>
);
} else {
return (
<ThreeDots
color={colors.bgPrimary}
height={scale * 20}
width={scale * 20}
radius={scale * 2}
wrapperClass='flex justify-center'
/>
);
}
2024-06-07 20:17:03 +03:00
}
export default Loader;