import { FC } from 'react'; import { makeStyles, Theme } from '@material-ui/core'; import { MiniTopoProps } from './Types'; const getStyles = makeStyles((theme: Theme) => ({ container: { height: '100%', width: 'auto', }, childNode: { transition: 'all .25s', cursor: 'pointer', transformOrigin: '50% 50%', transformBox: 'fill-box', '& circle': { transition: 'all .25s', }, '& text': { transition: 'all .25s', }, '&:hover, &:focus': { transform: 'scale(1.1)', filter: 'drop-shadow(3px 3px 5px rgba(0, 0, 0, .2))', }, '&:focus': { outline: 'none', '& svg path': { fill: 'white', }, '& circle': { fill: '#06AFF2', stroke: '#06AFF2', }, '& text': { fill: 'white', } } }, })); const capitalize = (s: string) => { return s.charAt(0).toUpperCase() + s.slice(1); } const MiniTopo: FC = (props) => { const classes = getStyles(); const { selectedCord, selectedChildNode, setCord } = props; const WIDTH = 400; // width for svg const HEIGHT = 400; // height for svg const LINE = 80; // line lenght from lv2 node const ANGLE = 10; // angle offset for lv2 node const R1 = 45; // root node radius const R2 = 30; // lv1 node radius const W3 = 20; // width of child rect const childNodeCenterX = WIDTH / 2 + LINE * Math.cos(ANGLE * Math.PI / 180); const childNodeCenterY = HEIGHT / 2 + LINE * Math.sin(ANGLE * Math.PI / 180); return ( { setCord(null) }}> {selectedCord ? capitalize(selectedCord.infos?.name) : ''} {`${selectedChildNode ? selectedChildNode.infos?.name : ''}`} ); }; export default MiniTopo;