UNPKG

@attivio/suit

Version:

Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.

82 lines (63 loc) 2.9 kB
'use strict'; exports.__esModule = true; exports.default = undefined; var _class, _temp; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _Glyphicon = require('react-bootstrap/lib/Glyphicon'); var _Glyphicon2 = _interopRequireDefault(_Glyphicon); 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 _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; } 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 = _react2.default.createElement(_Glyphicon2.default, { glyph: this.props.glyph }); } else if (this.props.uri) { contents = _react2.default.createElement('img', { src: this.props.uri, alt: this.props.title, style: { border: 'none' } }); } else { contents = _react2.default.createElement('span', null); } return _react2.default.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; }(_react2.default.Component), _class.defaultProps = { glyph: null, uri: null }, _class.displayName = 'MiniIconButton', _temp); exports.default = MiniIconButton; module.exports = exports['default'];