/** * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * Adapted from LiteMol (c) David Sehnal * * @author David Sehnal */ import { PluginUIComponent } from './base'; import { PluginToastManager } from '../mol-plugin/util/toast'; import { IconButton } from './controls/common'; import { CancelSvg } from './controls/icons'; class ToastEntry extends PluginUIComponent<{ entry: PluginToastManager.Entry }> { private hide = () => { const entry = this.props.entry; (entry.hide || function () { }).call(null); }; render() { const entry = this.props.entry; const message = typeof entry.message === 'string' ?
:
; return
this.hide()}> {entry.title}
{message}
; } } export class Toasts extends PluginUIComponent { componentDidMount() { this.subscribe(this.plugin.managers.toast.events.changed, () => this.forceUpdate()); } render() { const state = this.plugin.managers.toast.state; if (!state.entries.count()) return null; const entries: PluginToastManager.Entry[] = []; state.entries.forEach((t, k) => entries.push(t!)); entries.sort(function (x, y) { return x.serialNumber - y.serialNumber; }); return
{entries.map(e => )}
; } }