@attivio/suit
Version:
Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.
70 lines (56 loc) • 2.53 kB
JavaScript
var _class, _temp;
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 Glyphicon from 'react-bootstrap/lib/Glyphicon';
var MiniIconButton = (_temp = _class = function (_React$Component) {
_inherits(MiniIconButton, _React$Component);
function MiniIconButton(props) {
_classCallCheck(this, MiniIconButton);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
_this.onClick = _this.onClick.bind(_this);
return _this;
}
MiniIconButton.prototype.onClick = function onClick() {
if (this.button) {
this.button.blur();
}
this.props.onClick();
};
MiniIconButton.prototype.render = function render() {
var _this2 = this;
var buttonStyle = {
minWidth: 0,
border: 'none',
boxShadow: 'none',
padding: '5px 5px'
};
var contents = void 0;
if (this.props.glyph) {
contents = React.createElement(Glyphicon, { glyph: this.props.glyph });
} else if (this.props.uri) {
contents = React.createElement('img', { src: this.props.uri, alt: this.props.title, style: { border: 'none' } });
} else {
contents = React.createElement('span', null);
}
return React.createElement(
'button',
{
title: this.props.title,
onClick: this.onClick,
style: buttonStyle,
className: 'btn btn-default',
ref: function ref(c) {
_this2.button = c;
}
},
contents
);
};
return MiniIconButton;
}(React.Component), _class.defaultProps = {
glyph: null,
uri: null
}, _class.displayName = 'MiniIconButton', _temp);
export { MiniIconButton as default };