2020-04-09 00:29:13 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
|
|
|
import * as SVG from "~/components/system/svg";
|
|
|
|
|
|
|
|
import { css } from "@emotion/react";
|
2020-08-12 22:41:56 +03:00
|
|
|
import { GlobalTooltip } from "~/components/system/components/fragments/GlobalTooltip";
|
2020-04-09 00:29:13 +03:00
|
|
|
|
2020-08-09 01:04:17 +03:00
|
|
|
const STYLES_SCROLL = css`
|
|
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
overflow-y: scroll;
|
|
|
|
scrollbar-width: none;
|
|
|
|
-ms-overflow-style: -ms-autohiding-scrollbar;
|
|
|
|
::-webkit-scrollbar {
|
2020-08-09 06:52:22 +03:00
|
|
|
width: 4px;
|
2020-08-09 01:04:17 +03:00
|
|
|
}
|
|
|
|
::-webkit-scrollbar-track {
|
|
|
|
background: ${Constants.system.foreground};
|
|
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
|
|
background: ${Constants.system.darkGray};
|
|
|
|
}
|
|
|
|
`;
|
2020-04-09 00:29:13 +03:00
|
|
|
|
2020-08-14 11:29:29 +03:00
|
|
|
const STYLES_NO_VISIBLE_SCROLL = css`
|
|
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
overflow-y: scroll;
|
|
|
|
scrollbar-width: none;
|
|
|
|
-ms-overflow-style: -ms-autohiding-scrollbar;
|
|
|
|
::-webkit-scrollbar {
|
|
|
|
width: 0px;
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
::-webkit-scrollbar-track {
|
|
|
|
background: ${Constants.system.foreground};
|
|
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
|
|
background: ${Constants.system.darkGray};
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-08-08 03:10:28 +03:00
|
|
|
const STYLES_LAYOUT = css`
|
2020-04-09 00:29:13 +03:00
|
|
|
display: flex;
|
|
|
|
align-items: flex-start;
|
|
|
|
justify-content: space-between;
|
2020-08-09 06:52:22 +03:00
|
|
|
width: 100%;
|
2020-04-09 00:29:13 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_HEADER = css`
|
|
|
|
z-index: ${Constants.zindex.header};
|
|
|
|
height: ${Constants.sizes.header}px;
|
2020-08-08 03:10:28 +03:00
|
|
|
pointer-events: none;
|
|
|
|
width: 100%;
|
|
|
|
position: absolute;
|
2020-04-09 00:29:13 +03:00
|
|
|
left: 0;
|
|
|
|
right: 0;
|
2020-08-08 03:10:28 +03:00
|
|
|
top: 0;
|
2020-08-09 01:38:09 +03:00
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
|
|
|
}
|
2020-08-08 03:10:28 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_CONTENT = css`
|
|
|
|
background: ${Constants.system.white};
|
|
|
|
width: 100%;
|
|
|
|
min-width: 10%;
|
|
|
|
height: 100vh;
|
|
|
|
position: relative;
|
|
|
|
`;
|
|
|
|
|
2020-08-09 01:04:17 +03:00
|
|
|
const STYLES_BODY_WEB = css`
|
|
|
|
display: block;
|
2020-08-08 03:10:28 +03:00
|
|
|
height: 100%;
|
|
|
|
min-height: 10%;
|
|
|
|
width: 100%;
|
2020-08-09 01:04:17 +03:00
|
|
|
${STYLES_SCROLL}
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
2020-08-08 03:10:28 +03:00
|
|
|
}
|
2020-08-09 01:04:17 +03:00
|
|
|
`;
|
2020-08-08 03:10:28 +03:00
|
|
|
|
2020-08-09 01:04:17 +03:00
|
|
|
const STYLES_BODY_MOBILE = css`
|
|
|
|
display: none;
|
|
|
|
height: 100%;
|
|
|
|
min-height: 10%;
|
|
|
|
width: 100%;
|
2020-08-22 08:54:00 +03:00
|
|
|
padding: 0px 0px 88px 0px;
|
2020-08-09 01:04:17 +03:00
|
|
|
${STYLES_SCROLL}
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: block;
|
2020-08-08 03:10:28 +03:00
|
|
|
}
|
2020-04-09 00:29:13 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_NAVIGATION = css`
|
2020-08-14 11:29:29 +03:00
|
|
|
z-index: 1;
|
2020-08-08 03:10:28 +03:00
|
|
|
flex-shrink: 0;
|
|
|
|
height: 100vh;
|
2020-04-09 00:29:13 +03:00
|
|
|
z-index: ${Constants.zindex.navigation};
|
|
|
|
width: ${Constants.sizes.navigation}px;
|
2020-08-08 03:10:28 +03:00
|
|
|
border-right: 1px solid ${Constants.system.border};
|
2020-08-14 11:29:29 +03:00
|
|
|
${STYLES_NO_VISIBLE_SCROLL}
|
2020-08-09 01:38:09 +03:00
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
2020-08-09 01:04:17 +03:00
|
|
|
width: auto;
|
2020-08-08 03:10:28 +03:00
|
|
|
}
|
2020-08-09 01:04:17 +03:00
|
|
|
`;
|
2020-08-08 03:10:28 +03:00
|
|
|
|
2020-08-09 01:04:17 +03:00
|
|
|
const STYLES_SIDEBAR_WEB = css`
|
2020-08-08 03:10:28 +03:00
|
|
|
height: 100vh;
|
2020-04-09 00:29:13 +03:00
|
|
|
width: ${Constants.sizes.sidebar}px;
|
|
|
|
padding: 0;
|
|
|
|
flex-shrink: 0;
|
2020-08-08 03:10:28 +03:00
|
|
|
box-shadow: inset 1px 0 0 0 ${Constants.system.border};
|
2020-08-09 01:04:17 +03:00
|
|
|
${STYLES_SCROLL}
|
2020-08-09 01:38:09 +03:00
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
2020-08-09 01:04:17 +03:00
|
|
|
display: none;
|
2020-04-09 00:29:13 +03:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_SIDEBAR_HEADER = css`
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-end;
|
2020-08-22 08:54:00 +03:00
|
|
|
margin-bottom: 8px;
|
2020-04-09 00:29:13 +03:00
|
|
|
`;
|
|
|
|
|
2020-08-09 06:52:22 +03:00
|
|
|
const STYLES_SIDEBAR_CONTENT = css`
|
|
|
|
padding: 24px;
|
|
|
|
`;
|
|
|
|
|
2020-04-09 00:29:13 +03:00
|
|
|
const STYLES_BLOCK = css`
|
|
|
|
height: 56px;
|
|
|
|
width: 56px;
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
transition: 200ms ease all;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export default class ApplicationLayout extends React.Component {
|
2020-08-12 22:41:56 +03:00
|
|
|
_sidebar;
|
|
|
|
_navigation;
|
|
|
|
_body;
|
|
|
|
|
2020-04-09 00:29:13 +03:00
|
|
|
render() {
|
2020-08-09 01:04:17 +03:00
|
|
|
let sidebarElements = null;
|
|
|
|
if (this.props.sidebar) {
|
|
|
|
sidebarElements = (
|
|
|
|
<React.Fragment>
|
2020-08-20 08:45:43 +03:00
|
|
|
<GlobalTooltip
|
|
|
|
elementRef={this._sidebar}
|
|
|
|
allowedTypes={["sidebar"]}
|
|
|
|
/>
|
2020-08-09 01:04:17 +03:00
|
|
|
<div css={STYLES_SIDEBAR_HEADER}>
|
|
|
|
<div css={STYLES_BLOCK} onClick={this.props.onDismissSidebar}>
|
|
|
|
<SVG.Dismiss height="24px" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_SIDEBAR_CONTENT}>{this.props.sidebar}</div>
|
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
}
|
2020-04-09 00:29:13 +03:00
|
|
|
return (
|
2020-08-08 03:10:28 +03:00
|
|
|
<div css={STYLES_LAYOUT}>
|
2020-08-20 08:45:43 +03:00
|
|
|
<GlobalTooltip
|
|
|
|
elementRef={this._navigation}
|
|
|
|
allowedTypes={["navigation"]}
|
|
|
|
/>
|
2020-08-12 22:41:56 +03:00
|
|
|
<div
|
|
|
|
css={STYLES_NAVIGATION}
|
|
|
|
ref={(c) => {
|
|
|
|
this._navigation = c;
|
2020-08-20 08:45:43 +03:00
|
|
|
}}
|
|
|
|
>
|
2020-08-12 22:41:56 +03:00
|
|
|
{this.props.navigation}
|
|
|
|
</div>
|
2020-08-08 03:10:28 +03:00
|
|
|
<div css={STYLES_CONTENT}>
|
2020-08-14 11:29:29 +03:00
|
|
|
<GlobalTooltip elementRef={this._body} allowedTypes={["body"]} />
|
2020-08-08 03:10:28 +03:00
|
|
|
<div css={STYLES_HEADER}>{this.props.header}</div>
|
2020-08-12 22:41:56 +03:00
|
|
|
<div
|
|
|
|
css={STYLES_BODY_WEB}
|
|
|
|
ref={(c) => {
|
|
|
|
this._body = c;
|
2020-08-20 08:45:43 +03:00
|
|
|
}}
|
|
|
|
>
|
2020-08-12 22:41:56 +03:00
|
|
|
{this.props.children}
|
|
|
|
</div>
|
2020-08-20 08:45:43 +03:00
|
|
|
<div css={STYLES_BODY_MOBILE}>
|
|
|
|
{this.props.sidebar ? sidebarElements : this.props.children}
|
|
|
|
</div>
|
2020-08-08 03:10:28 +03:00
|
|
|
</div>
|
2020-08-12 22:41:56 +03:00
|
|
|
{this.props.sidebar ? (
|
|
|
|
<div
|
|
|
|
css={STYLES_SIDEBAR_WEB}
|
|
|
|
ref={(c) => {
|
|
|
|
this._sidebar = c;
|
2020-08-20 08:45:43 +03:00
|
|
|
}}
|
|
|
|
>
|
2020-08-12 22:41:56 +03:00
|
|
|
{sidebarElements}
|
|
|
|
</div>
|
|
|
|
) : null}
|
2020-08-08 03:10:28 +03:00
|
|
|
</div>
|
2020-04-09 00:29:13 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|