Debian Codegraph @

node/@patternfly/react-core/src/components/Page/examples/PageCenteredSection.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 Card,
18 CardBody
19 } from '@patternfly/react-core';
20 import pageSectionWidthLimitMaxWidth from '@patternfly/react-tokens/dist/esm/c_page_section_m_limit_width_MaxWidth';
21
22 export const PageCenteredSection: React.FunctionComponent = () => {
23 const [isSidebarOpen, setIsSidebarOpen] = useState(true);
24
25 const onSidebarToggle = () => {
26 setIsSidebarOpen(!isSidebarOpen);
27 };
28
29 const headerToolbar = (
30 <Toolbar id="centered-toolbar">
31 <ToolbarContent>
32 <ToolbarItem>header-tools</ToolbarItem>
33 </ToolbarContent>
34 </Toolbar>
35 );
36
37 const masthead = (
38 <Masthead>
39 <MastheadMain>
40 <MastheadToggle>
41 <PageToggleButton
42 aria-label="Global navigation"
43 isSidebarOpen={isSidebarOpen}
44 onSidebarToggle={onSidebarToggle}
45 id="centered-nav-toggle"
46 isHamburgerButton
47 />
48 </MastheadToggle>
49 <MastheadBrand>
50 <MastheadLogo href="https://patternfly.org" target="_blank">
51 Logo
52 </MastheadLogo>
53 </MastheadBrand>
54 </MastheadMain>
55 <MastheadContent>{headerToolbar}</MastheadContent>
56 </Masthead>
57 );
58
59 const sidebar = (
60 <PageSidebar isSidebarOpen={isSidebarOpen} id="centered-section-sidebar">
61 <PageSidebarBody>Navigation</PageSidebarBody>
62 </PageSidebar>
63 );
64
65 return (
66 <Page masthead={masthead} sidebar={sidebar}>
67 <PageSection isWidthLimited isCenterAligned aria-label="width limited page section">
68 <Card>
69 <CardBody>
70 When a width limited page section is wider than the value of
71 <code>{pageSectionWidthLimitMaxWidth.name}</code>, the section will be centered in the main section.
72 <br />
73 <br />
74 The content in this example is placed in a card to better illustrate how the section behaves when it is
75 centered. A card is not required to center a page section.
76 </CardBody>
77 </Card>
78 </PageSection>
79 </Page>
80 );
81 };