DocSpace-client/web/ASC.Web.Common/src/components/PageLayout/sub-components/article.js

112 lines
2.4 KiB
JavaScript
Raw Normal View History

import React from "react";
import styled, { css } from "styled-components";
import PropTypes from "prop-types";
2020-11-09 12:42:48 +00:00
import { utils} from "asc-web-components";
import { Resizable } from "re-resizable";
import { isMobile } from "react-device-detect";
2020-11-09 12:42:48 +00:00
const { tablet } = utils.device;
const StyledArticle = styled.article`
2020-11-09 12:42:48 +00:00
@media ${tablet} {
${(props) =>
props.visible &&
!props.pinned &&
css`
position: fixed;
z-index: 400;
`}
}
.resizable-block {
padding: 0 24px;
background: #f8f9f9;
min-width: 265px;
height: 100% !important;
max-width: ${(props) => (props.isLoaded ? "calc(100vw - 368px)" : "265px")};
box-sizing: border-box;
overflow: hidden auto;
display: flex;
flex-direction: column;
.resizable-border {
div {
cursor: ew-resize !important;
}
}
@media ${tablet} {
padding: 0 16px;
${(props) =>
props.visible
? props.pinned
? `
min-width: 240px;
2020-11-09 17:57:13 +00:00
margin-top: 56px;
height: calc(100% - 56px)!important;
.increaseHeight {
position: fixed;
height: 100%;
top: 0;
left: 0;
min-width: 240px;
background: #f8f9f9;
z-index: -1;
}
`
: `
position: fixed !important;
width: 240px !important;
min-width: 240px;
max-width: 240px;
position: fixed;
height: 100% !important;
top: 0;
left: 0;
z-index: 400;
.resizable-border {
display: none;
}
`
: `
display: none;
`}
2020-11-09 12:42:48 +00:00
}
2020-11-09 12:42:48 +00:00
}
`;
class Article extends React.Component {
render() {
//console.log("PageLayout Article render", this.props);
const { children, ...rest } = this.props;
const enable = {
top: false,
right: !isMobile,
bottom: false,
left: false,
};
return (
2020-11-09 12:42:48 +00:00
<StyledArticle {...rest} >
<Resizable
enable={enable}
className="resizable-block"
handleWrapperClass="resizable-border"
2020-11-09 12:42:48 +00:00
>
{children}
<div className="increaseHeight"></div>
</Resizable>
</StyledArticle>
2020-11-09 12:42:48 +00:00
);
}
}
Article.propTypes = {
children: PropTypes.any,
};
export default Article;