| 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 PageVerticalNav: React.FunctionComponent = () => { |
| 20 |
const [isSidebarOpen, setIsSidebarOpen] = useState(true); |
| 21 |
|
| 22 |
const onSidebarToggle = () => { |
| 23 |
setIsSidebarOpen(!isSidebarOpen); |
| 24 |
}; |
| 25 |
|
| 26 |
const headerToolbar = ( |
| 27 |
<Toolbar id="vertical-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="vertical-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="vertical-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">Vertical nav example section 1</h2> |
| 66 |
</PageSection> |
| 67 |
<PageSection variant="secondary" aria-labelledby="section-2"> |
| 68 |
<h2 id="section-2">Vertical nav example section 2 with secondary variant styling</h2> |
| 69 |
</PageSection> |
| 70 |
<PageSection aria-labelledby="section-3"> |
| 71 |
<h2 id="section-3">Vertical nav example section 3</h2> |
| 72 |
</PageSection> |
| 73 |
</Page> |
| 74 |
); |
| 75 |
}; |