import { useEffect, useRef, useState } from 'react' import PropTypes from 'prop-types' import { List, ListItemText, Tooltip, Popover } from '@material-ui/core' import { makeStyles } from '@material-ui/core/styles' import './Helper/SchematicEditor.css' import { AddComponent } from './Helper/SideBar' const useStyles = makeStyles((theme) => ({ popupInfo: { margin: theme.spacing(1.5), padding: theme.spacing(1.5), border: '1px solid blue', borderRadius: '5px' } })) export default function SideComp ({ component }) { const classes = useStyles() const imageRef = useRef() const [anchorEl, setAnchorEl] = useState(null) const handleClick = (event) => { setAnchorEl(event.currentTarget) } const handleClose = () => { setAnchorEl(null) } const open = Boolean(anchorEl) const id = open ? 'simple-popover' : undefined useEffect(() => { // Function call to make components draggable AddComponent(component, imageRef.current) }, [component]) const link1 = process.env.REACT_APP_BLOCK_NAME + ' Name' const link2 = process.env.REACT_APP_CATEGORY_NAME const link3 = process.env.REACT_APP_CATEGORIES_NAME return (
{/* Display Image thumbnail in left side pane */} {component.name} {/* Popover to display component information on single click */} {link1}: {component.name} { component.categories.length === 1 && {link2}: {component.categories[0].name} } { component.categories.length > 1 && {link3}: {component.categories.map((c) =>
  • {c.name}
  • )}
    }
    ) } SideComp.propTypes = { component: PropTypes.object.isRequired }