DocSpace-client/packages/asc-web-components/save-cancel-buttons/styled-save-cancel-buttons.js

115 lines
2.4 KiB
JavaScript

import styled from "styled-components";
import Base from "../themes/base";
import { tablet, desktop } from "../utils/device";
import { isMobile, isTablet } from "react-device-detect";
const StyledSaveCancelButtons = styled.div`
display: flex;
position: absolute;
justify-content: space-between;
box-sizing: border-box;
align-items: center;
bottom: ${(props) => props.theme.saveCancelButtons.bottom};
width: ${(props) =>
props.displaySettings
? "calc(100% - 40px)"
: props.theme.saveCancelButtons.width};
left: ${(props) =>
props.displaySettings ? "auto" : props.theme.saveCancelButtons.left};
padding: ${(props) =>
props.displaySettings
? "0px 0px 16px 0px"
: props.theme.saveCancelButtons.padding};
.save-button {
margin-right: ${(props) => props.theme.saveCancelButtons.marginRight};
}
.unsaved-changes {
color: ${(props) => props.theme.saveCancelButtons.unsavedColor};
}
${(props) =>
props.displaySettings &&
`
flex-direction: column-reverse;
align-items: flex-start;
.buttons-flex {
display: flex;
width: 100%;
}
.save-button, .cancel-button {
width: 100%;
height: auto;
line-height: 16px;
padding-top: 11px;
padding-bottom: 11px;
}
.unsaved-changes {
margin-bottom: 12px;
font-size: 12px;
font-weight: 600;
}
`}
@media (min-width: 376px) {
${(props) =>
props.displaySettings &&
(!isMobile || isTablet) &&
`
position: static;
max-width: none;
flex-direction: row;
justify-content: flex-start;
align-items: center;
padding-bottom: 24px;
.buttons-flex {
width: auto;
}
.save-button, .cancel-button {
max-width: max-content;
padding-left: 28px;
padding-right: 28px;
}
.unsaved-changes {
margin-left: 8px;
margin-bottom: 0;
}
`}
}
@media ${tablet} {
${(props) =>
!props.displaySettings &&
`
justify-content: flex-end;
position: fixed;
.unsaved-changes {
display: none;
}
`}
}
@media ${desktop} {
${(props) =>
props.displaySettings &&
!isTablet &&
`
.save-button, .cancel-button {
font-size: 13px;
line-height: 20px;
padding-top: 5px;
padding-bottom: 5px;
}
`}
}
`;
StyledSaveCancelButtons.defaultProps = { theme: Base };
export default StyledSaveCancelButtons;