forked from MastersAcademy/fe-react-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kostya Nosatskyi
authored and
Kostya Nosatskyi
committed
Aug 25, 2024
1 parent
975eeb9
commit 149681d
Showing
24 changed files
with
440 additions
and
151 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Navigation } from '@/components/navigation/Navigation.component.tsx'; | ||
import { SwitcherTheme } from '@/components/switherTheme/SwitcherTheme.component.tsx'; | ||
import { UserAuthorization } from '@/components/userAuthorization/UserAuthorization.component.tsx'; | ||
|
||
import styles from './burgerMenu.module.css'; | ||
|
||
export const BurgerMenu = () => ( | ||
<div className={styles.burgerMenu}> | ||
<Navigation location={'burger'} /> | ||
<UserAuthorization location={'burger'} /> | ||
<SwitcherTheme location={'burger'} /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.burgerMenu { | ||
display: none; | ||
} | ||
|
||
@media (max-width: 680px) { | ||
|
||
.burgerMenu { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
background-color: var(--bg-primary); | ||
width: 100%; | ||
height: 100vh; | ||
position: fixed; | ||
top: 80px; | ||
left: 0; | ||
z-index: 2; | ||
gap: 30px; | ||
padding-top: 130px; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import styles from './cartPage.module.css'; | ||
export const CartPage = () => ( | ||
<div className={styles.cartPageContainer}> | ||
<h2>Future cart page</h2> | ||
<h2 className={styles.mainText}>Opps...Unfortunately, this page is not yet available, but we are working on it</h2> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
.cartPageContainer { | ||
height: 100vh; | ||
font-family: inherit; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
.mainText { | ||
height: 80vh; | ||
margin: 100px 20px; | ||
text-align: center; | ||
} |
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 |
---|---|---|
@@ -1,94 +1,43 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import React, { useEffect } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { NavLink } from 'react-router-dom'; | ||
|
||
import { clsx } from 'clsx'; | ||
|
||
import logoMA from '@/assets/img/headerImg/logoMA.png'; | ||
import { LoginButton, Logout, SignUpButton, SignUpInActive } from '@/components/authenticationButton/AuthenticationButton.component.tsx'; | ||
import { BurgerMenu } from '@/components/burgerMenu/BurgerMenu.component.tsx'; | ||
import { Cart } from '@/components/cart/Cart.component.tsx'; | ||
import { SvgDarkThemeIcon, SvgLightThemeIcon } from '@/components/svgTheme/SvgTheme.component.tsx'; | ||
import { setTheme } from '@/store/reducers/theme'; | ||
import { selectedTheme } from '@/store/selector'; | ||
import { Navigation } from '@/components/navigation/Navigation.component.tsx'; | ||
import { SwitcherTheme } from '@/components/switherTheme/SwitcherTheme.component.tsx'; | ||
import { UserAuthorization } from '@/components/userAuthorization/UserAuthorization.component.tsx'; | ||
import { setBurgerOpen } from '@/store/reducers/burger'; | ||
import { openBurgerMenu } from '@/store/selector'; | ||
|
||
import styles from './header.module.css'; | ||
|
||
export const HeaderComponent: React.FC = () => { | ||
export const HeaderComponent = () => { | ||
const dispatch = useDispatch(); | ||
const activeTheme = useSelector(selectedTheme); | ||
const [isAuthorizedUser, setAuthorizedUser] = useState(false); | ||
|
||
const burgerOpen = useSelector(openBurgerMenu); | ||
useEffect(() => { | ||
const accessToken = sessionStorage.getItem('accessToken'); | ||
if (accessToken === null) { | ||
setAuthorizedUser(false); | ||
} else { | ||
setAuthorizedUser(true); | ||
} | ||
}, [isAuthorizedUser]); | ||
document.body.style.overflow = burgerOpen ? 'hidden' : 'auto'; | ||
|
||
const changeTheme = (theme: string) => { | ||
dispatch(setTheme(theme)); | ||
localStorage.setItem('themeUser', theme); | ||
}; | ||
return () => { | ||
document.body.style.overflow = 'auto'; | ||
}; | ||
}, [burgerOpen]); | ||
return ( | ||
<header className={styles.header}> | ||
<img className={styles.logoMA} src={logoMA} alt="Logo Masters academy" /> | ||
<div className={styles.switcherTheme}> | ||
<button | ||
className={clsx(styles.themeDayBtn, { [styles.activeTheme]: activeTheme === 'light' })} | ||
onClick={() => { | ||
changeTheme('light'); | ||
localStorage.setItem('themeUser', 'light'); | ||
}} | ||
> | ||
<SvgLightThemeIcon activeTheme={activeTheme} /> | ||
</button> | ||
<div className={styles.vertLine}></div> | ||
<button | ||
className={clsx(styles.themeNightBtn, { [styles.activeTheme]: activeTheme === 'dark' })} | ||
onClick={() => { | ||
changeTheme('dark'); | ||
localStorage.setItem('themeUser', 'dark'); | ||
}} | ||
> | ||
<SvgDarkThemeIcon activeTheme={activeTheme} /> | ||
</button> | ||
</div> | ||
<nav> | ||
<ul className={styles.navMenu}> | ||
<li className={styles.menuItem}> | ||
<NavLink className={({ isActive }) => clsx(styles.menuBtn, { [styles.activePage]: isActive })} to="/"> | ||
About | ||
</NavLink> | ||
</li> | ||
<li className={styles.menuItem}> | ||
<NavLink className={({ isActive }) => clsx(styles.menuBtn, { [styles.activePage]: isActive })} to="/products"> | ||
Products | ||
</NavLink> | ||
</li> | ||
</ul> | ||
</nav> | ||
<SwitcherTheme location={'header'} /> | ||
<Navigation location={'header'} /> | ||
<div className={styles.accountOptions}> | ||
<Cart isHeader /> | ||
<div className={styles.userAuthorization}> | ||
{isAuthorizedUser ? ( | ||
<> | ||
<Logout /> | ||
<SignUpInActive /> | ||
</> | ||
) : ( | ||
<> | ||
<LoginButton /> | ||
<SignUpButton /> | ||
</> | ||
)} | ||
</div> | ||
<div className={styles.burgerMenu}> | ||
<div className={styles.burgerLine} /> | ||
<div className={styles.burgerLine} /> | ||
</div> | ||
<UserAuthorization location={'header'} /> | ||
<button onClick={() => dispatch(setBurgerOpen(!burgerOpen))} className={styles.burgerMenu}> | ||
<div className={clsx(styles.burgerLineUp, { [styles.burgerLineUpActive]: burgerOpen === true })} /> | ||
<div className={clsx(styles.burgerLineDown, { [styles.burgerLineDownActive]: burgerOpen === true })} /> | ||
</button> | ||
</div> | ||
{burgerOpen && <BurgerMenu />} | ||
</header> | ||
); | ||
}; |
Oops, something went wrong.