Debian Codegraph @

node/@patternfly/react-core/src/demos/examples/Progress/ProgressWithOnlyIncreasing.tsx

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