2022-03-29 10:59:56 +00:00
|
|
|
import { Base } from "@appserver/components/themes";
|
2022-04-22 16:26:49 +00:00
|
|
|
import {
|
|
|
|
isTablet,
|
|
|
|
isMobile as isMobileUtils,
|
|
|
|
tablet,
|
|
|
|
} from "@appserver/components/utils/device";
|
2022-02-10 13:18:16 +00:00
|
|
|
import { inject } from "mobx-react";
|
2022-02-11 14:35:18 +00:00
|
|
|
import PropTypes from "prop-types";
|
2022-02-21 12:45:47 +00:00
|
|
|
import React, { useEffect } from "react";
|
2022-04-22 16:26:49 +00:00
|
|
|
import styled, { css } from "styled-components";
|
2022-04-22 15:10:20 +00:00
|
|
|
import CrossIcon from "@appserver/components/public/static/images/cross.react.svg";
|
|
|
|
|
2022-04-22 16:26:49 +00:00
|
|
|
import { isMobile } from "react-device-detect";
|
2022-02-09 09:13:16 +00:00
|
|
|
|
2022-03-30 17:48:54 +00:00
|
|
|
const StyledInfoPanelWrapper = styled.div.attrs(({ id }) => ({
|
|
|
|
id: id,
|
2022-02-21 12:45:47 +00:00
|
|
|
}))`
|
2022-04-27 12:39:20 +00:00
|
|
|
user-select: none;
|
2022-03-03 13:22:27 +00:00
|
|
|
height: auto;
|
|
|
|
width: auto;
|
2022-05-13 13:11:17 +00:00
|
|
|
background: ${(props) => props.theme.infoPanel.blurColor};
|
2022-05-04 14:37:54 +00:00
|
|
|
backdrop-filter: blur(3px);
|
2022-03-03 13:22:27 +00:00
|
|
|
|
|
|
|
@media ${tablet} {
|
2022-03-29 11:32:50 +00:00
|
|
|
z-index: 309;
|
2022-04-22 16:26:49 +00:00
|
|
|
position: fixed;
|
2022-03-03 13:22:27 +00:00
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
}
|
2022-04-22 16:26:49 +00:00
|
|
|
|
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
z-index: 309;
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
`}
|
2022-02-21 12:45:47 +00:00
|
|
|
`;
|
2022-02-10 13:18:16 +00:00
|
|
|
|
2022-02-21 12:45:47 +00:00
|
|
|
const StyledInfoPanel = styled.div`
|
2022-03-03 13:22:27 +00:00
|
|
|
height: 100%;
|
2022-03-25 15:58:07 +00:00
|
|
|
width: 400px;
|
2022-03-29 10:59:56 +00:00
|
|
|
background-color: ${(props) => props.theme.infoPanel.backgroundColor};
|
|
|
|
border-left: ${(props) => `1px solid ${props.theme.infoPanel.borderColor}`};
|
2022-03-03 13:22:27 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
|
2022-04-22 16:31:28 +00:00
|
|
|
.scroll-body {
|
|
|
|
padding-bottom: 20px;
|
|
|
|
}
|
|
|
|
|
2022-03-03 13:22:27 +00:00
|
|
|
@media ${tablet} {
|
|
|
|
position: absolute;
|
|
|
|
border: none;
|
|
|
|
right: 0;
|
2022-03-25 15:58:07 +00:00
|
|
|
width: 480px;
|
2022-03-03 13:22:27 +00:00
|
|
|
max-width: calc(100vw - 69px);
|
|
|
|
}
|
|
|
|
|
2022-04-22 16:26:49 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
position: absolute;
|
|
|
|
border: none;
|
|
|
|
right: 0;
|
|
|
|
width: 480px;
|
|
|
|
max-width: calc(100vw - 69px);
|
|
|
|
`}
|
|
|
|
|
|
|
|
@media (max-width: 428px) {
|
2022-03-03 13:22:27 +00:00
|
|
|
bottom: 0;
|
2022-04-22 16:26:49 +00:00
|
|
|
height: calc(100% - 64px);
|
2022-03-03 13:22:27 +00:00
|
|
|
width: 100vw;
|
|
|
|
max-width: 100vw;
|
|
|
|
}
|
2022-02-21 12:45:47 +00:00
|
|
|
`;
|
2022-02-10 13:18:16 +00:00
|
|
|
|
2022-04-22 15:10:20 +00:00
|
|
|
const StyledControlContainer = styled.div`
|
2022-03-03 13:22:27 +00:00
|
|
|
display: none;
|
2022-04-22 15:10:20 +00:00
|
|
|
|
|
|
|
width: 24px;
|
|
|
|
height: 24px;
|
|
|
|
position: absolute;
|
|
|
|
|
|
|
|
border-radius: 100px;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
z-index: 450;
|
2022-04-29 12:57:43 +00:00
|
|
|
/* background: ${(props) => props.theme.catalog.control.background}; */
|
2022-03-30 18:59:00 +00:00
|
|
|
|
2022-03-03 13:22:27 +00:00
|
|
|
@media ${tablet} {
|
2022-04-22 15:10:20 +00:00
|
|
|
display: flex;
|
|
|
|
|
2022-04-29 12:57:43 +00:00
|
|
|
top: 16px;
|
2022-04-22 15:10:20 +00:00
|
|
|
left: -34px;
|
2022-03-03 13:22:27 +00:00
|
|
|
}
|
2022-04-22 15:10:20 +00:00
|
|
|
|
|
|
|
${isMobile &&
|
|
|
|
css`
|
2022-04-22 16:26:49 +00:00
|
|
|
display: flex !important;
|
2022-04-22 15:10:20 +00:00
|
|
|
|
|
|
|
top: 18px;
|
|
|
|
left: -34px;
|
|
|
|
`}
|
|
|
|
|
2022-04-22 16:26:49 +00:00
|
|
|
@media (max-width: 428px) {
|
2022-04-22 15:10:20 +00:00
|
|
|
display: flex;
|
|
|
|
|
2022-04-22 16:26:49 +00:00
|
|
|
top: -34px;
|
2022-04-22 15:10:20 +00:00
|
|
|
right: 10px;
|
2022-04-22 16:26:49 +00:00
|
|
|
left: unset;
|
2022-03-03 13:22:27 +00:00
|
|
|
}
|
2022-02-21 12:45:47 +00:00
|
|
|
`;
|
2022-02-10 13:18:16 +00:00
|
|
|
|
2022-04-22 15:10:20 +00:00
|
|
|
StyledControlContainer.defaultProps = { theme: Base };
|
|
|
|
|
|
|
|
const StyledCrossIcon = styled(CrossIcon)`
|
2022-04-29 12:57:43 +00:00
|
|
|
width: 17px;
|
|
|
|
height: 17px;
|
2022-04-22 15:10:20 +00:00
|
|
|
z-index: 455;
|
|
|
|
path {
|
|
|
|
fill: ${(props) => props.theme.catalog.control.fill};
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
StyledCrossIcon.defaultProps = { theme: Base };
|
|
|
|
|
2022-03-28 09:44:35 +00:00
|
|
|
const InfoPanel = ({ children, isVisible, setIsVisible }) => {
|
2022-03-03 13:22:27 +00:00
|
|
|
if (!isVisible) return null;
|
|
|
|
|
|
|
|
const closeInfoPanel = () => setIsVisible(false);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const onMouseDown = (e) => {
|
2022-03-30 17:48:54 +00:00
|
|
|
if (e.target.id === "InfoPanelWrapper") closeInfoPanel();
|
2022-03-03 13:22:27 +00:00
|
|
|
};
|
|
|
|
|
2022-04-22 16:26:49 +00:00
|
|
|
if (isTablet() || isMobile || isMobileUtils()) {
|
|
|
|
document.addEventListener("mousedown", onMouseDown);
|
|
|
|
}
|
2022-03-03 13:22:27 +00:00
|
|
|
return () => document.removeEventListener("mousedown", onMouseDown);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
2022-03-30 17:48:54 +00:00
|
|
|
<StyledInfoPanelWrapper className="info-panel" id="InfoPanelWrapper">
|
2022-03-03 13:22:27 +00:00
|
|
|
<StyledInfoPanel>
|
2022-04-22 15:10:20 +00:00
|
|
|
<StyledControlContainer onClick={closeInfoPanel}>
|
|
|
|
<StyledCrossIcon />
|
|
|
|
</StyledControlContainer>
|
|
|
|
|
2022-03-03 13:22:27 +00:00
|
|
|
{children}
|
|
|
|
</StyledInfoPanel>
|
|
|
|
</StyledInfoPanelWrapper>
|
|
|
|
);
|
2022-02-09 09:13:16 +00:00
|
|
|
};
|
|
|
|
|
2022-02-11 14:35:18 +00:00
|
|
|
InfoPanel.propTypes = {
|
2022-03-03 13:22:27 +00:00
|
|
|
children: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(PropTypes.node),
|
|
|
|
PropTypes.node,
|
|
|
|
PropTypes.any,
|
|
|
|
]),
|
|
|
|
isVisible: PropTypes.bool,
|
2022-02-10 15:52:27 +00:00
|
|
|
};
|
|
|
|
|
2022-03-29 10:59:56 +00:00
|
|
|
StyledInfoPanelWrapper.defaultProps = { theme: Base };
|
|
|
|
StyledInfoPanel.defaultProps = { theme: Base };
|
|
|
|
InfoPanel.defaultProps = { theme: Base };
|
|
|
|
|
2022-03-28 09:44:35 +00:00
|
|
|
export default inject(({ infoPanelStore }) => {
|
2022-03-03 13:22:27 +00:00
|
|
|
let isVisible = false;
|
|
|
|
let setIsVisible = () => {};
|
|
|
|
|
|
|
|
if (infoPanelStore) {
|
|
|
|
isVisible = infoPanelStore.isVisible;
|
|
|
|
setIsVisible = infoPanelStore.setIsVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
isVisible,
|
|
|
|
setIsVisible,
|
|
|
|
};
|
2022-02-11 14:35:18 +00:00
|
|
|
})(InfoPanel);
|