Skip to content

Commit

Permalink
Fix: try-it experience layout (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewahome authored Mar 2, 2022
1 parent 9e9e8b5 commit 2cb40b6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
58 changes: 31 additions & 27 deletions src/app/views/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ class App extends Component<IAppProps, IAppState> {
if (showSidebar) {
this.changeDimensions('26%');
}

// @ts-ignore
this.props.actions!.toggleSidebar(properties);

Expand All @@ -299,9 +300,9 @@ class App extends Component<IAppProps, IAppState> {
<Authentication />
</div>
{minimised &&
<div className={minimised ? '' : 'col-2'} style={{position:'relative', left: '-9px'}}>
<FeedbackButton />
</div>
<div className={minimised ? '' : 'col-2'} style={{ position: 'relative', left: '-9px' }}>
<FeedbackButton />
</div>
}
<div className={minimised ? '' : 'col-2'}>
<Settings />
Expand Down Expand Up @@ -343,6 +344,27 @@ class App extends Component<IAppProps, IAppState> {
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,
Expand All @@ -359,7 +381,10 @@ class App extends Component<IAppProps, IAppState> {
const query = createShareLink(sampleQuery, authenticated);
const { mobileScreen, showSidebar } = sidebarProperties;

const displayContent = shouldDisplayContent();
const displayContent = this.shouldDisplayContent({
graphExplorerMode,
mobileScreen, showSidebar
});

const stackTokens: IStackTokens = {
childrenGap: 10,
Expand All @@ -377,7 +402,7 @@ class App extends Component<IAppProps, IAppState> {
sidebarWidth = classes.sidebarMini;
}

removeFlexBasisProperty();
this.removeFlexBasisProperty();

return (
// @ts-ignore
Expand Down Expand Up @@ -448,7 +473,7 @@ class App extends Component<IAppProps, IAppState> {
right: false
}}
size={{
width: contentWidth,
width: graphExplorerMode === Mode.TryIt ? '100%' : contentWidth,
height: '98vh'
}}
>
Expand All @@ -469,27 +494,6 @@ class App extends Component<IAppProps, IAppState> {
</div>
</ThemeContext.Provider>
);

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');
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/views/app-sections/HeaderMessaging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function headerMessaging(classes: any, query: string): React.ReactNode {
const loginType = getLoginType();

return (
<div style={{ marginBottom: 8 }}>
<div style={{ marginBottom: 8, paddingLeft: 10 }}>
{loginType === LoginType.Popup && <>
<MessageBar messageBarType={MessageBarType.info} isMultiline={true}>
<p>
Expand Down

0 comments on commit 2cb40b6

Please sign in to comment.