import { FC } from 'react'; import useWindowSize from "utils/useWindowSize"; import { useBoardStyles } from "./styles"; import { NODE_HEIGHT, NODE_WIDTH } from './constants'; export const SVGBoard: FC<{ graphHeight?: number, minGraphWidth?: number, nodeHeight?: number, nodeWidth?: number, zoomLevel?: number, }> = ({ children, graphHeight = 300, minGraphWidth = 300, nodeHeight = NODE_HEIGHT, nodeWidth = NODE_WIDTH, zoomLevel = 100, }) => { // state const { ratioWbh } = useWindowSize(); // alias const paddedZoomLevel = zoomLevel / 100; const graphWidth = Math.max( Math.round(graphHeight * ratioWbh), minGraphWidth ); const { classes, theme } = useBoardStyles({ boardHeight: Math.max(nodeHeight, graphHeight) * paddedZoomLevel, boardWidth: Math.max(4 * nodeWidth, graphWidth) * paddedZoomLevel, }); // render return