-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: navigation dropdown refactoring #392
Conversation
Preview is ready. |
src/navigation/components/NavigationListItem/NavigationListItem.tsx
Outdated
Show resolved
Hide resolved
7a3bacc
to
79dc2bc
Compare
src/navigation/components/DesktopNavigation/DesktopNavigation.tsx
Outdated
Show resolved
Hide resolved
src/navigation/components/DesktopNavigation/DesktopNavigation.tsx
Outdated
Show resolved
Hide resolved
...on/components/DesktopNavigation/components/RightDesktopNavigation/RightDesktopNavigation.tsx
Outdated
Show resolved
Hide resolved
...igation/components/MobileNavigation/components/MobileNavigationItem/MobileNavigationItem.tsx
Outdated
Show resolved
Hide resolved
src/hooks/useGetNavigationItem.ts
Outdated
|
||
const iconSizeKey: keyof NavigationItemBase = 'iconSize'; | ||
|
||
export default function useGetNavigationItem(iconSize = 20) { |
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.
why it is not just a getNavigationItemWithIconSize
function? It doesn't use any hooks inside(useCallback
can be removed).
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.
fixed
&__wrapper { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
|
||
height: var(--header-height); | ||
|
||
margin-block-start: 0px; |
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.
why do we decide to support indents like here instead of just margins?
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.
it was a rudiment
<div className={b('wrapper')}> | ||
{logo && ( | ||
<div className={b('left')}> | ||
<Logo {...logo} className={b('logo')} /> |
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.
Should Logo be inside of LeftDesktopNavigation and MobileMenuButton is inside of RightDesktopNavigation?
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.
I think "No, they should not". Both Logo
and MobileMenuButton
are specific items: they are always visible on every screen, they are not a part of concept NavigationItem
, adding this to Left
and Right
components will make logic of ones complicated
@@ -0,0 +1,71 @@ | |||
import React, {useCallback, useContext, useEffect} from 'react'; |
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.
src/navigation/components/DesktopNavigation/components/Left/Left.tsx
?
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.
agree
const {asPath, pathname} = useContext(LocationContext); | ||
|
||
const hidePopup = useCallback(() => { | ||
onActiveItemChange(); |
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.
seems like we can use onActiveItemChange
instead of hidePopup
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.
sure
useEffect(() => { | ||
hidePopup(); | ||
}, [hidePopup, asPath, pathname]); | ||
const onSidebarOpenedChange = useCallback((isOpen: boolean) => { |
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.
lets remove useCallback
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.
sure
2f609a9
to
f13393d
Compare
src/navigation/components/DesktopNavigation/DesktopNavigation.tsx
Outdated
Show resolved
Hide resolved
src/navigation/components/DesktopNavigation/components/LeftItemsWrapper/LeftItemsWrapper.tsx
Outdated
Show resolved
Hide resolved
src/navigation/components/DesktopNavigation/components/RightItemsWrapper/RightItemsWrapper.tsx
Outdated
Show resolved
Hide resolved
5256f27
to
974932a
Compare
isSidebarOpened, | ||
onSidebarOpenedChange, | ||
}) => { | ||
const iconProps = { |
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.
this variable is not necessary, you can remove it and also remove return to make notation more compact
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.
sure
&__links { | ||
position: relative; | ||
position: sticky; | ||
z-index: 98; |
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.
I think it needs to be constant because other way there is the question: 'Why 98'?)
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.
why? it is a history and a mystery
z-index: 98; |
made a constant
}; | ||
|
||
window.addEventListener('scroll', _.debounce(showBorderOnScroll, 20), {passive: true}); | ||
return () => window.removeEventListener('scroll', _.debounce(showBorderOnScroll, 20)); |
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.
Not sure but I think it should be link to same handler in addEventListener and removeEventListener. Now you are creating different ones with _.debounce
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.
good point
src/navigation/models.ts
Outdated
export interface NavigationListProps | ||
extends Pick< | ||
NavigationListItemProps, | ||
'activeItemId' | 'column' | 'className' | 'onActiveItemChange' | 'menuLayout' |
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.
there are activeItemId
and onActiveItemChange
repeating in interface below, could we create some base interface?
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.
done
* feat: navigation dropdown refactoring
No description provided.