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-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";
|
2021-03-03 09:47:28 +00:00
|
|
|
import { LayoutContextConsumer } from "studio/Layout/context";
|
2021-01-20 18:04:00 +00:00
|
|
|
import { isMobile } from "react-device-detect";
|
2021-02-24 17:11:23 +00:00
|
|
|
import { tablet, desktop } from "@appserver/components/utils/device";
|
2021-08-23 10:50:21 +00:00
|
|
|
import NoUserSelect from "@appserver/components/utils/commonStyles";
|
2022-03-18 10:45:26 +00:00
|
|
|
import { getBannerAttribute } from "@appserver/components/utils/banner";
|
|
|
|
|
2019-07-20 09:48:29 +00:00
|
|
|
const StyledSectionHeader = styled.div`
|
2021-10-13 13:04:49 +00:00
|
|
|
height: 42px;
|
2019-12-23 13:41:52 +00:00
|
|
|
margin-right: 24px;
|
2021-08-23 10:50:21 +00:00
|
|
|
${NoUserSelect}
|
2021-05-18 14:59:34 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
2022-02-01 08:17:10 +00:00
|
|
|
height: ${(props) => (props.maintenanceExist ? "120px" : "40px")};
|
2021-05-18 14:59:34 +00:00
|
|
|
width: ${(props) => !props.isLoaded && "100%"};
|
2021-10-22 10:03:17 +00:00
|
|
|
|
|
|
|
margin-top: 62px;
|
|
|
|
@media ${tablet} {
|
2022-02-01 08:17:10 +00:00
|
|
|
margin-top: ${(props) => props.marginTop};
|
2021-10-22 10:03:17 +00:00
|
|
|
}
|
2021-05-18 14:59:34 +00:00
|
|
|
`}
|
2019-12-23 13:41:52 +00:00
|
|
|
|
2021-10-20 12:52:02 +00:00
|
|
|
@media ${desktop} {
|
|
|
|
${(props) =>
|
|
|
|
(props.viewAs === "table" || props.viewAs === "tile") &&
|
|
|
|
"margin-left: -4px"};
|
|
|
|
}
|
|
|
|
|
2021-10-06 12:44:39 +00:00
|
|
|
@media ${tablet} {
|
|
|
|
${(props) =>
|
|
|
|
props.viewAs !== "tablet" &&
|
|
|
|
css`
|
|
|
|
.arrow-button {
|
|
|
|
svg {
|
2022-02-17 10:06:42 +00:00
|
|
|
width: 14px;
|
2021-10-06 12:44:39 +00:00
|
|
|
}
|
2022-02-17 10:06:42 +00:00
|
|
|
margin-right: 10px;
|
2021-10-06 12:44:39 +00:00
|
|
|
}
|
|
|
|
`}
|
|
|
|
}
|
2021-10-01 13:51:28 +00:00
|
|
|
|
2019-12-23 13:41:52 +00:00
|
|
|
@media ${tablet} {
|
|
|
|
margin-right: 16px;
|
|
|
|
}
|
2020-01-15 12:58:57 +00:00
|
|
|
|
|
|
|
.section-header {
|
2021-10-13 13:04:49 +00:00
|
|
|
height: 50px;
|
2021-05-18 14:59:34 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
max-width: calc(100vw - 32px);
|
|
|
|
width: 100%;
|
|
|
|
`}
|
2021-01-20 18:04:00 +00:00
|
|
|
|
2021-10-01 13:51:28 +00:00
|
|
|
${isMobile &&
|
2021-05-18 14:59:34 +00:00
|
|
|
css`
|
|
|
|
position: fixed;
|
2022-02-01 08:17:10 +00:00
|
|
|
top: ${(props) => props.top};
|
2021-01-26 13:25:53 +00:00
|
|
|
|
2021-05-18 14:59:34 +00:00
|
|
|
width: ${(props) =>
|
|
|
|
props.isArticlePinned ? `calc(100% - 272px)` : "100%"};
|
2021-01-26 13:25:53 +00:00
|
|
|
|
2021-05-18 14:59:34 +00:00
|
|
|
background-color: #fff;
|
|
|
|
z-index: 149;
|
|
|
|
padding-right: 16px;
|
|
|
|
`}
|
2021-03-22 15:11:39 +00:00
|
|
|
}
|
2021-05-18 14:59:34 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
.section-header,
|
|
|
|
.section-header--hidden {
|
|
|
|
&,
|
|
|
|
.group-button-menu-container > div:first-child {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
.group-button-menu-container {
|
2022-02-17 10:06:42 +00:00
|
|
|
padding-bottom: 0;
|
2021-05-18 14:59:34 +00:00
|
|
|
> div:first-child {
|
2022-02-17 10:06:42 +00:00
|
|
|
top: ${(props) => (!props.isSectionHeaderVisible ? "56px" : "0px")};
|
2020-11-17 08:36:49 +00:00
|
|
|
|
2021-05-18 14:59:34 +00:00
|
|
|
@media ${desktop} {
|
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
position: absolute;
|
|
|
|
`}
|
2021-01-21 11:19:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-22 15:11:39 +00:00
|
|
|
}
|
2021-05-18 14:59:34 +00:00
|
|
|
`}
|
|
|
|
.section-header--hidden {
|
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
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
|
|
|
|
2022-03-14 10:43:05 +00:00
|
|
|
this.state = { orientationChanged: false };
|
2020-10-26 07:31:04 +00:00
|
|
|
}
|
|
|
|
|
2022-03-14 10:43:05 +00:00
|
|
|
componentDidMount() {
|
|
|
|
window.addEventListener("orientationchange", this.orientationChangeHandler);
|
2020-08-11 12:35:24 +00:00
|
|
|
}
|
|
|
|
|
2022-03-14 10:43:05 +00:00
|
|
|
orientationChangeHandler = () => {
|
|
|
|
this.setState((state) => ({
|
|
|
|
orientationChanged: !state.orientationChanged,
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2022-02-01 08:17:10 +00:00
|
|
|
const {
|
|
|
|
isArticlePinned,
|
|
|
|
isHeaderVisible,
|
|
|
|
viewAs,
|
|
|
|
maintenanceExist,
|
2022-02-28 13:16:35 +00:00
|
|
|
snackbarExist,
|
2022-02-01 08:17:10 +00:00
|
|
|
...rest
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
let top = "48px";
|
2022-02-28 13:16:35 +00:00
|
|
|
let marginTop = "52px";
|
|
|
|
|
|
|
|
const mainBar = document.getElementById("main-bar");
|
2022-02-01 08:17:10 +00:00
|
|
|
|
|
|
|
if (maintenanceExist) {
|
2022-03-18 10:45:26 +00:00
|
|
|
const { sectionHeaderTop, sectionHeaderMarginTop } = getBannerAttribute();
|
2022-02-01 08:17:10 +00:00
|
|
|
|
2022-03-18 10:45:26 +00:00
|
|
|
top = sectionHeaderTop;
|
|
|
|
marginTop = sectionHeaderMarginTop;
|
2022-02-01 08:17:10 +00:00
|
|
|
}
|
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
|
|
|
|
isArticlePinned={isArticlePinned}
|
|
|
|
isSectionHeaderVisible={value.isVisible}
|
2021-10-06 12:44:39 +00:00
|
|
|
viewAs={viewAs}
|
2022-02-28 13:16:35 +00:00
|
|
|
maintenanceExist={maintenanceExist && mainBar}
|
2022-02-01 08:17:10 +00:00
|
|
|
top={top}
|
|
|
|
marginTop={marginTop}
|
2021-01-14 11:16:09 +00:00
|
|
|
>
|
2020-11-17 08:36:49 +00:00
|
|
|
<div
|
2021-01-26 15:21:50 +00:00
|
|
|
className={classnames("section-header hidingHeader", {
|
2021-05-18 14:59:34 +00:00
|
|
|
"section-header--hidden":
|
|
|
|
value.isVisible === undefined ? false : !value.isVisible,
|
2021-01-26 15:21:50 +00:00
|
|
|
})}
|
2020-11-17 08:36:49 +00:00
|
|
|
{...rest}
|
|
|
|
/>
|
2021-02-24 17:11:23 +00:00
|
|
|
</StyledSectionHeader>
|
2021-01-14 11:16:09 +00:00
|
|
|
)}
|
|
|
|
</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 15:21:50 +00:00
|
|
|
SectionHeader.propTypes = {
|
|
|
|
isArticlePinned: PropTypes.bool,
|
|
|
|
isHeaderVisible: PropTypes.bool,
|
|
|
|
};
|
2019-09-12 12:15:22 +00:00
|
|
|
export default SectionHeader;
|