2024-01-05 15:01:45 -06:00
|
|
|
import { blackA } from '@radix-ui/colors';
|
2024-01-22 15:50:41 -06:00
|
|
|
import { Flex, Text } from '@radix-ui/themes';
|
2024-01-05 15:01:45 -06:00
|
|
|
import { PuffLoader } from 'react-spinners';
|
|
|
|
|
import { theme } from '../../../stitches.config';
|
|
|
|
|
|
|
|
|
|
const NAV_HEIGHT = 52.65;
|
|
|
|
|
|
|
|
|
|
interface LoaderProps {
|
|
|
|
|
naked?: boolean;
|
|
|
|
|
color?: string;
|
2024-01-22 15:50:41 -06:00
|
|
|
progress?: number;
|
2024-01-05 15:01:45 -06:00
|
|
|
}
|
|
|
|
|
|
2024-01-22 15:50:41 -06:00
|
|
|
export function Loader({ naked, color, progress }: LoaderProps) {
|
2024-01-05 15:01:45 -06:00
|
|
|
const animation = (
|
2024-01-22 15:50:41 -06:00
|
|
|
<div style={{ position: 'relative' }}>
|
|
|
|
|
{progress !== undefined && (
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
left: '50%',
|
|
|
|
|
top: '50%',
|
2024-01-22 16:04:06 -06:00
|
|
|
transform: 'translate(calc(-50% + 5px), calc(-50% + 5px))',
|
2024-01-22 15:50:41 -06:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{Math.round(progress * 100)}%
|
|
|
|
|
</Text>
|
|
|
|
|
)}
|
|
|
|
|
<PuffLoader color={color ?? theme.colors.solidBackground} />
|
|
|
|
|
</div>
|
2024-01-05 15:01:45 -06:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (naked) return animation;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Flex
|
|
|
|
|
style={{
|
|
|
|
|
backgroundColor: blackA.blackA10,
|
|
|
|
|
position: 'fixed',
|
|
|
|
|
top: NAV_HEIGHT,
|
|
|
|
|
left: 0,
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: `calc(100% - ${NAV_HEIGHT}px)`,
|
|
|
|
|
padding: theme.spaces.paddingMajor,
|
|
|
|
|
}}
|
|
|
|
|
align="center"
|
|
|
|
|
justify="center"
|
|
|
|
|
>
|
|
|
|
|
{animation}
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
}
|