@metacell/geppetto-meta-ui
Version:
React components from geppetto-meta to create neuroscience applications and visualize data.
142 lines • 7.99 kB
JavaScript
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
import React, { Component } from 'react';
import Card from '@mui/material/Card';
import Modal from '@mui/material/Modal';
import Typography from '@mui/material/Typography';
import CardContent from '@mui/material/CardContent';
import CardActionArea from '@mui/material/CardActionArea';
import IconButtonWithTooltip from "../../common/IconButtonWithTooltip";
import { Matrix } from "../layouts/Matrix";
import { Force } from "../layouts/Force";
import { Hive } from "../layouts/Hive";
import { Chord } from "../layouts/Chord";
import { faCog } from "@fortawesome/free-solid-svg-icons";
import MatrixImg from '../images/matrix.svg';
import ForceImg from '../images/force.svg';
import HiveImg from '../images/hive.svg';
import ChordImg from '../images/chord.svg';
var classes = {
cardDeckWrapper: "connectivity-deck-wrapper",
cardWrapperTitle: "connectivity-deck-title",
cardDeck: "connectivity-deck-card-deck",
card: "connectivity-deck-card",
img: "connectivity-deck-card-img",
cardText: "connectivity-deck-card-text",
cardTitle: "connectivity-deck-card-title",
cardAction: "connectivity-deck-card-action",
cardImgTopCenterBlock: "connectivity-deck-card-img-top-center-block",
cardActionDisabled: "connectivity-deck-card-action-disabled",
button: "connectivity-deck-button"
};
var ConnectivityDeck = /*#__PURE__*/function (_Component) {
function ConnectivityDeck(props) {
var _this;
_classCallCheck(this, ConnectivityDeck);
_this = _callSuper(this, ConnectivityDeck, [props]);
_this.state = {
open: false
};
_this.deck = [{
title: "Adjacency matrix",
subtitle: "A coloured square at row 𝒊, column 𝒋 represents a directed connection from node 𝒋 to node 𝒊.",
handler: _this.props.handler.bind(_this, new Matrix()),
disabled: false,
img: MatrixImg
}, {
title: "Force-directed layout",
subtitle: "Draw circles for nodes, lines for connections, disregarding spatial information. ",
handler: _this.props.handler.bind(_this, new Force()),
disabled: false,
img: ForceImg
}, {
title: "Hive plot",
subtitle: "Axes correspond to node categories, arcs to connections." + "The position of each node along an axis is determined by " + "the total number of connections it makes.",
handler: _this.props.handler.bind(_this, new Hive(true)),
disabled: false,
img: HiveImg
}, {
title: "Chord diagram",
subtitle: "Circular slices correspond to node categories, chords to " + "connections. A gap between slice and chord indicate an " + "incoming connection. Use ctrl(shift) + mouse hover to " + "hide incoming(outgoing) connections from a population.",
handler: _this.props.handler.bind(_this, new Chord(false)),
disabled: false,
img: ChordImg
}];
return _this;
}
_inherits(ConnectivityDeck, _Component);
return _createClass(ConnectivityDeck, [{
key: "render",
value: function render() {
var _this2 = this;
var open = this.state.open;
return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(IconButtonWithTooltip, {
disabled: false,
onClick: function onClick() {
return _this2.setState({
open: true
});
},
className: classes.button,
icon: faCog,
tooltip: "Open layout selector"
}), /*#__PURE__*/React.createElement(Modal, {
open: open,
disableAutoFocus: true,
onClose: function onClose() {
return _this2.setState({
open: false
});
}
}, /*#__PURE__*/React.createElement("div", {
className: classes.cardDeckWrapper
}, /*#__PURE__*/React.createElement("p", {
className: classes.cardWrapperTitle
}, "How would you like to represent your network?"), /*#__PURE__*/React.createElement("div", {
className: classes.cardDeck
}, this.deck.map(function (_ref) {
var title = _ref.title,
subtitle = _ref.subtitle,
handler = _ref.handler,
disabled = _ref.disabled,
img = _ref.img;
return /*#__PURE__*/React.createElement(Card, {
raised: true,
className: classes.card,
key: title
}, /*#__PURE__*/React.createElement(CardActionArea, {
className: disabled ? classes.cardActionDisabled : classes.cardAction,
onClick: function onClick() {
handler();
_this2.setState({
open: false
});
},
disabled: disabled
}, /*#__PURE__*/React.createElement(CardContent, {
className: classes.cardText
}, /*#__PURE__*/React.createElement("img", {
className: classes.cardImgTopCenterBlock,
src: img
}), /*#__PURE__*/React.createElement(Typography, {
className: classes.cardTitle,
variant: "h5"
}, title), /*#__PURE__*/React.createElement(Typography, {
component: "p"
}, subtitle))));
})))));
}
}]);
}(Component);
export default ConnectivityDeck;