-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from fe-apr24-team2/main
add burger menu
- Loading branch information
Showing
9 changed files
with
214 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
@font-face { | ||
font-family: 'Mont'; | ||
src: url('/fonts/Mont-Bold.otf') format('opentype'); | ||
font-weight: bold; | ||
font-style: normal; | ||
} | ||
$menuFont: Mont, sans-serif; | ||
|
||
.burger-menu { | ||
position: relative; | ||
overflow: hidden; | ||
|
||
&__icon { | ||
background: none; | ||
border: none; | ||
cursor: pointer; | ||
padding: 16px; | ||
border-left: 1px solid #E2E6E9; | ||
|
||
@media (min-width: 640px) { | ||
display: none; | ||
} | ||
} | ||
|
||
&__logo { | ||
padding: 13px 16px; | ||
box-sizing: border-box; | ||
} | ||
|
||
&__content { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background: white; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
box-sizing: border-box; | ||
z-index: 1; | ||
font-family: $menuFont; | ||
} | ||
|
||
&__header { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
width: 100%; | ||
box-sizing: border-box; | ||
border: 1px solid #E2E6E9; | ||
height: 48px; | ||
} | ||
|
||
&__close { | ||
border-left: 1px solid #E2E6E9; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 16px; | ||
cursor: pointer; | ||
} | ||
|
||
&__list { | ||
width: 100%; | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
text-align: center; | ||
flex-grow: 1; | ||
} | ||
|
||
&__item { | ||
padding: 16px; | ||
} | ||
|
||
&__link { | ||
text-decoration: none; | ||
color: #89939A; | ||
padding: 8px 0; | ||
font-weight: 800; | ||
font-size: 12px; | ||
line-height: 11px; | ||
text-transform: uppercase; | ||
transition: 0.3s; | ||
&:hover { | ||
color: #313237; | ||
} | ||
} | ||
.is-active { | ||
position: relative; | ||
|
||
color: #313237; | ||
|
||
&::after { | ||
content: ''; | ||
position: absolute; | ||
width: 100%; | ||
height: 3px; | ||
background-color: #313237; | ||
border-radius: 8px; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
} | ||
} | ||
|
||
&__footer { | ||
display: flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
} | ||
|
||
&__icon-footer { | ||
width: 50%; | ||
height: 24px; | ||
box-sizing: border-box; | ||
border: 1px solid #E2E6E9; | ||
box-sizing: border-box; | ||
padding: 24px 72px; | ||
align-content: center; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
display: flex; | ||
|
||
&.is-active::after { | ||
content: ''; | ||
position: absolute; | ||
bottom: -2px; | ||
left: 0; | ||
right: 0; | ||
height: 2px; | ||
background-color: red; | ||
border-radius: 8px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* eslint-disable jsx-a11y/click-events-have-key-events */ | ||
/* eslint-disable jsx-a11y/anchor-is-valid */ | ||
/* eslint-disable jsx-a11y/no-static-element-interactions */ | ||
/* eslint-disable react/button-has-type */ | ||
// BurgerMenu.jsx | ||
import { useState, useEffect } from 'react'; | ||
import { NavLink, useLocation } from 'react-router-dom'; | ||
import './BurgerMenu.scss'; | ||
|
||
export const BurgerMenu = () => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const location = useLocation(); | ||
|
||
useEffect(() => { | ||
setIsOpen(false); | ||
}, [location]); | ||
|
||
return ( | ||
<div className={`burger-menu ${isOpen ? 'is-open' : ''}`}> | ||
<button className="burger-menu__icon" onClick={() => setIsOpen(!isOpen)}> | ||
<img src="\src\components\Header\img\menu.svg" alt="Menu" /> | ||
</button> | ||
{isOpen && ( | ||
<div className="burger-menu__content"> | ||
<div className="burger-menu__header"> | ||
<img src="\src\components\Header\img\logo.svg" alt="Nice Gadgets logo" className="burger-menu__logo" /> | ||
<a className="burger-menu__close" onClick={() => setIsOpen(!isOpen)}> | ||
<img src="\src\components\Header\img\Close.svg" alt="Close" /> | ||
</a> | ||
</div> | ||
<ul className="burger-menu__list"> | ||
<li className="burger-menu__item"> | ||
<NavLink to="/" className={({ isActive }) => `burger-menu__link ${isActive ? 'is-active' : ''}`}>Home</NavLink> | ||
</li> | ||
<li className="burger-menu__item"> | ||
<NavLink to="/phones" className={({ isActive }) => `burger-menu__link ${isActive ? 'is-active' : ''}`}>Phones</NavLink> | ||
</li> | ||
<li className="burger-menu__item"> | ||
<NavLink to="/tablets" className={({ isActive }) => `burger-menu__link ${isActive ? 'is-active' : ''}`}>Tablets</NavLink> | ||
</li> | ||
<li className="burger-menu__item"> | ||
<NavLink to="/accessories" className={({ isActive }) => `burger-menu__link ${isActive ? 'is-active' : ''}`}>Accessories</NavLink> | ||
</li> | ||
</ul> | ||
<div className="burger-menu__footer"> | ||
<a href="heart" className="burger-menu__icon-footer" aria-label="Heart"> | ||
<img src="\src\components\Header\img\heartLike.svg" alt="Heart" /> | ||
</a> | ||
<a href="/#cart" className="burger-menu__icon-footer" aria-label="Cart"> | ||
<img src="\src\components\Header\img\cart.svg" alt="Cart" /> | ||
</a> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.