| 1 |
import styles from '@patternfly/react-styles/css/components/Progress/progress'; |
| 2 |
import { css } from '@patternfly/react-styles'; |
| 3 |
|
| 4 |
export interface AriaProps { |
| 5 |
'aria-labelledby'?: string; |
| 6 |
'aria-label'?: string; |
| 7 |
'aria-describedby'?: string; |
| 8 |
'aria-valuemin'?: number; |
| 9 |
'aria-valuenow'?: number; |
| 10 |
'aria-valuemax'?: number; |
| 11 |
'aria-valuetext'?: string; |
| 12 |
} |
| 13 |
|
| 14 |
export interface ProgressBarProps extends React.HTMLProps<HTMLDivElement> { |
| 15 |
/** What should be rendered inside progress bar. */ |
| 16 |
children?: React.ReactNode; |
| 17 |
/** Additional classes for Progres bar. */ |
| 18 |
className?: string; |
| 19 |
/** Actual progress value. */ |
| 20 |
value: number; |
| 21 |
/** Minimal value of progress. */ |
| 22 |
progressBarAriaProps?: AriaProps; |
| 23 |
} |
| 24 |
|
| 25 |
export const ProgressBar: React.FunctionComponent<ProgressBarProps> = ({ |
| 26 |
progressBarAriaProps, |
| 27 |
className = '', |
| 28 |
children = null, |
| 29 |
value, |
| 30 |
...props |
| 31 |
}: ProgressBarProps) => ( |
| 32 |
<div role="progressbar" {...props} className={css(styles.progressBar, className)} {...progressBarAriaProps}> |
| 33 |
<div className={css(styles.progressIndicator)} style={{ width: `${value}%` }}> |
| 34 |
<span className={css(styles.progressMeasure)}>{children}</span> |
| 35 |
</div> |
| 36 |
</div> |
| 37 |
); |
| 38 |
ProgressBar.displayName = 'ProgressBar'; |