diff --git a/scm-ui-components/packages/ui-components/src/modals/ConfirmAlert.css b/scm-ui-components/packages/ui-components/src/modals/ConfirmAlert.css deleted file mode 100644 index 96246a44a5..0000000000 --- a/scm-ui-components/packages/ui-components/src/modals/ConfirmAlert.css +++ /dev/null @@ -1,102 +0,0 @@ -/*modified from https://github.com/GA-MO/react-confirm-alert*/ -.react-confirm-alert-overlay { - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 99; - background: rgba(255, 255, 255, 0.9); - display: -webkit-flex; - display: -moz-flex; - display: -ms-flex; - display: -o-flex; - display: flex; - justify-content: center; - -ms-align-items: center; - align-items: center; - opacity: 0; - -webkit-animation: react-confirm-alert-fadeIn 0.5s 0.2s forwards; - -moz-animation: react-confirm-alert-fadeIn 0.5s 0.2s forwards; - -o-animation: react-confirm-alert-fadeIn 0.5s 0.2s forwards; - animation: react-confirm-alert-fadeIn 0.5s 0.2s forwards; -} - -.react-confirm-alert-body { - font-family: Arial, Helvetica, sans-serif; - width: 400px; - padding: 30px; - text-align: left; - background: #fff; - border-radius: 10px; - box-shadow: 0 20px 75px rgba(0, 0, 0, 0.13); - color: #666; -} - -.react-confirm-alert-body > h1 { - margin-top: 0; -} - -.react-confirm-alert-body > h3 { - margin: 0; - font-size: 16px; -} - -.react-confirm-alert-button-group { - display: -webkit-flex; - display: -moz-flex; - display: -ms-flex; - display: -o-flex; - display: flex; - justify-content: flex-start; - margin-top: 20px; -} - -.react-confirm-alert-button-group > button { - outline: none; - background: #333; - border: none; - display: inline-block; - padding: 6px 18px; - color: #eee; - margin-right: 10px; - border-radius: 5px; - font-size: 12px; - cursor: pointer; -} - -@-webkit-keyframes react-confirm-alert-fadeIn { - from { - opacity: 0; - } - to { - opacity: 1; - } -} - -@-moz-keyframes react-confirm-alert-fadeIn { - from { - opacity: 0; - } - to { - opacity: 1; - } -} - -@-o-keyframes react-confirm-alert-fadeIn { - from { - opacity: 0; - } - to { - opacity: 1; - } -} - -@keyframes react-confirm-alert-fadeIn { - from { - opacity: 0; - } - to { - opacity: 1; - } -} diff --git a/scm-ui-components/packages/ui-components/src/modals/ConfirmAlert.js b/scm-ui-components/packages/ui-components/src/modals/ConfirmAlert.js index 1f93024865..6fe08c8ce8 100644 --- a/scm-ui-components/packages/ui-components/src/modals/ConfirmAlert.js +++ b/scm-ui-components/packages/ui-components/src/modals/ConfirmAlert.js @@ -1,9 +1,7 @@ // @flow -//modified from https://github.com/GA-MO/react-confirm-alert - import * as React from "react"; -import { render, unmountComponentAtNode } from "react-dom"; -import "./ConfirmAlert.css"; +import ReactDOM from "react-dom"; +import Modal from "./Modal"; type Button = { label: string, @@ -25,59 +23,47 @@ class ConfirmAlert extends React.Component { }; close = () => { - removeElementReconfirm(); + ReactDOM.unmountComponentAtNode(document.getElementById("modalRoot")); }; render() { const { title, message, buttons } = this.props; - return ( -
-
- { -
- {title &&

{title}

} - {message} -
- {buttons.map((button, i) => ( - - ))} -
-
- } -
+ const body = <>{message}; + + const footer = ( +
+ {buttons.map((button, i) => ( +

+ this.handleClickButton(button)} + > + {button.label} + +

+ ))}
); + + return ( + this.close()} + body={body} + active={true} + footer={footer} + /> + ); } } -function createElementReconfirm(properties: Props) { - const divTarget = document.createElement("div"); - divTarget.id = "react-confirm-alert"; - if (document.body) { - document.body.appendChild(divTarget); - render(, divTarget); - } -} - -function removeElementReconfirm() { - const target = document.getElementById("react-confirm-alert"); - if (target) { - unmountComponentAtNode(target); - if (target.parentNode) { - target.parentNode.removeChild(target); - } - } -} - export function confirmAlert(properties: Props) { - createElementReconfirm(properties); + const root = document.getElementById("modalRoot"); + if (root) { + ReactDOM.render(, root); + } } export default ConfirmAlert; diff --git a/scm-ui-components/packages/ui-components/src/modals/Modal.js b/scm-ui-components/packages/ui-components/src/modals/Modal.js new file mode 100644 index 0000000000..58da89381d --- /dev/null +++ b/scm-ui-components/packages/ui-components/src/modals/Modal.js @@ -0,0 +1,54 @@ +// @flow +import * as React from "react"; +import classNames from "classnames"; +import injectSheet from "react-jss"; + +type Props = { + title: string, + closeFunction: () => void, + body: any, + footer?: any, + active: boolean, + classes: any +}; + +const styles = { + resize: { + maxWidth: "100%", + width: "auto !important", + display: "inline-block" + } +}; + +class Modal extends React.Component { + render() { + const { title, closeFunction, body, footer, active, classes } = this.props; + + const isActive = active ? "is-active" : null; + + let showFooter = null; + if (footer) { + showFooter =
{footer}
; + } + + return ( +
+
+
+
+

{title}

+
+
{body}
+ {showFooter} +
+
+ ); + } +} + +export default injectSheet(styles)(Modal); diff --git a/scm-ui-components/packages/ui-components/src/modals/index.js b/scm-ui-components/packages/ui-components/src/modals/index.js index e75d082c1c..13b205dd1c 100644 --- a/scm-ui-components/packages/ui-components/src/modals/index.js +++ b/scm-ui-components/packages/ui-components/src/modals/index.js @@ -1,4 +1,5 @@ // @create-index export { default as ConfirmAlert, confirmAlert } from "./ConfirmAlert.js"; +export { default as Modal } from "./Modal.js"; diff --git a/scm-ui/public/index.mustache b/scm-ui/public/index.mustache index 590b5e3cdb..75efc78088 100644 --- a/scm-ui/public/index.mustache +++ b/scm-ui/public/index.mustache @@ -21,6 +21,8 @@ You need to enable JavaScript to run this app.
+
+