DocSpace-client/packages/asc-web-common/components/PageLayout/sub-components/catalog.js

73 lines
1.6 KiB
JavaScript
Raw Normal View History

import React from 'react';
2021-09-28 10:25:23 +00:00
import styled from 'styled-components';
import PropTypes from 'prop-types';
import { Resizable } from 're-resizable';
import { isMobile } from 'react-device-detect';
import { mobile, tablet } from '@appserver/components/utils/device';
const StyledCatalog = styled.div`
2021-09-28 10:25:23 +00:00
@media (hover: none) {
position: relative;
top: 48px;
}
.resizable-block {
display: flex;
flex-direction: column;
min-width: 256px;
width: 256px;
height: 100% !important;
background: #f8f9f9;
overflow: hidden;
.resizable-border {
div {
cursor: ew-resize !important;
}
}
@media ${tablet} {
min-width: ${(props) => (props.showText ? '240px' : '52px')};
max-width: ${(props) => (props.showText ? '240px' : '52px')};
.resizable-border {
display: none;
}
}
@media ${mobile} {
display: ${(props) => (props.showText ? 'flex' : 'none')};
min-width: 100vw;
width: 100vw;
margin: 0;
padding: 0;
}
}
`;
const Catalog = (props) => {
const { showText, children, ...rest } = props;
const enable = {
top: false,
right: !isMobile,
bottom: false,
left: false,
};
return (
<StyledCatalog showText={showText} {...rest}>
<Resizable
enable={enable}
className="resizable-block"
handleWrapperClass="resizable-border not-selectable">
{children}
</Resizable>
</StyledCatalog>
);
};
Catalog.propTypes = {
showText: PropTypes.bool,
children: PropTypes.any,
};
export default Catalog;