From 7f2cc8890aa606fd4be13fdad1307626b9322591 Mon Sep 17 00:00:00 2001 From: steven Date: Fri, 24 Mar 2023 17:01:28 +0800 Subject: [PATCH] feat: implement responsive sidebar --- components/ChatView/Header.tsx | 15 +-- components/ChatView/index.tsx | 5 +- components/ConnectionSidebar.tsx | 159 ++++++++++++++++--------------- pages/index.tsx | 33 ++++++- store/index.ts | 1 + store/layout.ts | 30 ++++++ 6 files changed, 158 insertions(+), 85 deletions(-) create mode 100644 store/layout.ts diff --git a/components/ChatView/Header.tsx b/components/ChatView/Header.tsx index 1276cb8..863afc5 100644 --- a/components/ChatView/Header.tsx +++ b/components/ChatView/Header.tsx @@ -12,15 +12,18 @@ const Header = () => { }, [title]); return ( -
-
- +
+
+ + {title}
- {title} -
+ {title} +
Crafted by diff --git a/components/ChatView/index.tsx b/components/ChatView/index.tsx index a4d3fbc..93535b2 100644 --- a/components/ChatView/index.tsx +++ b/components/ChatView/index.tsx @@ -110,7 +110,10 @@ const ChatView = () => { }; return ( -
+
{messageList.length === 0 ? ( diff --git a/components/ConnectionSidebar.tsx b/components/ConnectionSidebar.tsx index f0bdfb5..e0af815 100644 --- a/components/ConnectionSidebar.tsx +++ b/components/ConnectionSidebar.tsx @@ -1,8 +1,8 @@ import { head } from "lodash-es"; -import { useEffect, useState } from "react"; +import { useState } from "react"; import { createPortal } from "react-dom"; -import { useChatStore, useConnectionStore } from "@/store"; -import { Connection } from "@/types"; +import { useChatStore, useConnectionStore, useLayoutStore } from "@/store"; +import { Chat, Connection } from "@/types"; import Icon from "./Icon"; import EngineIcon from "./EngineIcon"; import CreateConnectionModal from "./CreateConnectionModal"; @@ -14,6 +14,7 @@ interface State { } const ConnectionSidebar = () => { + const layoutStore = useLayoutStore(); const connectionStore = useConnectionStore(); const chatStore = useChatStore(); const [state, setState] = useState({ @@ -65,88 +66,96 @@ const ConnectionSidebar = () => { } }; + const handleChatSelect = (chat: Chat) => { + chatStore.setCurrentChat(chat); + layoutStore.toggleSidebar(false); + }; + return ( <> -