import * as React from "react"; import { DataStorage } from 'babylonjs/Misc/dataStorage'; const downArrow = require("./downArrow.svg"); interface ILineContainerComponentProps { title: string; children: any[] | any; closed?: boolean; } export class LineContainerComponent extends React.Component { constructor(props: ILineContainerComponentProps) { super(props); let initialState = DataStorage.ReadBoolean(this.props.title, !this.props.closed); this.state = { isExpanded: initialState }; } switchExpandedState(): void { const newState = !this.state.isExpanded; DataStorage.WriteBoolean(this.props.title, newState); this.setState({ isExpanded: newState }); } renderHeader() { const className = this.state.isExpanded ? "collapse" : "collapse closed"; return (
this.switchExpandedState()}>
{this.props.title}
); } render() { if (!this.state.isExpanded) { return (
{ this.renderHeader() }
); } return (
{ this.renderHeader() }
{this.props.children}
); } }