Debian Codegraph @

node/@patternfly/react-core/src/components/Page/examples/PageGroupSection.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 PageGroup,
14 PageBreadcrumb,
15 PageToggleButton,
16 Breadcrumb,
17 BreadcrumbItem,
18 Nav,
19 NavList,
20 NavItem,
21 Toolbar,
22 ToolbarContent,
23 ToolbarItem
24 } from '@patternfly/react-core';
25
26 export const PageGroupSection: React.FunctionComponent = () => {
27 const [isSidebarOpen, setIsSidebarOpen] = useState(true);
28
29 const onSidebarToggle = () => {
30 setIsSidebarOpen(!isSidebarOpen);
31 };
32
33 const headerToolbar = (
34 <Toolbar id="group-section-toolbar">
35 <ToolbarContent>
36 <ToolbarItem>header-tools</ToolbarItem>
37 </ToolbarContent>
38 </Toolbar>
39 );
40
41 const masthead = (
42 <Masthead>
43 <MastheadMain>
44 <MastheadToggle>
45 <PageToggleButton
46 aria-label="Global navigation"
47 isSidebarOpen={isSidebarOpen}
48 onSidebarToggle={onSidebarToggle}
49 id="group-section-nav-toggle"
50 isHamburgerButton
51 />
52 </MastheadToggle>
53 <MastheadBrand>
54 <MastheadLogo href="https://patternfly.org" target="_blank">
55 Logo
56 </MastheadLogo>
57 </MastheadBrand>
58 </MastheadMain>
59 <MastheadContent>{headerToolbar}</MastheadContent>
60 </Masthead>
61 );
62
63 const sidebar = (
64 <PageSidebar isSidebarOpen={isSidebarOpen} id="group-section-sidebar">
65 <PageSidebarBody>Navigation</PageSidebarBody>
66 </PageSidebar>
67 );
68
69 return (
70 <Page masthead={masthead} sidebar={sidebar}>
71 <PageGroup>
72 <Nav aria-label="Group section navigation" variant="horizontal-subnav">
73 <NavList>
74 <NavItem href="#" itemId={0} isActive>
75 System panel
76 </NavItem>
77 <NavItem href="#" itemId={1}>
78 Policy
79 </NavItem>
80 <NavItem href="#" itemId={2}>
81 Authentication
82 </NavItem>
83 <NavItem href="#" itemId={3}>
84 Network services
85 </NavItem>
86 <NavItem href="#" itemId={4}>
87 Server
88 </NavItem>
89 </NavList>
90 </Nav>
91 <PageBreadcrumb>
92 <Breadcrumb>
93 <BreadcrumbItem>Section home</BreadcrumbItem>
94 <BreadcrumbItem to="#">Section title</BreadcrumbItem>
95 <BreadcrumbItem to="#">Section title</BreadcrumbItem>
96 <BreadcrumbItem to="#" isActive>
97 Section landing
98 </BreadcrumbItem>
99 </Breadcrumb>
100 </PageBreadcrumb>
101 <PageSection aria-labelledby="grouped-section">
102 <h2 id="grouped-section">Grouped section</h2>
103 </PageSection>
104 </PageGroup>
105 <PageSection aria-labelledby="section-1">
106 <h2 id="section-1">Grouped example section 1</h2>
107 </PageSection>
108 <PageSection aria-labelledby="section-2">
109 <h2 id="section-2">Grouped example section 2</h2>
110 </PageSection>
111 </Page>
112 );
113 };