diff --git a/apps/remix-ide/src/app/ui/tooltip.js b/apps/remix-ide/src/app/ui/tooltip.js index 63ab6283d5..700a08ef56 100644 --- a/apps/remix-ide/src/app/ui/tooltip.js +++ b/apps/remix-ide/src/app/ui/tooltip.js @@ -24,15 +24,6 @@ class Toaster { animation(this.tooltip, css.animateTop.className) } - /** - * Force resolve the promise to close - * the toaster ignoring timeout - */ - forceResolve () { - if (this.id) clearTimeout(this.id) - if (this.resolveFn) this.resolveFn() - } - render (tooltipText, actionElement, opts) { opts = defaultOptions(opts) let canShorten = true diff --git a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx index f28ce848fb..72e79383db 100644 --- a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx @@ -4,7 +4,8 @@ import StepManager from './step-manager/step-manager' import VmDebugger from './vm-debugger/vm-debugger' import VmDebuggerHead from './vm-debugger/vm-debugger-head' import { TransactionDebugger as Debugger } from '@remix-project/remix-debug' -import { DebuggerAPI, DebuggerUIProps } from './DebuggerAPI' +import { DebuggerUIProps } from './DebuggerAPI' +import { Toaster } from '@remix-ui/toaster' /* eslint-disable-next-line */ import './debugger-ui.css' @@ -23,7 +24,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => { debugging: false, opt: { debugWithGeneratedSources: false - } + }, + toastMessage: '' }) useEffect(() => { @@ -141,7 +143,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => { } }) } - const startDebugging = async (blockNumber, txNumber, tx) => { if (state.debugger) unLoad() if (!txNumber) return @@ -169,14 +170,20 @@ export const DebuggerUI = (props: DebuggerUIProps) => { txNumber, debugging: true, currentReceipt, - debugger: debuggerInstance + debugger: debuggerInstance, + toastMessage: `debugging ${txNumber}` } }) }).catch((error) => { - // toaster(error, null, null) + setState(prevState => { + return { + ...prevState, + toastMessage: JSON.stringify(error) + } + }) unLoad() }) -} + } const debug = (txHash) => { startDebugging(null, txHash, null) @@ -205,9 +212,9 @@ const vmDebugger = { registerEvent: state.debugger && state.debugger.vmDebuggerLogic ? state.debugger.vmDebuggerLogic.event.register.bind(state.debugger.vmDebuggerLogic.event) : null, triggerEvent: state.debugger && state.debugger.vmDebuggerLogic ? state.debugger.vmDebuggerLogic.event.trigger.bind(state.debugger.vmDebuggerLogic.event) : null } - - return ( + return (
Debugger Configuration
diff --git a/libs/remix-ui/toaster/.babelrc b/libs/remix-ui/toaster/.babelrc new file mode 100644 index 0000000000..09d67939cc --- /dev/null +++ b/libs/remix-ui/toaster/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["@nrwl/react/babel"], + "plugins": [] +} diff --git a/libs/remix-ui/toaster/.eslintrc b/libs/remix-ui/toaster/.eslintrc new file mode 100644 index 0000000000..b8666066e9 --- /dev/null +++ b/libs/remix-ui/toaster/.eslintrc @@ -0,0 +1,18 @@ +{ + "env": { + "browser": true, + "es6": true + }, + "extends": "../../../.eslintrc", + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parserOptions": { + "ecmaVersion": 11, + "sourceType": "module" + }, + "rules": { + "standard/no-callback-literal": "off" + } +} diff --git a/libs/remix-ui/toaster/README.md b/libs/remix-ui/toaster/README.md new file mode 100644 index 0000000000..7686d07019 --- /dev/null +++ b/libs/remix-ui/toaster/README.md @@ -0,0 +1,7 @@ +# remix-ui-toaster + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test remix-ui-toaster` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/remix-ui/toaster/src/index.ts b/libs/remix-ui/toaster/src/index.ts new file mode 100644 index 0000000000..1db646761e --- /dev/null +++ b/libs/remix-ui/toaster/src/index.ts @@ -0,0 +1 @@ +export * from './lib/toaster' diff --git a/libs/remix-ui/toaster/src/lib/toaster.css b/libs/remix-ui/toaster/src/lib/toaster.css new file mode 100644 index 0000000000..c026edbf49 --- /dev/null +++ b/libs/remix-ui/toaster/src/lib/toaster.css @@ -0,0 +1,43 @@ +.remixui_tooltip { + z-index: 1001; + display: flex; + justify-content: space-between; + align-items: center; + position: fixed; + min-height: 50px; + padding: 16px 24px 12px; + border-radius: 3px; + left: 40%; + font-size: 14px; + text-align: center; + bottom: -0px; + flex-direction: row; +} +@-webkit-keyframes remixui_animatebottom { + 0% {bottom: -300px} + 100% {bottom: 0px} +} +@keyframes remixui_animatebottom { + 0% {bottom: -300px} + 100% {bottom: 0px} +} +@-webkit-keyframes remixui_animatetop { + 0% {bottom: 0px} + 100% {bottom: -300px} +} +@keyframes remixui_animatetop { + 0% {bottom: 0px} + 100% {bottom: -300px} +} +.remixui_animateTop { + -webkit-animation-name: remixui_animatetop; + -webkit-animation-duration: 2s; + animation-name: remixui_animatetop; + animation-duration: 2s; +} +.remixui_animateBottom { + -webkit-animation-name: remixui_animatebottom; + -webkit-animation-duration: 2s; + animation-name: remixui_animatebottom; + animation-duration: 2s; +} diff --git a/libs/remix-ui/toaster/src/lib/toaster.tsx b/libs/remix-ui/toaster/src/lib/toaster.tsx new file mode 100644 index 0000000000..6d3039dbc4 --- /dev/null +++ b/libs/remix-ui/toaster/src/lib/toaster.tsx @@ -0,0 +1,108 @@ +import React, { useEffect, useState } from 'react' // eslint-disable-line +import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line + +import './toaster.css' + +/* eslint-disable-next-line */ +export interface ToasterProps { + message: string + timeOut?: number +} + +export const Toaster = (props: ToasterProps) => { + const [state, setState] = useState({ + message: '', + hide: true, + hiding: false, + timeOutId: null, + timeOut: props.timeOut || 7000, + showModal: false + }) + + useEffect(() => { + if (props.message) { + const timeOutId = setTimeout(() => { + setState(prevState => { + return { ...prevState, hiding: true } + }) + }, state.timeOut) + + setState(prevState => { + const shortTooltipText = props.message.length > 201 ? props.message.substring(0, 200) + '...' : props.message + + return { ...prevState, hide: false, hiding: false, timeOutId, message: shortTooltipText } + }) + } + }, [props.message]) + + useEffect(() => { + if (state.hiding) { + setTimeout(() => { + closeTheToaster() + }, 1800) + } + }, [state.hiding]) + + const showFullMessage = () => { + setState(prevState => { + return { ...prevState, showModal: true } + }) + } + + const hideFullMessage = () => { //eslint-disable-line + setState(prevState => { + return { ...prevState, showModal: false } + }) + } + + const closeTheToaster = () => { + if (state.timeOutId) { + clearTimeout(state.timeOutId) + } + setState(prevState => { + return { ...prevState, message: '', hide: true, hiding: false, timeOutId: null, showModal: false } + }) + } + + const handleMouseEnter = () => { + if (state.timeOutId) { + clearTimeout(state.timeOutId) + } + setState(prevState => { + return { ...prevState, timeOutId: null } + }) + } + + const handleMouseLeave = () => { + if (!state.timeOutId) { + const timeOutId = setTimeout(() => { + setState(prevState => { + return { ...prevState, hiding: true } + }) + }, state.timeOut) + + setState(prevState => { + return { ...prevState, timeOutId } + }) + } + } + + return ( + <> + {/*