import { Icon, Label, Stack } from "office-ui-fabric-react"; import * as React from "react"; import { accordionStackTokens } from "../Settings/SettingsRenderUtils"; export interface CollapsibleSectionProps { title: string; isExpandedByDefault: boolean; onExpand?: () => void; } export interface CollapsibleSectionState { isExpanded: boolean; } export class CollapsibleSectionComponent extends React.Component { constructor(props: CollapsibleSectionProps) { super(props); this.state = { isExpanded: this.props.isExpandedByDefault, }; } private toggleCollapsed = (): void => { this.setState({ isExpanded: !this.state.isExpanded }); }; public componentDidUpdate(): void { if (this.state.isExpanded && this.props.onExpand) { this.props.onExpand(); } } public render(): JSX.Element { return ( <> {this.state.isExpanded && this.props.children} ); } }