| 1 |
import { FormEvent, useState } from 'react'; |
| 2 |
import { ExpandableSection, Checkbox } from '@patternfly/react-core'; |
| 3 |
|
| 4 |
export const ExpandableSectionIndented: React.FunctionComponent = () => { |
| 5 |
const [isExpanded, setIsExpanded] = useState(true); |
| 6 |
const [isDisplayLgChecked, setIsDisplayLgChecked] = useState(false); |
| 7 |
|
| 8 |
const onToggle = (_event: React.MouseEvent, isExpanded: boolean) => { |
| 9 |
setIsExpanded(isExpanded); |
| 10 |
}; |
| 11 |
|
| 12 |
const onDisplaySizeCheck = (_event: FormEvent<HTMLInputElement>, checked: boolean) => setIsDisplayLgChecked(checked); |
| 13 |
|
| 14 |
return ( |
| 15 |
<> |
| 16 |
<Checkbox |
| 17 |
id="displaySize-checkbox" |
| 18 |
isChecked={isDisplayLgChecked} |
| 19 |
label='displaySize="lg"' |
| 20 |
onChange={onDisplaySizeCheck} |
| 21 |
/> |
| 22 |
<br /> |
| 23 |
<ExpandableSection |
| 24 |
toggleText={isExpanded ? 'Show less indented example content' : 'Show more indented example content'} |
| 25 |
onToggle={onToggle} |
| 26 |
isExpanded={isExpanded} |
| 27 |
isIndented |
| 28 |
displaySize={isDisplayLgChecked ? 'lg' : 'default'} |
| 29 |
> |
| 30 |
This content is visible only when the component is expanded. |
| 31 |
</ExpandableSection> |
| 32 |
</> |
| 33 |
); |
| 34 |
}; |