feishin/src/renderer/components/spinner/index.tsx

40 lines
809 B
TypeScript
Raw Normal View History

2023-06-02 13:07:30 -07:00
import { Center } from '@mantine/core';
2022-12-19 15:59:14 -08:00
import type { IconType } from 'react-icons';
import { RiLoader5Fill } from 'react-icons/ri';
import styled from 'styled-components';
import { rotating } from '/@/renderer/styles';
interface SpinnerProps extends IconType {
color?: string;
2023-06-02 13:07:30 -07:00
container?: boolean;
2022-12-19 15:59:14 -08:00
size?: number;
}
export const SpinnerIcon = styled(RiLoader5Fill)`
${rotating}
animation: rotating 1s ease-in-out infinite;
`;
export const Spinner = ({ ...props }: SpinnerProps) => {
2023-06-02 13:07:30 -07:00
if (props.container) {
return (
<Center
h="100%"
w="100%"
>
2023-06-03 00:39:52 -07:00
<SpinnerIcon
color={props.color}
size={props.size}
/>
2023-06-02 13:07:30 -07:00
</Center>
);
}
2022-12-19 15:59:14 -08:00
return <SpinnerIcon {...props} />;
};
Spinner.defaultProps = {
color: undefined,
size: 15,
};