wix-style-react
Version:
wix-style-react
139 lines (108 loc) • 4.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = undefined;
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 _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _Button = require('wix-style-react/Button');
var _Button2 = _interopRequireDefault(_Button);
var _GenericModalLayout = require('wix-style-react/GenericModalLayout');
var _GenericModalLayout2 = _interopRequireDefault(_GenericModalLayout);
var _Modal = require('wix-style-react/Modal');
var _Modal2 = _interopRequireDefault(_Modal);
var _ExampleGeneric = require('./ExampleGeneric.scss');
var _ExampleGeneric2 = _interopRequireDefault(_ExampleGeneric);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
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 _react2.default.createElement(
'div',
null,
_react2.default.createElement(
_Button2.default,
{ dataHook: 'open-modal-button', onClick: function onClick() {
return _this2.openModal();
} },
'Open Layout in Modal'
),
_react2.default.createElement(
_Modal2.default,
{
isOpen: this.state.isModalOpened,
onRequestClose: function onRequestClose() {
return _this2.closeModal();
},
contentLabel: 'Generic Modal layout',
shouldDisplayCloseButton: true
},
_react2.default.createElement(_GenericModalLayout2.default, {
header: _react2.default.createElement(
'div',
{ className: _ExampleGeneric2.default.header },
header
),
content: _react2.default.createElement(
'div',
{ className: _ExampleGeneric2.default.content },
content
),
footer: _react2.default.createElement(
'div',
{ className: _ExampleGeneric2.default.footer },
footer
),
fullscreen: fullscreen,
dataHook: 'generic-modal-layout'
})
)
);
}
}]);
return ExampleGeneric;
}(_react2.default.Component);
exports.default = ExampleGeneric;
ExampleGeneric.propTypes = {
header: _propTypes2.default.node,
content: _propTypes2.default.node,
footer: _propTypes2.default.node,
fullscreen: _propTypes2.default.bool
};
ExampleGeneric.displayName = 'GenericModalLayout';