2019-09-12 12:15:22 +00:00
|
|
|
import React from "react";
|
2020-11-19 13:34:34 +00:00
|
|
|
import styled, { css } from "styled-components";
|
2020-11-17 08:36:49 +00:00
|
|
|
import { utils } from "asc-web-components";
|
2020-12-08 11:09:46 +00:00
|
|
|
import equal from "fast-deep-equal/react";
|
2020-10-27 08:16:59 +00:00
|
|
|
import classnames from "classnames";
|
2020-11-19 14:53:12 +00:00
|
|
|
import PropTypes from "prop-types";
|
2020-11-19 07:24:52 +00:00
|
|
|
import { LayoutContextConsumer } from "../../Layout/context";
|
2021-01-20 18:04:00 +00:00
|
|
|
import { isMobile } from "react-device-detect";
|
2020-11-19 14:53:12 +00:00
|
|
|
|
2021-01-21 11:19:15 +00:00
|
|
|
const { tablet, desktop } = utils.device;
|
2019-07-20 09:48:29 +00:00
|
|
|
|
|
|
|
const StyledSectionHeader = styled.div`
|
2019-09-12 12:15:22 +00:00
|
|
|
border-bottom: 1px solid #eceef1;
|
2020-10-26 10:53:42 +00:00
|
|
|
height: 55px;
|
2019-12-23 13:41:52 +00:00
|
|
|
margin-right: 24px;
|
2020-11-06 13:15:03 +00:00
|
|
|
margin-top: -1px;
|
2021-01-26 13:25:53 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
//position: absolute;
|
|
|
|
//top: 56px;
|
|
|
|
|
|
|
|
height: 49px;
|
|
|
|
min-height: 48px;
|
|
|
|
max-height: 49px;
|
|
|
|
width: ${(props) => !props.isLoaded && "100%"};
|
|
|
|
margin-top: 64px;
|
|
|
|
@media ${tablet} {
|
|
|
|
margin-top: 55px;
|
|
|
|
}
|
|
|
|
`}
|
2019-12-23 13:41:52 +00:00
|
|
|
|
|
|
|
@media ${tablet} {
|
|
|
|
margin-right: 16px;
|
2020-08-18 14:02:20 +00:00
|
|
|
border-bottom: none;
|
2020-11-26 13:24:57 +00:00
|
|
|
|
2020-10-27 12:15:57 +00:00
|
|
|
${(props) =>
|
|
|
|
props.borderBottom &&
|
|
|
|
`
|
|
|
|
border-bottom: 1px solid #eceef1;
|
|
|
|
padding-bottom: 16px
|
|
|
|
`};
|
2019-12-23 13:41:52 +00:00
|
|
|
}
|
2020-01-15 12:58:57 +00:00
|
|
|
|
|
|
|
.section-header {
|
2021-01-20 18:04:00 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
2020-11-25 10:30:12 +00:00
|
|
|
max-width: calc(100vw - 32px);
|
2020-11-27 15:47:44 +00:00
|
|
|
width: 100%;
|
2021-01-20 18:04:00 +00:00
|
|
|
`}
|
|
|
|
|
|
|
|
//padding-top: 4px;
|
2021-01-26 13:25:53 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
position: fixed;
|
|
|
|
top: 56px;
|
|
|
|
|
|
|
|
width: ${(props) =>
|
|
|
|
props.isArticlePinned ? `calc(100% - 272px)` : "100%"};
|
|
|
|
/* ${(props) =>
|
|
|
|
props.sectionWidth &&
|
|
|
|
props.isArticlePinned &&
|
|
|
|
css`
|
|
|
|
max-width: ${props.sectionWidth + "px"};
|
|
|
|
`} */
|
|
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
z-index: ${(props) => (!props.isHeaderVisible ? "149" : "190")};
|
|
|
|
padding-right: 16px;
|
|
|
|
`}
|
2020-01-15 12:58:57 +00:00
|
|
|
}
|
2021-01-21 11:19:15 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
.section-header,
|
|
|
|
.section-header--hidden {
|
2021-01-15 07:04:24 +00:00
|
|
|
&,
|
|
|
|
.group-button-menu-container > div:first-child {
|
2021-01-14 11:16:09 +00:00
|
|
|
transition: top 0.3s cubic-bezier(0, 0, 0.8, 1);
|
|
|
|
-moz-transition: top 0.3s cubic-bezier(0, 0, 0.8, 1);
|
|
|
|
-ms-transition: top 0.3s cubic-bezier(0, 0, 0.8, 1);
|
|
|
|
-webkit-transition: top 0.3s cubic-bezier(0, 0, 0.8, 1);
|
|
|
|
-o-transition: top 0.3s cubic-bezier(0, 0, 0.8, 1);
|
|
|
|
}
|
2021-01-21 11:19:15 +00:00
|
|
|
.group-button-menu-container {
|
|
|
|
padding-bottom: 0 !important;
|
|
|
|
> div:first-child {
|
|
|
|
top: ${(props) =>
|
|
|
|
!props.isSectionHeaderVisible ? "56px" : "0px"} !important;
|
2020-11-17 08:36:49 +00:00
|
|
|
|
2021-01-21 11:19:15 +00:00
|
|
|
@media ${desktop} {
|
|
|
|
${isMobile &&
|
|
|
|
css`
|
2021-01-21 15:43:48 +00:00
|
|
|
position: absolute;
|
2021-01-21 11:19:15 +00:00
|
|
|
`}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`}
|
2020-11-02 08:55:59 +00:00
|
|
|
.section-header--hidden {
|
2021-01-20 18:04:00 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
2020-11-11 09:09:19 +00:00
|
|
|
top: -61px;
|
2021-01-20 18:04:00 +00:00
|
|
|
`}
|
2020-11-02 08:55:59 +00:00
|
|
|
}
|
2019-07-20 09:48:29 +00:00
|
|
|
`;
|
|
|
|
|
2020-08-11 12:35:24 +00:00
|
|
|
class SectionHeader extends React.Component {
|
2020-10-26 07:31:04 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2020-11-17 08:36:49 +00:00
|
|
|
|
2020-10-26 07:31:04 +00:00
|
|
|
this.focusRef = React.createRef();
|
|
|
|
}
|
|
|
|
|
2020-08-11 12:35:24 +00:00
|
|
|
shouldComponentUpdate(nextProps) {
|
2020-12-08 11:09:46 +00:00
|
|
|
return !equal(this.props, nextProps);
|
2020-08-11 12:35:24 +00:00
|
|
|
}
|
2020-10-27 08:16:59 +00:00
|
|
|
|
2020-08-11 12:35:24 +00:00
|
|
|
render() {
|
|
|
|
//console.log("PageLayout SectionHeader render");
|
|
|
|
// eslint-disable-next-line react/prop-types
|
2020-11-11 07:13:03 +00:00
|
|
|
|
2020-11-17 08:36:49 +00:00
|
|
|
const {
|
|
|
|
isArticlePinned,
|
|
|
|
borderBottom,
|
|
|
|
isHeaderVisible,
|
|
|
|
...rest
|
|
|
|
} = this.props;
|
2020-10-27 12:15:57 +00:00
|
|
|
|
2020-08-11 12:35:24 +00:00
|
|
|
return (
|
2021-01-14 11:16:09 +00:00
|
|
|
<LayoutContextConsumer>
|
|
|
|
{(value) => (
|
|
|
|
<StyledSectionHeader
|
|
|
|
isHeaderVisible={isHeaderVisible}
|
|
|
|
isArticlePinned={isArticlePinned}
|
|
|
|
borderBottom={borderBottom}
|
|
|
|
isSectionHeaderVisible={value.isVisible}
|
|
|
|
>
|
2020-11-17 08:36:49 +00:00
|
|
|
<div
|
2020-12-24 15:02:49 +00:00
|
|
|
className={classnames(
|
|
|
|
"section-header needToCancelAnimationWithTransition",
|
|
|
|
{
|
|
|
|
"section-header--hidden": !value.isVisible,
|
|
|
|
}
|
|
|
|
)}
|
2020-11-17 08:36:49 +00:00
|
|
|
{...rest}
|
|
|
|
/>
|
2021-01-14 11:16:09 +00:00
|
|
|
</StyledSectionHeader>
|
|
|
|
)}
|
|
|
|
</LayoutContextConsumer>
|
2020-08-11 12:35:24 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-07-20 09:48:29 +00:00
|
|
|
|
2019-09-12 12:15:22 +00:00
|
|
|
SectionHeader.displayName = "SectionHeader";
|
2021-01-26 13:25:53 +00:00
|
|
|
|
|
|
|
export default SectionHeader;
|