UNPKG

@attivio/suit

Version:

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

132 lines (112 loc) 4.1 kB
'use strict'; exports.__esModule = true; exports.default = undefined; var _class, _temp; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _DefaultImage = require('./DefaultImage'); var _DefaultImage2 = _interopRequireDefault(_DefaultImage); 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 CardPickerCard = (_temp = _class = function (_React$Component) { _inherits(CardPickerCard, _React$Component); function CardPickerCard(props) { _classCallCheck(this, CardPickerCard); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this.onClick = _this.onClick.bind(_this); return _this; } CardPickerCard.prototype.onClick = function onClick() { if (!this.props.selected) { this.props.onClick(); } if (this.card) { this.card.blur(); } }; CardPickerCard.prototype.render = function render() { var _this2 = this; var style = { height: '120px', width: 'calc(' + 100 / this.props.columns + '% - 6px)', margin: '3px', padding: '3px', color: '#2f75b0', backgroundColor: '#fff', border: this.props.selected ? '2px solid #2f75b0' : '1px solid #888', display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center' }; var icon = this.props.iconUri ? _react2.default.createElement(_DefaultImage2.default, { src: this.props.iconUri, defaultSrc: this.props.defaultIconUri, style: { maxHeight: '60px', maxWidth: '60px' }, alt: this.props.label + ' icon' }) : _react2.default.createElement('div', { style: { height: '60px', width: '60px' } }); return _react2.default.createElement( 'div', { title: this.props.description, style: style, onClick: this.onClick, role: 'button', tabIndex: 0, ref: function ref(c) { _this2.card = c; }, 'data-test': this.props.dataTestValue ? '' + this.props.dataTestValue : null }, _react2.default.createElement( 'div', { style: { height: '80px', paddingBottom: '10px', display: 'flex', flexDirection: 'column', justifyContent: 'flex-end', alignItems: 'center' } }, icon ), _react2.default.createElement( 'div', { style: { width: 'calc(100% - 6px)', marginTop: '7px', paddingBottom: '10px', textAlign: 'center', overflowX: 'hidden', overflowY: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' } }, this.props.label ) ); }; return CardPickerCard; }(_react2.default.Component), _class.defaultProps = { columns: 3, iconUri: null, defaultIconUri: null, description: null, dataTestValue: null }, _class.displayName = 'CardPickerCard', _temp); exports.default = CardPickerCard; module.exports = exports['default'];