react-base-guide
Version:
react ui components
85 lines (83 loc) • 2.93 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const styled_components_1 = __importStar(require("styled-components"));
const show = (0, styled_components_1.keyframes) `
0% { transform: scale(0.3); opacity: 0; }
100% { transform: scale(1); opacity: 1; }
`;
const hide = (0, styled_components_1.keyframes) `
0% { transform: scale(1); opacity: 1; }
100% { transform: scale(0); opacity: 0; }
`;
const showLayer = (0, styled_components_1.keyframes) `
0% { transform: translateX(-100%); opacity: 1; }
100% { transform: translateX(0); opacity: 1; }
`;
const hideLayer = (0, styled_components_1.keyframes) `
0% { transform: translateX(0); opacity: 1; }
100% { transform: translateX(-100%); opacity: 1; }
`;
const getStyles = (p) => {
return p.layer ? `
width: auto;
max-width: 70%;
height: 100%;
margin: 0;
` : `
width: 100%;
max-width: ${p.maxWidth || p.theme.screen.tablet};
height: auto;
margin: 0 auto;
border-radius: ${p.theme.radius.element};
`;
};
const animationsJson = {
show,
hide
};
const animationLayerJson = {
show: showLayer,
hide: hideLayer
};
const Window = styled_components_1.default.div `
position: relative;
box-sizing: border-box;
flex: none;
min-height: 100px;
max-height: ${p => p.maxHeight};
padding: 24px;
background: ${p => p.theme.palette.background.primary};
z-index: ${p => p.theme.zIndex.modal};
opacity: 0;
@media(max-width: ${p => p.theme.screen.tablet}) {
max-width: calc(100% - 30px);
padding: 10px;
}
${p => getStyles(p)}
animation: 0.3s ${p => (p.layer ? animationLayerJson[p.animation] : animationsJson[p.animation]) || "none"} forwards;
`;
exports.default = Window;
//# sourceMappingURL=window.js.map