-
Notifications
You must be signed in to change notification settings - Fork 117
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
[front] - feat: toggle sidebar #5211
Conversation
…igation - Added context state management for handling the visibility of the laptop navigation bar - Implemented a button to allow users to toggle the laptop navigation bar on and off - Wrapped the laptop navigation bar inside a Transition.Root component to control its visibility based on state - Modified the SidebarProvider to include the new state and context for laptop navigation control
- Extract `laptopNavOpen` state management into a new `NavigationBarProvider` - Wrap `RootLayout` with the `NavigationBarProvider` for handling navigation bar state [front/components/sparkle] - refactor: remove laptop navigation state from SidebarContext - Remove `laptopNavOpen` and its state management functions from `SidebarContext` - Adjust `SidebarProvider` to only provide `sidebarOpen` state after the split of contexts
- Removed redundant IconButton and Button imports not in use - Introduced ToggleSideBarButton component for cleaner code and separation of concerns - Removed inline css and redundant span elements for toggle button - Adjusted main content conditional padding logic for consistency - Cleaned up unnecessary class conditional logic simplifying readability - Ensured consistent use of classNames helper function
- Conditionally apply sidebar padding in AppLayout only when laptopNavOpen flag is true, preserving layout on smaller screens
- Upgraded the @dust-tt/sparkle package including new features and bug fixes - Added dependency on lottie-web version 5.12.2 to the sparkle package
…n `AppLayout.tsx` - Replace a custom toggle button implementation with a `CollapseButton` component from the sparkle library - Use `useRef` and `useCallback` for button reference and click event handler to optimize component performance - Maintain the toggle state for left and right direction using a local state variable
- Change the input bar from fixed to absolute positioning to improve layout management - Ensure input bar stays at the bottom, now wrapped in an additional div with relative positioning for better control on placement
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.
Note
Introduced a NavigationBarContext
to mimic the SidebarContext
. Curious to hear if this is no good practice?
Question
Why do we render a different nav bar for laptop and mobile? Why not a single instance deciding where to locate based on the device?
<div className="relative z-20 flex-initial"> | ||
<div className="4xl:px-0 absolute bottom-0 left-0 right-0"> | ||
<div className="mx-auto max-h-screen max-w-4xl pb-0 sm:pb-8"> | ||
<AssistantInputBar | ||
owner={owner} | ||
onSubmit={onSubmit} | ||
conversationId={conversationId} | ||
stickyMentions={stickyMentions} | ||
additionalAgentConfiguration={additionalAgentConfiguration} | ||
hideQuickActions={hideQuickActions} | ||
disableAutoFocus={disableAutoFocus} | ||
/> | ||
</div> |
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.
Had to modify the classes as fixed
was disabling the AssistantInputBar
to me translated
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.
roger that will test 👍
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.
Left a few comments. Will test locally.
Deferring review to @flvndvd as he has state/plans/ideas around the AppLayout
<div className="relative z-20 flex-initial"> | ||
<div className="4xl:px-0 absolute bottom-0 left-0 right-0"> | ||
<div className="mx-auto max-h-screen max-w-4xl pb-0 sm:pb-8"> | ||
<AssistantInputBar | ||
owner={owner} | ||
onSubmit={onSubmit} | ||
conversationId={conversationId} | ||
stickyMentions={stickyMentions} | ||
additionalAgentConfiguration={additionalAgentConfiguration} | ||
hideQuickActions={hideQuickActions} | ||
disableAutoFocus={disableAutoFocus} | ||
/> | ||
</div> |
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.
roger that will test 👍
- Renamed `laptopNavOpen` and `setLaptopNavOpen` to `navigationBarOpen` and `setNavigationBarOpen` for improved code readability - Updated associated usage and context of navigation bar state variables across the `AppLayout` component
…ng of navigation bar - Simplified the logic for displaying the navigation bar by removing the Transition.Root component when hideSidebar is false and navigationBarOpen is true
…RootLayout - Extracted NavigationBarProvider dependency from the RootLayout component [front/components/sparkle] - refactor: remove NavigationBarContext and Provider - Deleted NavigationBarContext and NavigationBarProvider to simplify the context providers - Moved navigationBar state management directly into AppLayout using useState
- Removed unnecessary padding in wide mode to utilize full screen width - Added consistent padding for the assistant new page to align with design standards
- Renamed prop from `setNavigationBarOpen` to `toggleNavigationBarVisibility` to improve function name semantics - Simplified div structures in AppLayout by removing unnecessary className conditions - Updated corresponding functions to use the new toggleNavigationBarVisibility prop for clarity and consistency
- Removed the `isWideMode` prop from `AppLayout` usage in `ConversationLayout.tsx` and `AssistantBuilder.tsx` files to streamline layout options - Adjusted styling in `AppLayout.tsx` by consolidating the `children` rendering into a single line for cleanliness and readability - Standardized padding styles in `assistant/new.tsx` for better code consistency
className={`hidden lg:fixed lg:top-1/2 lg:flex lg:h-10 lg:w-5 ${ | ||
navigationBarOpen ? "lg:left-80" : "lg:left-2" | ||
}`} |
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.
You can use the helper classNames()
.
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.
☝️
As per IRL discussion with @flvndvd, waiting for him to ship the new discussion design to rebase and use it. |
What's the new discussion design? |
With the rounded text boxes. Just tagged you in the corresponding Figma |
Ah this PR! 👍 Roger 👍 |
@flvndvd The only way I've found to fix the centering issue of the <div className={classNames("4xl:px-0 fixed bottom-0 left-0 right-0 z-20 flex-initial",
isNavigationBarOpen? "lg:left-80": "")}>
<div className="mx-auto max-h-screen max-w-4xl pb-0 sm:pb-8">
.... This seems to work but will require to create a |
- Correct the conditional application of positional styling for the navigation bar to respect 'navigationBarOpen' state - Ensure the sidebar does not overlap with navigation bar when it's not supposed to be open
As per IRL we will keep the current implementation, there's a bit of a glitch for viewports with a width in Opened an issue #5314. |
className={`hidden lg:fixed lg:top-1/2 lg:flex lg:h-10 lg:w-5 ${ | ||
navigationBarOpen ? "lg:left-80" : "lg:left-2" | ||
}`} |
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.
☝️
How do you open again the navbar from the first screenshot ? |
@albandum There's a small button on the left hand side |
…yling - Change parameter name to enhance readability in ToggleSideBarButton component - Adjust left positioning of toggle button when the navigation bar is open - Update state variable for navigation bar visibility to improve clarity throughout AppLayout component - Remove unnecessary top margin and increase button width for better alignment - Update package version for @dust-tt/sparkle to 0.2.153
Ok - not visible from the screenshot (I guess I thought it was something on my screen haha) but if there's some sort of animation that works 👍 |
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.
You need to remove the changes on pacakge-lock.json as well.
- Renamed `navigationBarOpen` to `isNavigationBarOpened` for consistency with naming conventions - Used the `classNames` utility for conditionally applying classes to improve readability and maintainability
3ccae10
to
970d2fc
Compare
Description
This PR aims at enabling toggle/untoggle the navigation bar on laptop: #4988 (comment)
Screenshots of how it will look like:
Risk
Breaking UI
Deploy Plan