@openstack_dev/gatsby-theme-marketing-oif-core 1.0.12 → 1.0.13
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.
- package/package.json +1 -1
- package/src/components/Navbar/AuthUserSubNavBar/index.js +145 -0
- package/src/components/Navbar/LoginButton/index.js +29 -0
- package/src/components/Navbar/MobileMenu/index.js +34 -0
- package/src/components/Navbar/MobileMenu/index.module.scss +9 -0
- package/src/components/Navbar/NavBarDropDown/index.js +47 -0
- package/src/components/Navbar/NavBarHeader/index.js +28 -0
- package/src/components/Navbar/NavBarHeader/index.module.scss +55 -0
- package/src/components/Navbar/NavBarItem/index.js +92 -0
- package/src/components/Navbar/PublicUserSubNavBar/index.js +83 -0
- package/src/components/Navbar/SearchBar/index.js +108 -0
- package/src/components/Navbar/SearchBar/index.module.scss +43 -0
- package/src/components/Navbar/index.js +24 -465
- package/src/components/Navbar/index.module.scss +2 -105
- package/src/components/Navbar/template.js +157 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { navigate } from "gatsby";
|
|
4
|
+
import { connect } from "react-redux";
|
|
5
|
+
import { Container } from "@mui/material";
|
|
6
|
+
import "@fortawesome/fontawesome-free/css/all.css";
|
|
7
|
+
import AppBar from "@mui/material/AppBar";
|
|
8
|
+
import Box from "@mui/material/Box";
|
|
9
|
+
import Toolbar from "@mui/material/Toolbar";
|
|
10
|
+
import PublicUserSubNavBar from "./PublicUserSubNavBar";
|
|
11
|
+
import AuthUserSubNavBar from "./AuthUserSubNavBar";
|
|
12
|
+
import NavBarItem from "./NavBarItem";
|
|
13
|
+
import MobileMenu from "./MobileMenu";
|
|
14
|
+
import SearchBar from "./SearchBar";
|
|
15
|
+
import NavBarHeader from "./NavBarHeader";
|
|
16
|
+
|
|
17
|
+
import styles from "./index.module.scss";
|
|
18
|
+
|
|
19
|
+
function NavBarTemplate({ data, isLoggedUser, member }) {
|
|
20
|
+
const [navbarMenu, setNavbarMenu] = React.useState("");
|
|
21
|
+
const [isMobileMenuOpen, setIsMobileMenuOpen] = React.useState(false);
|
|
22
|
+
const [isSearchBarOpen, setIsSearchBarOpen] = React.useState(false);
|
|
23
|
+
|
|
24
|
+
const handleSetActiveMenu = (option) => {
|
|
25
|
+
setNavbarMenu(navbarMenu === option ? "" : option);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const handleMobileMenuToggle = () => {
|
|
29
|
+
setIsMobileMenuOpen(!isMobileMenuOpen);
|
|
30
|
+
setNavbarMenu("");
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const handleNavigation = (ev, url) => {
|
|
34
|
+
ev.preventDefault();
|
|
35
|
+
navigate(url);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<nav role="navigation">
|
|
40
|
+
<AppBar
|
|
41
|
+
position="static"
|
|
42
|
+
className={styles.navbar}
|
|
43
|
+
sx={{ backgroundColor: "#fff", boxShadow: "none" }}
|
|
44
|
+
>
|
|
45
|
+
<Container maxWidth="xl">
|
|
46
|
+
<Toolbar disableGutters sx={{ flexWrap: "wrap" }}>
|
|
47
|
+
<NavBarHeader
|
|
48
|
+
setIsSearchBarOpen={(value) => setIsSearchBarOpen(value)}
|
|
49
|
+
/>
|
|
50
|
+
{/* Mobile Menu */}
|
|
51
|
+
<MobileMenu handleMobileMenuToggle={handleMobileMenuToggle} />
|
|
52
|
+
{/* Desktop Menu */}
|
|
53
|
+
<Box
|
|
54
|
+
sx={{
|
|
55
|
+
flexGrow: 1,
|
|
56
|
+
display: {
|
|
57
|
+
xs: "none",
|
|
58
|
+
md: isSearchBarOpen ? "none" : "flex",
|
|
59
|
+
},
|
|
60
|
+
justifyContent: "flex-end",
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{data.items.map(
|
|
64
|
+
(item) => item.display && (
|
|
65
|
+
<NavBarItem
|
|
66
|
+
key={`navbar-item-${item.title}`}
|
|
67
|
+
item={item}
|
|
68
|
+
navbarMenu={navbarMenu}
|
|
69
|
+
handleNavigation={handleNavigation}
|
|
70
|
+
/>
|
|
71
|
+
),
|
|
72
|
+
)}
|
|
73
|
+
</Box>
|
|
74
|
+
{isLoggedUser ? (
|
|
75
|
+
<AuthUserSubNavBar
|
|
76
|
+
isMobile={false}
|
|
77
|
+
member={member}
|
|
78
|
+
navbarMenu={navbarMenu}
|
|
79
|
+
isSearchBarOpen={isSearchBarOpen}
|
|
80
|
+
handleNavigation={handleNavigation}
|
|
81
|
+
/>
|
|
82
|
+
) : (
|
|
83
|
+
<PublicUserSubNavBar
|
|
84
|
+
isSearchBarOpen={isSearchBarOpen}
|
|
85
|
+
handleNavigation={handleNavigation}
|
|
86
|
+
isDesktop
|
|
87
|
+
/>
|
|
88
|
+
)}
|
|
89
|
+
</Toolbar>
|
|
90
|
+
<SearchBar isMobileMenuOpen={isMobileMenuOpen} isMobile />
|
|
91
|
+
{isMobileMenuOpen && (
|
|
92
|
+
<Box
|
|
93
|
+
className={styles.navbarMobileMenu}
|
|
94
|
+
sx={{
|
|
95
|
+
display: { xs: "flex", md: "none" },
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
{data.items.map(
|
|
99
|
+
(item) => item.display && (
|
|
100
|
+
<NavBarItem
|
|
101
|
+
item={item}
|
|
102
|
+
key={`navbar-item-mobile-${item.title}`}
|
|
103
|
+
navbarMenu={navbarMenu}
|
|
104
|
+
setActiveMenu={(option) => handleSetActiveMenu(option)}
|
|
105
|
+
handleNavigation={handleNavigation}
|
|
106
|
+
isMobile
|
|
107
|
+
/>
|
|
108
|
+
),
|
|
109
|
+
)}
|
|
110
|
+
{isLoggedUser ? (
|
|
111
|
+
<AuthUserSubNavBar
|
|
112
|
+
member={member}
|
|
113
|
+
navbarMenu={navbarMenu}
|
|
114
|
+
setActiveMenu={(option) => handleSetActiveMenu(option)}
|
|
115
|
+
handleNavigation={handleNavigation}
|
|
116
|
+
isMobile
|
|
117
|
+
/>
|
|
118
|
+
) : (
|
|
119
|
+
<PublicUserSubNavBar handleNavigation={handleNavigation} />
|
|
120
|
+
)}
|
|
121
|
+
</Box>
|
|
122
|
+
)}
|
|
123
|
+
</Container>
|
|
124
|
+
</AppBar>
|
|
125
|
+
</nav>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
NavBarTemplate.propTypes = {
|
|
130
|
+
isLoggedUser: PropTypes.bool.isRequired,
|
|
131
|
+
member: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf([null])]),
|
|
132
|
+
data: PropTypes.shape({
|
|
133
|
+
title: PropTypes.string,
|
|
134
|
+
link: PropTypes.string,
|
|
135
|
+
display: PropTypes.bool,
|
|
136
|
+
requiresAuth: PropTypes.bool,
|
|
137
|
+
items: PropTypes.arrayOf(
|
|
138
|
+
PropTypes.shape({
|
|
139
|
+
link: PropTypes.string,
|
|
140
|
+
title: PropTypes.string,
|
|
141
|
+
display: PropTypes.bool,
|
|
142
|
+
requiresAuth: PropTypes.bool,
|
|
143
|
+
}),
|
|
144
|
+
),
|
|
145
|
+
}).isRequired,
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
NavBarTemplate.defaultProps = {
|
|
149
|
+
member: null,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const mapStateToProps = ({ loggedUserState }) => ({
|
|
153
|
+
isLoggedUser: loggedUserState.isLoggedUser,
|
|
154
|
+
member: loggedUserState.member,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
export default connect(mapStateToProps, {})(NavBarTemplate);
|