UNPKG

@git-temporal/git-temporal-react

Version:

<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

59 lines (58 loc) 1.96 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = __importDefault(require("react")); const styles_1 = require("app/styles"); const containerStyle = { overflow: 'visible', }; const popupStyle = { _extends: 'popup', right: 0, marginRight: 0, minWidth: 180, zIndex: 4, }; const backdropStyle = { opacity: 0, position: 'fixed', top: 0, left: 0, height: '100%', width: '100%', zIndex: 3, }; const visible = { display: 'block' }; const hidden = { display: 'none' }; class Popup extends react_1.default.Component { constructor() { super(...arguments); this.onBackdropClick = (evt) => { this.props.onClose && this.props.onClose(evt); }; this.onMouseEnter = (evt) => { this.props.onMouseEnter && this.props.onMouseEnter(evt); }; this.onMouseLeave = (evt) => { this.props.onMouseLeave && this.props.onMouseLeave(evt); }; } render() { const popupStyles = [popupStyle, this.props.style]; const backdropStyles = [backdropStyle]; if (this.props.isOpen) { popupStyles.push(visible); backdropStyles.push(visible); } else { popupStyles.push(hidden); backdropStyles.push(hidden); } return (react_1.default.createElement("div", { style: styles_1.style(containerStyle) }, !this.props.noBackdrop && (react_1.default.createElement("div", { style: styles_1.style(backdropStyles), onClick: this.onBackdropClick })), react_1.default.createElement("div", { style: styles_1.style(popupStyles), onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave }, this.props.children))); } } exports.Popup = Popup;