wix-style-react
Version:
wix-style-react
86 lines (70 loc) • 4.22 kB
JavaScript
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
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 _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
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 { ButtonNext } from 'wix-ui-core/button-next';
import cx from 'classnames';
import { textButton } from 'wix-ui-core/themes/backoffice';
import { string, node, oneOf, element, bool, func } from 'prop-types';
var TextButton = (_temp = _class = function (_Component) {
_inherits(TextButton, _Component);
function TextButton() {
_classCallCheck(this, TextButton);
return _possibleConstructorReturn(this, (TextButton.__proto__ || Object.getPrototypeOf(TextButton)).apply(this, arguments));
}
_createClass(TextButton, [{
key: 'render',
value: function render() {
var _props = this.props,
skin = _props.skin,
underline = _props.underline,
weight = _props.weight,
size = _props.size,
children = _props.children,
className = _props.className,
dataHook = _props.dataHook,
rest = _objectWithoutProperties(_props, ['skin', 'underline', 'weight', 'size', 'children', 'className', 'dataHook']);
var classNames = cx(className, textButton(skin, underline, weight, size));
return React.createElement(
ButtonNext,
_extends({}, rest, { 'data-hook': dataHook, className: classNames }),
children
);
}
}]);
return TextButton;
}(Component), _class.displayName = 'TextButton', _class.propTypes = {
/** Additional classes */
className: string,
/** Skins of TextButton content */
skin: oneOf(['standard', 'light', 'premium', 'dark']),
/** Underline of TextButton content */
underline: oneOf(['none', 'onHover', 'always']),
/** Weight of TextButton content */
weight: oneOf(['thin', 'normal']),
/** Size of TextButton content */
size: oneOf(['small', 'medium']),
/** Click event handler */
onClick: func,
/** Element based icon (svg, image etc.) */
suffixIcon: element,
/** Element based icon (svg, image etc.) */
prefixIcon: element,
/** Applies disabled styles */
disabled: bool,
/** String based node */
children: node,
/** String based data hook */
dataHook: string
}, _class.defaultProps = {
skin: 'standard',
underline: 'none',
weight: 'thin',
size: 'medium',
disabled: false
}, _temp);
export default TextButton;