diff --git a/src/components/Notification/Notifications.css b/src/components/Notification/Notifications.css index bbbb27a9..4d70355a 100644 --- a/src/components/Notification/Notifications.css +++ b/src/components/Notification/Notifications.css @@ -30,7 +30,7 @@ } .top-left { - top: 12px; + top: 100px; left: 12px; transition: transform .3s ease-in; animation: notification-in-down .3s; diff --git a/src/components/Notification/Popup.css b/src/components/Notification/Popup.css new file mode 100644 index 00000000..70c296e0 --- /dev/null +++ b/src/components/Notification/Popup.css @@ -0,0 +1,160 @@ +.modal_wrapper { + z-index: 2999; + width: 100vw; + height: 100vh; + background-color: rgba(0, 0, 0, 0.338); + position: absolute; + left: 0; + top: 0; +} + +.modal_container { + position: fixed; + z-index: 3000; + transition: .3s ease; + display: flex; + justify-content: space-between; + height: max-content; + border-radius:12px; + box-shadow: 0 0 10px rgb(85, 84, 84); +} + +.modal { + display: flex; + flex-direction: column; + width: 35vw; + height: auto; + backdrop-filter: blur(5px); + +} + +.modal_close_icon { + color: white; + width: 2.5rem; + height: 2.5rem; + padding: 0.5rem +} + +.modal_status_icon{ + width: 2.5rem; + height: 2.5rem; + padding: 0.5rem +} + +.modal_bar { + align-self: flex-end; + border-radius: 10px 10px 0 0 ; +} + +.modal_content { + display: flex; + width: inherit; + border-radius: 0 0 10px 10px; + padding: 1rem 0.75rem; + background-color: white; +} + +.modal_message { + font-size: 20px; + line-height: 2em; + padding-left: 0.5rem; +} + +.modal_bar_content { + width: 35vw; + display: flex; + justify-content: flex-end; +} + +.modal_close_button { + background: transparent; + border: none; + align-self: flex-end; +} + +.top-right { + top: 100px; + right: 12px; + transition: transform .3s ease-in-out; + animation: notification-in-down .3s; +} + +.bottom-right { + bottom: 12px; + right: 12px; + transition: transform .3s ease-in-out; + animation: notification-in-up .3s; +} + +.top-left { + top: 100px; + left: 12px; + transition: transform .3s ease-in; + animation: notification-in-down .3s; +} + +.bottom-left { + bottom: 12px; + left: 12px; + transition: transform .3s ease-in; + animation: notification-in-up .3s; +} + +.center { + left: 35%; + top: 35%; + transition: transform .3s ease-in; + animation: notification-in-up .3s; +} + +.danger { + background-color: rgb(201, 25, 11); +} + +.danger_content { + color: rgb(201, 25, 11) +} + +.warning { + background-color: rgba(255, 98, 0); +} + +.warning_content { + color: rgb(237, 114, 37); +} + + +.success { + background-color: rgba(27, 235, 12); +} + +.success_content { + color: rgb(47, 193, 37); +} + +@media (min-width: 768px) { + .top-right { + top: 115px; + } +} +@keyframes notification-in-down { + from { + transform: translateY(-100%); + opacity: 0; + } + + to { + transform: translateY(0); + opacity: 0.9; + } +} + +@keyframes notification-in-up { + from { + transform: translateY(-100%); + } + + to { + transform: translateY(0); + } +} diff --git a/src/components/Notification/Popup.jsx b/src/components/Notification/Popup.jsx new file mode 100644 index 00000000..ba0568d6 --- /dev/null +++ b/src/components/Notification/Popup.jsx @@ -0,0 +1,47 @@ +import React, {useState} from "react"; +import PropTypes from 'prop-types'; +import "./Popup.css"; +import { CheckCircleIcon, ExclamationCircleIcon, ExclamationTriangleIcon, TimesIcon } from "@patternfly/react-icons"; + +const Popup = ({position, variant, title, closeable, timeout}) => { + const [alertVisible, setAlertVisible] = useState(true) + + const handleClose = () => setAlertVisible(false) + +if (closeable) setTimeout(handleClose, timeout ?? 7000) + +return ( + // onClick event handler on the main div makes it possible to close the notification if a user clicks anywhere on the screen + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions +
handleClose()}> +
+ {alertVisible && ( +
+
+
+ +
+
+
+ {variant === 'danger' && ()} + {variant === 'warning' && ()} + {variant === 'success' && ()} +

{title}

+
+
+ )} +
+
+ )} + + Popup.propTypes = { + position: PropTypes.string.isRequired, + variant: PropTypes.string, + title: PropTypes.string, + timeout: PropTypes.bool, + }; + + +export default Popup; \ No newline at end of file diff --git a/src/components/Notification/index.jsx b/src/components/Notification/index.jsx index 86243c52..640f39ba 100644 --- a/src/components/Notification/index.jsx +++ b/src/components/Notification/index.jsx @@ -1,21 +1,28 @@ -import React from 'react'; +import React, {useState} from 'react'; import { Alert, AlertActionCloseButton } from '@patternfly/react-core'; import PropTypes from 'prop-types'; import './Notifications.css'; -export const Notification = ({ position, variant, message, onClose, closeable, title, timeout }) => ( +export const Notification = ({ position, variant, message, onClose, closeable, title, timeout }) => { + const [alertVisible, setAlertVisible] = useState(true) + + const toggleAlert = () => setAlertVisible(false) + + return (
+ {alertVisible && ( } - timeout={timeout || 4000} + actionClose={closeable && toggleAlert()} />} + timeout={timeout} onTimeout={onClose} > {message} + )}
-); +)}; Notification.propTypes = { position: PropTypes.string.isRequired, diff --git a/src/components/Plugin/components/PluginBody/PluginBody.jsx b/src/components/Plugin/components/PluginBody/PluginBody.jsx index d770904d..31515f45 100644 --- a/src/components/Plugin/components/PluginBody/PluginBody.jsx +++ b/src/components/Plugin/components/PluginBody/PluginBody.jsx @@ -21,10 +21,11 @@ import { marked } from 'marked'; import { sanitize } from 'dompurify'; import './PluginBody.css'; -import ErrorNotification from '../../../Notification'; +// import ErrorNotification from '../../../Notification'; import HttpApiCallError from '../../../../errors/HttpApiCallError'; import { GithubAPIRepoError, GithubAPIReadmeError } from '../../../../errors/GithubError'; import { removeEmail } from '../../../../utils/common'; +import Popup from '../../../Notification/Popup'; const PluginBody = ({ pluginData }) => { const [activeTab, setActiveTab] = useState(1); @@ -117,7 +118,8 @@ const PluginBody = ({ pluginData }) => { return ( <> { errors.map((message, index) => ( -