react-kube
Version:
Kube CSS in React Components
99 lines (80 loc) • 4.01 kB
JavaScript
"use strict";
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 _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 _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) subClass.__proto__ = superClass; }
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
var _classnames = require("classnames");
var _classnames2 = _interopRequireDefault(_classnames);
var Button = (function (_React$Component) {
function Button() {
_classCallCheck(this, Button);
if (_React$Component != null) {
_React$Component.apply(this, arguments);
}
}
_inherits(Button, _React$Component);
_createClass(Button, [{
key: "render",
value: function render() {
var styles = (0, _classnames2["default"])({
"bold": this.props.bold,
"btn": true,
"btn-active": this.props.active,
"btn-big": this.props.big,
"btn-disabled": this.props.disabled,
"btn-outline": this.props.outline,
"btn-round": this.props.round,
"btn-small": this.props.small,
"btn-smaller": this.props.smaller,
"left": this.props.left,
"right": this.props.right
});
styles += this.props.color ? " btn-" + this.props.color : "";
styles += this.props.width ? " width-" + this.props.width : "";
var iconStyles = this.props.icon ? "fa fa-" + this.props.icon : "";
var button = _react2["default"].createElement(
"button",
{ className: (0, _classnames2["default"])(this.props.className, styles), onClick: this.props.onClick, style: this.props.style, type: this.props.type, value: this.props.value },
this.props.icon ? _react2["default"].createElement("li", { className: iconStyles }) : null,
this.props.children
);
return _react2["default"].createElement(
"div",
null,
this.props.append ? _react2["default"].createElement(
"span",
{ className: "btn-append" },
" ",
button,
" "
) : { button: button }
);
}
}]);
return Button;
})(_react2["default"].Component);
Button.propTypes = {
active: _react2["default"].PropTypes.bool,
append: _react2["default"].PropTypes.bool,
big: _react2["default"].PropTypes.bool,
bold: _react2["default"].PropTypes.bool,
children: _react2["default"].PropTypes.node,
className: _react2["default"].PropTypes.string,
color: _react2["default"].PropTypes.oneOf(["black", "blue", "red", "yellow", "green", "white"]),
disabled: _react2["default"].PropTypes.bool,
icon: _react2["default"].PropTypes.string,
left: _react2["default"].PropTypes.bool,
onClick: _react2["default"].PropTypes.func,
outline: _react2["default"].PropTypes.bool,
right: _react2["default"].PropTypes.bool,
round: _react2["default"].PropTypes.bool,
small: _react2["default"].PropTypes.bool,
smaller: _react2["default"].PropTypes.bool,
style: _react2["default"].PropTypes.object,
type: _react2["default"].PropTypes.string,
value: _react2["default"].PropTypes.string,
width: _react2["default"].PropTypes.bool
};
module.exports = Button;