kitchen-simulator
Version:
It is a kitchen simulator (self-contained micro-frontend).
106 lines • 3.54 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
var _excluded = ["type", "style", "styleHover", "children", "size"];
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import * as SharedStyle from "../../shared-style";
var BASE_STYLE = {
display: 'inline-block',
fontWeight: '400',
lineHeight: '1.25',
textAlign: 'center',
whiteSpace: 'nowrap',
verticalAlign: 'middle',
cursor: 'pointer',
WebkitUserSelect: 'none',
MozUserSelect: 'none',
MsUserSelect: 'none',
userSelect: 'none',
padding: '5px 14px',
fontSize: '14px',
color: SharedStyle.COLORS.black,
fonWeight: '400px',
transition: 'background-color 175ms ease, border 175ms ease',
outline: 'none',
borderRadius: '2px',
borderWidth: '1px',
borderType: 'solid',
width: '100%'
};
var BASE_STYLE_SIZE = {
small: {
fontSize: '12px',
padding: '3px 8px'
},
normal: {},
large: {
padding: '8px 20px'
}
};
var Button = /*#__PURE__*/function (_Component) {
function Button(props) {
var _this;
_classCallCheck(this, Button);
_this = _callSuper(this, Button, [props]);
_this.state = {
hover: false
};
return _this;
}
_inherits(Button, _Component);
return _createClass(Button, [{
key: "render",
value: function render() {
var _this2 = this;
var hover = this.state.hover;
var _this$props = this.props,
type = _this$props.type,
customStyle = _this$props.style,
customStyleHover = _this$props.styleHover,
children = _this$props.children,
size = _this$props.size,
rest = _objectWithoutProperties(_this$props, _excluded);
var styleMerged = Object.assign({}, BASE_STYLE, BASE_STYLE_SIZE[size], hover ? customStyleHover : customStyle);
return /*#__PURE__*/React.createElement("button", _extends({
type: type,
onMouseEnter: function onMouseEnter(e) {
return _this2.setState({
hover: true
});
},
onMouseLeave: function onMouseLeave(e) {
return _this2.setState({
hover: false
});
},
style: styleMerged
}, rest), children);
}
}]);
}(Component);
export { Button as default };
Button.defaultProps = {
type: 'button',
size: 'normal',
style: {
backgroundColor: '#e6e6e6',
borderColor: '#adadad'
},
styleHover: {
backgroundColor: '#d4d4d4',
borderColor: '#8c8c8c'
}
};
Button.propTypes = {
type: PropTypes.string,
style: PropTypes.object,
styleHover: PropTypes.object,
size: PropTypes.oneOf(['large', 'normal', 'small'])
};