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

40 lines
907 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 {
2023-07-01 19:10:05 -07:00
color?: string;
container?: boolean;
size?: number;
2022-12-19 15:59:14 -08:00
}
export const SpinnerIcon = styled(RiLoader5Fill)`
2023-07-01 19:10:05 -07:00
${rotating}
animation: rotating 1s ease-in-out infinite;
2022-12-19 15:59:14 -08:00
`;
export const Spinner = ({ ...props }: SpinnerProps) => {
2023-07-01 19:10:05 -07:00
if (props.container) {
return (
<Center
h="100%"
w="100%"
>
<SpinnerIcon
color={props.color}
size={props.size}
/>
</Center>
);
}
2023-06-02 13:07:30 -07:00
2023-07-01 19:10:05 -07:00
return <SpinnerIcon {...props} />;
2022-12-19 15:59:14 -08:00
};
Spinner.defaultProps = {
2023-07-01 19:10:05 -07:00
color: undefined,
size: 15,
2022-12-19 15:59:14 -08:00
};