wix-style-react
Version:
wix-style-react
85 lines (69 loc) • 4.17 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 { iconButton } from 'wix-ui-core/themes/backoffice';
import { string, node, bool, oneOf, func } from 'prop-types';
var IconButton = (_temp = _class = function (_Component) {
_inherits(IconButton, _Component);
function IconButton() {
_classCallCheck(this, IconButton);
return _possibleConstructorReturn(this, (IconButton.__proto__ || Object.getPrototypeOf(IconButton)).apply(this, arguments));
}
_createClass(IconButton, [{
key: 'render',
value: function render() {
var _props = this.props,
skin = _props.skin,
priority = _props.priority,
size = _props.size,
className = _props.className,
children = _props.children,
disabled = _props.disabled,
dataHook = _props.dataHook,
rest = _objectWithoutProperties(_props, ['skin', 'priority', 'size', 'className', 'children', 'disabled', 'dataHook']);
var classNames = cx(className, iconButton(skin, priority, size));
return React.createElement(
ButtonNext,
_extends({}, rest, {
'data-hook': dataHook,
className: classNames,
disabled: disabled
}),
React.cloneElement(children, {
size: size === 'small' ? '18px' : '24px'
})
);
}
}]);
return IconButton;
}(Component), _class.displayName = 'IconButton', _class.propTypes = {
/** Classes to be applied to the root element */
className: string,
/** Used for passing any wix-style-react icon.For external icon make sure to follow ux sizing guidelines */
children: node,
/** Button skins */
skin: oneOf(['standard', 'inverted', 'light']),
/** Button priority */
priority: oneOf(['primary', 'secondary']),
/** Button size */
size: oneOf(['small', 'medium']),
/** Click event handler */
onClick: func,
/** Applies disabled styles */
disabled: bool,
/** String based data hook */
dataHook: string
}, _class.defaultProps = {
skin: 'standard',
priority: 'primary',
size: 'medium',
disabled: false
}, _temp);
export default IconButton;