diff --git a/ghost/admin-x-settings/package.json b/ghost/admin-x-settings/package.json index 78cd29d80c..16d82f3a3b 100644 --- a/ghost/admin-x-settings/package.json +++ b/ghost/admin-x-settings/package.json @@ -76,6 +76,7 @@ "postcss": "8.4.24", "postcss-import": "^15.1.0", "prop-types": "15.8.1", + "react-hot-toast": "^2.4.1", "react-select": "^5.7.3", "rollup-plugin-node-builtins": "2.1.2", "storybook": "7.0.18", diff --git a/ghost/admin-x-settings/src/App.tsx b/ghost/admin-x-settings/src/App.tsx index 2dd025aa4b..d53098d3f6 100644 --- a/ghost/admin-x-settings/src/App.tsx +++ b/ghost/admin-x-settings/src/App.tsx @@ -5,16 +5,33 @@ import NiceModal from '@ebay/nice-modal-react'; import Settings from './components/Settings'; import Sidebar from './components/Sidebar'; import {ServicesProvider} from './components/providers/ServiceProvider'; +import {Toaster} from 'react-hot-toast'; +import {showToast} from './admin-x-ds/global/Toast'; interface AppProps { ghostVersion: string; } function App({ghostVersion}: AppProps) { + // const notify = () => toast.success('Here is your toast.', { + // duration: 10000000, + // position: 'bottom-left' + // }); + + const notify = () => showToast({ + message: 'Hello toast', + options: { + duration: 1000000, + position: 'bottom-left' + } + }); + return (
+ +
+
+ ); +}; + +export default Toast; + +export const showToast = ({ + message, + type = 'neutral', + icon = '', + options = { + position: 'bottom-left', + duration: 5000 + } +}: ShowToastProps): void => { + if (!options.position) { + options.position = 'bottom-left'; + } + + toast.custom(t => ( + + {message} + + ), + { + ...options + } + ); +}; \ No newline at end of file diff --git a/ghost/admin-x-settings/src/admin-x-ds/global/ToastContainer.tsx b/ghost/admin-x-settings/src/admin-x-ds/global/ToastContainer.tsx new file mode 100644 index 0000000000..36166a8a8c --- /dev/null +++ b/ghost/admin-x-settings/src/admin-x-ds/global/ToastContainer.tsx @@ -0,0 +1,15 @@ +import Button from './Button'; +import React from 'react'; +import {ShowToastProps, showToast} from './Toast'; + +const ToastContainer: React.FC = ({...props}) => { + return ( + <> +