2019-09-12 12:15:22 +00:00
|
|
|
import React from "react";
|
2020-10-29 14:33:05 +00:00
|
|
|
import styled, { css } from "styled-components";
|
|
|
|
import PropTypes from "prop-types";
|
|
|
|
import { Resizable } from "re-resizable";
|
|
|
|
import { isMobile } from "react-device-detect";
|
2021-10-01 12:30:11 +00:00
|
|
|
import { tablet } from "@appserver/components/utils/device";
|
2019-07-20 09:48:29 +00:00
|
|
|
|
|
|
|
const StyledArticle = styled.article`
|
2019-09-04 10:29:32 +00:00
|
|
|
@media ${tablet} {
|
2020-10-16 12:38:04 +00:00
|
|
|
${(props) =>
|
2020-10-29 14:33:05 +00:00
|
|
|
props.visible &&
|
|
|
|
!props.pinned &&
|
|
|
|
css`
|
|
|
|
position: fixed;
|
|
|
|
z-index: 400;
|
|
|
|
`}
|
|
|
|
}
|
2021-09-30 07:55:26 +00:00
|
|
|
|
2020-10-29 14:33:05 +00:00
|
|
|
.resizable-block {
|
2021-06-04 11:42:21 +00:00
|
|
|
padding: 0 20px;
|
2020-10-29 14:33:05 +00:00
|
|
|
background: #f8f9f9;
|
2021-10-04 12:08:56 +00:00
|
|
|
min-width: 256px;
|
2020-10-29 14:33:05 +00:00
|
|
|
height: 100% !important;
|
2021-03-20 13:20:51 +00:00
|
|
|
max-width: ${(props) =>
|
2021-10-04 12:08:56 +00:00
|
|
|
props.firstLoad ? "256px" : "calc(100vw - 368px)"};
|
2020-10-29 14:33:05 +00:00
|
|
|
box-sizing: border-box;
|
|
|
|
overflow: hidden auto;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
.resizable-border {
|
|
|
|
div {
|
|
|
|
cursor: ew-resize !important;
|
|
|
|
}
|
|
|
|
}
|
2021-04-13 09:43:17 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
2021-10-06 09:22:28 +00:00
|
|
|
margin-top: 48px;
|
|
|
|
height: calc(100% - 48px) !important;
|
2021-04-13 09:43:17 +00:00
|
|
|
width: 240px !important;
|
|
|
|
@media ${tablet} {
|
2021-10-06 09:22:28 +00:00
|
|
|
margin-top: ${(props) => (props.pinned ? "48px;" : "0;")};
|
2021-04-13 09:43:17 +00:00
|
|
|
}
|
|
|
|
`}
|
2020-10-29 14:33:05 +00:00
|
|
|
@media ${tablet} {
|
|
|
|
padding: 0 16px;
|
|
|
|
${(props) =>
|
|
|
|
props.visible
|
|
|
|
? props.pinned
|
|
|
|
? `
|
2019-07-20 09:48:29 +00:00
|
|
|
min-width: 240px;
|
2021-08-18 12:52:27 +00:00
|
|
|
max-width: 240px;
|
2021-01-20 18:56:32 +00:00
|
|
|
|
2021-01-21 10:41:59 +00:00
|
|
|
|
2020-12-29 13:36:08 +00:00
|
|
|
.increaseHeight {
|
2020-11-15 13:56:21 +00:00
|
|
|
position: fixed;
|
|
|
|
height: 100%;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
min-width: 240px;
|
|
|
|
background: #f8f9f9;
|
2020-11-16 08:00:12 +00:00
|
|
|
z-index: -1;
|
2020-11-15 13:56:21 +00:00
|
|
|
}
|
2019-07-20 09:48:29 +00:00
|
|
|
`
|
2020-10-29 14:33:05 +00:00
|
|
|
: `
|
|
|
|
position: fixed !important;
|
2021-04-19 11:08:40 +00:00
|
|
|
width: 260px !important;
|
|
|
|
min-width: 260px;
|
|
|
|
max-width: 260px;
|
2019-07-20 09:48:29 +00:00
|
|
|
position: fixed;
|
2020-10-29 14:33:05 +00:00
|
|
|
height: 100% !important;
|
2019-07-20 09:48:29 +00:00
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
z-index: 400;
|
2020-10-29 14:33:05 +00:00
|
|
|
.resizable-border {
|
|
|
|
display: none;
|
|
|
|
}
|
2021-04-19 11:16:42 +00:00
|
|
|
|
|
|
|
.newItem {
|
|
|
|
right: -24px;
|
|
|
|
}
|
2019-07-20 09:48:29 +00:00
|
|
|
`
|
2020-10-29 14:33:05 +00:00
|
|
|
: `
|
|
|
|
display: none;
|
2019-09-12 12:15:22 +00:00
|
|
|
`}
|
2020-10-29 14:33:05 +00:00
|
|
|
}
|
2019-07-20 09:48:29 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2019-07-28 20:39:59 +00:00
|
|
|
class Article extends React.Component {
|
|
|
|
render() {
|
2020-10-29 14:33:05 +00:00
|
|
|
//console.log("PageLayout Article render", this.props);
|
|
|
|
const { children, ...rest } = this.props;
|
|
|
|
const enable = {
|
|
|
|
top: false,
|
|
|
|
right: !isMobile,
|
|
|
|
bottom: false,
|
|
|
|
left: false,
|
|
|
|
};
|
2021-01-20 18:04:00 +00:00
|
|
|
|
2020-10-29 14:33:05 +00:00
|
|
|
return (
|
|
|
|
<StyledArticle {...rest}>
|
|
|
|
<Resizable
|
|
|
|
enable={enable}
|
|
|
|
className="resizable-block"
|
2021-04-13 09:43:17 +00:00
|
|
|
handleWrapperClass="resizable-border not-selectable"
|
2020-10-29 14:33:05 +00:00
|
|
|
>
|
|
|
|
{children}
|
2020-11-15 13:56:21 +00:00
|
|
|
<div className="increaseHeight"></div>
|
2020-10-29 14:33:05 +00:00
|
|
|
</Resizable>
|
|
|
|
</StyledArticle>
|
|
|
|
);
|
2019-09-10 07:03:36 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-20 09:48:29 +00:00
|
|
|
|
2020-10-29 14:33:05 +00:00
|
|
|
Article.propTypes = {
|
|
|
|
children: PropTypes.any,
|
|
|
|
};
|
|
|
|
|
2019-09-12 12:15:22 +00:00
|
|
|
export default Article;
|