UNPKG

wix-style-react

Version:
102 lines (87 loc) 4.09 kB
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _class, _temp; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } import React, { Component } from 'react'; import Tooltip from '../../../src/Tooltip'; import Button from '../../../src/Button'; import { SHORT_CONTENT, LONG_CONTENT } from '../content'; var TooltipForEyesOnly = (_temp = _class = function (_Component) { _inherits(TooltipForEyesOnly, _Component); function TooltipForEyesOnly() { _classCallCheck(this, TooltipForEyesOnly); var _this = _possibleConstructorReturn(this, (TooltipForEyesOnly.__proto__ || Object.getPrototypeOf(TooltipForEyesOnly)).call(this)); _this.state = { content: SHORT_CONTENT, style: {}, popover: false }; return _this; } _createClass(TooltipForEyesOnly, [{ key: 'render', value: function render() { var _this2 = this; var _state = this.state, style = _state.style, content = _state.content; var isE2e = global.self === global.top; return isE2e ? React.createElement( 'div', { 'data-hook': 'tooltip-e2e-wrapper' }, React.createElement( Tooltip, { active: true, shouldUpdatePosition: true, showImmediately: true, popover: this.state.popover, showTrigger: 'custom', hideTrigger: 'custom', appendToParent: true, content: React.createElement( 'div', { 'data-hook': 'tooltip-e2e-tooltip' }, content ) }, React.createElement( 'div', { style: style, 'data-hook': 'tooltip-anchor' }, 'My Father is a Tooltip' ) ), React.createElement( Button, { dataHook: 'long-text-button', onClick: function onClick() { return _this2._onClick(); } }, 'Change State' ), React.createElement( Button, { dataHook: 'popover-button', onClick: function onClick() { return _this2.togglePopover(); } }, 'Toggle popover' ) ) : null; } }, { key: 'togglePopover', value: function togglePopover() { this.setState({ popover: !this.state.popover }); } }, { key: '_onClick', value: function _onClick() { this.setState({ style: { position: 'relative', left: '20px' }, content: LONG_CONTENT }); } }]); return TooltipForEyesOnly; }(Component), _class.displayName = 'TooltipForEyesOnly', _class.propTypes = {}, _class.defaultProps = {}, _temp); export { TooltipForEyesOnly as default };