UNPKG

wix-style-react

Version:
114 lines (96 loc) 4.15 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; }; }(); 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 PropTypes from 'prop-types'; import React from 'react'; import Button from 'wix-style-react/Button'; import GenericModalLayout from 'wix-style-react/GenericModalLayout'; import Modal from 'wix-style-react/Modal'; import styles from './ExampleGeneric.scss'; var ExampleGeneric = function (_React$Component) { _inherits(ExampleGeneric, _React$Component); function ExampleGeneric() { _classCallCheck(this, ExampleGeneric); var _this = _possibleConstructorReturn(this, (ExampleGeneric.__proto__ || Object.getPrototypeOf(ExampleGeneric)).call(this)); _this.state = { isModalOpened: false }; return _this; } _createClass(ExampleGeneric, [{ key: 'openModal', value: function openModal() { this.setState({ isModalOpened: true }); } }, { key: 'closeModal', value: function closeModal() { this.setState({ isModalOpened: false }); } }, { key: 'render', value: function render() { var _this2 = this; var _props = this.props, header = _props.header, content = _props.content, footer = _props.footer, fullscreen = _props.fullscreen; return React.createElement( 'div', null, React.createElement( Button, { dataHook: 'open-modal-button', onClick: function onClick() { return _this2.openModal(); } }, 'Open Layout in Modal' ), React.createElement( Modal, { isOpen: this.state.isModalOpened, onRequestClose: function onRequestClose() { return _this2.closeModal(); }, contentLabel: 'Generic Modal layout', shouldDisplayCloseButton: true }, React.createElement(GenericModalLayout, { header: React.createElement( 'div', { className: styles.header }, header ), content: React.createElement( 'div', { className: styles.content }, content ), footer: React.createElement( 'div', { className: styles.footer }, footer ), fullscreen: fullscreen, dataHook: 'generic-modal-layout' }) ) ); } }]); return ExampleGeneric; }(React.Component); export { ExampleGeneric as default }; ExampleGeneric.propTypes = { header: PropTypes.node, content: PropTypes.node, footer: PropTypes.node, fullscreen: PropTypes.bool }; ExampleGeneric.displayName = 'GenericModalLayout';