Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added account popup to mobile navbar #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/Button/Button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
transition: transform .3s ease-in-out;
aspect-ratio: 1;
cursor: pointer;

display: flex;
justify-content: center;
align-items: center;
}
.button:hover {
transform: scale(1.1)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
.button {
width: 100%;
aspect-ratio: 1;
background: none;
outline: none;
border: none;

display: flex;
justify-content: center;
align-items: center;
position: relative;
}

.icon {
width: 1.5rem;
height: 1.5rem;

cursor: pointer;
}


.crossIconBox {
height: 100%;
margin-left: auto;
aspect-ratio: 1;
display: flex;
justify-content: center;

background: #f2f2f2;

position: relative;
z-index: 99;
}

.crossIcon {
width: 1.5rem;
height: 1.5rem;
}

.popupContainer {
position: relative;
}

.innerContainer {
display: flex;
flex-direction: column;

background-color: #fff;

position: absolute;
right: 0;
z-index: 99;
}

.buttons {
display: flex;
flex-direction: column;
gap: 1rem;

padding: 1rem;
background: #f2f2f2;
}
.buttons button {
width: 100%;
height: 100%;
padding: .625rem 1.25rem;
border-radius: .2rem;
border: none;
aspect-ratio: 10/1;

text-transform: uppercase;
font-size: 1rem;

cursor: pointer
}
.buttons button:hover {
text-decoration: underline;
}
.loginButton {
background: #003942;
border: 1px solid #003942 !important;
color: #fff;
}
.loginButton:hover {
background: rgba(0, 57, 66, .7)
}
.registerButton {
background: #fff;
border: 1px solid #003942 !important;
color: #003942;
}
.registerButton:hover {
background: rgba(0, 221, 255, 0.1)
}

.links {
display: flex;
flex-direction: column;
}
.link {
padding: 1rem;
}

.link:hover {
background: #f2f2f2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { useState } from "react";
import { Link } from 'react-router-dom';

import { GoPerson } from "react-icons/go";
import { RxCross2 } from "react-icons/rx";

import Button from "../../../Button/Button";
import MobileUnderlay from "../MobileUnderlay/MobileUnderlay";
import styles from "./MobileAccountPopup.module.css";

const MobileAccountPopup = () => {
const [isActive, setIsActive] = useState(false);

function handleActivatePopup() {
setIsActive((prevIsActive) => !prevIsActive);
}

return (
<>
{!isActive ? (
<button onClick={handleActivatePopup} className={styles.button}>
<GoPerson className={styles.icon} />
</button>
) : (
<div className={styles.popupContainer}>
<div className={styles.crossIconBox}>
<Button handleClick={handleActivatePopup}>
<RxCross2 className={styles.crossIcon} />
</Button>
</div>
<div className={styles.innerContainer}>
<div className={styles.buttons}>
<button className={styles.loginButton}>login</button>
<button className={styles.registerButton}>register</button>
</div>
<div className={styles.links}>
<Link to='#' className={styles.link}>Your Wishlist</Link>
<Link to='#' className={styles.link}>Your Orders</Link>
</div>
</div>
<MobileUnderlay deactivate={handleActivatePopup} />
</div>
)}
</>
);
};

export default MobileAccountPopup;
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { useState } from "react";

import { BiSearchAlt2 } from "react-icons/bi";


import Button from "../../../Button/Button";

import SearchBar from './SearchBar/SearchBar'
import SearchBar from "./SearchBar/SearchBar";

import styles from "./Search.module.css";
import styles from "./MobileSearchPopup.module.css";

const Search = () => {
const [isActive, setIsActive] = useState(false);
Expand All @@ -16,20 +15,19 @@ const Search = () => {
setIsActive(true);
}

function deactivateSearch() {
setIsActive(false)
}

function deactivateSearch() {
setIsActive(false);
}

return (
<>
{!isActive ? (
<Button handleClick={activateSearch}>
<Button handleClick={activateSearch}>
<BiSearchAlt2 className={styles.icon} />
</Button>
) : (
<>
<SearchBar deactivate={deactivateSearch} />
<SearchBar deactivate={deactivateSearch} />
</>
)}
</>
Expand Down
15 changes: 7 additions & 8 deletions src/components/PageWrapper/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import { Link } from "react-router-dom";

import { BiChevronRight } from "react-icons/bi";
import { GrMenu } from "react-icons/gr";
import { GoPerson } from "react-icons/go";
import { BsBasket3 } from "react-icons/bs";
import { MdHome } from "react-icons/md";
import { RxCross2 } from "react-icons/rx";

import Button from "../../Button/Button";
import Search from './Search/Search'
import MobileSearchPopup from './MobileSearchPopup/MobileSearchPopup'
import MobileUnderlay from './MobileUnderlay/MobileUnderlay';
import MobileAccountPopup from './MobileAccountPopup/MobileAccountPopup';

import { images } from "../../../assets/index";
import { type Pages } from "../../../lib/types";

import styles from "./NavBar.module.css";
import MobileUnderlay from './MobileUnderlay/MobileUnderlay';

const NavBar = () => {
const [isMenuActive, setIsMenuActive] = useState(false);
Expand Down Expand Up @@ -50,15 +51,13 @@ const NavBar = () => {
<Button handleClick={activateMenu}>
<GrMenu className={styles.icon} />
</Button>
<Search />
<MobileSearchPopup />
</div>
<Link to="/" className={styles.logoBox}>
<img src={images.logo} alt="logo" className={styles.logo} />
</Link>
<div className={styles.iconContainer}>
<Link to="/accountHome" className={styles.accountIcon}>
<GoPerson className={styles.icon} />
</Link>
<MobileAccountPopup />
<Button>
<BsBasket3 className={styles.icon} />
</Button>
Expand All @@ -68,7 +67,7 @@ const NavBar = () => {
<>
<div className={styles.mobileMenu}>
<div className={styles.navIcons}>
<Link to='/'>
<Link to='/' onClick={deactivateMenu}>
<MdHome className={styles.icon} />
</Link>
<Button handleClick={deactivateMenu}>
Expand Down