2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2019-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-01-30 20:15:07 +00:00
|
|
|
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',
|
2020-08-21 22:04:19 +00:00
|
|
|
] as const;
|
|
|
|
export type SpinnerDirection = typeof SpinnerDirections[number];
|
|
|
|
|
|
|
|
export interface Props {
|
2019-06-26 19:33:13 +00:00
|
|
|
size?: string;
|
2020-08-21 22:04:19 +00:00
|
|
|
svgSize: SpinnerSvgSize;
|
|
|
|
direction?: SpinnerDirection;
|
2019-01-30 20:15:07 +00:00
|
|
|
}
|
|
|
|
|
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>
|
|
|
|
);
|