mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
28 lines
756 B
JavaScript
28 lines
756 B
JavaScript
import { useAnimation } from "framer-motion";
|
|
import React, { useEffect } from "react";
|
|
import { Flex } from "rebass";
|
|
import { AnimatedBox } from "../animated";
|
|
|
|
function ProgressBar(props) {
|
|
const { width, progress, duration = 1, onLoadingEnd, sx } = props;
|
|
const animation = useAnimation();
|
|
useEffect(() => {
|
|
animation.start({ width: `${progress}%`, transition: { duration } });
|
|
}, [animation, progress, duration]);
|
|
|
|
return (
|
|
<Flex overflow="hidden" width={width} sx={sx}>
|
|
<AnimatedBox
|
|
height={5}
|
|
initial={{ width: "0%" }}
|
|
animate={animation}
|
|
bg="primary"
|
|
sx={{ borderRadius: "default" }}
|
|
onAnimationComplete={onLoadingEnd}
|
|
/>
|
|
</Flex>
|
|
);
|
|
}
|
|
|
|
export default ProgressBar;
|