import { IPanelProps, IRenderFunction, Panel, PanelType } from "office-ui-fabric-react"; import * as React from "react"; export interface PanelContainerProps { headerText: string; panelContent: JSX.Element; isConsoleExpanded: boolean; isOpen: boolean; closePanel: () => void; panelWidth?: string; onRenderNavigationContent?: IRenderFunction; } export interface PanelContainerState { height: string; } export class PanelContainerComponent extends React.Component { private static readonly consoleHeaderHeight = 32; private static readonly consoleContentHeight = 220; constructor(props: PanelContainerProps) { super(props); this.state = { height: this.getPanelHeight(), }; } componentDidMount(): void { window.addEventListener("resize", () => this.setState({ height: this.getPanelHeight() })); } componentWillUnmount(): void { window.removeEventListener("resize", () => this.setState({ height: this.getPanelHeight() })); } render(): JSX.Element { if (!this.props.panelContent) { return <>; } return ( {this.props.panelContent} ); } private onDissmiss = (ev?: React.SyntheticEvent): void => { if ((ev.target as HTMLElement).id === "notificationConsoleHeader") { ev.preventDefault(); } else { this.props.closePanel(); } }; private getPanelHeight = (): string => { const consoleHeight = this.props.isConsoleExpanded ? PanelContainerComponent.consoleContentHeight + PanelContainerComponent.consoleHeaderHeight : PanelContainerComponent.consoleHeaderHeight; const panelHeight = window.innerHeight - consoleHeight; return panelHeight + "px"; }; }