2019-09-12 12:15:22 +00:00
|
|
|
import React from "react";
|
|
|
|
import PropTypes from "prop-types";
|
|
|
|
import styled from "styled-components";
|
2019-12-20 11:35:53 +00:00
|
|
|
import Scrollbar from "../scrollbar";
|
2019-07-10 09:49:14 +00:00
|
|
|
|
2019-09-27 12:27:16 +00:00
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
/* eslint-disable react/prop-types */
|
2020-10-16 13:16:01 +00:00
|
|
|
const Container = ({ visible, scale, zIndex, ...props }) => (
|
|
|
|
<aside {...props} />
|
|
|
|
);
|
2019-09-27 12:27:16 +00:00
|
|
|
/* eslint-enable react/prop-types */
|
|
|
|
/* eslint-enable no-unused-vars */
|
|
|
|
|
|
|
|
const StyledAside = styled(Container)`
|
2019-07-10 09:49:14 +00:00
|
|
|
background-color: #fff;
|
|
|
|
height: 100%;
|
|
|
|
overflow-x: hidden;
|
|
|
|
overflow-y: auto;
|
|
|
|
position: fixed;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
2020-10-16 13:16:01 +00:00
|
|
|
transform: translateX(
|
2020-11-11 12:42:45 +00:00
|
|
|
${(props) => (props.visible ? "0" : props.scale ? "100%" : "325px")}
|
2020-10-16 13:16:01 +00:00
|
|
|
);
|
2019-09-12 12:15:22 +00:00
|
|
|
transition: transform 0.3s ease-in-out;
|
2020-10-29 08:10:40 +00:00
|
|
|
width: ${(props) => (props.scale ? "100%" : "325px")};
|
2020-10-16 13:16:01 +00:00
|
|
|
z-index: ${(props) => props.zIndex};
|
2019-12-20 15:40:43 +00:00
|
|
|
box-sizing: border-box;
|
2019-11-11 12:00:18 +00:00
|
|
|
|
|
|
|
&.modal-dialog-aside {
|
|
|
|
padding-bottom: 64px;
|
|
|
|
|
|
|
|
.modal-dialog-aside-footer {
|
|
|
|
position: fixed;
|
2019-12-20 15:40:43 +00:00
|
|
|
bottom: 16px;
|
2019-11-11 12:00:18 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-10 09:49:14 +00:00
|
|
|
`;
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
const Aside = React.memo((props) => {
|
2019-08-13 11:21:28 +00:00
|
|
|
//console.log("Aside render");
|
2020-10-16 13:16:01 +00:00
|
|
|
const { visible, children, scale, zIndex, className } = props;
|
2019-07-16 10:44:17 +00:00
|
|
|
|
|
|
|
return (
|
2020-10-16 13:16:01 +00:00
|
|
|
<StyledAside
|
|
|
|
visible={visible}
|
|
|
|
scale={scale}
|
|
|
|
zIndex={zIndex}
|
|
|
|
className={className}
|
|
|
|
>
|
2019-09-12 12:15:22 +00:00
|
|
|
<Scrollbar>{children}</Scrollbar>
|
2019-07-16 10:44:17 +00:00
|
|
|
</StyledAside>
|
|
|
|
);
|
2019-07-28 20:39:59 +00:00
|
|
|
});
|
2019-07-10 09:49:14 +00:00
|
|
|
|
2019-09-12 12:15:22 +00:00
|
|
|
Aside.displayName = "Aside";
|
|
|
|
|
|
|
|
Aside.propTypes = {
|
|
|
|
visible: PropTypes.bool,
|
2019-09-26 13:09:50 +00:00
|
|
|
scale: PropTypes.bool,
|
|
|
|
className: PropTypes.string,
|
2019-10-03 07:17:51 +00:00
|
|
|
zIndex: PropTypes.number,
|
2019-09-12 12:15:22 +00:00
|
|
|
children: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(PropTypes.node),
|
2020-10-16 13:16:01 +00:00
|
|
|
PropTypes.node,
|
|
|
|
]),
|
2019-09-12 12:15:22 +00:00
|
|
|
};
|
2019-09-26 13:09:50 +00:00
|
|
|
Aside.defaultProps = {
|
|
|
|
scale: false,
|
2020-10-16 13:16:01 +00:00
|
|
|
zIndex: 400,
|
2019-09-26 13:09:50 +00:00
|
|
|
};
|
2019-09-12 12:15:22 +00:00
|
|
|
|
|
|
|
export default Aside;
|