2019-09-12 12:15:22 +00:00
|
|
|
import React from "react";
|
2020-02-10 14:34:56 +00:00
|
|
|
import styled from "styled-components";
|
2020-11-17 08:36:49 +00:00
|
|
|
import { utils } from "asc-web-components";
|
2020-08-11 12:35:24 +00:00
|
|
|
import isEqual from "lodash/isEqual";
|
2020-10-27 08:16:59 +00:00
|
|
|
import classnames from "classnames";
|
2020-11-19 07:24:52 +00:00
|
|
|
import { LayoutContextConsumer } from "../../Layout/context";
|
2020-11-17 08:36:49 +00:00
|
|
|
|
2019-12-23 13:41:52 +00:00
|
|
|
const { tablet } = 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;
|
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-10-27 12:15:57 +00:00
|
|
|
${(props) =>
|
|
|
|
props.borderBottom &&
|
|
|
|
`
|
|
|
|
border-bottom: 1px solid #eceef1;
|
|
|
|
padding-bottom: 16px
|
|
|
|
`};
|
2020-10-26 10:53:42 +00:00
|
|
|
height: 49px;
|
2019-12-23 13:41:52 +00:00
|
|
|
}
|
2020-01-15 12:58:57 +00:00
|
|
|
|
|
|
|
.section-header {
|
|
|
|
width: calc(100% - 76px);
|
|
|
|
|
|
|
|
@media ${tablet} {
|
2020-11-09 12:42:48 +00:00
|
|
|
width: ${(props) =>
|
2020-11-17 08:36:49 +00:00
|
|
|
props.isArticlePinned ? `calc(100% - 272px)` : "100%"};
|
|
|
|
background-color: #fff;
|
|
|
|
position: fixed;
|
2020-11-19 07:24:52 +00:00
|
|
|
|
2020-11-17 08:36:49 +00:00
|
|
|
top: ${(props) => (!props.isHeaderVisible ? "56px" : "0")};
|
2020-11-19 07:24:52 +00:00
|
|
|
|
2020-11-17 08:36:49 +00:00
|
|
|
z-index: 155;
|
2020-11-11 09:09:19 +00:00
|
|
|
|
|
|
|
padding-right: 16px;
|
2020-11-10 16:45:29 +00:00
|
|
|
|
2020-10-26 10:53:42 +00:00
|
|
|
padding-top: 4px;
|
2020-01-15 12:58:57 +00:00
|
|
|
}
|
2020-01-16 09:25:28 +00:00
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
h1,
|
|
|
|
h2,
|
|
|
|
h3,
|
|
|
|
h4,
|
|
|
|
h5,
|
|
|
|
h6 {
|
2020-01-16 09:25:28 +00:00
|
|
|
max-width: calc(100vw - 435px);
|
|
|
|
|
|
|
|
@media ${tablet} {
|
2020-10-16 12:38:04 +00:00
|
|
|
max-width: ${(props) =>
|
|
|
|
props.isArticlePinned ? `calc(100vw - 320px)` : `calc(100vw - 96px)`};
|
2020-01-16 09:25:28 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-15 12:58:57 +00:00
|
|
|
}
|
2020-11-02 08:55:59 +00:00
|
|
|
|
2020-11-17 08:36:49 +00:00
|
|
|
.section-header,
|
|
|
|
.section-header--hidden {
|
|
|
|
@media ${tablet} {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-02 08:55:59 +00:00
|
|
|
.section-header--hidden {
|
|
|
|
@media ${tablet} {
|
2020-11-11 09:09:19 +00:00
|
|
|
top: -61px;
|
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) {
|
|
|
|
return !isEqual(this.props, nextProps);
|
|
|
|
}
|
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 (
|
2020-10-27 12:15:57 +00:00
|
|
|
<StyledSectionHeader
|
2020-11-17 08:36:49 +00:00
|
|
|
isHeaderVisible={isHeaderVisible}
|
2020-10-27 12:15:57 +00:00
|
|
|
isArticlePinned={isArticlePinned}
|
|
|
|
borderBottom={borderBottom}
|
|
|
|
>
|
2020-11-17 08:36:49 +00:00
|
|
|
<LayoutContextConsumer>
|
|
|
|
{(value) => (
|
|
|
|
<div
|
|
|
|
className={classnames("section-header", {
|
|
|
|
"section-header--hidden": !value.isVisible,
|
|
|
|
})}
|
|
|
|
{...rest}
|
|
|
|
/>
|
|
|
|
)}
|
2020-11-15 16:15:48 +00:00
|
|
|
</LayoutContextConsumer>
|
2020-08-11 12:35:24 +00:00
|
|
|
</StyledSectionHeader>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-07-20 09:48:29 +00:00
|
|
|
|
2019-09-12 12:15:22 +00:00
|
|
|
SectionHeader.displayName = "SectionHeader";
|
|
|
|
|
|
|
|
export default SectionHeader;
|