diff --git a/README.md b/README.md index ecadf06..614ac42 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Expect frequent improvements. - [x] Markdown support (3/17/23) - [x] Code syntax highlighting (3/18/23) +- [x] Toggle sidebar (3/18/23) ## Modifications diff --git a/components/Sidebar/Sidebar.tsx b/components/Sidebar/Sidebar.tsx index 4902986..ff8451c 100644 --- a/components/Sidebar/Sidebar.tsx +++ b/components/Sidebar/Sidebar.tsx @@ -1,5 +1,5 @@ import { Conversation } from "@/types"; -import { IconPlus } from "@tabler/icons-react"; +import { IconArrowBarLeft, IconPlus } from "@tabler/icons-react"; import { FC } from "react"; import { Conversations } from "./Conversations"; import { SidebarSettings } from "./SidebarSettings"; @@ -13,14 +13,15 @@ interface Props { onToggleLightMode: (mode: "light" | "dark") => void; onSelectConversation: (conversation: Conversation) => void; onDeleteConversation: (conversation: Conversation) => void; + onToggleSidebar: () => void; } -export const Sidebar: FC = ({ loading, conversations, lightMode, selectedConversation, onNewConversation, onToggleLightMode, onSelectConversation, onDeleteConversation }) => { +export const Sidebar: FC = ({ loading, conversations, lightMode, selectedConversation, onNewConversation, onToggleLightMode, onSelectConversation, onDeleteConversation, onToggleSidebar }) => { return (
-
+
+ +
diff --git a/pages/index.tsx b/pages/index.tsx index ca730da..584138f 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,6 +1,7 @@ import { Chat } from "@/components/Chat/Chat"; import { Sidebar } from "@/components/Sidebar/Sidebar"; import { Conversation, Message, OpenAIModel } from "@/types"; +import { IconArrowBarRight } from "@tabler/icons-react"; import Head from "next/head"; import { useEffect, useState } from "react"; @@ -11,6 +12,7 @@ export default function Home() { const [model, setModel] = useState(OpenAIModel.GPT_3_5); const [lightMode, setLightMode] = useState<"dark" | "light">("dark"); const [disabled, setDisabled] = useState(false); + const [showSidebar, setShowSidebar] = useState(true); const handleSend = async (message: Message) => { if (selectedConversation) { @@ -205,16 +207,24 @@ export default function Home() { {selectedConversation && (
- + {showSidebar ? ( + setShowSidebar(!showSidebar)} + /> + ) : ( + setShowSidebar(!showSidebar)} + /> + )}