ucsc-xena-client
Version:
UCSC Xena Client. Functional genomics visualizations.
105 lines (84 loc) • 4.15 kB
JavaScript
/**
* UCSC Xena Client
* http://xena.ucsc.edu
*
* Column add component, displayed between column cards and after last column card. Used as click handler for inserting
* or adding new card.
*
* State
* -----
* actionKey - Index of add column.
* height - Height of add column component.
* last - True if add column is after the last visualization column.
*
* Actions
* -------
* onClick - called on click of component.
* onHover - called on mouse over and mouse out on component.
*/
;
// Core dependencies, components
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return 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 React = require('react');
var classNames = require('classnames');
// Styles
var compStyles = require('./ColumnAdd.module.css');
var ColumnAdd = function (_React$Component) {
_inherits(ColumnAdd, _React$Component);
function ColumnAdd() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, ColumnAdd);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ColumnAdd.__proto__ || Object.getPrototypeOf(ColumnAdd)).call.apply(_ref, [this].concat(args))), _this), _this.onClick = function () {
_this.props.onClick(_this.props.actionKey);
}, _this.onMouseOut = function () {
var _this$props = _this.props,
last = _this$props.last,
onHover = _this$props.onHover,
actionKey = _this$props.actionKey;
if (!last) {
onHover(actionKey, false);
}
}, _this.onMouseOver = function () {
var _this$props2 = _this.props,
last = _this$props2.last,
onHover = _this$props2.onHover,
actionKey = _this$props2.actionKey;
if (!last) {
onHover(actionKey, true);
}
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(ColumnAdd, [{
key: 'render',
value: function render() {
var _props = this.props,
show = _props.show,
last = _props.last;
return React.createElement(
'div',
{ className: classNames(compStyles.ColumnAdd, _defineProperty({}, compStyles.last, last && show)),
style: { visibility: show ? 'visible' : 'hidden' },
onClick: this.onClick,
onMouseOut: this.onMouseOut,
onMouseOver: this.onMouseOver },
React.createElement(
'div',
{ className: compStyles.text },
'Click to ',
last ? 'Add' : 'Insert',
' Column'
)
);
}
}]);
return ColumnAdd;
}(React.Component);
module.exports = ColumnAdd;