| 1 |
import { useState } from 'react'; |
| 2 |
import { Progress, Button, Stack, StackItem } from '@patternfly/react-core'; |
| 3 |
import accessibilityStyles from '@patternfly/react-styles/css/utilities/Accessibility/accessibility'; |
| 4 |
|
| 5 |
export const ProgressBasic: React.FunctionComponent = () => { |
| 6 |
const [currentValue, setCurrentValue] = useState(0); |
| 7 |
|
| 8 |
const onProgressUpdate = (nextValue) => { |
| 9 |
setCurrentValue(nextValue); |
| 10 |
}; |
| 11 |
|
| 12 |
return ( |
| 13 |
<Stack> |
| 14 |
<StackItem> |
| 15 |
<Button onClick={() => onProgressUpdate(currentValue - 10)} isDisabled={currentValue === 0}> |
| 16 |
Decrease value |
| 17 |
</Button>{' '} |
| 18 |
<Button onClick={() => onProgressUpdate(currentValue + 10)} isDisabled={currentValue === 100}> |
| 19 |
Increase value |
| 20 |
</Button> |
| 21 |
<br /> |
| 22 |
<br /> |
| 23 |
</StackItem> |
| 24 |
<StackItem> |
| 25 |
<div className={accessibilityStyles.screenReader} aria-live="polite"> |
| 26 |
{`Progress value is ${currentValue}%.`} |
| 27 |
</div> |
| 28 |
<Progress value={currentValue} title="Title" /> |
| 29 |
</StackItem> |
| 30 |
</Stack> |
| 31 |
); |
| 32 |
}; |