import { h, Component } from '/js/web_modules/preact.js'; import htm from '/js/web_modules/htm.js'; import MicroModal from '/js/web_modules/micromodal/dist/micromodal.min.js'; const html = htm.bind(h); export default class ExternalActionModal extends Component { constructor(props) { super(props); this.state = { iframeLoaded: false, }; this.setIframeLoaded = this.setIframeLoaded.bind(this); } componentDidMount() { // initalize and display Micromodal on mount try { MicroModal.init({ awaitCloseAnimation: false, awaitOpenAnimation: true, // if using css animations to open the modal. This allows it to wait for the animation to finish before focusing on an element inside the modal. }); MicroModal.show('external-actions-modal', { onClose: this.props.onClose, }); } catch (e) { console.log('micromodal error: ', e); } } setIframeLoaded() { this.setState({ iframeLoaded: true, }); } render() { const { action } = this.props; const { url, title, description } = action; const { iframeLoaded } = this.state; const iframeStyle = iframeLoaded ? null : { backgroundImage: 'url(/img/loading.gif)', }; return html`