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

#340-sidebar #398

Merged
merged 5 commits into from
May 30, 2024
Merged

#340-sidebar #398

merged 5 commits into from
May 30, 2024

Conversation

MargaritaShumilina
Copy link
Collaborator

@MargaritaShumilina MargaritaShumilina commented May 26, 2024

Сделала сайдбар, выглядит вот так:
image

Активная ссылка подсвечивается, если она из подкатегорий, главная категория сразу открыта при переходе, чтобы отделить ее от остальных.

@MargaritaShumilina
Copy link
Collaborator Author

Пришлось дополнить компонент Александра, но вроде ничего не сломала

@MargaritaShumilina
Copy link
Collaborator Author

Ага, ага, не сломала :) Но вроде теперь все окей )

Copy link
Collaborator

@aimenin aimenin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отличная работа, парочка предложений по улучшению кода

const { slug } = useParams()
const getMainCategories = useSelector(getCategorySelector)

const [itemActive, setItemActive] = useState<MainCategoryInfo | BranchesData>()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай эти два стейта и useEffect вынесем в кастомный хук, откуда будем получать эти параметры.
Положить его можно в папку с этим же компонентом в models

branch={branch}
itemName={item.name}>
<ul role="list">
{item.branches.map(el => (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может добавим проверку, что в item есть branches?

@@ -20,11 +26,36 @@ export interface ISideBar {
* @param {function} onClick - функция выхода из профиля handleLogOut;
* @param {function} onKeyUp - функция выхода из профиля handleLogOut при нажатии клавиши Enter;
* @param {JSX.Element} children - контент;
* Далее, для сайдбара на странице категори;
* @param {string} to - если есть ссылка для item верхнего уровня, передает путь
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эти параметры я бы передавал объектом, так же еще я бы добавил флаг - раскрывающийся или нет это sidebar, чтобы было сразу понятно, как мы его используем

@MargaritaShumilina
Copy link
Collaborator Author

Вынесла лишнее в хук, добавила проверку на наличие веток, перенесла все, что связано с сайдбаром категории в объект. А вот про флаг не поняла. У SideBar есть isVisible, как я поняла, как раз для того, чтобы выделить раскрывающийся список и нераскрывающийся. Или нужен какой-то другой флаг?

@aimenin aimenin self-requested a review May 30, 2024 11:22
Copy link
Collaborator

@aimenin aimenin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отлично, только одно маленькое замечание


import styles from './SideBar.module.scss'

export interface ISideBar {
type TCategorySidebar = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

этот тип выносим в папку model, в папке с компонентом у нас только типизация компонента

@MargaritaShumilina MargaritaShumilina merged commit 59af645 into master May 30, 2024
1 check passed
@MargaritaShumilina MargaritaShumilina deleted the enhancement-340-sidebar branch May 30, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants