From 8bb45974346221ce99518ee09458c6053a6a568a Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Tue, 31 May 2022 16:28:07 -0400 Subject: [PATCH] fix(striker-ui): allow server preview to switch inner panel --- striker-ui/components/Display/Preview.tsx | 49 ++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/striker-ui/components/Display/Preview.tsx b/striker-ui/components/Display/Preview.tsx index b8151bc6..f505e5b5 100644 --- a/striker-ui/components/Display/Preview.tsx +++ b/striker-ui/components/Display/Preview.tsx @@ -5,14 +5,15 @@ import { PowerOffOutlined as PowerOffOutlinedIcon, } from '@mui/icons-material'; -import { GREY } from '../../lib/consts/DEFAULT_THEME'; +import { BORDER_RADIUS, GREY } from '../../lib/consts/DEFAULT_THEME'; import IconButton from '../IconButton'; -import { Panel, PanelHeader } from '../Panels'; -import { HeaderText } from '../Text'; +import { InnerPanel, InnerPanelHeader, Panel, PanelHeader } from '../Panels'; +import { BodyText, HeaderText } from '../Text'; type PreviewOptionalProps = { isShowControls?: boolean; + isUseInnerPanel?: boolean; setMode?: Dispatch> | null; }; @@ -23,11 +24,40 @@ type PreviewProps = PreviewOptionalProps & { const PREVIEW_DEFAULT_PROPS: Required = { isShowControls: true, + isUseInnerPanel: false, setMode: null, }; +const PreviewPanel: FC<{ isUseInnerPanel: boolean }> = ({ + children, + isUseInnerPanel, +}) => + isUseInnerPanel ? ( + {children} + ) : ( + {children} + ); + +const PreviewPanelHeader: FC<{ isUseInnerPanel: boolean; text: string }> = ({ + children, + isUseInnerPanel, + text, +}) => + isUseInnerPanel ? ( + + + {children} + + ) : ( + + + {children} + + ); + const Preview: FC = ({ isShowControls = PREVIEW_DEFAULT_PROPS.isShowControls, + isUseInnerPanel = PREVIEW_DEFAULT_PROPS.isUseInnerPanel, serverName, setMode, uuid, @@ -55,10 +85,11 @@ const Preview: FC = ({ }, [uuid]); return ( - - - - + + = ({ component="span" onClick={() => setMode?.call(null, false)} sx={{ + borderRadius: BORDER_RADIUS, color: GREY, padding: 0, }} @@ -92,7 +124,6 @@ const Preview: FC = ({ @@ -107,7 +138,7 @@ const Preview: FC = ({ )} - + ); };