Skip to content

Commit 4045472

Browse files
committed
mobile menu:built the mobile menu
1 parent 737e048 commit 4045472

File tree

4 files changed

+103
-30
lines changed

4 files changed

+103
-30
lines changed

src/Nav.js

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,56 @@ import logo from "../src/images/meta.png";
66
import Button from "./components/Button";
77
import { faBars } from "@fortawesome/free-solid-svg-icons";
88
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
9-
import { Link } from 'react-router-dom';
10-
11-
12-
13-
function Nav() {
14-
9+
import { Link } from "react-router-dom";
10+
import withToggler from "./components/HOCS/withToggler";
1511

12+
function Nav({ toggleValue, Toggling }) {
13+
console.log(toggleValue);
1614
return (
1715
<section className="nav--container grid">
18-
<div className="nav-section_content">
19-
<div className="logo--container">
20-
<img src={home} alt="a home icon" className="home--img" />
21-
<img src={logo} className="meta--logo" alt="metabnb logo" />
22-
</div>
23-
<nav>
24-
<ul className="nav-links">
25-
<li className="nav-link">Home</li>
26-
<Link to='/place'><li className="nav-link">Place to stay</li></Link>
27-
<li className="nav-link">NFTs</li>
28-
<li className="nav-link">Community</li>
29-
</ul>
30-
</nav>
31-
<div>
32-
{" "}
33-
<Button name="Connect wallet" styleclass="nav-btn"/>
34-
</div>
35-
<div className="hamburger-menu">
36-
<FontAwesomeIcon icon={faBars} className="hamburger-menu" />
16+
<div className="nav--container_2">
17+
<div className="nav-section_content">
18+
<div className="logo--container">
19+
<img src={home} alt="a home icon" className="home--img" />
20+
<img src={logo} className="meta--logo" alt="metabnb logo" />
21+
</div>
22+
<nav>
23+
<ul className="nav-links">
24+
<li className="nav-link">Home</li>
25+
<Link to="/place">
26+
<li className="nav-link">Place to stay</li>
27+
</Link>
28+
<li className="nav-link">NFTs</li>
29+
<li className="nav-link">Community</li>
30+
</ul>
31+
</nav>
32+
<div>
33+
{" "}
34+
<Button name="Connect wallet" styleclass="nav-btn" />
35+
</div>
36+
37+
<div className="hamburger-menu" onClick={Toggling}>
38+
<FontAwesomeIcon icon={faBars} className="hamburger-menu" />
39+
</div>
3740
</div>
41+
{/* TOGGLE MENU LIST */}
42+
{toggleValue ? (
43+
<div className="mobile-menu_list">
44+
<Link to="/">
45+
<p>Home</p>
46+
</Link>
47+
<Link to="/place">
48+
<p>Place to stay</p>
49+
</Link>
50+
<p>NFTs</p>
51+
<p>Community</p>
52+
</div>
53+
) : (
54+
""
55+
)}
3856
</div>
3957
</section>
4058
);
4159
}
4260

43-
export default Nav;
61+
export default withToggler(Nav);

src/components/HOCS/withToggler.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { React, Component } from "react";
2+
3+
function withToggler(Component) {
4+
return function (props) {
5+
return <Toggler CalledComp={Component} {...props} />;
6+
};
7+
}
8+
9+
class Toggler extends Component {
10+
state = {
11+
togglestate: "false",
12+
};
13+
toggling = () => {
14+
this.setState({ togglestate: !this.state.togglestate });
15+
};
16+
17+
render() {
18+
const TheCalledComp = this.props.CalledComp;
19+
20+
return (
21+
<div>
22+
<TheCalledComp
23+
toggleValue={this.state.togglestate}
24+
Toggling={this.toggling}
25+
/>
26+
</div>
27+
);
28+
}
29+
}
30+
31+
export default withToggler;

src/styles/nav.css

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
11
.nav--container {
2-
background: linear-gradient(124.4deg, #ffffff 10.8%, #ffffff 87.34%);
2+
/* background: linear-gradient(124.4deg, #ffffff 10.8%, #ffffff 87.34%); */
33
align-items: center;
4+
5+
6+
47
}
5-
.nav-section_content {
8+
.nav--container_2{
69
grid-column: center-start/center-end;
10+
display: flex;
11+
flex-direction: column;
12+
13+
}
14+
.nav-section_content {
15+
716
display: flex;
817
justify-content: space-between;
918
align-items: center;
1019
flex-wrap:wrap ;
20+
position: relative;
21+
22+
padding: 1rem 0;
23+
}
24+
.mobile-menu_list{
25+
align-self: flex-end;
26+
27+
28+
width: 100%;
29+
text-align: right;
30+
font-size: 1.5rem;
31+
line-height: 2;
32+
border-bottom: 1px solid #6F6CE1;
33+
border-radius: 1rem;
1134
}
35+
1236
.logo--container {
1337
display: flex;
1438
align-items: center;

src/styles/styles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ div#root {
1717
max-width: 100%;
1818
height: 100vh;
1919
display: grid;
20-
grid-template-rows: 12% min-content min-content;
20+
grid-template-rows: repeat(3,min-content);
2121

2222
}
2323
a{
@@ -33,7 +33,7 @@ html {
3333
[right-start] minmax(3%, 1fr)
3434
[right-end center-start] repeat(8, minmax(min-content, 14rem))
3535
[center-end left-start] minmax(3%, 1fr) [left-end];
36-
grid-template-rows: auto;
36+
3737
}
3838
.purp {
3939
color: var(--purple);

0 commit comments

Comments
 (0)