import React, { Dispatch, SetStateAction, useEffect, useState } from 'react'; import classNames from 'classnames'; import { FaCompress, FaCompressAlt, FaExpand, FaExpandAlt } from 'react-icons/fa'; import './Enlargeable.css'; export interface EnlargeableProps { /** * The ID used to identify this component in Dash callbacks. */ id?: string; /** * Dash-assigned callback that should be called to report property changes * to Dash, to make them available for callbacks. */ setProps?: (value: any) => any; /** * Additional class to apply to the modal-content element */ className?: string; expanded?: boolean; setExpanded?: Dispatch>; hideButton?: boolean; } /** * Wrap around a content or a component to enable that content to be enlarged in a full screen modal. */ export const Enlargeable: React.FC = ({ className = '', ...otherProps }) => { const props = { className, ...otherProps }; let expanded: boolean = false; let setExpanded: Dispatch>; /** * Expanded variabled can be controlled from inside the component * or outside the component if props are supplied. */ if (!props.expanded || !props.setExpanded) { var [expandedState, setExpandedState] = useState(false); expanded = expandedState; setExpanded = setExpandedState; } else { expanded = props.expanded; setExpanded = props.setExpanded; } return (
setExpanded(false)} >
{!props.hideButton && ( )} {props.children}
); };