2021-01-14 18:07:05 +00:00
|
|
|
// Copyright 2019-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// 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',
|
2021-01-29 22:16:48 +00:00
|
|
|
'on-avatar',
|
2020-08-21 22:04:19 +00:00
|
|
|
] as const;
|
|
|
|
export type SpinnerDirection = typeof SpinnerDirections[number];
|
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
export type Props = {
|
2021-01-29 22:58:28 +00:00
|
|
|
moduleClassName?: string;
|
|
|
|
direction?: SpinnerDirection;
|
2019-06-26 19:33:13 +00:00
|
|
|
size?: string;
|
2020-08-21 22:04:19 +00:00
|
|
|
svgSize: SpinnerSvgSize;
|
2021-01-14 18:07:05 +00:00
|
|
|
};
|
2019-01-30 20:15:07 +00:00
|
|
|
|
2021-01-29 22:58:28 +00:00
|
|
|
export const Spinner = ({
|
|
|
|
moduleClassName,
|
|
|
|
size,
|
|
|
|
svgSize,
|
|
|
|
direction,
|
|
|
|
}: Props): JSX.Element => (
|
2020-09-12 00:46:52 +00:00
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
'module-spinner__container',
|
|
|
|
`module-spinner__container--${svgSize}`,
|
|
|
|
direction ? `module-spinner__container--${direction}` : null,
|
2021-01-29 22:58:28 +00:00
|
|
|
direction ? `module-spinner__container--${svgSize}-${direction}` : null,
|
|
|
|
moduleClassName ? `${moduleClassName}__container` : null
|
2020-09-12 00:46:52 +00:00
|
|
|
)}
|
|
|
|
style={{
|
|
|
|
height: size,
|
|
|
|
width: size,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
'module-spinner__circle',
|
|
|
|
`module-spinner__circle--${svgSize}`,
|
|
|
|
direction ? `module-spinner__circle--${direction}` : null,
|
2021-01-29 22:58:28 +00:00
|
|
|
direction ? `module-spinner__circle--${svgSize}-${direction}` : null,
|
|
|
|
moduleClassName ? `${moduleClassName}__circle` : null
|
2020-09-12 00:46:52 +00:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
'module-spinner__arc',
|
|
|
|
`module-spinner__arc--${svgSize}`,
|
|
|
|
direction ? `module-spinner__arc--${direction}` : null,
|
2021-01-29 22:58:28 +00:00
|
|
|
direction ? `module-spinner__arc--${svgSize}-${direction}` : null,
|
|
|
|
moduleClassName ? `${moduleClassName}__arc` : null
|
2020-09-12 00:46:52 +00:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|