UNPKG

quantumai-design-system

Version:

퀀텀에이아이의 디자인 시스템

57 lines (56 loc) 4.74 kB
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx } from "@emotion/react/jsx-runtime"; import styled from '@emotion/styled'; import { createContext, forwardRef } from 'react'; import { BASE_SHADOW, COLORS } from '../../../styles/theme'; import ModalFooter from './ModalFooter'; import ModalHeader from './ModalHeader'; import { ModalBody } from './ModalBody'; import { mixinSize, transitionSet } from '../../../utils/styleSet'; import Portal from '../../Base/Portal'; import useTransition from '../../../hooks/useTransition'; export var ModalContext = createContext({}); var Modal = forwardRef(function (_a, ref) { var _b = _a.show, show = _b === void 0 ? false : _b, id = _a.id, onCloseModal = _a.onCloseModal, _c = _a.isOutSideClose, isOutSideClose = _c === void 0 ? true : _c, _d = _a.width, width = _d === void 0 ? 540 : _d, children = _a.children, props = __rest(_a, ["show", "id", "onCloseModal", "isOutSideClose", "width", "children"]); var _e = useTransition(!!show), isMount = _e[0], isTransition = _e[1], onEndTransition = _e[2]; if (!isMount) return; return (_jsx(Portal, { id: "modal-root", children: _jsx(ModalContainer, { "data-show": isTransition, onClick: function () { return isOutSideClose && (onCloseModal === null || onCloseModal === void 0 ? void 0 : onCloseModal()); }, children: _jsx(ModalContent, __assign({ ref: ref, onClick: function (e) { var _a; e.stopPropagation(); (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e); }, "data-show": isTransition, onTransitionEnd: onEndTransition, width: width }, props, { children: _jsx(ModalContext.Provider, { value: { onCloseModal: onCloseModal }, children: children }) })) }) })); }); export default Object.assign(Modal, { Header: ModalHeader, Body: ModalBody, Footer: ModalFooter, }); var ModalContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n width: 100vw;\n height: 100vh;\n background-color: rgba(0, 0, 0, 0.2);\n padding: 40px;\n opacity: 0;\n pointer-events: none;\n z-index: 0;\n ", "\n\n &[data-show='true'] {\n opacity: 1;\n pointer-events: auto;\n z-index: 1000;\n }\n"], ["\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n width: 100vw;\n height: 100vh;\n background-color: rgba(0, 0, 0, 0.2);\n padding: 40px;\n opacity: 0;\n pointer-events: none;\n z-index: 0;\n ", "\n\n &[data-show='true'] {\n opacity: 1;\n pointer-events: auto;\n z-index: 1000;\n }\n"])), transitionSet('opacity')); var ModalContent = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n max-width: 100%;\n max-height: 100%;\n background-color: ", ";\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n box-shadow: ", ";\n border-radius: 10px;\n ", "\n transform: translateY(+40px);\n ", "\n\n &[data-show='true'] {\n transform: translateY(-0px);\n }\n"], ["\n max-width: 100%;\n max-height: 100%;\n background-color: ", ";\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n box-shadow: ", ";\n border-radius: 10px;\n ", "\n transform: translateY(+40px);\n ", "\n\n &[data-show='true'] {\n transform: translateY(-0px);\n }\n"])), COLORS.white, BASE_SHADOW.l, function (props) { return mixinSize(props); }, transitionSet('transform')); var templateObject_1, templateObject_2;