-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Merge pull request #27 from fayez-baig/comonent/ProgressBar
fix: progressbar component
- Loading branch information
Showing
10 changed files
with
151 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/components/Elements/ProgressBar/ProgressBar.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import { Story } from '@storybook/react/types-6-0'; | ||
import ProgressBar from './ProgressBar'; | ||
import { ProgressBarProps } from './types'; | ||
|
||
const Color = [ | ||
'default', | ||
'primary', | ||
'link', | ||
'info', | ||
'success', | ||
'warning', | ||
'danger' | ||
]; | ||
|
||
const SizeValues = ['default', 'small', 'medium', 'large']; | ||
|
||
export default { | ||
argTypes: { | ||
color: { | ||
control: { | ||
options: Color, | ||
type: 'inline-radio' | ||
} | ||
}, | ||
|
||
max: { | ||
control: { | ||
type: 'text' | ||
} | ||
}, | ||
size: { | ||
control: { | ||
options: SizeValues, | ||
type: 'inline-radio' | ||
} | ||
}, | ||
value: { | ||
control: { | ||
type: 'text' | ||
} | ||
} | ||
}, | ||
component: ProgressBar, | ||
title: 'Elements/ProgressBar' | ||
}; | ||
|
||
const defaultProgressBarTemplate: Story<ProgressBarProps> = args => ( | ||
<ProgressBar {...args} /> | ||
); | ||
|
||
export const Default = defaultProgressBarTemplate.bind({}); | ||
|
||
Default.args = { | ||
color: 'default', | ||
max: 100, | ||
size: 'default', | ||
value: 30 | ||
}; | ||
|
||
const indeterminateProgressBarTemplate: Story<ProgressBarProps> = args => ( | ||
<ProgressBar {...args} /> | ||
); | ||
|
||
export const Indeterminate = indeterminateProgressBarTemplate.bind({}); | ||
|
||
Indeterminate.args = { | ||
color: 'default', | ||
max: 100, | ||
size: 'default' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { getStyles } from '../../styles/getStyles'; | ||
import { ProgressBarProps, defaultProps } from './types'; | ||
|
||
const ProgressBar: React.FC<ProgressBarProps> = ({ | ||
children, | ||
value, | ||
color, | ||
size, | ||
...otherProgessBarProps | ||
}) => { | ||
let progressBarClassesStr = 'progress,'; | ||
color !== 'default' && (progressBarClassesStr += `is-${color},`); | ||
size !== 'default' && (progressBarClassesStr += `is-${size},`); | ||
|
||
const classes = getStyles(progressBarClassesStr.split(',')); | ||
return ( | ||
<progress className={classes} value={value} {...otherProgessBarProps}> | ||
{`${value}%`} | ||
</progress> | ||
); | ||
}; | ||
|
||
ProgressBar.defaultProps = defaultProps; | ||
|
||
export default ProgressBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
type Color = | ||
| 'default' | ||
| 'primary' | ||
| 'link' | ||
| 'info' | ||
| 'success' | ||
| 'warning' | ||
| 'danger'; | ||
|
||
type Size = 'default' | 'small' | 'medium' | 'large'; | ||
|
||
export interface ProgressBarProps { | ||
color?: Color; | ||
max?: number; | ||
size?: Size; | ||
value?: number; | ||
} | ||
|
||
export const defaultProps: ProgressBarProps = { | ||
max: 100, | ||
size: 'default' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters