From 3cb8a80e8d7fcf6bd8da42fd4f70ec4d0ee88be6 Mon Sep 17 00:00:00 2001 From: Sean Hatfield Date: Wed, 6 Mar 2024 17:22:36 -0800 Subject: [PATCH] [STYLE] Implement new side bar menus (#815) * WIP main sidebar designs * hover states and active states for main sidebar * main and settings sidebar UI updates & improve performance using Link instead of * update borders to match rest of UI in all pages * update borders of all containers to match rest of UI * remove unneeded conditional * small changes to UI to conform to designs Fix conditional hook render * add check for roles to SettingsButton component and hide button from footer when in mobile * typo --------- Co-authored-by: timothycarambat --- frontend/src/components/DefaultChat/index.jsx | 2 +- frontend/src/components/Footer/index.jsx | 13 ++- .../src/components/SettingsButton/index.jsx | 31 +++++++ .../src/components/SettingsSidebar/index.jsx | 75 +++++++--------- .../Sidebar/ActiveWorkspaces/index.jsx | 85 +++++++++++-------- frontend/src/components/Sidebar/index.jsx | 71 ++++++---------- .../components/UserMenu/UserButton/index.jsx | 4 +- .../WorkspaceChat/ChatContainer/index.jsx | 2 +- .../src/pages/Admin/Invitations/index.jsx | 2 +- frontend/src/pages/Admin/Logging/index.jsx | 2 +- frontend/src/pages/Admin/System/index.jsx | 2 +- frontend/src/pages/Admin/Users/index.jsx | 2 +- frontend/src/pages/Admin/Workspaces/index.jsx | 2 +- .../pages/GeneralSettings/ApiKeys/index.jsx | 2 +- .../GeneralSettings/Appearance/index.jsx | 2 +- .../src/pages/GeneralSettings/Chats/index.jsx | 2 +- .../GeneralSettings/EmbedChats/index.jsx | 2 +- .../GeneralSettings/EmbedConfigs/index.jsx | 2 +- .../pages/GeneralSettings/Security/index.jsx | 2 +- .../GeneralSettings/VectorDatabase/index.jsx | 4 +- .../src/pages/WorkspaceSettings/index.jsx | 4 +- frontend/tailwind.config.js | 3 +- 22 files changed, 168 insertions(+), 148 deletions(-) create mode 100644 frontend/src/components/SettingsButton/index.jsx diff --git a/frontend/src/components/DefaultChat/index.jsx b/frontend/src/components/DefaultChat/index.jsx index 8bc6c7cb..a20e323b 100644 --- a/frontend/src/components/DefaultChat/index.jsx +++ b/frontend/src/components/DefaultChat/index.jsx @@ -335,7 +335,7 @@ export default function DefaultChatContainer() { return (
{isMobile && } {fetchedMessages.length === 0 diff --git a/frontend/src/components/Footer/index.jsx b/frontend/src/components/Footer/index.jsx index 26b271a8..fc51dde7 100644 --- a/frontend/src/components/Footer/index.jsx +++ b/frontend/src/components/Footer/index.jsx @@ -1,6 +1,5 @@ import System from "@/models/system"; import paths from "@/utils/paths"; -import { safeJsonParse } from "@/utils/request"; import { BookOpen, DiscordLogo, @@ -13,6 +12,8 @@ import { LinkSimple, } from "@phosphor-icons/react"; import React, { useEffect, useState } from "react"; +import SettingsButton from "../SettingsButton"; +import { isMobile } from "react-device-detect"; export const MAX_ICONS = 3; export const ICON_COMPONENTS = { @@ -44,11 +45,12 @@ export default function Footer() { if (!Array.isArray(footerData) || footerData.length === 0) { return ( -
+
@@ -56,6 +58,7 @@ export default function Footer() { @@ -63,6 +66,7 @@ export default function Footer() { + {!isMobile && }
); } return ( -
+
); diff --git a/frontend/src/components/SettingsButton/index.jsx b/frontend/src/components/SettingsButton/index.jsx new file mode 100644 index 00000000..0903862d --- /dev/null +++ b/frontend/src/components/SettingsButton/index.jsx @@ -0,0 +1,31 @@ +import useUser from "@/hooks/useUser"; +import paths from "@/utils/paths"; +import { ArrowUUpLeft, Wrench } from "@phosphor-icons/react"; +import { Link } from "react-router-dom"; +import { useMatch } from "react-router-dom"; + +export default function SettingsButton() { + const isInSettings = !!useMatch("/settings/*"); + const { user } = useUser(); + + if (user && user?.role === "default") return null; + + if (isInSettings) + return ( + + + + ); + + return ( + + + + ); +} diff --git a/frontend/src/components/SettingsSidebar/index.jsx b/frontend/src/components/SettingsSidebar/index.jsx index ea488711..112b641b 100644 --- a/frontend/src/components/SettingsSidebar/index.jsx +++ b/frontend/src/components/SettingsSidebar/index.jsx @@ -13,7 +13,6 @@ import { Database, Lock, House, - X, List, FileCode, Plugs, @@ -25,6 +24,7 @@ import useUser from "@/hooks/useUser"; import { USER_BACKGROUND_COLOR } from "@/utils/constants"; import { isMobile } from "react-device-detect"; import Footer from "../Footer"; +import { Link } from "react-router-dom"; export default function SettingsSidebar() { const { logo } = useLogo(); @@ -112,9 +112,7 @@ export default function SettingsSidebar() {
-
-
-
+
@@ -124,50 +122,38 @@ export default function SettingsSidebar() { } return ( - <> +
+ + Logo +
-
- {/* Header Information */} -
-
- Logo -
-
- - - -
+
+
+ Instance Settings
-
- Settings -
- {/* Primary Body */} -
+
- {/* Options */}
-
-
-
+
- +
); } @@ -195,24 +181,25 @@ const Option = ({ return ( <> -
- + {React.cloneElement(icon, { weight: isActive ? "fill" : "regular" })} -

+

{btnText}

-
+
{!!subOptions && (isActive || hasActiveChild) && (
{ async function getWorkspaces() { @@ -90,55 +91,60 @@ export default function ActiveWorkspaces() { href={isActive ? null : paths.workspace.chat(workspace.slug)} className={` transition-all duration-[200ms] - flex flex-grow w-[75%] gap-x-2 py-[6px] px-[12px] rounded-lg text-slate-200 justify-start items-center - hover:bg-workspace-item-selected-gradient + flex flex-grow w-[75%] gap-x-2 py-[6px] px-[12px] rounded-[4px] text-white justify-start items-center + hover:bg-workspace-item-selected-gradient border-outline ${ isActive - ? "border-2 bg-workspace-item-selected-gradient border-white" - : "border bg-workspace-item-gradient bg-opacity-60 border-transparent hover:border-slate-100 hover:border-opacity-50" + ? "bg-workspace-item-selected-gradient font-medium border-none" + : "border-[1px]" }`} >

{isActive || isHovered - ? truncate(workspace.name, 17) + ? truncate(workspace.name, 15) : truncate(workspace.name, 20)}

{(isActive || isHovered || gearHover[workspace.id]) && user?.role !== "default" ? ( -
- + onMouseLeave={() => + handleUploadMouseLeave(workspace.id) + } + className="rounded-md flex items-center justify-center ml-auto" + > + + +
handleGearMouseEnter(workspace.id)} onMouseLeave={() => handleGearMouseLeave(workspace.id)} - className="rounded-md flex items-center justify-center text-white ml-auto" + className="rounded-md flex items-center justify-center text-[#A7A8A9] hover:text-white ml-auto" > - +
+ +
) : null} diff --git a/frontend/src/components/Sidebar/index.jsx b/frontend/src/components/Sidebar/index.jsx index d14099b2..75c854d9 100644 --- a/frontend/src/components/Sidebar/index.jsx +++ b/frontend/src/components/Sidebar/index.jsx @@ -1,14 +1,16 @@ import React, { useEffect, useRef, useState } from "react"; -import { Wrench, Plus, List } from "@phosphor-icons/react"; +import { Plus, List } from "@phosphor-icons/react"; import NewWorkspaceModal, { useNewWorkspaceModal, } from "../Modals/NewWorkspace"; import ActiveWorkspaces from "./ActiveWorkspaces"; -import paths from "@/utils/paths"; import { USER_BACKGROUND_COLOR } from "@/utils/constants"; import useLogo from "@/hooks/useLogo"; import useUser from "@/hooks/useUser"; import Footer from "../Footer"; +import SettingsButton from "../SettingsButton"; +import { Link } from "react-router-dom"; +import paths from "@/utils/paths"; export default function Sidebar() { const { user } = useUser(); @@ -21,40 +23,33 @@ export default function Sidebar() { } = useNewWorkspaceModal(); return ( - <> +
+ + Logo +
- {/* Header Information */} -
-
- Logo -
- {(!user || user?.role !== "default") && ( -
- -
- )} -
- - {/* Primary Body */} -
+
{(!user || user?.role !== "default") && (
{showingNewWsModal && } - +
); } @@ -149,11 +144,9 @@ export function SidebarMobileHeader() { style={{ objectFit: "contain" }} />
- {(!user || user?.role !== "default") && ( -
- -
- )} +
+ +
{/* Primary Body */} @@ -190,17 +183,3 @@ export function SidebarMobileHeader() { ); } - -function SettingsButton() { - const { user } = useUser(); - return ( - - - - ); -} diff --git a/frontend/src/components/UserMenu/UserButton/index.jsx b/frontend/src/components/UserMenu/UserButton/index.jsx index 99db9441..28730bfb 100644 --- a/frontend/src/components/UserMenu/UserButton/index.jsx +++ b/frontend/src/components/UserMenu/UserButton/index.jsx @@ -61,7 +61,7 @@ export default function UserButton() { type="button" className="uppercase transition-all duration-300 w-[35px] h-[35px] text-base font-semibold rounded-full flex items-center bg-sidebar-button hover:bg-menu-item-selected-gradient justify-center text-white p-2 hover:border-slate-100 hover:border-opacity-50 border-transparent border" > - {mode === "multi" ? userDisplay() : } + {mode === "multi" ? : } {showMenu && ( @@ -109,7 +109,7 @@ export default function UserButton() { ); } -function userDisplay() { +function UserDisplay() { const { pfp } = usePfp(); const user = userFromStorage(); diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx index 8a99a62a..293da491 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx @@ -108,7 +108,7 @@ export default function ChatContainer({ workspace, knownHistory = [] }) { return (
{isMobile && }
diff --git a/frontend/src/pages/Admin/Invitations/index.jsx b/frontend/src/pages/Admin/Invitations/index.jsx index a4a99e93..31b2b792 100644 --- a/frontend/src/pages/Admin/Invitations/index.jsx +++ b/frontend/src/pages/Admin/Invitations/index.jsx @@ -18,7 +18,7 @@ export default function AdminInvites() {
diff --git a/frontend/src/pages/Admin/Logging/index.jsx b/frontend/src/pages/Admin/Logging/index.jsx index 246cf211..f405c9a6 100644 --- a/frontend/src/pages/Admin/Logging/index.jsx +++ b/frontend/src/pages/Admin/Logging/index.jsx @@ -30,7 +30,7 @@ export default function AdminLogs() {
diff --git a/frontend/src/pages/Admin/System/index.jsx b/frontend/src/pages/Admin/System/index.jsx index c561efd2..9fe4c718 100644 --- a/frontend/src/pages/Admin/System/index.jsx +++ b/frontend/src/pages/Admin/System/index.jsx @@ -43,7 +43,7 @@ export default function AdminSystem() {
diff --git a/frontend/src/pages/Admin/Workspaces/index.jsx b/frontend/src/pages/Admin/Workspaces/index.jsx index 62a28094..fa612af1 100644 --- a/frontend/src/pages/Admin/Workspaces/index.jsx +++ b/frontend/src/pages/Admin/Workspaces/index.jsx @@ -18,7 +18,7 @@ export default function AdminWorkspaces() {
diff --git a/frontend/src/pages/GeneralSettings/ApiKeys/index.jsx b/frontend/src/pages/GeneralSettings/ApiKeys/index.jsx index 9ba3335f..606dbf0f 100644 --- a/frontend/src/pages/GeneralSettings/ApiKeys/index.jsx +++ b/frontend/src/pages/GeneralSettings/ApiKeys/index.jsx @@ -20,7 +20,7 @@ export default function AdminApiKeys() {
diff --git a/frontend/src/pages/GeneralSettings/Appearance/index.jsx b/frontend/src/pages/GeneralSettings/Appearance/index.jsx index 9aed853b..c2311a2c 100644 --- a/frontend/src/pages/GeneralSettings/Appearance/index.jsx +++ b/frontend/src/pages/GeneralSettings/Appearance/index.jsx @@ -11,7 +11,7 @@ export default function Appearance() {
diff --git a/frontend/src/pages/GeneralSettings/Chats/index.jsx b/frontend/src/pages/GeneralSettings/Chats/index.jsx index aeb341c1..5afde115 100644 --- a/frontend/src/pages/GeneralSettings/Chats/index.jsx +++ b/frontend/src/pages/GeneralSettings/Chats/index.jsx @@ -90,7 +90,7 @@ export default function WorkspaceChats() {
diff --git a/frontend/src/pages/GeneralSettings/EmbedChats/index.jsx b/frontend/src/pages/GeneralSettings/EmbedChats/index.jsx index 23c5bf18..d6079f39 100644 --- a/frontend/src/pages/GeneralSettings/EmbedChats/index.jsx +++ b/frontend/src/pages/GeneralSettings/EmbedChats/index.jsx @@ -14,7 +14,7 @@ export default function EmbedChats() {
diff --git a/frontend/src/pages/GeneralSettings/EmbedConfigs/index.jsx b/frontend/src/pages/GeneralSettings/EmbedConfigs/index.jsx index 4257b029..73a2ca6d 100644 --- a/frontend/src/pages/GeneralSettings/EmbedConfigs/index.jsx +++ b/frontend/src/pages/GeneralSettings/EmbedConfigs/index.jsx @@ -17,7 +17,7 @@ export default function EmbedConfigs() {
diff --git a/frontend/src/pages/GeneralSettings/Security/index.jsx b/frontend/src/pages/GeneralSettings/Security/index.jsx index 26d40868..298a81ad 100644 --- a/frontend/src/pages/GeneralSettings/Security/index.jsx +++ b/frontend/src/pages/GeneralSettings/Security/index.jsx @@ -13,7 +13,7 @@ export default function GeneralSecurity() {
diff --git a/frontend/src/pages/GeneralSettings/VectorDatabase/index.jsx b/frontend/src/pages/GeneralSettings/VectorDatabase/index.jsx index e5eacaea..36242d14 100644 --- a/frontend/src/pages/GeneralSettings/VectorDatabase/index.jsx +++ b/frontend/src/pages/GeneralSettings/VectorDatabase/index.jsx @@ -165,7 +165,7 @@ export default function GeneralVectorDatabase() { {loading ? (
@@ -174,7 +174,7 @@ export default function GeneralVectorDatabase() { ) : (
}
- +