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

[front] - feat: toggle sidebar #5211

Merged
merged 20 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
69c1908
[front/components/sparkle] - feature: introduce toggle for laptop nav…
May 22, 2024
6aaa4b4
[front/components/app] - refactor: introduce NavigationBarProvider
May 22, 2024
0c8f1f0
[front] - refactor: streamline toggle button for laptop navigation
May 22, 2024
e24887b
[front] - fix: adjust sidebar padding based on laptopNavOpen state
May 22, 2024
628fd7e
[front] - feature: update @dust-tt/sparkle to version 0.2.152
May 22, 2024
6ddffbd
Merge branch 'main' into feat/toggle-sidebar
May 22, 2024
d8da336
[front/components/sparkle] - refactor: update toggle sidebar button i…
May 22, 2024
9d37365
[front] - refactor: adjust positioning of assistant input bar
May 22, 2024
76c31c9
[front] - refactor: rename navigation bar state variables for clarity
May 23, 2024
8ce15dc
[front/components/sparkle] - refactor: streamline conditional renderi…
May 23, 2024
5b91659
[front/components/app] - refactor: remove NavigationBarProvider from …
May 23, 2024
c519280
Fix new conversation input bar layout
flvndvd May 23, 2024
ab7a7b8
[front] - fix: adjust layout and padding for consistency
May 23, 2024
9a075fd
[front] - refactor: update ToggleSideBarButton prop for better clarity
May 23, 2024
2e72be2
[front] - refactor: remove wide mode layout option from components
May 23, 2024
d791626
merge main branch
May 27, 2024
5ae2e29
[front] - fix: adjust navigation bar positioning logic
May 29, 2024
e6ab9a3
[front] - refactor: update navigation bar toggle functionality and st…
May 29, 2024
9480537
[front] - refactor: standardize prop naming in ToggleSideBarButton
May 29, 2024
970d2fc
fix: package-lock.json
May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export default function ConversationLayout({
<AppLayout
subscription={subscription}
owner={owner}
isWideMode={!!conversation}
pageTitle={
conversation?.title
? `Dust - ${conversation?.title}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ export function FixedAssistantInputBar({
disableAutoFocus?: boolean;
}) {
return (
<div className="4xl:px-0 fixed bottom-0 left-0 right-0 z-20 flex-initial lg:left-80">
<div className="mx-auto max-h-screen max-w-4xl pb-0 sm:pb-8">
<div className="4xl:px-0 fixed bottom-0 z-20 w-full flex-initial">
<div className="max-h-screen max-w-4xl pb-0 sm:pb-8">
<AssistantInputBar
owner={owner}
onSubmit={onSubmit}
Expand Down
1 change: 0 additions & 1 deletion front/components/assistant_builder/AssistantBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ export default function AssistantBuilder({
<AppLayout
subscription={subscription}
hideSidebar
isWideMode
owner={owner}
gaTrackingId={gaTrackingId}
topNavigationCurrent="assistants"
Expand Down
72 changes: 59 additions & 13 deletions front/components/sparkle/AppLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Banner, Item, Logo, Tab, XMarkIcon } from "@dust-tt/sparkle";
import {
Banner,
CollapseButton,
Item,
Logo,
Tab,
XMarkIcon,
} from "@dust-tt/sparkle";
import type { SubscriptionType, WorkspaceType } from "@dust-tt/types";
import { Dialog, Transition } from "@headlessui/react";
import { Bars3Icon } from "@heroicons/react/20/solid";
Expand All @@ -7,7 +14,14 @@ import Link from "next/link";
import type { NextRouter } from "next/router";
import { useRouter } from "next/router";
import Script from "next/script";
import React, { Fragment, useContext, useEffect, useState } from "react";
import React, {
Fragment,
useCallback,
useContext,
useEffect,
useRef,
useState,
} from "react";

import { CONVERSATION_PARENT_SCROLL_DIV_ID } from "@app/components/assistant/conversation/lib";
import type {
Expand All @@ -26,6 +40,36 @@ import { classNames } from "@app/lib/utils";
*/
const SHOW_INCIDENT_BANNER = false;

function ToggleSideBarButton({
navigationBarOpen,
toggleNavigationBarVisibility,
}: {
navigationBarOpen: boolean;
toggleNavigationBarVisibility: (open: boolean) => void;
}) {
JulesBelveze marked this conversation as resolved.
Show resolved Hide resolved
const buttonRef = useRef<HTMLDivElement>(null);
const [direction, setDirection] = useState<"left" | "right">("left");

const handleClick = useCallback(() => {
toggleNavigationBarVisibility(!navigationBarOpen);
setDirection((prevDirection) =>
prevDirection === "left" ? "right" : "left"
);
}, [navigationBarOpen, toggleNavigationBarVisibility]);

return (
<div
ref={buttonRef}
onClick={handleClick}
className={`hidden lg:fixed lg:top-1/2 lg:flex lg:h-10 lg:w-5 ${
navigationBarOpen ? "lg:left-80" : "lg:left-2"
}`}
>
Copy link
Contributor

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().

Copy link
Contributor

Choose a reason for hiding this comment

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

☝️

<CollapseButton direction={direction} />
</div>
);
}

function NavigationBar({
owner,
subscription,
Expand Down Expand Up @@ -191,7 +235,6 @@ export const appLayoutBack = async (
export default function AppLayout({
owner,
subscription,
isWideMode = false,
hideSidebar = false,
topNavigationCurrent,
subNavigation,
Expand All @@ -214,6 +257,7 @@ export default function AppLayout({
children: React.ReactNode;
}) {
const { sidebarOpen, setSidebarOpen } = useContext(SidebarContext);
const [navigationBarOpen, setNavigationBarOpen] = useState(true);
const [loaded, setLoaded] = useState(false);
JulesBelveze marked this conversation as resolved.
Show resolved Hide resolved
const router = useRouter();
const user = useUser();
Expand Down Expand Up @@ -355,7 +399,7 @@ export default function AppLayout({
</Transition.Root>
)}

{!hideSidebar && (
{!hideSidebar && navigationBarOpen && (
<div className="hidden lg:fixed lg:inset-y-0 lg:z-0 lg:flex lg:w-80 lg:flex-col">
{loaded && (
<NavigationBar
Expand All @@ -373,7 +417,7 @@ export default function AppLayout({
<div
className={classNames(
"mt-0 h-full flex-1",
!hideSidebar ? "lg:pl-80" : ""
!hideSidebar ? (navigationBarOpen ? "lg:pl-80" : "lg:pl-0") : ""
)}
>
<div
Expand Down Expand Up @@ -417,16 +461,18 @@ export default function AppLayout({
titleChildren ? "" : "lg:pt-8"
)}
>
<div
className={classNames(
"mx-auto h-full",
isWideMode ? "w-full" : "max-w-4xl px-6"
)}
>
{loaded && children}
</div>
<div className="mx-auto h-full max-w-4xl">{loaded && children}</div>
</main>
</div>

<div>
<ToggleSideBarButton
navigationBarOpen={navigationBarOpen}
toggleNavigationBarVisibility={(isVisible) =>
setNavigationBarOpen(isVisible)
}
/>
</div>
</div>
<>
<Script
Expand Down
9 changes: 5 additions & 4 deletions front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@amplitude/analytics-browser": "^2.5.2",
"@amplitude/analytics-node": "^1.3.5",
"@auth0/nextjs-auth0": "^3.5.0",
"@dust-tt/sparkle": "0.2.151",
"@dust-tt/sparkle": "0.2.152",
JulesBelveze marked this conversation as resolved.
Show resolved Hide resolved
"@dust-tt/types": "file:../types",
"@emoji-mart/data": "^1.1.2",
"@emoji-mart/react": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion front/pages/w/[wId]/assistant/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default function AssistantNew({
onClose={() => setConversationHelperModal(null)}
/>
)}
<div className="flex h-full items-center pb-20">
<div className="flex h-full items-center px-6 pb-20">
<div className="flex text-sm font-normal text-element-800">
<Page.Vertical gap="md" align="left">
{/* FEATURED AGENTS */}
Expand Down
Loading