ConceptPortal-public/rsconcept/frontend/src/components/ui/Loader.tsx

34 lines
832 B
TypeScript
Raw Normal View History

'use client';
import { ThreeCircles, ThreeDots } from 'react-loader-spinner';
2023-07-15 17:46:19 +03:00
import { useConceptOptions } from '@/context/ConceptOptionsContext';
2024-03-20 15:27:32 +03:00
import AnimateFade from '../wrap/AnimateFade';
2024-01-07 03:29:16 +03:00
interface LoaderProps {
/** Scale of the loader from 1 to 10. */
scale?: number;
/** Show a circular loader. */
circular?: boolean;
}
/**
* Displays animated loader.
*/
function Loader({ scale = 5, circular }: LoaderProps) {
2024-04-01 19:07:20 +03:00
const { colors } = useConceptOptions();
2023-07-15 17:46:19 +03:00
return (
2024-01-07 03:29:16 +03:00
<AnimateFade noFadeIn className='flex justify-center'>
{circular ? (
<ThreeCircles color={colors.bgPrimary} height={scale * 20} width={scale * 20} />
) : (
<ThreeDots color={colors.bgPrimary} height={scale * 20} width={scale * 20} radius={scale * 2} />
)}
2024-01-07 03:29:16 +03:00
</AnimateFade>
2023-12-28 14:04:44 +03:00
);
}
2024-01-07 03:29:16 +03:00
export default Loader;