Debian Codegraph @

node/@patternfly/react-core/src/components/ExpandableSection/examples/ExpandableSectionDetached.tsx

raw
1 import { useState } from 'react';
2 import { ExpandableSection, ExpandableSectionToggle, Stack, StackItem } from '@patternfly/react-core';
3
4 export const ExpandableSectionDetached: React.FunctionComponent = () => {
5 const [isExpanded, setIsExpanded] = useState(false);
6
7 const onToggle = (isExpanded: boolean) => {
8 setIsExpanded(isExpanded);
9 };
10
11 const contentId = 'detached-expandable-section-content';
12 const toggleId = 'detached-expandable-section-toggle';
13 return (
14 <Stack hasGutter>
15 <StackItem>
16 <ExpandableSection isExpanded={isExpanded} isDetached direction="up" toggleId={toggleId} contentId={contentId}>
17 This content is visible only when the component is expanded.
18 </ExpandableSection>
19 </StackItem>
20 <StackItem>
21 <ExpandableSectionToggle
22 isExpanded={isExpanded}
23 onToggle={onToggle}
24 toggleId={toggleId}
25 contentId={contentId}
26 direction="up"
27 >
28 {isExpanded ? 'Show less detached example content' : 'Show more detached example content'}
29 </ExpandableSectionToggle>
30 </StackItem>
31 </Stack>
32 );
33 };