2022-07-22 19:01:25 +00:00
|
|
|
import { Base } from "@docspace/components/themes";
|
2022-04-22 16:26:49 +00:00
|
|
|
import {
|
|
|
|
isTablet,
|
|
|
|
isMobile as isMobileUtils,
|
|
|
|
tablet,
|
2022-06-02 16:34:41 +00:00
|
|
|
isDesktop,
|
2022-07-22 19:01:25 +00:00
|
|
|
} from "@docspace/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-07-22 19:01:25 +00:00
|
|
|
import CrossIcon from "@docspace/components/public/static/images/cross.react.svg";
|
2022-04-22 15:10:20 +00:00
|
|
|
|
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
|
|
|
|
2022-06-03 10:45:39 +00:00
|
|
|
@media ${tablet} {
|
|
|
|
z-index: 309;
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
}
|
|
|
|
|
2022-06-21 14:38:12 +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-06-03 10:45:39 +00:00
|
|
|
@media ${tablet} {
|
|
|
|
position: absolute;
|
|
|
|
border: none;
|
|
|
|
right: 0;
|
|
|
|
width: 480px;
|
|
|
|
max-width: calc(100vw - 69px);
|
|
|
|
}
|
|
|
|
|
2022-06-21 14:38:12 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
position: absolute;
|
|
|
|
border: none;
|
|
|
|
right: 0;
|
|
|
|
width: 480px;
|
|
|
|
max-width: calc(100vw - 69px);
|
|
|
|
`}
|
|
|
|
|
2022-04-22 16:26:49 +00:00
|
|
|
@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-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
|
|
|
|
2022-06-21 14:38:12 +00:00
|
|
|
${isMobile &&
|
|
|
|
css`
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
top: 16px;
|
|
|
|
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-06-16 16:01:30 +00:00
|
|
|
const InfoPanel = ({ children, isVisible, setIsVisible, viewAs, isFiles }) => {
|
2022-03-03 13:22:27 +00:00
|
|
|
if (!isVisible) return null;
|
|
|
|
|
|
|
|
const closeInfoPanel = () => setIsVisible(false);
|
|
|
|
|
2022-06-16 16:01:30 +00:00
|
|
|
useEffect(() => {
|
|
|
|
if (!isFiles) closeInfoPanel();
|
|
|
|
}, [isFiles]);
|
|
|
|
|
2022-03-03 13:22:27 +00:00
|
|
|
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-06-02 16:34:41 +00:00
|
|
|
if (viewAs === "row" || isTablet() || isMobile || isMobileUtils())
|
2022-04-22 16:26:49 +00:00
|
|
|
document.addEventListener("mousedown", onMouseDown);
|
2022-06-02 16:34:41 +00:00
|
|
|
|
|
|
|
window.onpopstate = () => {
|
2022-06-03 10:45:39 +00:00
|
|
|
if (!isDesktop() && isVisible) closeInfoPanel();
|
2022-06-02 16:34:41 +00:00
|
|
|
};
|
|
|
|
|
2022-03-03 13:22:27 +00:00
|
|
|
return () => document.removeEventListener("mousedown", onMouseDown);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
2022-05-18 07:39:59 +00:00
|
|
|
<StyledInfoPanelWrapper
|
|
|
|
isRowView={viewAs === "row"}
|
|
|
|
className="info-panel"
|
|
|
|
id="InfoPanelWrapper"
|
|
|
|
>
|
|
|
|
<StyledInfoPanel isRowView={viewAs === "row"}>
|
|
|
|
<StyledControlContainer
|
|
|
|
isRowView={viewAs === "row"}
|
|
|
|
onClick={closeInfoPanel}
|
|
|
|
>
|
2022-04-22 15:10:20 +00:00
|
|
|
<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-06-16 16:01:30 +00:00
|
|
|
export default inject(({ auth, filesStore }) => {
|
2022-05-30 10:46:45 +00:00
|
|
|
const { isVisible, setIsVisible } = auth.infoPanelStore;
|
2022-06-16 16:01:30 +00:00
|
|
|
const isFiles = true && filesStore;
|
|
|
|
|
2022-03-03 13:22:27 +00:00
|
|
|
return {
|
|
|
|
isVisible,
|
|
|
|
setIsVisible,
|
2022-06-16 16:01:30 +00:00
|
|
|
isFiles,
|
2022-03-03 13:22:27 +00:00
|
|
|
};
|
2022-02-11 14:35:18 +00:00
|
|
|
})(InfoPanel);
|