Debian Codegraph @

node/@patternfly/react-core/src/demos/examples/Nav/NavDockedNav.tsx

raw
1 import { useRef, useState, useEffect } from 'react';
2 import {
3 Brand,
4 Breadcrumb,
5 BreadcrumbItem,
6 Button,
7 Card,
8 CardBody,
9 Content,
10 Divider,
11 Gallery,
12 GalleryItem,
13 Masthead,
14 MastheadMain,
15 MastheadLogo,
16 MastheadContent,
17 MastheadBrand,
18 MastheadToggle,
19 MenuToggle,
20 Nav,
21 NavItem,
22 NavList,
23 Page,
24 PageSection,
25 PageToggleButton,
26 SkipToContent,
27 Toolbar,
28 ToolbarContent,
29 ToolbarGroup,
30 ToolbarItem,
31 Tooltip
32 } from '@patternfly/react-core';
33 import RhUiQuestionMarkCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-question-mark-circle-fill-icon';
34 import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
35 import FolderIcon from '@patternfly/react-icons/dist/esm/icons/folder-icon';
36 import CloudIcon from '@patternfly/react-icons/dist/esm/icons/cloud-icon';
37 import RhUiCodeIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-code-icon';
38 import RhUiThumbnailViewSmallFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-thumbnail-view-small-fill-icon';
39 import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
40 import pfIconLogo from '@patternfly/react-core/src/demos/assets/PF-IconLogo-color.svg';
41 import globalBreakpointXl from '@patternfly/react-tokens/dist/esm/t_global_breakpoint_xl';
42
43 interface NavOnSelectProps {
44 groupId: number | string;
45 itemId: number | string;
46 to: string;
47 }
48
49 export const NavDockedNav: React.FunctionComponent = () => {
50 const [activeItem, setActiveItem] = useState(1);
51 const [isDockExpanded, setIsDockExpanded] = useState(false);
52 const [isDockTextExpanded, setIsDockTextExpanded] = useState(false);
53 const [isMobile, setIsMobile] = useState(false);
54
55 useEffect(() => {
56 const mobileBreakpoint = Number.parseInt(globalBreakpointXl.value) * 16;
57 const mediaQuery = window.matchMedia(`(max-width: ${mobileBreakpoint}px)`);
58 const handleResize = (e: MediaQueryListEvent | MediaQueryList) => {
59 setIsMobile(e.matches);
60 };
61
62 handleResize(mediaQuery);
63 mediaQuery.addEventListener('change', handleResize);
64
65 return () => mediaQuery.removeEventListener('change', handleResize);
66 }, []);
67
68 const onNavSelect = (_event: React.FormEvent<HTMLInputElement>, selectedItem: NavOnSelectProps) => {
69 typeof selectedItem.itemId === 'number' && setActiveItem(selectedItem.itemId);
70 };
71
72 const mobileTextLogo = (
73 <svg height="37px" viewBox="0 0 679 158">
74 <title>PatternFly</title>
75 <defs>
76 <linearGradient x1="68%" y1="2.25860997e-13%" x2="32%" y2="100%" id="linearGradient-">
77 <stop stopColor="#2B9AF3" offset="0%"></stop>
78 <stop stopColor="#73BCF7" stopOpacity="0.502212631" offset="100%"></stop>
79 </linearGradient>
80 </defs>
81 <g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
82 <g
83 transform="translate(206.000000, 45.750000)"
84 fill="var(--pf-t--global--text--color--regular)"
85 fillRule="nonzero"
86 >
87 <path d="M0,65.25 L0,2.25 L33.21,2.25 C37.35,2.25 41.025,3.135 44.235,4.905 C47.445,6.675 49.98,9.09 51.84,12.15 C53.7,15.21 54.63,18.72 54.63,22.68 C54.63,26.46 53.7,29.865 51.84,32.895 C49.98,35.925 47.43,38.31 44.19,40.05 C40.95,41.79 37.29,42.66 33.21,42.66 L15.48,42.66 L15.48,65.25 L0,65.25 Z M15.48,29.88 L31.41,29.88 C33.69,29.88 35.52,29.22 36.9,27.9 C38.28,26.58 38.97,24.87 38.97,22.77 C38.97,20.61 38.28,18.855 36.9,17.505 C35.52,16.155 33.69,15.48 31.41,15.48 L15.48,15.48 L15.48,29.88 Z"></path>
88 <path d="M77.04,66.06 C73.68,66.06 70.695,65.43 68.085,64.17 C65.475,62.91 63.435,61.17 61.965,58.95 C60.495,56.73 59.76,54.18 59.76,51.3 C59.76,46.74 61.485,43.215 64.935,40.725 C68.385,38.235 73.2,36.99 79.38,36.99 C83.1,36.99 86.7,37.44 90.18,38.34 L90.18,36 C90.18,31.26 87.15,28.89 81.09,28.89 C77.49,28.89 72.69,30.15 66.69,32.67 L61.47,21.96 C69.15,18.48 76.56,16.74 83.7,16.74 C90.3,16.74 95.43,18.315 99.09,21.465 C102.75,24.615 104.58,29.04 104.58,34.74 L104.58,65.25 L90.18,65.25 L90.18,62.37 C88.26,63.69 86.235,64.635 84.105,65.205 C81.975,65.775 79.62,66.06 77.04,66.06 Z M73.62,51.03 C73.62,52.53 74.28,53.7 75.6,54.54 C76.92,55.38 78.75,55.8 81.09,55.8 C84.69,55.8 87.72,55.05 90.18,53.55 L90.18,47.43 C87.42,46.71 84.54,46.35 81.54,46.35 C79.02,46.35 77.07,46.755 75.69,47.565 C74.31,48.375 73.62,49.53 73.62,51.03 Z"></path>
89 <path d="M137.25,65.88 C125.73,65.88 119.97,60.84 119.97,50.76 L119.97,29.79 L110.34,29.79 L110.34,17.64 L119.97,17.64 L119.97,5.4 L134.55,2.25 L134.55,17.64 L147.87,17.64 L147.87,29.79 L134.55,29.79 L134.55,47.88 C134.55,49.98 135.015,51.465 135.945,52.335 C136.875,53.205 138.51,53.64 140.85,53.64 C143.01,53.64 145.2,53.31 147.42,52.65 L147.42,64.44 C146.1,64.86 144.42,65.205 142.38,65.475 C140.34,65.745 138.63,65.88 137.25,65.88 Z"></path>
90 <path d="M177.57,65.88 C166.05,65.88 160.29,60.84 160.29,50.76 L160.29,29.79 L150.66,29.79 L150.66,17.64 L160.29,17.64 L160.29,5.4 L174.87,2.25 L174.87,17.64 L188.19,17.64 L188.19,29.79 L174.87,29.79 L174.87,47.88 C174.87,49.98 175.335,51.465 176.265,52.335 C177.195,53.205 178.83,53.64 181.17,53.64 C183.33,53.64 185.52,53.31 187.74,52.65 L187.74,64.44 C186.42,64.86 184.74,65.205 182.7,65.475 C180.66,65.745 178.95,65.88 177.57,65.88 Z"></path>
91 <path d="M217.62,66.15 C212.76,66.15 208.365,65.055 204.435,62.865 C200.505,60.675 197.4,57.72 195.12,54 C192.84,50.28 191.7,46.11 191.7,41.49 C191.7,36.87 192.795,32.7 194.985,28.98 C197.175,25.26 200.16,22.305 203.94,20.115 C207.72,17.925 211.92,16.83 216.54,16.83 C221.22,16.83 225.36,17.955 228.96,20.205 C232.56,22.455 235.395,25.53 237.465,29.43 C239.535,33.33 240.57,37.8 240.57,42.84 L240.57,46.44 L206.64,46.44 C207.6,48.66 209.1,50.475 211.14,51.885 C213.18,53.295 215.58,54 218.34,54 C222.42,54 225.6,52.8 227.88,50.4 L237.51,58.95 C234.51,61.47 231.435,63.3 228.285,64.44 C225.135,65.58 221.58,66.15 217.62,66.15 Z M206.37,36.27 L226.26,36.27 C225.48,33.99 224.205,32.16 222.435,30.78 C220.665,29.4 218.61,28.71 216.27,28.71 C213.87,28.71 211.8,29.37 210.06,30.69 C208.32,32.01 207.09,33.87 206.37,36.27 Z"></path>
92 <path d="M247.41,65.25 L247.41,17.64 L261.99,17.64 L261.99,22.41 C265.23,18.51 269.4,16.56 274.5,16.56 C277.08,16.62 278.91,17.01 279.99,17.73 L279.99,30.42 C277.95,29.46 275.64,28.98 273.06,28.98 C270.78,28.98 268.665,29.505 266.715,30.555 C264.765,31.605 263.19,33.09 261.99,35.01 L261.99,65.25 L247.41,65.25 Z"></path>
93 <path d="M286.29,65.25 L286.29,17.64 L300.87,17.64 L300.87,20.88 C304.47,18.12 308.73,16.74 313.65,16.74 C317.37,16.74 320.655,17.55 323.505,19.17 C326.355,20.79 328.59,23.04 330.21,25.92 C331.83,28.8 332.64,32.13 332.64,35.91 L332.64,65.25 L318.06,65.25 L318.06,37.89 C318.06,35.25 317.28,33.15 315.72,31.59 C314.16,30.03 312.06,29.25 309.42,29.25 C305.76,29.25 302.91,30.51 300.87,33.03 L300.87,65.25 L286.29,65.25 Z"></path>
94 <polygon points="342 65.25 342 2.25 392.04 2.25 392.04 15.66 357.48 15.66 357.48 27.45 380.52 27.45 380.52 40.41 357.48 40.41 357.48 65.25"></polygon>
95 <polygon points="399.96 65.25 399.96 2.25 414.54 0 414.54 65.25"></polygon>
96 <path d="M429.21,84.69 C428.07,84.69 426.96,84.645 425.88,84.555 C424.8,84.465 423.9,84.33 423.18,84.15 L423.18,71.73 C424.38,71.97 425.88,72.09 427.68,72.09 C432.36,72.09 435.51,70.05 437.13,65.97 L437.13,65.88 L418.86,17.64 L434.97,17.64 L445.5,47.61 L457.74,17.64 L473.49,17.64 L452.16,67.68 C450.42,71.82 448.5,75.135 446.4,77.625 C444.3,80.115 441.87,81.915 439.11,83.025 C436.35,84.135 433.05,84.69 429.21,84.69 Z"></path>
97 </g>
98 <g transform="translate(0.000000, 0.000000)">
99 <path
100 d="M61.826087,0 L158,0 L158,96.173913 L147.695652,96.173913 C100.271201,96.173913 61.826087,57.7287992 61.826087,10.3043478 L61.826087,0 L61.826087,0 Z"
101 fill="#0066CC"
102 ></path>
103 <path
104 d="M158,3.43478261 L65.2608696,158 L138,158 C149.045695,158 158,149.045695 158,138 L158,3.43478261 L158,3.43478261 Z"
105 fill="url(#linearGradient-)"
106 ></path>
107 <path
108 d="M123.652174,-30.9130435 L30.9130435,123.652174 L103.652174,123.652174 C114.697869,123.652174 123.652174,114.697869 123.652174,103.652174 L123.652174,-30.9130435 L123.652174,-30.9130435 Z"
109 fill="url(#linearGradient-)"
110 transform="translate(77.282609, 46.369565) scale(1, -1) rotate(90.000000) translate(-77.282609, -46.369565) "
111 ></path>
112 </g>
113 </g>
114 </svg>
115 );
116
117 const dockTextLogo = (
118 <svg height="37px" viewBox="0 0 679 158">
119 <title>PatternFly</title>
120 <defs>
121 <linearGradient
122 x1="68%"
123 y1="2.25860997e-13%"
124 x2="32%"
125 y2="100%"
126 id="linearGradient-nav-docked-expanded-example-masthead"
127 >
128 <stop stopColor="#2B9AF3" offset="0%"></stop>
129 <stop stopColor="#73BCF7" stopOpacity="0.502212631" offset="100%"></stop>
130 </linearGradient>
131 </defs>
132 <g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
133 <g
134 transform="translate(206.000000, 45.750000)"
135 fill="var(--pf-t--global--text--color--regular)"
136 fillRule="nonzero"
137 >
138 <path d="M0,65.25 L0,2.25 L33.21,2.25 C37.35,2.25 41.025,3.135 44.235,4.905 C47.445,6.675 49.98,9.09 51.84,12.15 C53.7,15.21 54.63,18.72 54.63,22.68 C54.63,26.46 53.7,29.865 51.84,32.895 C49.98,35.925 47.43,38.31 44.19,40.05 C40.95,41.79 37.29,42.66 33.21,42.66 L15.48,42.66 L15.48,65.25 L0,65.25 Z M15.48,29.88 L31.41,29.88 C33.69,29.88 35.52,29.22 36.9,27.9 C38.28,26.58 38.97,24.87 38.97,22.77 C38.97,20.61 38.28,18.855 36.9,17.505 C35.52,16.155 33.69,15.48 31.41,15.48 L15.48,15.48 L15.48,29.88 Z"></path>
139 <path d="M77.04,66.06 C73.68,66.06 70.695,65.43 68.085,64.17 C65.475,62.91 63.435,61.17 61.965,58.95 C60.495,56.73 59.76,54.18 59.76,51.3 C59.76,46.74 61.485,43.215 64.935,40.725 C68.385,38.235 73.2,36.99 79.38,36.99 C83.1,36.99 86.7,37.44 90.18,38.34 L90.18,36 C90.18,31.26 87.15,28.89 81.09,28.89 C77.49,28.89 72.69,30.15 66.69,32.67 L61.47,21.96 C69.15,18.48 76.56,16.74 83.7,16.74 C90.3,16.74 95.43,18.315 99.09,21.465 C102.75,24.615 104.58,29.04 104.58,34.74 L104.58,65.25 L90.18,65.25 L90.18,62.37 C88.26,63.69 86.235,64.635 84.105,65.205 C81.975,65.775 79.62,66.06 77.04,66.06 Z M73.62,51.03 C73.62,52.53 74.28,53.7 75.6,54.54 C76.92,55.38 78.75,55.8 81.09,55.8 C84.69,55.8 87.72,55.05 90.18,53.55 L90.18,47.43 C87.42,46.71 84.54,46.35 81.54,46.35 C79.02,46.35 77.07,46.755 75.69,47.565 C74.31,48.375 73.62,49.53 73.62,51.03 Z"></path>
140 <path d="M137.25,65.88 C125.73,65.88 119.97,60.84 119.97,50.76 L119.97,29.79 L110.34,29.79 L110.34,17.64 L119.97,17.64 L119.97,5.4 L134.55,2.25 L134.55,17.64 L147.87,17.64 L147.87,29.79 L134.55,29.79 L134.55,47.88 C134.55,49.98 135.015,51.465 135.945,52.335 C136.875,53.205 138.51,53.64 140.85,53.64 C143.01,53.64 145.2,53.31 147.42,52.65 L147.42,64.44 C146.1,64.86 144.42,65.205 142.38,65.475 C140.34,65.745 138.63,65.88 137.25,65.88 Z"></path>
141 <path d="M177.57,65.88 C166.05,65.88 160.29,60.84 160.29,50.76 L160.29,29.79 L150.66,29.79 L150.66,17.64 L160.29,17.64 L160.29,5.4 L174.87,2.25 L174.87,17.64 L188.19,17.64 L188.19,29.79 L174.87,29.79 L174.87,47.88 C174.87,49.98 175.335,51.465 176.265,52.335 C177.195,53.205 178.83,53.64 181.17,53.64 C183.33,53.64 185.52,53.31 187.74,52.65 L187.74,64.44 C186.42,64.86 184.74,65.205 182.7,65.475 C180.66,65.745 178.95,65.88 177.57,65.88 Z"></path>
142 <path d="M217.62,66.15 C212.76,66.15 208.365,65.055 204.435,62.865 C200.505,60.675 197.4,57.72 195.12,54 C192.84,50.28 191.7,46.11 191.7,41.49 C191.7,36.87 192.795,32.7 194.985,28.98 C197.175,25.26 200.16,22.305 203.94,20.115 C207.72,17.925 211.92,16.83 216.54,16.83 C221.22,16.83 225.36,17.955 228.96,20.205 C232.56,22.455 235.395,25.53 237.465,29.43 C239.535,33.33 240.57,37.8 240.57,42.84 L240.57,46.44 L206.64,46.44 C207.6,48.66 209.1,50.475 211.14,51.885 C213.18,53.295 215.58,54 218.34,54 C222.42,54 225.6,52.8 227.88,50.4 L237.51,58.95 C234.51,61.47 231.435,63.3 228.285,64.44 C225.135,65.58 221.58,66.15 217.62,66.15 Z M206.37,36.27 L226.26,36.27 C225.48,33.99 224.205,32.16 222.435,30.78 C220.665,29.4 218.61,28.71 216.27,28.71 C213.87,28.71 211.8,29.37 210.06,30.69 C208.32,32.01 207.09,33.87 206.37,36.27 Z"></path>
143 <path d="M247.41,65.25 L247.41,17.64 L261.99,17.64 L261.99,22.41 C265.23,18.51 269.4,16.56 274.5,16.56 C277.08,16.62 278.91,17.01 279.99,17.73 L279.99,30.42 C277.95,29.46 275.64,28.98 273.06,28.98 C270.78,28.98 268.665,29.505 266.715,30.555 C264.765,31.605 263.19,33.09 261.99,35.01 L261.99,65.25 L247.41,65.25 Z"></path>
144 <path d="M286.29,65.25 L286.29,17.64 L300.87,17.64 L300.87,20.88 C304.47,18.12 308.73,16.74 313.65,16.74 C317.37,16.74 320.655,17.55 323.505,19.17 C326.355,20.79 328.59,23.04 330.21,25.92 C331.83,28.8 332.64,32.13 332.64,35.91 L332.64,65.25 L318.06,65.25 L318.06,37.89 C318.06,35.25 317.28,33.15 315.72,31.59 C314.16,30.03 312.06,29.25 309.42,29.25 C305.76,29.25 302.91,30.51 300.87,33.03 L300.87,65.25 L286.29,65.25 Z"></path>
145 <polygon points="342 65.25 342 2.25 392.04 2.25 392.04 15.66 357.48 15.66 357.48 27.45 380.52 27.45 380.52 40.41 357.48 40.41 357.48 65.25"></polygon>
146 <polygon points="399.96 65.25 399.96 2.25 414.54 0 414.54 65.25"></polygon>
147 <path d="M429.21,84.69 C428.07,84.69 426.96,84.645 425.88,84.555 C424.8,84.465 423.9,84.33 423.18,84.15 L423.18,71.73 C424.38,71.97 425.88,72.09 427.68,72.09 C432.36,72.09 435.51,70.05 437.13,65.97 L437.13,65.88 L418.86,17.64 L434.97,17.64 L445.5,47.61 L457.74,17.64 L473.49,17.64 L452.16,67.68 C450.42,71.82 448.5,75.135 446.4,77.625 C444.3,80.115 441.87,81.915 439.11,83.025 C436.35,84.135 433.05,84.69 429.21,84.69 Z"></path>
148 </g>
149 <g transform="translate(0.000000, 0.000000)">
150 <path
151 d="M61.826087,0 L158,0 L158,96.173913 L147.695652,96.173913 C100.271201,96.173913 61.826087,57.7287992 61.826087,10.3043478 L61.826087,0 L61.826087,0 Z"
152 fill="#0066CC"
153 ></path>
154 <path
155 d="M158,3.43478261 L65.2608696,158 L138,158 C149.045695,158 158,149.045695 158,138 L158,3.43478261 L158,3.43478261 Z"
156 fill="url(#linearGradient-nav-docked-expanded-example-masthead)"
157 ></path>
158 <path
159 d="M123.652174,-30.9130435 L30.9130435,123.652174 L103.652174,123.652174 C114.697869,123.652174 123.652174,114.697869 123.652174,103.652174 L123.652174,-30.9130435 L123.652174,-30.9130435 Z"
160 fill="url(#linearGradient-nav-docked-expanded-example-masthead)"
161 transform="translate(77.282609, 46.369565) scale(1, -1) rotate(90.000000) translate(-77.282609, -46.369565) "
162 ></path>
163 </g>
164 </g>
165 </svg>
166 );
167
168 const dashboardBreadcrumb = (
169 <Breadcrumb>
170 <BreadcrumbItem>Section home</BreadcrumbItem>
171 <BreadcrumbItem to="#">Section title</BreadcrumbItem>
172 <BreadcrumbItem to="#">Section title</BreadcrumbItem>
173 <BreadcrumbItem to="#" isActive>
174 Section landing
175 </BreadcrumbItem>
176 </Breadcrumb>
177 );
178
179 const navItem1Ref = useRef<HTMLAnchorElement>(null);
180 const navItem2Ref = useRef<HTMLAnchorElement>(null);
181 const navItem3Ref = useRef<HTMLAnchorElement>(null);
182 const navItem4Ref = useRef<HTMLAnchorElement>(null);
183 const appsRef = useRef<HTMLButtonElement>(null);
184 const settingsRef = useRef<HTMLButtonElement>(null);
185 const helpRef = useRef<HTMLButtonElement>(null);
186 const mobileToggleRef = useRef<HTMLButtonElement>(null);
187 const dockedToggleRef = useRef<HTMLButtonElement>(null);
188
189 const onMobileToggle = () => {
190 setIsDockExpanded(!isDockExpanded);
191
192 setTimeout(() => {
193 dockedToggleRef.current?.focus();
194 }, 200);
195 };
196
197 const onToggleDock = () => {
198 if (isMobile) {
199 setIsDockExpanded(!isDockExpanded);
200
201 if (isDockExpanded) {
202 setTimeout(() => {
203 mobileToggleRef.current?.focus();
204 }, 200);
205 }
206 } else {
207 setIsDockTextExpanded(!isDockTextExpanded);
208 }
209 };
210
211 // Mobile masthead - shown on mobile viewports only, hidden on desktop
212 const mobileMasthead = (
213 <Masthead display={{ default: 'inline' }} id="mobile-masthead">
214 <MastheadMain>
215 <MastheadToggle>
216 <PageToggleButton
217 innerRef={mobileToggleRef}
218 variant="plain"
219 aria-label="Global navigation"
220 isSidebarOpen={isDockExpanded}
221 onSidebarToggle={onMobileToggle}
222 isHamburgerButton
223 />
224 </MastheadToggle>
225 <MastheadBrand>
226 <MastheadLogo component={(props) => <a {...props} href="#" />}>{mobileTextLogo}</MastheadLogo>
227 </MastheadBrand>
228 </MastheadMain>
229 <MastheadContent>
230 <Toolbar isStatic id="mobile-toolbar">
231 <ToolbarContent>
232 <ToolbarItem align={{ default: 'alignEnd' }}>
233 <Button variant="plain" icon={<SearchIcon />} aria-label="Search" />
234 </ToolbarItem>
235 </ToolbarContent>
236 </Toolbar>
237 </MastheadContent>
238 </Masthead>
239 );
240
241 // Docked masthead - vertical navigation sidebar
242 const dockedMasthead = (
243 <Masthead
244 {...(isMobile && !isDockExpanded && { inert: '' })}
245 display={{ default: undefined }}
246 id="docked-masthead"
247 variant="docked"
248 >
249 <MastheadMain>
250 <MastheadToggle>
251 <Button
252 ref={dockedToggleRef}
253 variant="plain"
254 isHamburger
255 onClick={onToggleDock}
256 aria-label="Global navigation"
257 isExpanded={isDockTextExpanded}
258 />
259 </MastheadToggle>
260 <MastheadBrand>
261 <MastheadLogo component={(props) => <a {...props} href="#" />} isCompact>
262 <Brand src={pfIconLogo} alt="PatternFly" heights={{ default: '37px' }} />
263 </MastheadLogo>
264 <MastheadLogo component={(props) => <a {...props} href="#" />}>{dockTextLogo}</MastheadLogo>
265 </MastheadBrand>
266 </MastheadMain>
267 <Divider />
268 <MastheadContent>
269 <Toolbar isVertical>
270 <ToolbarContent>
271 <ToolbarItem>
272 <Nav onSelect={onNavSelect} variant="docked" aria-label="Global">
273 <NavList>
274 <NavItem
275 preventDefault
276 id="nav-link1"
277 to="#nav-link1"
278 itemId={0}
279 isActive={activeItem === 0}
280 icon={<CubeIcon />}
281 anchorRef={navItem1Ref}
282 aria-label="System panel"
283 >
284 System panel
285 </NavItem>
286 <NavItem
287 preventDefault
288 id="nav-link2"
289 to="#nav-link2"
290 itemId={1}
291 isActive={activeItem === 1}
292 icon={<FolderIcon />}
293 anchorRef={navItem2Ref}
294 aria-label="Policy"
295 >
296 Policy
297 </NavItem>
298 <NavItem
299 preventDefault
300 id="nav-link3"
301 to="#nav-link3"
302 itemId={2}
303 isActive={activeItem === 2}
304 icon={<CloudIcon />}
305 anchorRef={navItem3Ref}
306 aria-label="Authentication"
307 >
308 Authentication
309 </NavItem>
310 <NavItem
311 preventDefault
312 id="nav-link4"
313 to="#nav-link4"
314 itemId={3}
315 isActive={activeItem === 3}
316 icon={<RhUiCodeIcon />}
317 anchorRef={navItem4Ref}
318 aria-label="Network services"
319 >
320 Network services
321 </NavItem>
322 </NavList>
323 </Nav>
324 {!isDockTextExpanded && !isDockExpanded && (
325 <>
326 <Tooltip aria="none" aria-live="off" triggerRef={navItem1Ref} content="System panel"></Tooltip>
327 <Tooltip aria="none" aria-live="off" triggerRef={navItem2Ref} content="Policy"></Tooltip>
328 <Tooltip aria="none" aria-live="off" triggerRef={navItem3Ref} content="Authentication"></Tooltip>
329 <Tooltip aria="none" aria-live="off" triggerRef={navItem4Ref} content="Network services"></Tooltip>
330 </>
331 )}
332 </ToolbarItem>
333 <ToolbarGroup
334 variant="action-group-plain"
335 align={{ default: 'alignEnd' }}
336 gap={{ default: 'gapNone', md: 'gapMd' }}
337 >
338 <ToolbarItem>
339 {isDockTextExpanded || isDockExpanded ? (
340 <MenuToggle
341 ref={appsRef}
342 variant="plain"
343 icon={<RhUiThumbnailViewSmallFillIcon />}
344 isDocked
345 aria-label="Applications"
346 >
347 Applications
348 </MenuToggle>
349 ) : (
350 <Tooltip aria="none" aria-live="off" triggerRef={appsRef} content="Applications">
351 <MenuToggle
352 ref={appsRef}
353 variant="plain"
354 icon={<RhUiThumbnailViewSmallFillIcon />}
355 isDocked
356 aria-label="Applications"
357 >
358 Applications
359 </MenuToggle>
360 </Tooltip>
361 )}
362 </ToolbarItem>
363 <ToolbarItem>
364 {isDockTextExpanded || isDockExpanded ? (
365 <Button ref={settingsRef} aria-label="Settings" isSettings variant="plain" isDocked>
366 Settings
367 </Button>
368 ) : (
369 <Tooltip aria="none" aria-live="off" triggerRef={settingsRef} content="Settings">
370 <Button ref={settingsRef} aria-label="Settings" isSettings variant="plain" isDocked>
371 Settings
372 </Button>
373 </Tooltip>
374 )}
375 </ToolbarItem>
376 <ToolbarItem>
377 {isDockTextExpanded || isDockExpanded ? (
378 <MenuToggle
379 ref={helpRef}
380 variant="plain"
381 icon={<RhUiQuestionMarkCircleFillIcon />}
382 isDocked
383 aria-label="Help"
384 >
385 Help
386 </MenuToggle>
387 ) : (
388 <Tooltip aria="none" aria-live="off" triggerRef={helpRef} content="Help">
389 <MenuToggle
390 ref={helpRef}
391 variant="plain"
392 icon={<RhUiQuestionMarkCircleFillIcon />}
393 isDocked
394 aria-label="Help"
395 >
396 Help
397 </MenuToggle>
398 </Tooltip>
399 )}
400 </ToolbarItem>
401 </ToolbarGroup>
402 </ToolbarContent>
403 </Toolbar>
404 </MastheadContent>
405 </Masthead>
406 );
407
408 const mainContainerId = 'main-content-page-layout-docked-nav';
409
410 const handleClick = (event: React.MouseEvent) => {
411 event.preventDefault();
412
413 const mainContentElement = document.getElementById(mainContainerId);
414 if (mainContentElement) {
415 mainContentElement.focus();
416 }
417 };
418
419 const pageSkipToContent = (
420 <SkipToContent onClick={handleClick} href={`#${mainContainerId}`}>
421 Skip to content
422 </SkipToContent>
423 );
424
425 return (
426 <>
427 <Page
428 variant="docked"
429 isDockExpanded={isDockExpanded}
430 isDockTextExpanded={isDockTextExpanded}
431 masthead={mobileMasthead}
432 dockContent={dockedMasthead}
433 skipToContent={pageSkipToContent}
434 breadcrumb={dashboardBreadcrumb}
435 mainContainerId={mainContainerId}
436 isHorizontalSubnavWidthLimited
437 isBreadcrumbWidthLimited
438 isBreadcrumbGrouped
439 additionalGroupedContent={
440 <PageSection aria-labelledby="main-title">
441 <Content>
442 <h1 id="main-title">Main title</h1>
443 <p>This is a full page demo.</p>
444 </Content>
445 </PageSection>
446 }
447 >
448 <PageSection aria-label="Card gallery">
449 <Gallery hasGutter>
450 {Array.from({ length: 10 }).map((_value, index) => (
451 <GalleryItem key={index}>
452 <Card>
453 <CardBody>This is a card</CardBody>
454 </Card>
455 </GalleryItem>
456 ))}
457 </Gallery>
458 </PageSection>
459 </Page>
460 </>
461 );
462 };