UNPKG

@attivio/suit

Version:

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

62 lines (48 loc) 2.57 kB
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 _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 Button from 'react-bootstrap/lib/Button'; import Glyphicon from 'react-bootstrap/lib/Glyphicon'; /** * A button to live in the navbar. Can have either an icon or a text label or both. * (It needs to at least have one or the other, though.) Clicking the button calls * the onClick handler. */ var NavbarButton = (_temp = _class = function (_React$Component) { _inherits(NavbarButton, _React$Component); function NavbarButton(props) { _classCallCheck(this, NavbarButton); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this.onClick = _this.onClick.bind(_this); return _this; } NavbarButton.prototype.onClick = function onClick() { this.props.onClick(); }; NavbarButton.prototype.render = function render() { var icon = this.props.icon ? React.createElement( 'span', null, React.createElement(Glyphicon, { glyph: this.props.icon, style: { paddingRight: this.props.label ? '8px' : 0 } }) ) : null; return React.createElement( Button, _extends({ onClick: this.onClick }, this.props), icon, this.props.label ); }; return NavbarButton; }(React.Component), _class.defaultProps = { label: '', icon: null }, _class.displayName = 'NavbarButton', _temp); export { NavbarButton as default };