@openstack_dev/gatsby-theme-marketing-oif-core 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,471 +1,30 @@
1
- import * as React from "react";
2
- import PropTypes from "prop-types";
3
- import { Script, navigate } from "gatsby";
4
- import { connect } from "react-redux";
5
- import { doLogin } from "openstack-uicore-foundation/lib/security/methods";
6
- import { Container } from "@mui/material";
7
- import SearchIcon from "@mui/icons-material/Search";
8
- import "@fortawesome/fontawesome-free/css/all.css";
9
- import AppBar from "@mui/material/AppBar";
10
- import Box from "@mui/material/Box";
11
- import Toolbar from "@mui/material/Toolbar";
12
- import IconButton from "@mui/material/IconButton";
13
- import MenuIcon from "@mui/icons-material/Menu";
14
- import AddIcon from "@mui/icons-material/Add";
15
- import RemoveIcon from "@mui/icons-material/Remove";
16
- import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
17
- import Button from "@mui/material/Button";
18
- import Link from "../Link";
19
-
20
- import navbarContent from "../../content/navbar/index.json";
21
-
22
- import styles from "./index.module.scss";
23
- import {
24
- SEARCH_WIDGET_BASE_URL,
25
- getEnvVariable,
26
- } from "../../utils/envVariables";
27
-
28
- function Navbar({ isLoggedUser, member }) {
29
- const [navbarMenu, setNavbarMenu] = React.useState(null);
30
- const [isMobileMenuOpen, setIsMobileMenuOpen] = React.useState(false);
31
- const [isSearchBarOpen, setIsSearchBarOpen] = React.useState(false);
32
-
33
- const handleSetActiveMenu = (option) => {
34
- setNavbarMenu(navbarMenu === option ? null : option);
35
- };
36
-
37
- const handleMobileMenuToggle = () => {
38
- setIsMobileMenuOpen(!isMobileMenuOpen);
39
- setNavbarMenu(null);
40
- };
41
-
42
- const onClickLogout = () => {
43
- navigate("/auth/logout", {
44
- state: {
45
- backUrl: window.location.pathname,
46
- },
47
- });
48
- };
49
-
50
- const handleCloseSearchBar = (event) => {
51
- if (event?.target.matches(".ossw-search-bar-close")) {
52
- setIsSearchBarOpen(false);
53
- }
54
- };
55
-
56
- React.useEffect(() => {
57
- document.addEventListener("click", handleCloseSearchBar);
58
- return () => {
59
- document.removeEventListener("click", handleCloseSearchBar);
60
- };
61
- }, []);
62
-
63
- React.useEffect(() => {
64
- if (isSearchBarOpen) {
65
- const inputElement = document.getElementById("search-bar-input");
66
- if (inputElement) {
67
- inputElement.focus();
1
+ import React from "react";
2
+ import { useStaticQuery, graphql } from "gatsby";
3
+ import NavBarTemplate from "./template";
4
+
5
+ const navBarQuery = graphql`
6
+ query {
7
+ navbarJson {
8
+ items {
9
+ display
10
+ link
11
+ requiresAuth
12
+ title
13
+ items {
14
+ display
15
+ link
16
+ requiresAuth
17
+ title
18
+ }
68
19
  }
69
20
  }
70
- }, [isSearchBarOpen]);
21
+ }
22
+ `;
71
23
 
72
- const handleNavigation = (url) => {
73
- navigate(url);
74
- };
24
+ function NavBar() {
25
+ const { navbarJson: navBarContent } = useStaticQuery(navBarQuery);
75
26
 
76
- return (
77
- <nav role="navigation">
78
- <Script
79
- src={`${getEnvVariable(SEARCH_WIDGET_BASE_URL)}/widget/embed.min.js`}
80
- onLoad={() => console.log("Script loaded")}
81
- />
82
- <AppBar
83
- position="static"
84
- className={styles.navbar}
85
- sx={{ backgroundColor: "#fff", boxShadow: "none" }}
86
- >
87
- <Container maxWidth="xl">
88
- <Toolbar disableGutters sx={{ flexWrap: "wrap" }}>
89
- <Box className={styles.navbarHeader}>
90
- <div className={styles.brandWrapper}>
91
- <a
92
- className={styles.navbarBrand}
93
- href="/"
94
- alt="Openstack logo"
95
- aria-label="Go to homepage"
96
- />
97
- </div>
98
- <Box
99
- className={styles.searchWrapper}
100
- sx={{ display: { xs: "none", md: "flex" } }}
101
- >
102
- <div
103
- role="button"
104
- tabIndex={0}
105
- onKeyDown={(event) => {
106
- if (event.key === "Enter" || event.key === " ") setIsSearchBarOpen(true);
107
- }}
108
- onClick={() => setIsSearchBarOpen(true)}
109
- className={styles.searchComponent}
110
- >
111
- <SearchIcon className={styles.searchIcon} />
112
- <span className={styles.headerSearchText}>Search</span>
113
- </div>
114
- <Box
115
- className={`openstack-search-bar ${styles.openstackSearchBar}`}
116
- style={{
117
- visibility: isSearchBarOpen ? "visible" : "hidden",
118
- opacity: isSearchBarOpen ? "1" : "0",
119
- }}
120
- data-baseurl={getEnvVariable(SEARCH_WIDGET_BASE_URL)}
121
- data-context="www-openstack"
122
- />
123
- </Box>
124
- </Box>
125
- {/* Mobile Menu */}
126
- <Box
127
- className={styles.mobileMenuWrapper}
128
- sx={{ flexGrow: 1, display: { xs: "flex", md: "none" } }}
129
- >
130
- <IconButton
131
- className={styles.toggleIcon}
132
- size="large"
133
- aria-label="account of current user"
134
- aria-controls="menu-appbar"
135
- aria-haspopup="true"
136
- onClick={() => handleMobileMenuToggle()}
137
- color="inherit"
138
- >
139
- <MenuIcon />
140
- </IconButton>
141
- </Box>
142
- {/* Desktop Menu */}
143
- <Box
144
- sx={{
145
- flexGrow: 1,
146
- display: {
147
- xs: "none",
148
- md: isSearchBarOpen ? "none" : "flex",
149
- },
150
- justifyContent: "flex-end",
151
- }}
152
- >
153
- {navbarContent.items.map(
154
- (item) => item.display && (
155
- <Link
156
- className={styles.navbarOption}
157
- key={item.title}
158
- sx={{ my: 2, display: "block" }}
159
- href={item.link}
160
- >
161
- {item.items?.length > 0 ? (
162
- <>
163
- {item.title}
164
- <ArrowDropDownIcon className={styles.arrowDownIcon} />
165
- <Box className={styles.dropDownMenu}>
166
- {item.items.map((subItem) => (!subItem.title && !subItem.link ? (
167
- <div
168
- className={styles.divider}
169
- key={subItem.title}
170
- />
171
- ) : (
172
- <Button
173
- className={styles.dropdownMenuOption}
174
- key={subItem.title}
175
- onClick={() => handleNavigation(subItem.link)}
176
- sx={{ display: "block" }}
177
- disableRipple
178
- >
179
- {subItem.title}
180
- </Button>
181
- )))}
182
- </Box>
183
- </>
184
- ) : (
185
- item.title
186
- )}
187
- </Link>
188
- ),
189
- )}
190
- </Box>
191
- {isLoggedUser ? (
192
- <Box
193
- maxWidth="15%"
194
- sx={{
195
- display: {
196
- xs: "none",
197
- md: isSearchBarOpen ? "none" : "flex",
198
- },
199
- justifyContent: "flex-end",
200
- marginLeft: "auto",
201
- }}
202
- >
203
- <Box
204
- className={`${styles.navbarOption}`}
205
- sx={{ my: 2, display: "block" }}
206
- >
207
- My Account
208
- <ArrowDropDownIcon className={styles.arrowDownIcon} />
209
- <Box className={styles.dropDownMenu}>
210
- <Button
211
- className={styles.dropdownMenuOption}
212
- onClick={() => handleNavigation("/profile/")}
213
- sx={{ display: "block" }}
214
- disableRipple
215
- >
216
- Edit Profile
217
- </Button>
218
- <Button
219
- className={styles.dropdownMenuOption}
220
- onClick={() => handleNavigation(
221
- `/community/members/profile/${
222
- member.id
223
- }/${`${member.first_name.toLowerCase()}-${member.last_name.toLowerCase()}`}`,
224
- )}
225
- sx={{ display: "block" }}
226
- disableRipple
227
- >
228
- View Public Profile
229
- </Button>
230
- <div className={styles.divider} />
231
- <Button
232
- className={styles.dropdownMenuOption}
233
- sx={{ display: "block" }}
234
- onClick={onClickLogout}
235
- disableRipple
236
- >
237
- Log out
238
- </Button>
239
- </Box>
240
- </Box>
241
- </Box>
242
- ) : (
243
- <Box
244
- maxWidth="15%"
245
- sx={{
246
- display: {
247
- xs: "none",
248
- md: isSearchBarOpen ? "none" : "flex",
249
- },
250
- justifyContent: "flex-end",
251
- marginLeft: "auto",
252
- }}
253
- >
254
- <Box
255
- className={`${styles.navbarOption} ${styles.join}`}
256
- sx={{ my: 2, display: "block" }}
257
- >
258
- Join
259
- <ArrowDropDownIcon className={styles.arrowDownIcon} />
260
- <Box className={styles.dropDownMenu}>
261
- <Button
262
- className={styles.dropdownMenuOption}
263
- onClick={() => handleNavigation("https://openinfra.dev/join")}
264
- sx={{ display: "block" }}
265
- disableRipple
266
- >
267
- Sign up for Foundation Membership
268
- </Button>
269
- <Button
270
- className={styles.dropdownMenuOption}
271
- onClick={() => handleNavigation("https://openinfra.dev/join")}
272
- sx={{ display: "block" }}
273
- disableRipple
274
- >
275
- Sponsor the Foundation
276
- </Button>
277
- <Button
278
- className={styles.dropdownMenuOption}
279
- onClick={() => handleNavigation("https://openinfra.dev")}
280
- sx={{ display: "block" }}
281
- disableRipple
282
- >
283
- More about the Foundation
284
- </Button>
285
- </Box>
286
- </Box>
287
- <Button
288
- className={`${styles.navbarOption} ${styles.login}`}
289
- onClick={() => doLogin("/")}
290
- sx={{ my: 2, display: "block" }}
291
- disableRipple
292
- >
293
- Log in
294
- </Button>
295
- </Box>
296
- )}
297
- </Toolbar>
298
- <Box
299
- className={`${styles.openstackSearchBarMobile} openstack-search-bar ossw-mobile`}
300
- sx={{
301
- visibility: {
302
- xs: isMobileMenuOpen ? "visible" : "hidden",
303
- md: "hidden",
304
- },
305
- opacity: { xs: isMobileMenuOpen ? "1" : "0", md: "0" },
306
- height: { xs: isMobileMenuOpen ? "auto" : 0, md: 0 },
307
- color: "#8a959e",
308
- }}
309
- data-baseurl={getEnvVariable(SEARCH_WIDGET_BASE_URL)}
310
- data-context="www-openstack"
311
- />
312
- {isMobileMenuOpen && (
313
- <Box
314
- className={styles.navbarMobileMenu}
315
- sx={{
316
- display: { xs: "flex", md: "none" },
317
- }}
318
- >
319
- {navbarContent.items.map(
320
- (item) => item.display && (
321
- <>
322
- <Button
323
- disableRipple
324
- className={styles.mobileOption}
325
- key={`${item.title}-mobile`}
326
- onClick={() => handleSetActiveMenu(item.title)}
327
- >
328
- {item.title}
329
- {item.items?.length > 0
330
- && (item.title === navbarMenu ? (
331
- <RemoveIcon aria-hidden="true" />
332
- ) : (
333
- <AddIcon aria-hidden="true" />
334
- ))}
335
- </Button>
336
- {item.items?.length > 0 && item.title === navbarMenu && (
337
- <Box className={styles.mobileDropdownMenu}>
338
- {item.items.map((subItem) => (!subItem.title && !subItem.link ? (
339
- <div
340
- className={styles.divider}
341
- key={subItem.title}
342
- />
343
- ) : (
344
- <Button
345
- className={styles.mobileDropdownOption}
346
- key={`${subItem.title}-mobile`}
347
- onClick={() => handleNavigation(subItem.link)}
348
- sx={{ display: "block" }}
349
- disableRipple
350
- >
351
- {subItem.title}
352
- </Button>
353
- )))}
354
- </Box>
355
- )}
356
- </>
357
- ),
358
- )}
359
- {isLoggedUser ? (
360
- <>
361
- <Button
362
- className={styles.mobileOption}
363
- onClick={() => handleSetActiveMenu("My Account")}
364
- disableRipple
365
- >
366
- My Account
367
- {navbarMenu === "My Account" ? (
368
- <RemoveIcon aria-hidden="true" />
369
- ) : (
370
- <AddIcon aria-hidden="true" />
371
- )}
372
- </Button>
373
- {navbarMenu === "My Account" && (
374
- <Box className={styles.mobileDropdownMenu}>
375
- <Button
376
- className={styles.mobileDropdownOption}
377
- onClick={() => handleNavigation("/profile/")}
378
- sx={{ display: "block" }}
379
- disableRipple
380
- >
381
- Edit Profile
382
- </Button>
383
- <Button
384
- className={styles.mobileDropdownOption}
385
- onClick={() => handleNavigation(
386
- `/community/members/profile/${
387
- member.id
388
- }/${`${member.first_name.toLowerCase()}-${member.last_name.toLowerCase()}`}`,
389
- )}
390
- sx={{ display: "block" }}
391
- disableRipple
392
- >
393
- View Public Profile
394
- </Button>
395
- <div className={styles.divider} />
396
- <Button
397
- className={styles.mobileDropdownOption}
398
- sx={{ display: "block" }}
399
- onClick={onClickLogout}
400
- disableRipple
401
- >
402
- Log out
403
- </Button>
404
- </Box>
405
- )}
406
- </>
407
- ) : (
408
- <Box>
409
- <Box
410
- className={`${styles.navbarOption} ${styles.join}`}
411
- sx={{ my: 2, display: "block" }}
412
- >
413
- Join
414
- <ArrowDropDownIcon className={styles.arrowDownIcon} />
415
- <Box className={styles.dropDownMenu}>
416
- <Button
417
- className={styles.dropdownMenuOption}
418
- onClick={() => handleNavigation("https://openinfra.dev/join")}
419
- sx={{ display: "block" }}
420
- disableRipple
421
- >
422
- Sign up for Foundation Membership
423
- </Button>
424
- <Button
425
- className={styles.dropdownMenuOption}
426
- onClick={() => handleNavigation("https://openinfra.dev/join")}
427
- sx={{ display: "block" }}
428
- disableRipple
429
- >
430
- Sponsor the Foundation
431
- </Button>
432
- <Button
433
- className={styles.dropdownMenuOption}
434
- onClick={() => handleNavigation("https://openinfra.dev")}
435
- sx={{ display: "block" }}
436
- disableRipple
437
- >
438
- More about the Foundation
439
- </Button>
440
- </Box>
441
- </Box>
442
- <Button
443
- className={`${styles.navbarOption} ${styles.login}`}
444
- onClick={() => doLogin("/")}
445
- sx={{ my: 2, display: "block" }}
446
- disableRipple
447
- >
448
- Log in
449
- </Button>
450
- </Box>
451
- )}
452
- </Box>
453
- )}
454
- </Container>
455
- </AppBar>
456
- </nav>
457
- );
27
+ return <NavBarTemplate data={navBarContent} />;
458
28
  }
459
29
 
460
- Navbar.propTypes = {
461
- isLoggedUser: PropTypes.bool.isRequired,
462
- member: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf([null])])
463
- .isRequired,
464
- };
465
-
466
- const mapStateToProps = ({ loggedUserState }) => ({
467
- isLoggedUser: loggedUserState.isLoggedUser,
468
- member: loggedUserState.member,
469
- });
470
-
471
- export default connect(mapStateToProps, {})(Navbar);
30
+ export default NavBar;
@@ -8,107 +8,13 @@
8
8
  min-height: 50px;
9
9
  border: 1px solid transparent;
10
10
  box-shadow: none;
11
- .navbarHeader {
12
- .brandWrapper {
13
- margin: 10px 0;
14
- padding-right: 20px;
15
- float: left;
16
- border-right: 1px solid #eee;
17
- min-width: 135px;
18
- a.navbarBrand {
19
- background: url("../../images/openstack-logo-full.svg") left no-repeat;
20
- height: 35px;
21
- width: 135px;
22
- color: #777;
23
- padding: 15px 15px;
24
- font-size: 18px;
25
- line-height: 20px;
26
- display: block;
27
- }
28
- }
29
- .searchWrapper {
30
- padding: 21px 0px 15px 20px;
31
- float: left;
32
- text-transform: uppercase;
33
- color: #8a959e;
34
- font-size: 12px;
35
- font-weight: 400;
36
- line-height: 17.15px;
37
- .searchComponent {
38
- cursor: pointer;
39
- z-index: 5;
40
- position: relative;
41
- .searchIcon {
42
- width: 12px;
43
- height: 12px;
44
- line-height: 12px;
45
- margin-right: 5px;
46
- }
47
- }
48
- .openstackSearchBar {
49
- width: 100%;
50
- position: absolute;
51
- top: 0;
52
- z-index: 100;
53
- height: 70px;
54
- padding-top: 10px;
55
- padding-right: 12%;
56
- background-color: #fff;
57
- opacity: 0;
58
- transition: opacity 0.3s ease;
59
- }
60
- @media (max-width: 768px) {
61
- display: none;
62
- }
63
- @media (max-width: 1160px) {
64
- .headerSearchText {
65
- display: none;
66
- }
67
- }
68
- }
69
- .navbarToggle {
70
- appearance: button;
71
- cursor: pointer;
72
- position: relative;
73
- float: right;
74
- padding: 9px 10px;
75
- margin-top: 8px;
76
- margin-bottom: 8px;
77
- background: transparent;
78
- border: none;
79
- .iconBar {
80
- background-color: #5a5a5a;
81
- height: 3px;
82
- border-radius: 3px;
83
- display: block;
84
- width: 22px;
85
- margin-top: 4px;
86
- }
87
- @media (min-width: 768px) {
88
- display: none;
89
- }
90
- }
91
- @media (min-width: 768px) and (max-width: 1310px) {
92
- .brandWrapper {
93
- width: 75px;
94
- min-width: 75px;
95
- margin-top: 0;
96
- a.navbarBrand {
97
- background: url("../../images/openstack-logo-vert.svg") left no-repeat;
98
- margin-left: 0px !important;
99
- height: 54px;
100
- width: 59px;
101
- }
102
- }
103
- }
104
- }
105
11
  .navbarOption {
106
12
  color: #8a959e;
107
13
  font-size: 12px;
108
14
  font-weight: 400;
109
15
  text-transform: uppercase;
110
16
  position: relative;
111
- padding: 15px 15px 20px;
17
+ padding: 20px 15px 15px;
112
18
  text-decoration: none;
113
19
  text-align: left;
114
20
  cursor: pointer;
@@ -225,7 +131,7 @@
225
131
  padding: 3px 25px;
226
132
  border-radius: 4px;
227
133
  color: #fff;
228
- margin-top: 12px;
134
+ margin-top: 17px;
229
135
  font-size: 14px;
230
136
  height: 22px;
231
137
  &:hover {
@@ -235,15 +141,6 @@
235
141
  }
236
142
  }
237
143
  }
238
- .mobileMenuWrapper {
239
- .toggleIcon {
240
- color: #5a5a5a;
241
- margin-left: auto;
242
- &:hover {
243
- background-color: transparent;
244
- }
245
- }
246
- }
247
144
  .navbarMobileMenu {
248
145
  flex-direction: column;
249
146
  .openstackSearchBarMobile {