import React from 'react'; import { XAxis } from 'recharts'; import {GripIcon} from '../Icons'; import usePrevious from '../utils/usePrevious'; export interface ToolBarProps { displayMode?: 'visible' | 'hover' | 'hidden'; style?: any; //TODO if function } export type Props = ToolBarProps; export const ToolBar = (props: any) => { const {customizedProps, displayMode, style} = props; const toolbarRef = React.useRef(null); const [toolbarDimentions, setToolbarDimentions] = React.useState({width: 0, height: 0}) const prevDimentions = usePrevious(toolbarDimentions); const [hover, setHover] = React.useState(false); React.useEffect(() => { if (toolbarRef?.current) {// && prevDimentions != toolbarDimentions const current = toolbarRef.current setToolbarDimentions({width: current.offsetWidth, height: current.offsetHeight}); } }, [toolbarRef?.current]) return (
{ setHover(true); //TODO: trigger if hover over graph }} onMouseLeave={e => { setHover(false); }} style={{ position: 'absolute', cursor: 'pointer', zIndex: 1, // opacity: displayMode == 'hover' && !hover ? 0: 1, ...style }} >
{props.children}
); }