DocSpace-client/packages/components/aside/styled-aside.js

172 lines
3.9 KiB
JavaScript

import React from "react";
import styled, { css } from "styled-components";
import Base from "../themes/base";
import CrossReactSvg from "PUBLIC_DIR/images/cross.react.svg";
import { tablet, mobile, mobileFooterHeight } from "../utils/device";
/* eslint-disable no-unused-vars */
/* eslint-disable react/prop-types */
const Container = ({
visible,
scale,
zIndex,
contentPaddingBottom,
...props
}) => <aside {...props} />;
/* eslint-enable react/prop-types */
/* eslint-enable no-unused-vars */
const StyledAside = styled(Container)`
background-color: ${(props) => props.theme.aside.backgroundColor};
height: ${({ asideHeight, theme }) =>
asideHeight ? asideHeight : theme.aside.height};
margin-bottom: ${({ keyboardHeight }) =>
keyboardHeight ? `${keyboardHeight}px` : 0};
position: fixed;
top: ${(props) => props.theme.aside.top};
${(props) =>
props.theme.interfaceDirection === "rtl"
? css`
left: ${(props) => props.theme.aside.right};
transform: translateX(
${props.visible ? "0" : props.scale ? "-100%" : "-480px"}
);
`
: css`
right: ${(props) => props.theme.aside.right};
transform: translateX(
${props.visible ? "0" : props.scale ? "100%" : "480px"}
);
`}
transition: ${(props) => props.theme.aside.transition};
width: ${(props) => (props.scale ? "100%" : "480px")};
z-index: ${(props) => props.zIndex};
box-sizing: border-box;
@media ${tablet} {
max-width: calc(100% - 69px);
${(props) =>
props.theme.interfaceDirection === "rtl"
? css`
transform: translateX(
${props.visible ? "0" : props.scale ? "-100%" : "-480px"}
);
`
: css`
transform: translateX(
${props.visible ? "0" : props.scale ? "100%" : "480px"}
);
`}
}
@media ${mobile} {
bottom: 0;
top: unset;
height: ${({ asideHeight }) =>
asideHeight
? `calc(${asideHeight} - ${mobileFooterHeight})`
: `calc(100% - ${mobileFooterHeight})`};
width: 100%;
max-width: 100%;
${(props) =>
props.theme.interfaceDirection === "rtl"
? css`
transform: translateX(
${(props) => (props.visible ? "0" : "-100%")}
);
`
: css`
transform: translateX(${(props) => (props.visible ? "0" : "100%")});
`}
aside:not(:first-child) {
height: 100%;
}
}
&.modal-dialog-aside {
padding-bottom: ${(props) =>
props.contentPaddingBottom
? props.contentPaddingBottom
: props.theme.aside.paddingBottom};
.modal-dialog-aside-footer {
position: fixed;
bottom: ${(props) => props.theme.aside.bottom};
}
}
`;
StyledAside.defaultProps = { theme: Base };
const StyledControlContainer = styled.div`
display: flex;
width: 17px;
height: 17px;
position: absolute;
cursor: pointer;
align-items: center;
justify-content: center;
z-index: 450;
top: 18px;
${(props) =>
props.theme.interfaceDirection === "rtl" ? `right: -27px;` : `left: -27px;`}
@media ${tablet} {
display: flex;
top: 18px;
${(props) =>
props.theme.interfaceDirection === "rtl"
? `right: -27px;`
: `left: -27px;`}
}
@media ${mobile} {
display: flex;
top: -27px;
right: 10px;
left: unset;
${(props) =>
props.theme.interfaceDirection === "rtl"
? css`
right: unset;
left: 10px;
`
: css`
right: 10px;
left: unset;
`}
}
`;
StyledControlContainer.defaultProps = { theme: Base };
const StyledCrossIcon = styled(CrossReactSvg)`
width: 17px;
height: 17px;
z-index: 455;
path {
fill: ${(props) => props.theme.catalog.control.fill};
}
`;
StyledCrossIcon.defaultProps = { theme: Base };
export { StyledAside, StyledControlContainer, StyledCrossIcon };