UNPKG

@intuitionrobotics/thunderstorm

Version:
32 lines 1.93 kB
import * as React from 'react'; import { GenericSelect } from "../GenericSelect.js"; import { BrowserHistoryModule } from "../../modules/HistoryModule.js"; const PLAYGROUND = "playground"; export class Playground extends React.Component { constructor(props) { super(props); const queryParam = 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, { iconClose: this.props.iconClose, iconOpen: this.props.iconOpen, selectedOption: this.state.selectedScreen, options: this.props.screens, onChange: (screen) => { this.setState({ selectedScreen: screen }); 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, { ...data[0] }); return React.createElement(this.state.selectedScreen.renderer, { ...data }); } } //# sourceMappingURL=Playground.js.map