Skip to content

Commit

Permalink
Merge pull request #11 from fe-apr24-team2/main
Browse files Browse the repository at this point in the history
add burger menu
  • Loading branch information
lesdyman authored Aug 1, 2024
2 parents b43321d + 93d47d1 commit a76675b
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 70 deletions.
137 changes: 137 additions & 0 deletions src/components/Header/BurgerMenu/BurgerMenu.scss
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;
}
}
}
57 changes: 57 additions & 0 deletions src/components/Header/BurgerMenu/BurgerMenu.tsx
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>
);
};
41 changes: 14 additions & 27 deletions src/components/Header/Header.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$header-height-desktop: 64px;
$header-height-tablet: 48px;
$header-height-phone: 48px;
$mainFont: Mont, sans-serif;

@font-face {
Expand All @@ -25,18 +26,20 @@ $mainFont: Mont, sans-serif;

.header {
display: flex;
border: 1px solid #E2E6E9;
box-sizing: border-box;
position: sticky;
z-index: 2;
top: 0;
background-color: #fff;
box-shadow: 0px 1px 0px 0px #e2e6e9;

li,
a {
list-style: none;
text-decoration: none;
}

@include on-phone {
height: $header-height-phone;
}

@include on-tablet {
height: $header-height-tablet;
}
Expand Down Expand Up @@ -107,6 +110,11 @@ $mainFont: Mont, sans-serif;
box-sizing: border-box;
transition: color 0.3s;


&__item {
list-style: none;
}

&__list {
display: flex;
align-items: center;
Expand Down Expand Up @@ -196,7 +204,7 @@ $mainFont: Mont, sans-serif;
padding: 32px;
background-repeat: no-repeat;
background-position: center;
border: 1px solid #e2e6e9;
border-left: 1px solid #E2E6E9;
box-sizing: border-box;
border-right: none;
}
Expand All @@ -208,7 +216,7 @@ $mainFont: Mont, sans-serif;
padding: 32px;
background-repeat: no-repeat;
background-position: center;
border: 1px solid #e2e6e9;
border-left: 1px solid #E2E6E9;
box-sizing: border-box;
}

Expand All @@ -223,24 +231,3 @@ $mainFont: Mont, sans-serif;
}
}

.burger-menu {
display: none;
@include on-phone {
display: flex;
box-shadow: -1px 0 0 0 #e2e6e9;
flex-direction: column;
justify-content: space-between;
width: 24px;
height: 24px;
padding: 16px;
cursor: pointer;

// span {
// display: block;
// width: 100%;
// height: 2px;
// background-color: black;
// transition: all 0.3s;
// }
}
}
8 changes: 3 additions & 5 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NavLink } from 'react-router-dom';
import './index.scss';
import React from 'react';
import logo from './logo.svg';
import menu from './menu.svg';
import { BurgerMenu } from './BurgerMenu/BurgerMenu';
import logo from './img/logo.svg';

export const Header: React.FC = () => {
return (
Expand Down Expand Up @@ -54,9 +54,7 @@ export const Header: React.FC = () => {
<a href="heart" className="icon icon--heart" aria-label="Heart" />
<a href="/#cart" className="icon icon--cart" aria-label="Cart" />
</div>
</div>
<div className="burger-menu">
<img src={menu} alt="Menu" />
<BurgerMenu />
</div>
</div>
</div>
Expand Down
5 changes: 0 additions & 5 deletions src/components/Header/cart.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/Header/heartLike.svg

This file was deleted.

3 changes: 3 additions & 0 deletions src/components/Header/img/Close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 0 additions & 25 deletions src/components/Header/logo.svg

This file was deleted.

5 changes: 0 additions & 5 deletions src/components/Header/menu.svg

This file was deleted.

0 comments on commit a76675b

Please sign in to comment.