Closes #5383 ## Light theme <img width="905" alt="image" src="https://github.com/twentyhq/twenty/assets/3098428/ab0683c5-ded3-420c-ace6-684d38794a2d"> ## Dark theme <img width="903" alt="image" src="https://github.com/twentyhq/twenty/assets/3098428/4e43ca35-438d-4ba0-8388-1f061c6ccfb0">
44 lines
1016 B
TypeScript
44 lines
1016 B
TypeScript
import { useState } from 'react';
|
|
import styled from '@emotion/styled';
|
|
import { motion } from 'framer-motion';
|
|
|
|
export type ProgressBarProps = {
|
|
className?: string;
|
|
color?: string;
|
|
value: number;
|
|
};
|
|
|
|
export type StyledBarProps = {
|
|
className?: string;
|
|
};
|
|
|
|
const StyledBar = styled.div<StyledBarProps>`
|
|
height: ${({ theme }) => theme.spacing(2)};
|
|
overflow: hidden;
|
|
width: 100%;
|
|
`;
|
|
|
|
const StyledBarFilling = styled(motion.div)<{ color?: string }>`
|
|
background-color: ${({ color, theme }) => color ?? theme.font.color.primary};
|
|
height: 100%;
|
|
`;
|
|
|
|
export const ProgressBar = ({ className, color, value }: ProgressBarProps) => {
|
|
const [initialValue] = useState(value);
|
|
|
|
return (
|
|
<StyledBar
|
|
className={className}
|
|
role="progressbar"
|
|
aria-valuenow={Math.ceil(value)}
|
|
>
|
|
<StyledBarFilling
|
|
initial={{ width: `${initialValue}%` }}
|
|
animate={{ width: `${value}%` }}
|
|
color={color}
|
|
transition={{ ease: 'linear' }}
|
|
/>
|
|
</StyledBar>
|
|
);
|
|
};
|