DocSpace-buildtools/packages/components/modal-dialog/styled-modal-dialog.js

153 lines
3.8 KiB
JavaScript
Raw Normal View History

2022-04-08 22:42:38 +00:00
import styled, { css } from "styled-components";
2021-02-25 21:19:45 +00:00
import Base from "../themes/base";
import Box from "../box";
2022-07-19 23:24:30 +00:00
import { mobile, smallTablet, tablet } from "../utils/device";
import { isMobile } from "react-device-detect";
2022-04-08 23:41:44 +00:00
const StyledModal = styled.div`
pointer-events: none;
&.modal-active {
pointer-events: all;
}
.loader-wrapper {
padding: 0 16px 16px;
}
2022-03-15 15:08:32 +00:00
`;
const Dialog = styled.div`
display: flex;
align-items: center;
justify-content: center;
width: auto;
margin: 0 auto;
min-height: 100%;
`;
const Content = styled.div.attrs((props) => ({
style: {
marginBottom:
props.modalSwipeOffset < 0 ? `${props.modalSwipeOffset * 1.1}px` : "0px",
},
}))`
box-sizing: border-box;
position: relative;
background-color: ${(props) => props.theme.modalDialog.backgroundColor};
color: ${(props) => props.theme.modalDialog.textColor};
padding: ${(props) =>
props.currentDisplayType === "modal" ? "0" : "0 0 -16px"};
2022-03-15 15:08:32 +00:00
${(props) =>
props.currentDisplayType === "modal"
? css`
height: auto;
max-height: ${(props) =>
props.autoMaxHeight ? "auto" : props.isLarge ? "400px" : "280px"};
width: ${(props) =>
props.autoMaxWidth ? "auto" : props.isLarge ? "520px" : "400px"};
border-radius: 6px;
@media ${smallTablet} {
transform: translateY(${(props) => (props.visible ? "0" : "100%")});
transition: transform 0.3s ease-in-out;
position: absolute;
bottom: 0;
width: 100%;
height: auto;
border-radius: 6px 6px 0 0;
}
`
: css`
width: 480px;
display: flex;
flex-direction: column;
position: absolute;
top: 0;
right: 0;
bottom: 0;
transform: translateX(${(props) => (props.visible ? "0" : "100%")});
transition: transform 0.3s ease-in-out;
@media ${smallTablet} {
transform: translateY(${(props) => (props.visible ? "0" : "100%")});
2022-07-12 14:40:00 +00:00
height: calc(100% - 64px);
width: 100%;
left: 0;
top: auto;
bottom: 0;
}
`}
`;
const StyledHeader = styled.div`
display: flex;
align-items: center;
border-bottom: ${(props) =>
`1px solid ${props.theme.modalDialog.headerBorderColor}`};
2022-03-15 15:08:32 +00:00
margin-bottom: 16px;
height: 52px;
padding: 0 16px 0;
2022-03-15 15:08:32 +00:00
.heading {
font-family: "Open Sans";
color: ${(props) => props.theme.modalDialog.textColor};
font-weight: 700;
2022-09-21 13:26:19 +00:00
font-size: "21px";
2022-03-15 15:08:32 +00:00
}
`;
const StyledBody = styled(Box)`
position: relative;
2022-04-18 13:41:17 +00:00
padding: 0 16px;
padding-bottom: ${(props) =>
props.currentDisplayType === "aside" || props.hasFooter ? "8px" : "16px"};
2022-08-19 01:10:12 +00:00
#modal-scroll > .scroll-body {
${isMobile && "margin-right: 0 !important"}
padding-right: 16px !important;
${(props) =>
props.isScrollLocked &&
css`
margin-right: 0 !important;
overflow: hidden !important;
`}
2022-07-22 23:05:17 +00:00
}
${(props) =>
props.currentDisplayType === "aside" &&
css`
2022-07-19 23:24:30 +00:00
margin-right: ${props.withBodyScroll ? "-16px" : "0"};
padding-bottom: 8px;
height: 100%;
min-height: auto;
`}
`;
const StyledFooter = styled.div`
display: flex;
flex-direction: row;
2022-04-22 13:46:22 +00:00
${(props) =>
props.withFooterBorder &&
`border-top: 1px solid ${props.theme.modalDialog.headerBorderColor}`};
2022-03-15 15:08:32 +00:00
padding: 16px;
gap: 8px;
@media ${tablet} {
gap: 10px;
}
${(props) =>
props.isDoubleFooterLine &&
css`
flex-direction: column;
div {
display: flex;
gap: 8px;
}
`}
`;
2022-03-15 15:08:32 +00:00
Dialog.defaultProps = { theme: Base };
StyledHeader.defaultProps = { theme: Base };
Content.defaultProps = { theme: Base };
export { StyledModal, StyledHeader, Content, Dialog, StyledBody, StyledFooter };