| 1 |
import React from "react"; |
| 2 |
// PatternFly |
| 3 |
import { |
| 4 |
JumpLinks, |
| 5 |
JumpLinksItem, |
| 6 |
Sidebar, |
| 7 |
SidebarContent, |
| 8 |
SidebarPanel, |
| 9 |
} from "@patternfly/react-core"; |
| 10 |
import HelpTextWithIconLayout from "../HelpTextWithIconLayout"; |
| 11 |
|
| 12 |
interface SidebarLayoutProps { |
| 13 |
itemNames: string[]; |
| 14 |
children: React.ReactNode; |
| 15 |
} |
| 16 |
|
| 17 |
const SidebarLayout = (props: SidebarLayoutProps) => { |
| 18 |
// Utility functions |
| 19 |
const parseNameToId = (name: string) => { |
| 20 |
return name.toLowerCase().replace(/ /g, "-"); |
| 21 |
}; |
| 22 |
|
| 23 |
// Render component |
| 24 |
return ( |
| 25 |
<> |
| 26 |
<Sidebar isPanelRight> |
| 27 |
<SidebarPanel variant="sticky"> |
| 28 |
<HelpTextWithIconLayout textContent="Help" /> |
| 29 |
<JumpLinks |
| 30 |
isVertical |
| 31 |
label="Jump to section" |
| 32 |
scrollableSelector="#settings-page" |
| 33 |
offset={220} // for masthead |
| 34 |
expandable={{ default: "expandable", md: "nonExpandable" }} |
| 35 |
> |
| 36 |
{props.itemNames.map((item, index) => ( |
| 37 |
<JumpLinksItem key={index} href={"#" + parseNameToId(item)}> |
| 38 |
{item} |
| 39 |
</JumpLinksItem> |
| 40 |
))} |
| 41 |
</JumpLinks> |
| 42 |
</SidebarPanel> |
| 43 |
<SidebarContent className="pf-v6-u-mr-xl"> |
| 44 |
{props.children} |
| 45 |
</SidebarContent> |
| 46 |
</Sidebar> |
| 47 |
</> |
| 48 |
); |
| 49 |
}; |
| 50 |
|
| 51 |
export default SidebarLayout; |