UNPKG

ucsc-xena-client

Version:

UCSC Xena Client. Functional genomics visualizations.

140 lines (115 loc) 5.72 kB
/** * UCSC Xena Client * http://xena.ucsc.edu * * Standard Xena help box, hand-rolled outside of RTB as we may require more than one help box (ie dialog) open * at a time, and we want to be able to control the overlay or lack thereof. RTB currently does not allow multiple * dialogs open at the same time, or theming to control overlay styles. * * There are two possible formats of help boxes. * 1. A help box positioned to the right of the item being highlighted. The help box is drawn with a triangle on the * left-hand side of the help box dialog, and a dotted line is drawn from the left-hand side of the viewport to the * triangle. * 2. A help box positioned below the item being highlighted. The help box is drawn with a triangle on the top side of * dialog help box. * * State * ----- * - x: Position of left hand side of help box. * - y: Position of top of help box. * - w: Width of help box. * - o: Orientation of help box (to determine where to place/point help box triangle), 'Right' or 'Below'. * * Actions * ------- * - onClose: Called when "GOT IT" button clicked to hide help box. * * Children should be in the format: * <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> * * For example, * <HelpBox x={882} y={271} w={280} o={'Right'}><p>Each row contains data from a single sample.</p><p>Row order is determined by sorting the rows by their column values.</p></HelpBox> */ 'use strict'; // 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; }; }(); var _button = require('react-toolbox/lib/button'); function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } 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('./HelpBox.module.css'); // Setup for help box displayed to right of item being highlighted (with row marker). 27.5 used in width calculations // of marker comes from 16px margin (standard MD width) plus 11.5px for triangle. This smaller width creates the // necessary break between the marker and the right triangle. var HelpBoxR = function HelpBoxR(props) { var w = props.w, children = props.children; return React.createElement( 'div', { className: classNames(compStyles.HelpBox, compStyles.withMarker, compStyles.helpRight) }, React.createElement('div', { className: compStyles.rowMarker }), React.createElement( 'div', { style: { width: w }, className: compStyles.helpBoxBounds }, children ) ); }; // Setup for help box displayed below item being highlighted. var HelpBoxB = function HelpBoxB(props) { var w = props.w, children = props.children; return React.createElement( 'div', { style: { width: w }, className: classNames(compStyles.HelpBox, compStyles.helpBoxBounds, compStyles.helpBelow) }, children ); }; var HelpBox = function (_React$Component) { _inherits(HelpBox, _React$Component); function HelpBox() { var _ref; var _temp, _this, _ret; _classCallCheck(this, HelpBox); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = HelpBox.__proto__ || Object.getPrototypeOf(HelpBox)).call.apply(_ref, [this].concat(args))), _this), _this.onClose = function () { _this.props.onClose(); }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(HelpBox, [{ key: 'render', value: function render() { var _props = this.props, children = _props.children, o = _props.o, boxProps = _objectWithoutProperties(_props, ['children', 'o']); var Box = o === 'Right' ? HelpBoxR : HelpBoxB; return React.createElement( Box, boxProps, React.createElement( 'div', { className: compStyles.helpBoxContent }, children ), React.createElement( 'div', { className: compStyles.buttonContainer }, React.createElement( _button.Button, { accent: true, onClick: this.onClose }, 'GOT IT' ) ) ); } }]); return HelpBox; }(React.Component); module.exports = HelpBox;