2022-03-21 11:09:01 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
import Stack from '../stack/stack';
|
|
|
|
import Text from '../text/text';
|
|
|
|
|
|
|
|
import './spinner.css';
|
|
|
|
|
2022-05-18 12:38:49 -07:00
|
|
|
interface ISpinner {
|
2022-04-30 21:39:58 -07:00
|
|
|
/** Width and height of the spinner in pixels. */
|
2022-03-21 11:09:01 -07:00
|
|
|
size?: number,
|
2022-04-30 21:39:58 -07:00
|
|
|
/** Whether to display "Loading..." beneath the spinner. */
|
2022-03-21 11:09:01 -07:00
|
|
|
withText?: boolean
|
|
|
|
}
|
|
|
|
|
2022-04-30 21:39:58 -07:00
|
|
|
/** Spinning loading placeholder. */
|
2022-05-18 12:38:49 -07:00
|
|
|
const Spinner = ({ size = 30, withText = true }: ISpinner) => (
|
2022-03-21 11:09:01 -07:00
|
|
|
<Stack space={2} justifyContent='center' alignItems='center'>
|
|
|
|
<div className='spinner' style={{ width: size, height: size }}>
|
|
|
|
{Array.from(Array(12).keys()).map(i => (
|
|
|
|
<div key={i}> </div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{withText && (
|
|
|
|
<Text theme='muted' tracking='wide'>
|
|
|
|
<FormattedMessage id='loading_indicator.label' defaultMessage='Loading…' />
|
|
|
|
</Text>
|
|
|
|
)}
|
|
|
|
</Stack>
|
|
|
|
);
|
|
|
|
|
2022-05-18 12:38:49 -07:00
|
|
|
export default Spinner;
|