2023-06-17 08:50:56 +02:00
|
|
|
import React, { useEffect, useRef, useState } from "react";
|
|
|
|
import {
|
2023-10-23 22:10:34 +02:00
|
|
|
Wrench,
|
|
|
|
GithubLogo,
|
2023-06-17 08:50:56 +02:00
|
|
|
BookOpen,
|
2023-10-23 22:10:34 +02:00
|
|
|
DiscordLogo,
|
|
|
|
DotsThree,
|
2023-11-09 17:55:20 +01:00
|
|
|
Plus,
|
|
|
|
List,
|
2023-10-23 22:10:34 +02:00
|
|
|
} from "@phosphor-icons/react";
|
2023-06-04 04:28:07 +02:00
|
|
|
import NewWorkspaceModal, {
|
|
|
|
useNewWorkspaceModal,
|
|
|
|
} from "../Modals/NewWorkspace";
|
|
|
|
import ActiveWorkspaces from "./ActiveWorkspaces";
|
|
|
|
import paths from "../../utils/paths";
|
2023-11-09 17:55:20 +01:00
|
|
|
import { USER_BACKGROUND_COLOR } from "../../utils/constants";
|
2023-08-15 00:22:55 +02:00
|
|
|
import useLogo from "../../hooks/useLogo";
|
2023-06-04 04:28:07 +02:00
|
|
|
|
|
|
|
export default function Sidebar() {
|
2023-08-15 00:22:55 +02:00
|
|
|
const { logo } = useLogo();
|
2023-06-04 04:28:07 +02:00
|
|
|
const sidebarRef = useRef(null);
|
|
|
|
const {
|
|
|
|
showing: showingNewWsModal,
|
|
|
|
showModal: showNewWsModal,
|
|
|
|
hideModal: hideNewWsModal,
|
|
|
|
} = useNewWorkspaceModal();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div
|
|
|
|
ref={sidebarRef}
|
|
|
|
style={{ height: "calc(100% - 32px)" }}
|
2023-10-23 22:10:34 +02:00
|
|
|
className="transition-all duration-500 relative m-[16px] rounded-[26px] bg-sidebar border-4 border-accent min-w-[250px] p-[18px]"
|
2023-06-04 04:28:07 +02:00
|
|
|
>
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="flex flex-col h-full overflow-x-hidden">
|
2023-06-04 04:28:07 +02:00
|
|
|
{/* Header Information */}
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="flex items-center justify-between mb-4">
|
|
|
|
<div className="flex shrink-0 max-w-[65%] items-center justify-start">
|
2023-08-15 00:22:55 +02:00
|
|
|
<img
|
|
|
|
src={logo}
|
|
|
|
alt="Logo"
|
|
|
|
className="rounded max-h-[40px]"
|
|
|
|
style={{ objectFit: "contain" }}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="flex gap-x-2 items-center text-slate-200">
|
|
|
|
{/* <AdminHome /> */}
|
|
|
|
<SettingsButton />
|
2023-06-04 04:28:07 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* Primary Body */}
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="flex-grow flex flex-col">
|
|
|
|
<div className="flex flex-col gap-y-4 pb-8 overflow-y-scroll no-scroll">
|
|
|
|
<div className="flex gap-x-2 items-center justify-between">
|
|
|
|
<button
|
|
|
|
onClick={showNewWsModal}
|
|
|
|
className="flex flex-grow w-[75%] h-[44px] gap-x-2 py-[5px] px-4 bg-white rounded-lg text-sidebar justify-center items-center hover:bg-opacity-80 transition-all duration-300"
|
|
|
|
>
|
|
|
|
<Plus className="h-5 w-5" />
|
|
|
|
<p className="text-sidebar text-sm font-semibold">
|
|
|
|
New Workspace
|
|
|
|
</p>
|
|
|
|
</button>
|
2023-06-04 04:28:07 +02:00
|
|
|
</div>
|
2023-10-23 22:10:34 +02:00
|
|
|
<ActiveWorkspaces />
|
2023-06-04 04:28:07 +02:00
|
|
|
</div>
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="flex flex-col flex-grow justify-end mb-2">
|
|
|
|
{/* <div className="flex flex-col gap-y-2">
|
2023-06-04 04:28:07 +02:00
|
|
|
<div className="w-full flex items-center justify-between">
|
|
|
|
<LLMStatus />
|
|
|
|
<IndexCount />
|
|
|
|
</div>
|
|
|
|
<a
|
2023-08-12 02:28:30 +02:00
|
|
|
href={paths.feedback()}
|
2023-06-08 23:26:29 +02:00
|
|
|
target="_blank"
|
2023-10-23 22:10:34 +02:00
|
|
|
className="flex flex-grow w-[100%] h-[36px] gap-x-2 py-[5px] px-4 border border-transparent rounded-lg text-slate-200 justify-center items-center bg-stone-800 hover:bg-stone-900"
|
2023-06-04 04:28:07 +02:00
|
|
|
>
|
2023-08-12 02:28:30 +02:00
|
|
|
<AtSign className="h-4 w-4" />
|
2023-10-23 22:10:34 +02:00
|
|
|
<p className="text-slate-200 text-xs leading-loose font-semibold">
|
2023-08-12 02:28:30 +02:00
|
|
|
Feedback form
|
2023-06-04 04:28:07 +02:00
|
|
|
</p>
|
|
|
|
</a>
|
2023-08-12 02:33:17 +02:00
|
|
|
<ManagedHosting />
|
2023-08-04 00:59:51 +02:00
|
|
|
<LogoutButton />
|
2023-10-23 22:10:34 +02:00
|
|
|
</div> */}
|
2023-06-04 04:28:07 +02:00
|
|
|
|
|
|
|
{/* Footer */}
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="flex justify-center mt-2">
|
|
|
|
<div className="flex space-x-4">
|
2023-06-04 04:28:07 +02:00
|
|
|
<a
|
|
|
|
href={paths.github()}
|
2023-10-23 22:10:34 +02:00
|
|
|
className="transition-all duration-300 p-2 rounded-full text-white bg-sidebar-button hover:bg-menu-item-selected-gradient hover:border-slate-100 hover:border-opacity-50 border-transparent border"
|
2023-06-04 04:28:07 +02:00
|
|
|
>
|
2023-10-23 22:10:34 +02:00
|
|
|
<GithubLogo weight="fill" className="h-5 w-5 " />
|
2023-06-04 04:28:07 +02:00
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
href={paths.docs()}
|
2023-10-23 22:10:34 +02:00
|
|
|
className="transition-all duration-300 p-2 rounded-full text-white bg-sidebar-button hover:bg-menu-item-selected-gradient hover:border-slate-100 hover:border-opacity-50 border-transparent border"
|
2023-06-04 04:28:07 +02:00
|
|
|
>
|
2023-10-23 22:10:34 +02:00
|
|
|
<BookOpen weight="fill" className="h-5 w-5 " />
|
2023-06-04 04:28:07 +02:00
|
|
|
</a>
|
2023-07-21 21:05:39 +02:00
|
|
|
<a
|
|
|
|
href={paths.discord()}
|
2023-10-23 22:10:34 +02:00
|
|
|
className="transition-all duration-300 p-2 rounded-full text-white bg-sidebar-button hover:bg-menu-item-selected-gradient hover:border-slate-100 hover:border-opacity-50 border-transparent border"
|
2023-07-21 21:05:39 +02:00
|
|
|
>
|
2023-10-23 22:10:34 +02:00
|
|
|
<DiscordLogo
|
|
|
|
weight="fill"
|
|
|
|
className="h-5 w-5 stroke-slate-200 group-hover:stroke-slate-200"
|
|
|
|
/>
|
2023-07-21 21:05:39 +02:00
|
|
|
</a>
|
2023-10-23 22:10:34 +02:00
|
|
|
<button className="invisible transition-all duration-300 p-2 rounded-full text-white bg-sidebar-button hover:bg-menu-item-selected-gradient hover:border-slate-100 hover:border-opacity-50 border-transparent border">
|
|
|
|
<DotsThree className="h-5 w-5 group-hover:stroke-slate-200" />
|
|
|
|
</button>
|
2023-06-04 04:28:07 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{showingNewWsModal && <NewWorkspaceModal hideModal={hideNewWsModal} />}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2023-06-17 08:50:56 +02:00
|
|
|
|
|
|
|
export function SidebarMobileHeader() {
|
2023-08-15 00:22:55 +02:00
|
|
|
const { logo } = useLogo();
|
2023-07-25 19:37:04 +02:00
|
|
|
const sidebarRef = useRef(null);
|
2023-06-17 08:50:56 +02:00
|
|
|
const [showSidebar, setShowSidebar] = useState(false);
|
|
|
|
const [showBgOverlay, setShowBgOverlay] = useState(false);
|
|
|
|
const {
|
|
|
|
showing: showingNewWsModal,
|
|
|
|
showModal: showNewWsModal,
|
|
|
|
hideModal: hideNewWsModal,
|
|
|
|
} = useNewWorkspaceModal();
|
|
|
|
|
|
|
|
useEffect(() => {
|
2023-08-18 23:36:58 +02:00
|
|
|
// Darkens the rest of the screen
|
|
|
|
// when sidebar is open.
|
2023-06-17 08:50:56 +02:00
|
|
|
function handleBg() {
|
|
|
|
if (showSidebar) {
|
|
|
|
setTimeout(() => {
|
|
|
|
setShowBgOverlay(true);
|
|
|
|
}, 300);
|
|
|
|
} else {
|
|
|
|
setShowBgOverlay(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleBg();
|
|
|
|
}, [showSidebar]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="fixed top-0 left-0 right-0 z-10 flex justify-between items-center px-4 py-2 bg-sidebar text-slate-200 shadow-lg h-16">
|
2023-06-17 08:50:56 +02:00
|
|
|
<button
|
|
|
|
onClick={() => setShowSidebar(true)}
|
2023-10-23 22:10:34 +02:00
|
|
|
className="rounded-md p-2 flex items-center justify-center text-slate-200"
|
2023-06-17 08:50:56 +02:00
|
|
|
>
|
2023-11-09 17:55:20 +01:00
|
|
|
<List className="h-6 w-6" />
|
2023-06-17 08:50:56 +02:00
|
|
|
</button>
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="flex items-center justify-center flex-grow">
|
2023-08-15 00:22:55 +02:00
|
|
|
<img
|
|
|
|
src={logo}
|
|
|
|
alt="Logo"
|
2023-10-23 22:10:34 +02:00
|
|
|
className="block mx-auto h-6 w-auto"
|
|
|
|
style={{ maxHeight: "40px", objectFit: "contain" }}
|
2023-08-15 00:22:55 +02:00
|
|
|
/>
|
|
|
|
</div>
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="w-12"></div>
|
2023-06-17 08:50:56 +02:00
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
transform: showSidebar ? `translateX(0vw)` : `translateX(-100vw)`,
|
|
|
|
}}
|
|
|
|
className={`z-99 fixed top-0 left-0 transition-all duration-500 w-[100vw] h-[100vh]`}
|
|
|
|
>
|
|
|
|
<div
|
2023-08-12 02:33:17 +02:00
|
|
|
className={`${
|
|
|
|
showBgOverlay
|
|
|
|
? "transition-all opacity-1"
|
|
|
|
: "transition-none opacity-0"
|
2023-10-23 22:10:34 +02:00
|
|
|
} duration-500 fixed top-0 left-0 ${USER_BACKGROUND_COLOR} bg-opacity-75 w-screen h-screen`}
|
2023-06-17 08:50:56 +02:00
|
|
|
onClick={() => setShowSidebar(false)}
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
ref={sidebarRef}
|
2023-10-23 22:10:34 +02:00
|
|
|
className="relative h-[100vh] fixed top-0 left-0 rounded-r-[26px] bg-sidebar w-[80%] p-[18px] "
|
2023-06-17 08:50:56 +02:00
|
|
|
>
|
|
|
|
<div className="w-full h-full flex flex-col overflow-x-hidden items-between">
|
|
|
|
{/* Header Information */}
|
2023-08-18 23:36:58 +02:00
|
|
|
<div className="flex w-full items-center justify-between gap-x-4">
|
|
|
|
<div className="flex shrink-1 w-fit items-center justify-start">
|
2023-08-15 00:22:55 +02:00
|
|
|
<img
|
|
|
|
src={logo}
|
|
|
|
alt="Logo"
|
|
|
|
className="rounded w-full max-h-[40px]"
|
|
|
|
style={{ objectFit: "contain" }}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-08-18 23:36:58 +02:00
|
|
|
<div className="flex gap-x-2 items-center text-slate-500 shink-0">
|
2023-10-23 22:10:34 +02:00
|
|
|
<SettingsButton />
|
2023-06-17 08:50:56 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* Primary Body */}
|
|
|
|
<div className="h-full flex flex-col w-full justify-between pt-4 overflow-y-hidden ">
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="h-auto md:sidebar-items">
|
2023-06-17 08:50:56 +02:00
|
|
|
<div
|
|
|
|
style={{ height: "calc(100vw - -3rem)" }}
|
|
|
|
className=" flex flex-col gap-y-4 pb-8 overflow-y-scroll no-scroll"
|
|
|
|
>
|
|
|
|
<div className="flex gap-x-2 items-center justify-between">
|
|
|
|
<button
|
|
|
|
onClick={showNewWsModal}
|
2023-10-23 22:10:34 +02:00
|
|
|
className="flex flex-grow w-[75%] h-[44px] gap-x-2 py-[5px] px-4 bg-white rounded-lg text-sidebar justify-center items-center hover:bg-opacity-80 transition-all duration-300"
|
2023-06-17 08:50:56 +02:00
|
|
|
>
|
2023-10-23 22:10:34 +02:00
|
|
|
<Plus className="h-5 w-5" />
|
|
|
|
<p className="text-sidebar text-sm font-semibold">
|
|
|
|
New Workspace
|
2023-06-17 08:50:56 +02:00
|
|
|
</p>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<ActiveWorkspaces />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{/* Footer */}
|
2023-10-23 22:10:34 +02:00
|
|
|
<div className="flex justify-center mt-2">
|
|
|
|
<div className="flex space-x-4">
|
2023-06-17 08:50:56 +02:00
|
|
|
<a
|
|
|
|
href={paths.github()}
|
2023-10-23 22:10:34 +02:00
|
|
|
className="transition-all duration-300 p-2 rounded-full text-white bg-sidebar-button hover:bg-menu-item-selected-gradient hover:border-slate-100 hover:border-opacity-50 border-transparent border"
|
2023-06-17 08:50:56 +02:00
|
|
|
>
|
2023-10-23 22:10:34 +02:00
|
|
|
<GithubLogo weight="fill" className="h-5 w-5 " />
|
2023-06-17 08:50:56 +02:00
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
href={paths.docs()}
|
2023-10-23 22:10:34 +02:00
|
|
|
className="transition-all duration-300 p-2 rounded-full text-white bg-sidebar-button hover:bg-menu-item-selected-gradient hover:border-slate-100 hover:border-opacity-50 border-transparent border"
|
2023-06-17 08:50:56 +02:00
|
|
|
>
|
2023-10-23 22:10:34 +02:00
|
|
|
<BookOpen weight="fill" className="h-5 w-5 " />
|
2023-06-17 08:50:56 +02:00
|
|
|
</a>
|
2023-07-21 21:05:39 +02:00
|
|
|
<a
|
|
|
|
href={paths.discord()}
|
2023-10-23 22:10:34 +02:00
|
|
|
className="transition-all duration-300 p-2 rounded-full text-white bg-sidebar-button hover:bg-menu-item-selected-gradient hover:border-slate-100 hover:border-opacity-50 border-transparent border"
|
2023-07-21 21:05:39 +02:00
|
|
|
>
|
2023-10-23 22:10:34 +02:00
|
|
|
<DiscordLogo
|
|
|
|
weight="fill"
|
|
|
|
className="h-5 w-5 stroke-slate-200 group-hover:stroke-slate-200"
|
|
|
|
/>
|
2023-07-21 21:05:39 +02:00
|
|
|
</a>
|
2023-10-23 22:10:34 +02:00
|
|
|
{/* <button className="invisible transition-all duration-300 p-2 rounded-full text-white bg-sidebar-button hover:bg-menu-item-selected-gradient hover:border-slate-100 hover:border-opacity-50 border-transparent border">
|
|
|
|
<DotsThree className="h-5 w-5 group-hover:stroke-slate-200" />
|
|
|
|
</button> */}
|
2023-06-17 08:50:56 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{showingNewWsModal && <NewWorkspaceModal hideModal={hideNewWsModal} />}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2023-07-25 19:37:04 +02:00
|
|
|
|
2023-10-23 22:10:34 +02:00
|
|
|
function SettingsButton() {
|
2023-08-18 23:36:58 +02:00
|
|
|
return (
|
2023-10-23 22:10:34 +02:00
|
|
|
<a
|
|
|
|
href={paths.general.llmPreference()}
|
|
|
|
className="transition-all duration-300 p-2 rounded-full text-white bg-sidebar-button hover:bg-menu-item-selected-gradient hover:border-slate-100 hover:border-opacity-50 border-transparent border"
|
2023-08-18 23:36:58 +02:00
|
|
|
>
|
2023-10-23 22:10:34 +02:00
|
|
|
<Wrench className="h-4 w-4" weight="fill" />
|
|
|
|
</a>
|
2023-08-18 23:36:58 +02:00
|
|
|
);
|
|
|
|
}
|