import * as React from "react"; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faChevronDown } from '@fortawesome/free-solid-svg-icons'; interface ILineContainerComponentProps { title: string, children: any[] | any, closed?: boolean } export class LineContainerComponent extends React.Component { constructor(props: ILineContainerComponentProps) { super(props); this.state = { isExpanded: !this.props.closed }; } switchExpandedState(): void { this.setState({ isExpanded: !this.state.isExpanded }); } renderHeader() { const className = this.state.isExpanded ? "collapse" : "collapse closed"; return (
{this.props.title}
this.switchExpandedState()}>
) } render() { if (!this.state.isExpanded) { return (
{ this.renderHeader() }
) } return (
{ this.renderHeader() }
{this.props.children}
); } }