import classNames from 'classnames'; import React, { ReactNode, useState } from 'react'; import { useDrawerContext } from './DrawerContextProvider'; interface Props { /** * The ID used to identify this component in Dash callbacks */ id?: string; /** * Dash-assigned callback that should be called whenever any of the * properties change */ setProps?: (value: any) => any; /** * Class name applied to the drawer trigger span. * The "mpc-drawer-trigger" class is added automatically */ className?: string; /** * The ID of the drawer that this trigger should open. */ forDrawerId: string; } /** * Render a trigger that opens a ModalContent that is within the same ModalContextProvider */ export const DrawerTrigger: React.FC = (props) => { const { activeDrawer, setActiveDrawer } = useDrawerContext(); return ( { if (activeDrawer === props.forDrawerId) { setActiveDrawer(null); } else { setActiveDrawer(props.forDrawerId); } }} > {props.children} ); };