-
Notifications
You must be signed in to change notification settings - Fork 1
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
enhancement_341_header_adaptive #346
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { FC, lazy, useState, Suspense, useEffect } from 'react' | ||
import { useSelector } from 'react-redux' | ||
|
||
import SearchIcon from '@/assets/images/header/iconSearch.svg' | ||
import { getUserAuthStatus } from '@/features/login/model/selectors/getUserAuthStatus' | ||
import { logout } from '@/features/login/model/services/logout/logout' | ||
import { loginActions } from '@/features/login/model/slice/loginSlice' | ||
|
@@ -11,6 +12,7 @@ import PersonIcon from '@/shared/icons/person.svg' | |
import PersonAuthIcon from '@/shared/icons/person_auth.svg' | ||
import ScalesIcon from '@/shared/icons/scales.svg' | ||
import { useAppDispatch } from '@/shared/libs/hooks/store' | ||
import { useResize } from '@/shared/libs/hooks/useResize' | ||
import { Button } from '@/shared/ui/Button/Button' | ||
import Link from '@/shared/ui/Link/Link' | ||
import Modal from '@/shared/ui/Modal/Modal' | ||
|
@@ -33,6 +35,8 @@ const HeaderAccount: FC<HeaderAccountProps> = ({ counter, total }) => { | |
const [isModalOpen, setIsModalOpen] = useState(false) | ||
const [isModalClosing, setIsModalClosing] = useState(false) | ||
|
||
const { isScreenLg } = useResize() | ||
|
||
const dispatch = useAppDispatch() | ||
const isAuth = useSelector(getUserAuthStatus) | ||
|
||
|
@@ -68,41 +72,48 @@ const HeaderAccount: FC<HeaderAccountProps> = ({ counter, total }) => { | |
</Suspense> | ||
</Modal> | ||
)} | ||
<ul className={styles['header__cart-wrapper']}> | ||
<ul className={isScreenLg ? `${styles.header__cartWrapper}` : `${styles.header__cartWrapperMobile}`}> | ||
{!isScreenLg && <SearchIcon />} | ||
<li> | ||
{isAuth ? ( | ||
// Временная реализация | ||
// TODO заменить на дропдаун на ховер в контекстном меню добавить пункт-кнопку для разлогина пока висит на иконке | ||
<Button onClick={onLogout} className={styles.header__cart}> | ||
<PersonAuthIcon /> | ||
</Button> | ||
) : ( | ||
<Button onClick={handlePersonIconClick} className={styles.header__cart}> | ||
<PersonIcon /> | ||
</Button> | ||
)} | ||
{/* Временная реализация | ||
TODO заменить на дропдаун на ховер в контекстном меню добавить пункт-кнопку для разлогина пока висит на иконке */} | ||
<Button | ||
onClick={isAuth ? onLogout : handlePersonIconClick} | ||
className={isScreenLg ? `${styles.header__cart}` : `${styles.header__cartMobile}`}> | ||
{isAuth ? <PersonAuthIcon /> : <PersonIcon />} | ||
</Button> | ||
</li> | ||
|
||
{isScreenLg && ( | ||
<li> | ||
<Link to={Routes.COMPARE} className={styles.header__cart}> | ||
<ScalesIcon /> | ||
</Link> | ||
</li> | ||
)} | ||
|
||
{isScreenLg && ( | ||
<li> | ||
<Link to={Routes.FAVORITES} className={styles.header__cart}> | ||
<HeartIcon /> | ||
</Link> | ||
</li> | ||
)} | ||
|
||
<li> | ||
<Link to={Routes.COMPARE} className={styles.header__cart}> | ||
<ScalesIcon /> | ||
</Link> | ||
</li> | ||
<li> | ||
<Link to={Routes.FAVORITES} className={styles.header__cart}> | ||
<HeartIcon /> | ||
</Link> | ||
</li> | ||
<li> | ||
<Link to={Routes.CART} className={styles.header__cart}> | ||
<Link | ||
to={Routes.CART} | ||
className={isScreenLg ? `${styles.header__cart}` : `${styles.header__cartMobile}`}> | ||
<CartIcon /> | ||
<div className={styles['header__cart-container']}> | ||
<div className={styles['header__counter-container']}> | ||
<p className={styles['header__cart-total-text']}>Корзина</p> | ||
<p className={styles['header__cart-counter']}>{counter}</p> | ||
{isScreenLg && ( | ||
<div className={styles['header__cart-container']}> | ||
<div className={styles['header__counter-container']}> | ||
<p className={styles['header__cart-total-text']}>Корзина</p> | ||
<p className={styles['header__cart-counter']}>{counter}</p> | ||
</div> | ||
<p className={styles['header__cart-total']}>{total}</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не используем просто тег p - используем нашу типографику |
||
</div> | ||
<p className={styles['header__cart-total']}>{total}</p> | ||
</div> | ||
)} | ||
</Link> | ||
</li> | ||
</ul> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import HeaderMenuSign from './ui/HeaderMenuSign' | ||
export default HeaderMenuSign |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@use '@/shared/styles/utils/variables' as var; | ||
|
||
.headerMenuSign { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 5px; | ||
width: 20px; | ||
height: 16px; | ||
cursor: pointer; | ||
|
||
&__stripe { | ||
width: 100%; | ||
height: 2px; | ||
background: var.$white; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import HeaderMenuSign from './HeaderMenuSign' | ||
|
||
const meta = { | ||
title: 'entities/HeaderMenuSign', | ||
component: HeaderMenuSign, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
tags: ['autodocs'], | ||
args: {} | ||
} satisfies Meta<typeof HeaderMenuSign> | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof HeaderMenuSign> | ||
|
||
export const Default: Story = () => { | ||
return ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
width: '30px', | ||
height: '30px', | ||
background: '#ccc' | ||
}}> | ||
<HeaderMenuSign /> | ||
</div> | ||
) | ||
} | ||
|
||
Default.args = {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { FC } from 'react' | ||
|
||
import styles from './HeaderMenuSign.module.scss' | ||
|
||
const HeaderMenuSign: FC = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не очень понял компонент, мб оставишь коммент над ним - что это такое |
||
return ( | ||
<ul tabIndex={0} className={styles.headerMenuSign}> | ||
<li className={styles.headerMenuSign__stripe}></li> | ||
<li className={styles.headerMenuSign__stripe}></li> | ||
<li className={styles.headerMenuSign__stripe}></li> | ||
</ul> | ||
) | ||
} | ||
|
||
export default HeaderMenuSign |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему у нас две картинки iconSearch?