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

37 lines
754 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%"
>
<SpinnerIcon {...props} />
</Center>
);
}
2022-12-19 15:59:14 -08:00
return <SpinnerIcon {...props} />;
};
Spinner.defaultProps = {
color: undefined,
size: 15,
};