diff --git a/src/components/ui/Progress/Progress.stories.js b/src/components/ui/Progress/Progress.stories.js new file mode 100644 index 00000000..29dec33e --- /dev/null +++ b/src/components/ui/Progress/Progress.stories.js @@ -0,0 +1,24 @@ + +import Progress from './Progress'; +import SandboxEditor from '~/components/tools/SandboxEditor/SandboxEditor'; + + +// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export +export default { + title: 'UI/Data Display/Progress', + component: Progress, + render: (args) => +
+ +
+
, +}; + +// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args +export const All = { + args: { + label: 'progress label', + maxValue: 100, + value: 45, + }, +}; diff --git a/src/components/ui/Progress/Progress.tsx b/src/components/ui/Progress/Progress.tsx new file mode 100644 index 00000000..d8ac5aa1 --- /dev/null +++ b/src/components/ui/Progress/Progress.tsx @@ -0,0 +1,34 @@ +import React, {useState, useEffect} from 'react'; + +interface ProgressProps { + value: number; + maxValue: number; + label: string; +} + +const Progress: React.FC = ({value, maxValue, label}) => { + console.log(label); + const [percentage, setPercentage] = useState(0); + + useEffect(() => { + const calculatedPercentage = (value / maxValue) * 100; + setPercentage(calculatedPercentage); + }, [value, maxValue]); + + return ( +
+
+ {label} +
+
+ ); +}; + +export default Progress;