UNPKG

@intuitionrobotics/thunderstorm

Version:
36 lines 2.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Playground = void 0; const React = require("react"); const GenericSelect_1 = require("../GenericSelect"); const HistoryModule_1 = require("../../modules/HistoryModule"); const PLAYGROUND = "playground"; class Playground extends React.Component { constructor(props) { super(props); const queryParam = HistoryModule_1.BrowserHistoryModule.getQueryParams()[PLAYGROUND]; const screen = this.props.screens.find(s => s.name === queryParam); this.state = { selectedScreen: screen }; } render() { return React.createElement("div", { className: 'match_height match_width' }, React.createElement("div", { className: 'match_height match_width', style: { alignSelf: "start", padding: "20px" } }, React.createElement(GenericSelect_1.GenericSelect, { iconClose: this.props.iconClose, iconOpen: this.props.iconOpen, selectedOption: this.state.selectedScreen, options: this.props.screens, onChange: (screen) => { this.setState({ selectedScreen: screen }); HistoryModule_1.BrowserHistoryModule.addQueryParam(PLAYGROUND, screen.name); }, styles: this.props.selectStyle, presentation: (screen) => screen.name })), React.createElement("div", { style: { borderStyle: "double", display: "inline-block", padding: "12px", margin: "12px" } }, this.renderPlayground())); } renderPlayground() { if (!this.state.selectedScreen) return React.createElement("div", null, "Select a playground"); const data = this.state.selectedScreen.data; if (!data || data.length === 0) return React.createElement(this.state.selectedScreen.renderer, null); if (data.length === 1) return React.createElement(this.state.selectedScreen.renderer, Object.assign({}, data[0])); return React.createElement(this.state.selectedScreen.renderer, Object.assign({}, data)); } } exports.Playground = Playground; //# sourceMappingURL=Playground.js.map