From 2cb40b65443e10af5db91e677326e9f3ae2d2b04 Mon Sep 17 00:00:00 2001 From: Charles Wahome Date: Wed, 2 Mar 2022 17:17:31 +0300 Subject: [PATCH] Fix: try-it experience layout (#1495) --- src/app/views/App.tsx | 58 ++++++++++--------- .../views/app-sections/HeaderMessaging.tsx | 2 +- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/app/views/App.tsx b/src/app/views/App.tsx index 76fe47b64..edf2b83c3 100644 --- a/src/app/views/App.tsx +++ b/src/app/views/App.tsx @@ -281,6 +281,7 @@ class App extends Component { if (showSidebar) { this.changeDimensions('26%'); } + // @ts-ignore this.props.actions!.toggleSidebar(properties); @@ -299,9 +300,9 @@ class App extends Component { {minimised && -
- -
+
+ +
}
@@ -343,6 +344,27 @@ class App extends Component { return width; } + private shouldDisplayContent(parameters: any) { + const { graphExplorerMode, mobileScreen, showSidebar } = parameters; + return !(graphExplorerMode === Mode.Complete && mobileScreen && showSidebar); + } + + private removeFlexBasisProperty() { + /* + flex-basis style property is added automatically when the window resizes + and is set to 100% leading to a distortion of the page when these exact steps are followed. + https://github.com/microsoftgraph/microsoft-graph-explorer-v4/pull/1433#issuecomment-1036135231 + Removing the property altogether helps maintain the layout of the page. + */ + + const collection = document.getElementsByClassName('layout'); + if (collection?.length === 0) { + return; + } + const element: any = collection[0]; + element.style.removeProperty('flex-basis'); + } + public render() { const classes = classNames(this.props); const { authenticated, graphExplorerMode, minimised, sampleQuery, @@ -359,7 +381,10 @@ class App extends Component { const query = createShareLink(sampleQuery, authenticated); const { mobileScreen, showSidebar } = sidebarProperties; - const displayContent = shouldDisplayContent(); + const displayContent = this.shouldDisplayContent({ + graphExplorerMode, + mobileScreen, showSidebar + }); const stackTokens: IStackTokens = { childrenGap: 10, @@ -377,7 +402,7 @@ class App extends Component { sidebarWidth = classes.sidebarMini; } - removeFlexBasisProperty(); + this.removeFlexBasisProperty(); return ( // @ts-ignore @@ -448,7 +473,7 @@ class App extends Component { right: false }} size={{ - width: contentWidth, + width: graphExplorerMode === Mode.TryIt ? '100%' : contentWidth, height: '98vh' }} > @@ -469,27 +494,6 @@ class App extends Component {
); - - function shouldDisplayContent() { - return !(graphExplorerMode === Mode.Complete && mobileScreen && showSidebar); - } - - function removeFlexBasisProperty() { - /* - flex-basis style property is added automatically when the window resizes - and is set to 100% leading to a distortion of the page when these exact steps are followed. - https://github.com/microsoftgraph/microsoft-graph-explorer-v4/pull/1433#issuecomment-1036135231 - - Removing the property altogether helps maintain the layout of the page. - */ - - const collection = document.getElementsByClassName('layout'); - if (collection?.length === 0) { - return; - } - const element: any = collection[0]; - element.style.removeProperty('flex-basis'); - } } } diff --git a/src/app/views/app-sections/HeaderMessaging.tsx b/src/app/views/app-sections/HeaderMessaging.tsx index 858e073ad..c082b94f0 100644 --- a/src/app/views/app-sections/HeaderMessaging.tsx +++ b/src/app/views/app-sections/HeaderMessaging.tsx @@ -10,7 +10,7 @@ export function headerMessaging(classes: any, query: string): React.ReactNode { const loginType = getLoginType(); return ( -
+
{loginType === LoginType.Popup && <>