Debian Codegraph @

node/@patternfly/react-core/src/components/Page/examples/PageWithOrWithoutFill.tsx

raw
1 import { useState } from 'react';
2 import {
3 Page,
4 Masthead,
5 MastheadMain,
6 MastheadToggle,
7 MastheadBrand,
8 MastheadLogo,
9 MastheadContent,
10 PageSidebar,
11 PageSidebarBody,
12 PageSection,
13 PageToggleButton,
14 Toolbar,
15 ToolbarContent,
16 ToolbarItem
17 } from '@patternfly/react-core';
18
19 export const PageWithOrWithoutFill: React.FunctionComponent = () => {
20 const [isSidebarOpen, setIsSidebarOpen] = useState(true);
21
22 const onSidebarToggle = () => {
23 setIsSidebarOpen(!isSidebarOpen);
24 };
25
26 const headerToolbar = (
27 <Toolbar id="fill-toolbar">
28 <ToolbarContent>
29 <ToolbarItem>header-tools</ToolbarItem>
30 </ToolbarContent>
31 </Toolbar>
32 );
33
34 const masthead = (
35 <Masthead>
36 <MastheadMain>
37 <MastheadToggle>
38 <PageToggleButton
39 isHamburgerButton
40 aria-label="Global navigation"
41 isSidebarOpen={isSidebarOpen}
42 onSidebarToggle={onSidebarToggle}
43 id="fill-nav-toggle"
44 />
45 </MastheadToggle>
46 <MastheadBrand>
47 <MastheadLogo href="https://patternfly.org" target="_blank">
48 Logo
49 </MastheadLogo>
50 </MastheadBrand>
51 </MastheadMain>
52 <MastheadContent>{headerToolbar}</MastheadContent>
53 </Masthead>
54 );
55
56 const sidebar = (
57 <PageSidebar isSidebarOpen={isSidebarOpen} id="fill-sidebar">
58 <PageSidebarBody>Navigation</PageSidebarBody>
59 </PageSidebar>
60 );
61
62 return (
63 <Page isContentFilled masthead={masthead} sidebar={sidebar}>
64 <PageSection aria-labelledby="section-1">
65 <h2 id="section-1">Section without fill</h2>
66 </PageSection>
67 <PageSection isFilled={true} variant="secondary" aria-labelledby="section-2">
68 <h2 id="section-2">Section with fill</h2>
69 </PageSection>
70 <PageSection aria-labelledby="section-3">
71 <h2 id="section-3">Another section without fill</h2>
72 </PageSection>
73 </Page>
74 );
75 };