import { memo } from 'react'; import styled from '@emotion/styled'; import { keyframes, css } from '@emotion/react'; import { lighten } from 'polished'; import { primary, white } from 'styles/colors'; import { fontSize, fontWeight } from 'styles/fonts'; import { GROUND } from 'styles/zIndex'; const fillup = keyframes` from { width: 0; } to { width: 100%; } `; const Container = styled.div` position: relative; ${({ theme: { rtl } }) => rtl && css` direction: rtl; `} width: 100%; height: 2.625em; line-height: 2.625em; border-radius: 2px; background: ${lighten(0.3, primary.main)}; color: ${white}; font-size: ${fontSize.medium}; font-weight: ${fontWeight.bold}; cursor: not-allowed; `; const Progress = styled.div>` position: absolute; width: 0; height: 2.625em; border-radius: 2px; background: ${primary.main}; animation-name: ${fillup}; animation-duration: ${({ duration }) => duration}; animation-timing-function: linear; animation-fill-mode: forwards; `; const Label = styled.div` position: absolute; width: 100%; text-align: center; z-index: ${GROUND + 1}; `; interface Props { /** Label for the bar */ label?: string; /** Duration of the wait, may be specified in either seconds (s) or milliseconds (ms) */ duration?: string; /** String representing information related to the countdown */ title?: string; /** Rest Props */ [rest: string]: any; } /** * CountdownBar component is like progress bar for a fixed duration. * Commonly used when you need to delay user action/input/submission for a predetermined duration, * while providing a sense of progression to the user. */ const CountdownBar = ({ label = '', duration = '60000ms', title = '', ...rest }: Props) => ( ); export default memo(CountdownBar);