From ea58612b8a9f4b68909c296c183ded67cceb31f1 Mon Sep 17 00:00:00 2001 From: xzdry Date: Fri, 23 Dec 2022 15:33:45 +0800 Subject: [PATCH] feat: add the ability to hide the sidebar & remove zoom function --- .gitignore | 3 + packages/editor/src/components/Editor.tsx | 163 ++++++++++-------- .../components/EditorHeader/EditorHeader.tsx | 51 ++++-- 3 files changed, 128 insertions(+), 89 deletions(-) diff --git a/.gitignore b/.gitignore index d600a5e1..36fd843b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ typings coverage stats.html + +# vscode extensions +.history \ No newline at end of file diff --git a/packages/editor/src/components/Editor.tsx b/packages/editor/src/components/Editor.tsx index 817abc69..cd537471 100644 --- a/packages/editor/src/components/Editor.tsx +++ b/packages/editor/src/components/Editor.tsx @@ -60,7 +60,8 @@ export const Editor: React.FC = observer( setExplorerMenuTab, } = editorStore; - const [scale, setScale] = useState(100); + const [isDisplayLeftMenu, setIsDisplayLeftMenu] = useState(true); + const [isDisplayRightMenu, setIsDisplayRightMenu] = useState(true); const [preview, setPreview] = useState(false); const [codeMode, setCodeMode] = useState(false); const [isDisplayApp, setIsDisplayApp] = useState(true); @@ -124,7 +125,6 @@ export const Editor: React.FC = observer( flexDirection="column" width="full" height="full" - transform={`scale(${scale / 100})`} position="relative" overflow="hidden" > @@ -141,100 +141,111 @@ export const Editor: React.FC = observer( return ( <> - - - { - setExplorerMenuTab(activatedTab); - }} - > - - Explorer - UI - Data - State - - - - - - - - - - - - - - - - - - - - {appBox} + {isDisplayLeftMenu ? ( { + setExplorerMenuTab(activatedTab); + }} > - - Inspect - Insert + + Explorer + UI + Data + State - - {inspectForm} - - + + + + + + + + + + + + + ) : null} + + {appBox} + {isDisplayRightMenu ? ( + + + + + Inspect + Insert + + + {inspectForm} + + + + + + + + ) : null} {activeDataSource && activeDataSourceType === DataSourceType.API ? ( = observer( > setCodeMode(true)} /> diff --git a/packages/editor/src/components/EditorHeader/EditorHeader.tsx b/packages/editor/src/components/EditorHeader/EditorHeader.tsx index a7d22bba..c325f3cc 100644 --- a/packages/editor/src/components/EditorHeader/EditorHeader.tsx +++ b/packages/editor/src/components/EditorHeader/EditorHeader.tsx @@ -1,27 +1,50 @@ import React from 'react'; -import { Flex, Button, Box } from '@chakra-ui/react'; -import { AddIcon, MinusIcon } from '@chakra-ui/icons'; +import { Flex, Button, Icon } from '@chakra-ui/react'; +const SideBarIcon: React.FC<{ + transform?: string; + color?: string; + onClick?: () => void; +}> = props => ( + + + +); export const EditorHeader: React.FC<{ - scale: number; - setScale: (v: number) => void; + isDisplayLeftMenu: boolean; + isDisplayRightMenu: boolean; + setIsDisplayLeftMenu: (show: boolean) => void; + setIsDisplayRightMenu: (show: boolean) => void; onPreview: () => void; onCodeMode: () => void; onRefresh: () => void; -}> = ({ scale, setScale, onPreview, onCodeMode, onRefresh }) => { +}> = ({ + onPreview, + onCodeMode, + onRefresh, + setIsDisplayLeftMenu, + setIsDisplayRightMenu, + isDisplayLeftMenu, + isDisplayRightMenu, +}) => { return ( - - - {scale}% - - + setIsDisplayLeftMenu(!isDisplayLeftMenu)} + /> + setIsDisplayRightMenu(!isDisplayRightMenu)} + />