"use client"; import "@/app/globals.css"; import { CSSProperties, useEffect, useState } from "react"; export default function Preview(props: PreviewPropsType) { const {x, y, width, height} = props; const [style, setStyle] = useState({ top: 0, left: 0, width: 0, height: 0, }); useEffect(() => { setStyle({ top: y, left: x, width: width, height: height, // visibility: width * height === 0 ? 'hidden' : 'none' }); }, [props.height, props.width, props.x, props.y]) return (
{width * height === 0 || `${width} * ${height}`} {x * y === 0 || `${x}, ${y}`}
); } export type PreviewPropsType = { x: number; y: number; width: number; height: number; };