diff --git a/packages/ui-toolkit/src/components/atoms/ProgressBar/ProgressBar.tsx b/packages/ui-toolkit/src/components/atoms/ProgressBar/ProgressBar.tsx index 5d8deab6..6e789644 100644 --- a/packages/ui-toolkit/src/components/atoms/ProgressBar/ProgressBar.tsx +++ b/packages/ui-toolkit/src/components/atoms/ProgressBar/ProgressBar.tsx @@ -6,7 +6,6 @@ import { getIntegerRandomNoBetweenTwoNo } from '../../../utils/helper'; import './progressBar.css'; class ProgressBar extends React.PureComponent { - progressbarId = ''; @@ -20,29 +19,12 @@ class ProgressBar extends React.PureComponent { render() { const { isCircular } = this.props; - return ( - -
- { - isCircular ? this.getCircularProgressBar() : this.getLinearProgressBar() - } -
- -
- ); + return {isCircular ? this.getCircularProgressBar() : this.getLinearProgressBar()}; } getLinearProgressBar = () => { - const { - color, - backgroundColor, - containerThickness, - completedValue, - size, - fillerThickness, - borderRadius - } = this.props; + const { color, backgroundColor, containerThickness, completedValue, size, fillerThickness, borderRadius } = this.props; const containerStyle = { width: size, @@ -55,36 +37,23 @@ class ProgressBar extends React.PureComponent { height: fillerThickness, backgroundColor: color, borderRadius: borderRadius - }; return ( -
-
-
+ >
); - } + }; getCircularProgressBar = () => { - const { - color, - backgroundColor, - containerThickness, - completedValue, - size, - fillerThickness, - text, - addTextClass - } = this.props; + const { color, backgroundColor, containerThickness, completedValue, size, fillerThickness, text, addTextClass } = this.props; const textClass = addTextClass ? addTextClass : ''; @@ -96,7 +65,7 @@ class ProgressBar extends React.PureComponent { const dashArray = radius * Math.PI * 2; - const dashOffset = dashArray - (dashArray * completedValue / 100); + const dashOffset = dashArray - (dashArray * completedValue) / 100; const fillerStyle = { strokeDasharray: dashArray, @@ -106,13 +75,11 @@ class ProgressBar extends React.PureComponent { }; return ( - - { /> { - text && - - {text} - + text && ( + + {text} + + ) } - ); - - } + }; animateProgressBar = () => { @@ -153,7 +121,7 @@ class ProgressBar extends React.PureComponent { if (elem) { elem.style.display = 'block'; } - } + }; public static defaultProps: DefaultProps = { @@ -165,7 +133,7 @@ class ProgressBar extends React.PureComponent { text: '', addTextClass: '', size: '' - } + }; } @@ -190,7 +158,7 @@ type DefaultProps = { text styling allowed - Note: The text is added using and element and doesn't support the normal class styling please use fill instead of color and equivalent styling for element */ -} +}; type RequiredProps = { @@ -199,7 +167,7 @@ type RequiredProps = { /*percentage of the filled amount*/ completedValue: number; name: string; -} +}; export type Props = DefaultProps & RequiredProps; diff --git a/packages/ui-toolkit/src/components/atoms/ProgressBar/progressBar.css b/packages/ui-toolkit/src/components/atoms/ProgressBar/progressBar.css index d146dc46..c8ac78ec 100644 --- a/packages/ui-toolkit/src/components/atoms/ProgressBar/progressBar.css +++ b/packages/ui-toolkit/src/components/atoms/ProgressBar/progressBar.css @@ -1,12 +1,10 @@ .pb65LinearMain { border-radius: 5; - background-color: var(--gray150); height: 10px; } .pb65CircleMain { stroke-linecap: round; - stroke: var(--gray150); fill: none; } @@ -27,7 +25,6 @@ } .pb65MainTxt { - text-anchor: middle; font-size: 16px; } diff --git a/packages/ui-toolkit/stories/ProgressBar.stories.tsx b/packages/ui-toolkit/stories/ProgressBar.stories.tsx index 9d5f0828..d2a97614 100644 --- a/packages/ui-toolkit/stories/ProgressBar.stories.tsx +++ b/packages/ui-toolkit/stories/ProgressBar.stories.tsx @@ -1,8 +1,8 @@ import React from 'react'; -import { Story } from "@storybook/react"; +import { Story } from '@storybook/react'; import { ProgressBar } from '../src/components/atoms'; -import { Props as ProgressBarProps } from '../src/components/atoms/ProgressBar'; +import { Props as ProgressBarProps } from '../src/components/atoms/ProgressBar/ProgressBar'; export default { title: 'ProgressBar', @@ -10,17 +10,35 @@ export default { }; -export const Template: Story = (args) => { +const Template: Story = (args) => { return ( -
- +
+
); -} +}; + +export const Linear = Template.bind({}); +Linear.args = { + name: 'Linear Progress bar', + color: 'var(--purple500)', + fillerThickness: 8, + containerThickness: 5, + backgroundColor: 'var(--gray150)', + size: 420, + completedValue: 80 +}; -Template.args = { - name: "Demo ProgressBar", - color: "var(--purple500)", - fillerThickness: 10, - size: 420 -} +export const Circular = Template.bind({}); +Circular.args = { + name: 'Cicular progress bar', + isCircular: true, + color: 'var(--green500)', + backgroundColor: 'var(--gray150)', + text: 'Hello', + addTextClass: 'contentAccent', + fillerThickness: 6, + containerThickness: 2, + size: 100, + completedValue: 50 +};