signal-desktop/ts/components/Spinner.tsx

59 lines
1.6 KiB
TypeScript
Raw Normal View History

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',
] 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;
}
export class Spinner extends React.Component<Props> {
public render() {
2019-06-26 19:33:13 +00:00
const { size, svgSize, direction } = this.props;
return (
<div
className={classNames(
'module-spinner__container',
2019-06-26 19:33:13 +00:00
`module-spinner__container--${svgSize}`,
direction ? `module-spinner__container--${direction}` : null,
2019-06-26 19:33:13 +00:00
direction
? `module-spinner__container--${svgSize}-${direction}`
: null
)}
2019-06-26 19:33:13 +00:00
style={{
height: size,
width: size,
}}
>
<div
className={classNames(
'module-spinner__circle',
2019-06-26 19:33:13 +00:00
`module-spinner__circle--${svgSize}`,
direction ? `module-spinner__circle--${direction}` : null,
2019-06-26 19:33:13 +00:00
direction ? `module-spinner__circle--${svgSize}-${direction}` : null
)}
/>
<div
className={classNames(
'module-spinner__arc',
2019-06-26 19:33:13 +00:00
`module-spinner__arc--${svgSize}`,
direction ? `module-spinner__arc--${direction}` : null,
2019-06-26 19:33:13 +00:00
direction ? `module-spinner__arc--${svgSize}-${direction}` : null
)}
/>
</div>
);
}
}