From b813df53439f7529685ab2ae40c0d6b7794ea538 Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Sun, 26 Mar 2023 16:56:38 +0800 Subject: [PATCH] feat: collapsible side menu issue #110 --- src/assets/icons/DownArrow.tsx | 3 +- src/assets/icons/MenuIcon.tsx | 25 ++++++++ src/components/Chat/Chat.tsx | 9 ++- .../Chat/ChatContent/Message/Message.tsx | 11 +++- src/components/Menu/Menu.tsx | 57 ++++++++++++++----- src/components/MobileBar/MobileBar.tsx | 25 ++------ src/store/config-slice.ts | 9 +++ src/store/store.ts | 1 + 8 files changed, 101 insertions(+), 39 deletions(-) create mode 100644 src/assets/icons/MenuIcon.tsx diff --git a/src/assets/icons/DownArrow.tsx b/src/assets/icons/DownArrow.tsx index 9603b08..c077a8b 100644 --- a/src/assets/icons/DownArrow.tsx +++ b/src/assets/icons/DownArrow.tsx @@ -1,6 +1,6 @@ import React from 'react'; -const DownArrow = () => { +const DownArrow = (props: React.SVGProps) => { return ( { height='1em' width='1em' xmlns='http://www.w3.org/2000/svg' + {...props} > diff --git a/src/assets/icons/MenuIcon.tsx b/src/assets/icons/MenuIcon.tsx new file mode 100644 index 0000000..ab8ecdf --- /dev/null +++ b/src/assets/icons/MenuIcon.tsx @@ -0,0 +1,25 @@ +import React from 'react'; + +const MenuIcon = (props: React.SVGProps) => { + return ( + + + + + + ); +}; + +export default MenuIcon; diff --git a/src/components/Chat/Chat.tsx b/src/components/Chat/Chat.tsx index fde63af..7ec9c86 100644 --- a/src/components/Chat/Chat.tsx +++ b/src/components/Chat/Chat.tsx @@ -1,12 +1,19 @@ import React from 'react'; +import useStore from '@store/store'; import ChatContent from './ChatContent'; import MobileBar from '../MobileBar'; import StopGeneratingButton from '@components/StopGeneratingButton/StopGeneratingButton'; const Chat = () => { + const hideSideMenu = useStore((state) => state.hideSideMenu); + return ( -
+
diff --git a/src/components/Chat/ChatContent/Message/Message.tsx b/src/components/Chat/ChatContent/Message/Message.tsx index 9536d88..05a6bd1 100644 --- a/src/components/Chat/ChatContent/Message/Message.tsx +++ b/src/components/Chat/ChatContent/Message/Message.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import useStore from '@store/store'; import Avatar from './Avatar'; import MessageContent from './MessageContent'; @@ -25,13 +26,21 @@ const Message = React.memo( messageIndex: number; sticky?: boolean; }) => { + const hideSideMenu = useStore((state) => state.hideSideMenu); + return (
-
+
{ + const hideSideMenu = useStore((state) => state.hideSideMenu); + const setHideSideMenu = useStore((state) => state.setHideSideMenu); + + useEffect(() => { + window.addEventListener('resize', () => { + if (window.innerWidth < 768) setHideSideMenu(true); + }); + }, []); + return ( <>