Skip to content

Improve layout and components for different orientations #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"ramda": "^0.27.0",
"react": "^16.13.1",
"react-animated-dots": "^1.0.0",
"react-div-100vh": "^0.3.8",
"react-dnd": "^11.1.3",
"react-dnd-html5-backend": "^11.1.3",
"react-dnd-multi-backend": "^6.0.2",
Expand Down Expand Up @@ -95,6 +96,7 @@
"@types/prettier": "^2.0.2",
"@types/ramda": "^0.27.11",
"@types/react": "^16.9.25",
"@types/react-div-100vh": "^0.3.0",
"@types/react-dom": "^16.9.5",
"@types/react-highlight-words": "^0.16.1",
"@types/react-list": "^0.8.5",
Expand Down Expand Up @@ -123,6 +125,7 @@
"express": "^4.16.2",
"flux-standard-action": "^2.0.1",
"ie-version": "^0.1.0",
"lorem-ipsum": "^2.0.3",
"netlify-cli": "^2.58.0",
"nock": "^12.0.3",
"papaparse": "^5.0.0",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app-styles.sass
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
.previous-queries-filter
display: none

a:hover
text-decoration: none // We want some padding between the line and the text so we deactivate native browser behaviour
body
// In order to not highlight text etc. while dragging we need to disable these events.
-webkit-touch-callout: none /* iOS Safari */
Expand Down
41 changes: 30 additions & 11 deletions frontend/src/js/ContentLayout/ContentLayout.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
import React from "react";
import { ContentLayout } from "./index";
import { loremIpsum } from "lorem-ipsum";

export default {
title: "ContentLayout"
};

const Box: React.FC<{ text: string; color: string; style?: any }> = ({
text,
color,
style
}) => <div style={{ ...style, backgroundColor: color }}>Info {text}</div>;
const Box: React.FC<{
text?: string;
title: string;
words?: number;
color: string;
style?: any;
}> = ({ text, words = 1, color, style, title }) => (
<div
style={{
...style,
backgroundColor: color,
overflow: "auto",
height: "100%"
}}
>
<div>
<h2>{title}</h2>
{text}
</div>
{loremIpsum({ count: words })}
</div>
);

export const Layout = () => (
<ContentLayout
info={<Box text="Info" color="grey" />}
editor={<Box text="Editor" color="blue" />}
tools={<Box text="Tools" color="red" />}
info={<Box title="Info" color="grey" />}
editor={<Box title="Editor" color="cyan" />}
tools={<Box title="Tools" color="red" />}
/>
);

export const LayoutWithContent = () => (
<ContentLayout
info={<Box style={{ height: "1200px" }} text="Info" color="grey" />}
editor={<Box text="Editor" color="blue" />}
tools={<Box text="Tools" color="red" />}
info={<Box title="Info" words={50} color="grey" />}
editor={<Box title="Editor" words={50} color="cyan" />}
tools={<Box title="Tools" words={50} color="red" />}
/>
);
30 changes: 16 additions & 14 deletions frontend/src/js/ContentLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import React from "react";
import { Col, Row } from "reactstrap";
import "bootstrap/dist/css/bootstrap.css";
import styles from "./layout.module.scss";
import Div100vh from "react-div-100vh";

type ContentLayoutProps = {
info: React.ReactNode;
editor: React.ReactNode;
tools: React.ReactNode;
menu?: React.ReactNode;
};

export const ContentLayout: React.FC<ContentLayoutProps> = ({
menu = "This is the menu",
info,
editor,
tools
}) => (
<div>
<Row noGutters>
<Col xs={12} md={12} lg={5} className="border-bottom border-right">
{editor}
</Col>
<Col xs={12} md={8} lg={4} className="border-bottom border-right">
{tools}
</Col>
<Col xs={12} md={4} lg={3} className="border-bottom border-right">
{info}
</Col>
</Row>
</div>
<Div100vh>
<div className={styles.outer}>
<div className={styles.menu}>{menu}</div>
<div className={styles.content}>
<div className={styles.editor}>{editor}</div>
<div className={styles.toolSection}>
<div className={styles.tools}>{tools}</div>
<div className={styles.info}>{info}</div>
</div>
</div>
</div>
</Div100vh>
);
58 changes: 58 additions & 0 deletions frontend/src/js/ContentLayout/layout.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.outer {
display: flex;
flex-direction: column;
justify-content: stretch;
height:100%;
}

.content {
overflow: auto;
display: flex;
flex-direction: column;
flex-grow: 1;
height: 0; //This is a dirty hack to enable flex behaviour for Safari on iOS.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monotv Check this crazy f**k. When I remove this line, it breaks only on iOS.

Copy link

@monotv monotv Jul 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@levino Yeah that's why I don't like web projects :P How does it break? Is the view collapsing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no "view" in "web" my friend. The div is vertically too small.

iPad with the rule:

IMG_0001

iPad without the rule:

IMG_0002

Chrome iPad preview without(!) the rule:

localhost_8000_(iPad) (3)

}

.menu {
overflow: auto;
flex-grow: 0;
}

.editor {
flex-basis: 70%;
overflow: auto;
}

.toolSection {
flex-direction: row;
display: flex;
overflow: auto;
flex-basis: 30%;
}


.info {
flex-basis: 30%;
overflow: auto;
}

.tools {
flex-basis: 70%;
overflow: auto;
}



@media screen and (orientation: landscape) {
.content {
flex-direction: row;
}
.toolSection {
flex-direction: column;
flex-basis: 30%;
overflow: initial;
}
.info {
flex-basis: auto;
}
}
3 changes: 1 addition & 2 deletions frontend/src/js/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { FunctionComponent } from "react";

import { useStartup } from "../startup/useStartup";
import Header from "../header/Header";
import SnackMessage from "../snack-message/SnackMessage";
import Content from "./Content";

const App: FunctionComponent<any> = props => {
useStartup();

return <>{[<Header />, <Content {...props} />, <SnackMessage />]}</>;
return <>{[<Content {...props} />, <SnackMessage />]}</>;
};

export default App;
2 changes: 2 additions & 0 deletions frontend/src/js/app/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import LeftPane from "./LeftPane";
import RightPane from "./RightPane";
import { ContentLayout } from "../ContentLayout";
import { BackendFactory } from "dnd-core";
import Header from "../header/Header";

interface PreviewItemProps {
theme?: any;
Expand Down Expand Up @@ -83,6 +84,7 @@ const Content = ({ displayTooltip, rightTabs }: PropsType) => {
options={CustomHTML5toTouch}
>
<ContentLayout
menu={<Header />}
info={displayTooltip ? <Tooltip /> : <ActivateTooltip />}
editor={<RightPane tabs={rightTabs} />}
tools={<LeftPane />}
Expand Down
33 changes: 6 additions & 27 deletions frontend/src/js/pane/Pane.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from "react";
import styled from "@emotion/styled";
import PaneTabNavigation from "./PaneTabNavigation";

type PropsType = {
Expand All @@ -10,36 +9,16 @@ type PropsType = {
children?: React.Node;
};

const Root = styled("div")`
width: 100%;
height: 100%;

padding: ${//@ts-ignore
({ left, right }) => (left || right ? "50px 0 10px" : "0")};
`;

const Container = styled("div")`
height: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
position: relative;
`;

const Pane = (props: PropsType) => {
const paneType = props.left ? "left" : "right";

return (
<Root
//@ts-ignore
left={props.left}
right={props.right}
>
<Container>
<PaneTabNavigation paneType={paneType} />
<Container className="pane__body">{props.children}</Container>
</Container>
</Root>
<div className="h-100 d-flex flex-column">
<PaneTabNavigation paneType={paneType} />
<div className="flex-grow-1 overflow-auto d-flex flex-column">
{props.children}
</div>
</div>
);
};

Expand Down
8 changes: 2 additions & 6 deletions frontend/src/js/standard-query-editor/Query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ type PropsT = {
dateRange: Record<string, any>;
};

const Container = styled("div")`
height: 100%;
`;

const Groups = styled("div")`
display: flex;
flex-direction: row;
Expand All @@ -70,7 +66,7 @@ const QueryGroupConnector = styled("p")`

const Query = (props: PropsT) => {
return (
<Container>
<div className="flex-grow-1">
{props.isEmptyQuery ? (
<QueryEditorDropzone
isInitial
Expand Down Expand Up @@ -126,7 +122,7 @@ const Query = (props: PropsT) => {
)}
</Groups>
)}
</Container>
</div>
);
};

Expand Down
5 changes: 1 addition & 4 deletions frontend/src/js/standard-query-editor/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ type PropsType = {
};

const Root = styled("div")`
flex-grow: 1;
height: 100%;
overflow: auto;
padding: 0 10px 10px 10px;
`;

export const QueryEditor = (props: PropsType) => (
<Root>
<Root className="flex-grow-1 overflow-auto d-flex">
<Query selectedDatasetId={props.selectedDatasetId} />
<StandardQueryNodeEditor
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { StandardQueryRunner } from "./StandardQueryRunner";
import { QueryClearButton } from "./QueryClearButton";

const StandardQueryEditorTab = (props: TabPropsType) => (
<>
<div className="d-flex flex-column flex-grow-1">
<QueryClearButton />
<QueryEditor selectedDatasetId={props.selectedDatasetId} />
<StandardQueryRunner datasetId={props.selectedDatasetId} />
</>
</div>
);

export default StandardQueryEditorTab;
21 changes: 20 additions & 1 deletion frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2896,6 +2896,13 @@
"@types/history" "*"
"@types/react" "*"

"@types/react-div-100vh@^0.3.0":
version "0.3.0"
resolved "https://registry.npmjs.org/@types/react-div-100vh/-/react-div-100vh-0.3.0.tgz#3146b567304c6d9587f340fdb4b6e612596f07ad"
integrity sha512-ooouxtvbj+mP/OmdAh91+huVECechS2Svb55zTWMaRPXIG4XXL4+TESR7navmm6kvlnZRhDNb7/2qUOTrQm17g==
dependencies:
"@types/react" "*"

"@types/react-dom@*", "@types/react-dom@^16.9.5":
version "16.9.8"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.8.tgz#fe4c1e11dfc67155733dfa6aa65108b4971cb423"
Expand Down Expand Up @@ -5613,7 +5620,7 @@ comma-separated-tokens@^1.0.0:
resolved "https://registry.yarnpkg.com/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz#632b80b6117867a158f1080ad498b2fbe7e3f5ea"
integrity sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==

commander@^2.11.0, commander@^2.19.0, commander@^2.20.0, commander@^2.20.3, commander@^2.3.0:
commander@^2.11.0, commander@^2.17.1, commander@^2.19.0, commander@^2.20.0, commander@^2.20.3, commander@^2.3.0:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
Expand Down Expand Up @@ -11392,6 +11399,13 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3
dependencies:
js-tokens "^3.0.0 || ^4.0.0"

lorem-ipsum@^2.0.3:
version "2.0.3"
resolved "https://registry.npmjs.org/lorem-ipsum/-/lorem-ipsum-2.0.3.tgz#9f1fa634780c9f58a349d4e091c3ba74f733164e"
integrity sha512-CX2r84DMWjW/DWiuzicTI9aRaJPAw2cvAGMJYZh/nx12OkTGqloj8y8FU0S8ZkKwOdqhfxEA6Ly8CW2P6Yxjwg==
dependencies:
commander "^2.17.1"

loud-rejection@^1.0.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f"
Expand Down Expand Up @@ -14512,6 +14526,11 @@ react-dev-utils@^9.0.0:
strip-ansi "5.2.0"
text-table "0.2.0"

react-div-100vh@^0.3.8:
version "0.3.8"
resolved "https://registry.npmjs.org/react-div-100vh/-/react-div-100vh-0.3.8.tgz#54e4c32d0286a65e92367fc0a07cc3f2f00739d8"
integrity sha512-1kDFW+HXYpfac1tfJ4BcQmgTSeTtLVs2FO2ZNHcwLIga+oVluexUEISCBJvr9xq98DK8tcygY3259EvIy5O+3g==

react-dnd-html5-backend@^11.1.3:
version "11.1.3"
resolved "https://registry.npmjs.org/react-dnd-html5-backend/-/react-dnd-html5-backend-11.1.3.tgz#2749f04f416ec230ea193f5c1fbea2de7dffb8f7"
Expand Down