-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 - Compact sidebar #7414
feat - Compact sidebar #7414
Conversation
Log
|
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.
PR Summary
This pull request implements a compact sidebar feature as requested in issue #7143, transforming the navigation drawer into a collapsible component that displays only icons when collapsed.
- Introduced
isNavigationDrawerExpandedState
to replaceisNavigationDrawerOpenState
for managing drawer expansion - Added
NavigationDrawerCollapsedGreyBox
component for compact view of active items - Updated
NavigationDrawerHeader
,NavigationDrawerItem
, and other components to support both expanded and collapsed states - Implemented conditional rendering in
CurrentWorkspaceMemberFavorites
andNavigationDrawerSectionForObjectMetadataItems
for compact view - Added
navigationDrawerExpandedMemorizedState
to remember drawer state across navigation
17 file(s) reviewed, 10 comment(s)
Edit PR Review Bot Settings
@@ -37,6 +44,8 @@ export const MainNavigationDrawerItems = () => { | |||
label="Settings" | |||
to={'/settings/profile'} | |||
onClick={() => { | |||
setNavigationDrawerExpandedMemorized(isNavigationDrawerExpanded); |
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.
style: Consider moving this logic to a separate function for better readability and reusability
@@ -52,15 +49,15 @@ export const MobileNavigationBar = () => { | |||
if (!isCommandMenuOpened) { | |||
openCommandMenu(); | |||
} | |||
setIsNavigationDrawerOpen(false); | |||
setIsNavigationDrawerExpanded(false); |
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.
style: Consider using 'setIsNavigationDrawerExpanded(false)' instead of 'setIsNavigationDrawerExpanded(false)' for consistency with other state updates
label={sectionTitle} | ||
onClick={() => toggleNavigationSection()} | ||
/> | ||
{isNavigationSectionOpen && renderObjectMetadataItems()} |
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.
style: Ensure renderObjectMetadataItems is only called when the section is open
to={navigationMemorizedUrl} | ||
replace | ||
onClick={() => | ||
setIsNavigationDrawerExpanded(navigationDrawerExpandedMemorized) |
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.
style: Consider adding a comment explaining the purpose of this state change
...nt/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx
Outdated
Show resolved
Hide resolved
background-color: ${({ theme }) => theme.background.transparent.lighter}; | ||
border: 1px solid ${({ theme }) => theme.background.transparent.lighter}; | ||
border-radius: ${({ theme }) => theme.border.radius.sm}; |
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.
style: Using the same color for background and border may not provide enough contrast. Consider using a slightly darker shade for the border.
const [isNavigationDrawerExpanded, setIsNavigationDrawerExpanded] = | ||
useRecoilState(isNavigationDrawerExpandedState); | ||
const isSettingsPage = useIsSettingsPage(); |
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.
style: Consider memoizing this value to prevent unnecessary re-renders
<StyledKeyBoardShortcut className="keyboard-shortcuts"> | ||
{keyboard} | ||
</StyledKeyBoardShortcut> | ||
{isNavigationDrawerExpanded || isSettingsPage ? ( |
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.
style: This conditional rendering might cause layout shifts. Consider using CSS to hide/show elements instead
...twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
Outdated
Show resolved
Hide resolved
import { atom } from 'recoil'; | ||
import { MOBILE_VIEWPORT } from 'twenty-ui'; | ||
|
||
const isMobile = window.innerWidth <= MOBILE_VIEWPORT; |
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.
logic: isMobile is set only once when the file is loaded. Consider using a hook or event listener for responsive behavior
@Bonapara |
Nice 😍 |
@ehconitin what do you mean about the clarification on the colors? We can schedule a quick call to talk about it! A few fixes:
CleanShot.2024-10-09.at.11.07.43.mp4
|
@ehconitin think we can do something like on figma with animate. We need to animate all the disapearing components in the navBar, not the navBar itself. Here is a quick proof of concept: de77463 Enregistrement.de.l.ecran.2024-10-10.a.17.47.08.mov |
Thanks @martmull ! 🫡 |
3a2431a
to
493160b
Compare
86220d9
to
7e3a9c2
Compare
c894fc9
to
b0df7ad
Compare
de04b42
to
7be0a3c
Compare
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.
7be0a3c
to
855cbcb
Compare
e8acb79
to
934d214
Compare
|
||
width: ${(props) => | ||
!props.isNavigationDrawerExpanded | ||
? `${NAV_DRAWER_WIDTHS.menu.desktop.collapsed - 24}px` |
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.
could 24 be a shared variable with the existing menu width?
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.
will try to
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.
difficult tbh
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.
PR Summary
(updates since last review)
This PR continues the implementation of the compact sidebar feature, focusing on refining navigation components and improving overall functionality. Key changes include:
- Introduced new hooks and components for managing the compact sidebar state and rendering
- Updated various components to support both expanded and collapsed sidebar states
- Improved handling of object metadata items and favorites in the navigation drawer
- Refined styling and layout for better responsiveness and user experience
While the changes align with the desired behavior, there are a few points to consider:
- Ensure consistent handling of loading states across components to prevent UI flickering
- Review and optimize performance for components with complex rendering logic
- Double-check accessibility features, especially for keyboard navigation in the compact mode
298 file(s) reviewed, 167 comment(s)
Edit PR Review Bot Settings | Greptile
setNavigationDrawerExpandedMemorized(isNavigationDrawerExpanded); | ||
setIsNavigationDrawerExpanded(true); | ||
setNavigationMemorizedUrl(location.pathname + location.search); | ||
}} |
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.
logic: This logic might cause unexpected behavior if the user navigates directly to the settings page
export const useIsSettingsDrawer = () => { | ||
const isMobile = useIsMobile(); | ||
const isSettingsPage = useIsSettingsPage(); | ||
const currentMobileNavigationDrawer = useRecoilValue( | ||
currentMobileNavigationDrawerState, | ||
); | ||
return isMobile | ||
? currentMobileNavigationDrawer === 'settings' | ||
: isSettingsPage; | ||
}; |
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.
style: Consider adding a brief comment explaining the purpose of this hook
onClick={() => toggleNavigationSection()} | ||
/> | ||
</NavigationDrawerAnimatedCollapseWrapper> | ||
{isNavigationSectionOpen && renderObjectMetadataItems()} |
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.
style: Ensure renderObjectMetadataItems is only called when the section is open
Recent updates
demo.mov
To Do