import styled from '@emotion/styled';
import { css } from '@emotion/react';
import { primary, nobel } from 'styles/colors';
const Container = styled.div<{ step: number; totalSteps: number }>`
position: relative;
display: grid;
${({ step, totalSteps }) => {
const template: string[] = [];
for (let i = 1; i <= totalSteps; i += 1) {
template.push(step === i ? '25%' : '1fr');
}
return css`
grid-template-columns: ${template.join(' ')};
`;
}}
grid-template-rows: auto;
column-gap: 2px;
width: 100%;
height: 100%;
@keyframes load {
0% {
width: 0;
}
100% {
width: 100%;
}
}
`;
const Indicator = styled.div<{ step: number; index: number; color: string }>`
height: 100%;
border-radius: 999px;
${({ step, index, color }) =>
css`
background-color: ${step > index ? color : nobel[200]};
`}
${({ step, index, color }) =>
step === index
? css`
position: relative;
::after {
position: absolute;
content: '';
inset: 0;
border-radius: 999px;
background-color: ${color};
animation: 2s ease 0s infinite normal forwards running load;
}
`
: ''}
`;
interface Props {
/** current step */
step?: number;
/** Number of step */
totalSteps?: number;
/** Color of the StatusLoader */
color?: string;
}
/**
* StatusLoader component is used to indicate the order status.
*/
const StatusLoader = ({
step = 0,
totalSteps = 6,
color = primary.main,
}: Props) => {
// eslint-disable-next-line no-undef
const separators: JSX.Element[] = [];
for (let i = 1; i <= totalSteps; i += 1) {
separators.push();
}
return (
{separators}
);
};
export default StatusLoader;