Skip to content

Commit 082546f

Browse files
author
Nika Kolesnikova
committed
conditional display of Home/Burger/Close button, or NavIcon component
1 parent 448dada commit 082546f

File tree

2 files changed

+21
-51
lines changed

2 files changed

+21
-51
lines changed

frontend/frontside/src/components/NavBar&Footer/NavBar.css

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,6 @@
5555
display: none;
5656
}
5757

58-
.close-icon {
59-
font-size: 6rem;
60-
align-self: flex-end;
61-
position: absolute;
62-
right: 5%;
63-
top: 5%;
64-
65-
}
66-
67-
.burger-icon {
68-
z-index: 3;
69-
display: none;
70-
font-size: unset;
71-
transition: all smooth;
72-
}
73-
7458

7559
nav {
7660
position: relative;
@@ -117,23 +101,6 @@
117101
display: flex;
118102
}
119103

120-
.close-icon {
121-
font-size: 6rem;
122-
align-self: flex-end;
123-
position: absolute;
124-
right: 10%;
125-
top: 50%;
126-
127-
}
128-
129-
.burger-icon {
130-
z-index: 3;
131-
display: flex;
132-
font-size: 2.5rem;
133-
transition: all smooth;
134-
}
135-
136-
137104
nav {
138105
position: relative;
139106
background: linear-gradient(146deg, rgba(255,255,255,0) 0%, rgba(51,51,51,0.25) 51%, rgba(239,244,255,0) 100%);
@@ -181,23 +148,6 @@
181148
display: flex;
182149
}
183150

184-
.close-icon {
185-
font-size: 6rem;
186-
align-self: flex-end;
187-
position: absolute;
188-
right: 5%;
189-
top: 5%;
190-
191-
}
192-
193-
.burger-icon {
194-
z-index: 3;
195-
display: flex;
196-
font-size: 2rem;
197-
transition: all smooth;
198-
}
199-
200-
201151
nav {
202152
position: relative;
203153
background: linear-gradient(146deg, rgba(255,255,255,0) 0%, rgba(51,51,51,0.25) 51%, rgba(239,244,255,0) 100%);

frontend/frontside/src/components/NavIcon/NavIcon.jsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import React from 'react';
22
import { IoMenu, IoCloseOutline, IoCaretBackCircle } from "react-icons/io5";
3+
import { useLocation } from 'react-router-dom';
34
import './NavIconStyle.css';
45

56
const NavIcon = ({type, isVisible, handleBurgerIconClick}) => {
67

8+
// check current path
9+
const location = useLocation();
10+
711
// on click of to top button
812
const handleClick = () => {
913
//scroll to top
@@ -40,7 +44,23 @@ const NavIcon = ({type, isVisible, handleBurgerIconClick}) => {
4044
)
4145
}
4246

43-
return type === 'burger' ? burgerIcon() : toTopIcon();
47+
//
48+
const getIcon = () => {
49+
// list of paths where no footer icon is needed
50+
const noHomeIconPaths = ['/log-in', '/sign-up', 'profile'];
51+
52+
// if burger icon is specified
53+
if(type) {
54+
// display burger icon
55+
return burgerIcon();
56+
} else {
57+
// if burger icon isnt specified, check path, display Home button accordingly
58+
return noHomeIconPaths.includes(location.pathname) ? null : toTopIcon();
59+
}
60+
}
61+
62+
// main function ----------------------------
63+
return getIcon();
4464
}
4565

4666
export default NavIcon;

0 commit comments

Comments
 (0)