import React from 'react'; import { isNumber } from 'lodash'; import { Countdown } from '../Countdown'; import { Spinner } from '../Spinner'; export type STATE_ENUM = 'idle' | 'countdown' | 'loading'; export type Props = { state: STATE_ENUM; duration?: number; expiresAt?: number; onComplete?: () => unknown; }; const FAKE_DURATION = 1000; export class TimelineLoadingRow extends React.PureComponent { public renderContents(): JSX.Element { const { state, duration, expiresAt, onComplete } = this.props; if (state === 'idle') { const fakeExpiresAt = Date.now() - FAKE_DURATION; return ; } if (state === 'countdown' && isNumber(duration) && isNumber(expiresAt)) { return ( ); } return ; } public render(): JSX.Element { return (
{this.renderContents()}
); } }