signal-desktop/ts/components/Spinner.tsx

56 lines
1.5 KiB
TypeScript
Raw Normal View History

// Copyright 2019-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import classNames from 'classnames';
2020-08-21 22:04:19 +00:00
export const SpinnerSvgSizes = ['small', 'normal'] as const;
export type SpinnerSvgSize = typeof SpinnerSvgSizes[number];
export const SpinnerDirections = [
'outgoing',
'incoming',
'on-background',
2020-10-06 17:06:34 +00:00
'on-progress-dialog',
'on-avatar',
2020-08-21 22:04:19 +00:00
] as const;
export type SpinnerDirection = typeof SpinnerDirections[number];
export type Props = {
2019-06-26 19:33:13 +00:00
size?: string;
2020-08-21 22:04:19 +00:00
svgSize: SpinnerSvgSize;
direction?: SpinnerDirection;
};
2020-09-12 00:46:52 +00:00
export const Spinner = ({ size, svgSize, direction }: Props): JSX.Element => (
<div
className={classNames(
'module-spinner__container',
`module-spinner__container--${svgSize}`,
direction ? `module-spinner__container--${direction}` : null,
direction ? `module-spinner__container--${svgSize}-${direction}` : null
)}
style={{
height: size,
width: size,
}}
>
<div
className={classNames(
'module-spinner__circle',
`module-spinner__circle--${svgSize}`,
direction ? `module-spinner__circle--${direction}` : null,
direction ? `module-spinner__circle--${svgSize}-${direction}` : null
)}
/>
<div
className={classNames(
'module-spinner__arc',
`module-spinner__arc--${svgSize}`,
direction ? `module-spinner__arc--${direction}` : null,
direction ? `module-spinner__arc--${svgSize}-${direction}` : null
)}
/>
</div>
);