wix-style-react
Version:
wix-style-react
152 lines (132 loc) • 5.8 kB
JavaScript
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 React from 'react';
import { Container, Row, Col } from 'wix-style-react/Grid';
import Card from 'wix-style-react/Card';
import Collapse from 'wix-style-react/Collapse';
import FormField from 'wix-style-react/FormField';
import Input from 'wix-style-react/Input';
import Button from 'wix-style-react/Button';
import TextLink from 'wix-style-react/TextLink';
import Tooltip from 'wix-style-react/Tooltip';
var _default = function (_React$Component) {
_inherits(_default, _React$Component);
function _default() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, _default);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = _default.__proto__ || Object.getPrototypeOf(_default)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
firstCardOpen: true,
secondCardOpen: false
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(_default, [{
key: 'render',
value: function render() {
var _this2 = this;
var _state = this.state,
firstCardOpen = _state.firstCardOpen,
secondCardOpen = _state.secondCardOpen;
return React.createElement(
'div',
{ style: { background: '#F0F4F7', padding: 30 } },
React.createElement(
Container,
null,
React.createElement(
Row,
null,
React.createElement(
Col,
{ span: 6 },
React.createElement(
Card,
null,
React.createElement(Card.Header, {
title: 'Card with collapsable content',
withoutDivider: !firstCardOpen,
suffix: React.createElement(
Button,
{
onClick: function onClick() {
return _this2.setState(function (state) {
return {
firstCardOpen: !state.firstCardOpen
};
});
}
},
firstCardOpen ? 'Close' : 'Open'
)
}),
React.createElement(
Collapse,
{ open: firstCardOpen },
React.createElement(
Card.Content,
null,
field()
)
)
)
),
React.createElement(
Col,
{ span: 6 },
React.createElement(
Card,
null,
React.createElement(Card.Header, {
title: 'Card with collapsable content #2',
withoutDivider: !secondCardOpen,
suffix: React.createElement(
Tooltip,
{
content: 'Click me to ' + (secondCardOpen ? 'squeeze' : 'expand') + '!'
},
React.createElement(
TextLink,
{
onClick: function onClick() {
return _this2.setState(function (state) {
return {
secondCardOpen: !state.secondCardOpen
};
});
}
},
secondCardOpen ? 'Close' : 'Open'
)
)
}),
React.createElement(
Collapse,
{ open: secondCardOpen },
React.createElement(
Card.Content,
null,
field()
)
)
)
)
)
)
);
}
}]);
return _default;
}(React.Component);
export { _default as default };
function field() {
return React.createElement(
FormField,
{ label: 'Text Field' },
React.createElement(Input, { placeholder: 'You can type here' })
);
}