Debian Codegraph @

node/@patternfly/react-core/src/components/Page/examples/PageMainSectionPadding.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 PageMainSectionPadding: React.FunctionComponent = () => {
20 const [isSidebarOpen, setIsSidebarOpen] = useState(true);
21
22 const onSidebarToggle = () => {
23 setIsSidebarOpen(!isSidebarOpen);
24 };
25
26 const headerToolbar = (
27 <Toolbar id="main-padding-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 aria-label="Global navigation"
40 isSidebarOpen={isSidebarOpen}
41 onSidebarToggle={onSidebarToggle}
42 id="main-padding-nav-toggle"
43 isHamburgerButton
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="main-padding-sidebar">
58 <PageSidebarBody>Navigation</PageSidebarBody>
59 </PageSidebar>
60 );
61
62 return (
63 <Page masthead={masthead} sidebar={sidebar}>
64 <PageSection aria-labelledby="section-1">
65 <h2 id="section-1">Section with default padding</h2>
66 </PageSection>
67 <PageSection padding={{ default: 'noPadding' }} aria-labelledby="section-2">
68 <h2 id="section-2">Section with no padding</h2>
69 </PageSection>
70 <PageSection padding={{ default: 'noPadding', md: 'padding' }} aria-labelledby="section-3">
71 <h2 id="section-3">Section with padding on medium</h2>
72 </PageSection>
73 <PageSection padding={{ md: 'noPadding' }} aria-labelledby="section-4">
74 <h2 id="section-4">Section with no padding on medium</h2>
75 </PageSection>
76 </Page>
77 );
78 };