2019-08-07 10:57:54 +00:00
|
|
|
import React from "react";
|
|
|
|
import PropTypes from "prop-types";
|
|
|
|
import styled from "styled-components";
|
2019-12-20 11:35:53 +00:00
|
|
|
import { utils, Scrollbar } from "asc-web-components";
|
|
|
|
const { tablet } = utils.device;
|
2019-07-20 09:48:29 +00:00
|
|
|
|
|
|
|
const StyledSectionBody = styled.div`
|
|
|
|
margin: 16px 0;
|
2019-07-29 12:51:56 +00:00
|
|
|
${props => props.displayBorder && `outline: 1px dotted;`}
|
2019-07-20 09:48:29 +00:00
|
|
|
flex-grow: 1;
|
2019-09-10 12:41:52 +00:00
|
|
|
height: 100%;
|
2019-07-20 09:48:29 +00:00
|
|
|
`;
|
|
|
|
|
2019-11-14 12:13:54 +00:00
|
|
|
const StyledSpacer = styled.div`
|
|
|
|
display: none;
|
|
|
|
min-height: 64px;
|
|
|
|
|
|
|
|
@media ${tablet} {
|
|
|
|
display: ${props => (props.pinned ? "none" : "block")};
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2019-08-07 10:57:54 +00:00
|
|
|
const SectionBody = React.memo(props => {
|
2019-08-13 11:21:28 +00:00
|
|
|
//console.log("PageLayout SectionBody render");
|
2019-11-14 12:13:54 +00:00
|
|
|
const { children, withScroll, pinned } = props;
|
2019-07-20 09:48:29 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<StyledSectionBody>
|
2019-09-12 12:15:22 +00:00
|
|
|
{withScroll ? (
|
2019-11-14 12:13:54 +00:00
|
|
|
<Scrollbar stype="mediumBlack">
|
|
|
|
{children}
|
|
|
|
<StyledSpacer pinned={pinned}/>
|
|
|
|
</Scrollbar>
|
2019-09-12 12:15:22 +00:00
|
|
|
) : (
|
2019-11-14 12:13:54 +00:00
|
|
|
<>
|
|
|
|
{children}
|
|
|
|
<StyledSpacer pinned={pinned}/>
|
|
|
|
</>
|
2019-09-12 12:15:22 +00:00
|
|
|
)}
|
2019-07-20 09:48:29 +00:00
|
|
|
</StyledSectionBody>
|
|
|
|
);
|
2019-07-28 20:39:59 +00:00
|
|
|
});
|
2019-07-20 09:48:29 +00:00
|
|
|
|
2019-09-10 12:41:52 +00:00
|
|
|
SectionBody.displayName = "SectionBody";
|
|
|
|
|
2019-08-07 10:57:54 +00:00
|
|
|
SectionBody.propTypes = {
|
2019-09-10 12:41:52 +00:00
|
|
|
withScroll: PropTypes.bool,
|
2019-11-14 12:13:54 +00:00
|
|
|
pinned: PropTypes.bool,
|
2019-09-10 12:41:52 +00:00
|
|
|
children: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(PropTypes.node),
|
2019-09-12 12:15:22 +00:00
|
|
|
PropTypes.node,
|
|
|
|
PropTypes.any
|
2019-09-10 12:41:52 +00:00
|
|
|
])
|
2019-08-07 10:57:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SectionBody.defaultProps = {
|
2019-11-14 12:13:54 +00:00
|
|
|
withScroll: true,
|
|
|
|
pinned: false
|
2019-08-07 10:57:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default SectionBody;
|