import { Box } from "@radix-ui/themes"; import { useEffect, useRef } from "react"; import { embedPreviews } from "../../constants/embeds"; import { useEmbedStateCurry } from "../../stores/embedState/utilities"; interface PreviewWrapperProps { name: keyof typeof embedPreviews; naked?: boolean; } export function PreviewWrapper({ name, naked }: PreviewWrapperProps) { const { useEmbedState } = useEmbedStateCurry(); const width = useEmbedState("width"); const height = useEmbedState("height"); const Preview = embedPreviews[name]; const wrapper = useRef(null); useEffect(() => { if (!wrapper.current) return; wrapper.current.classList.remove("preview-container-animated"); void wrapper.current.offsetWidth; wrapper.current.classList.add("preview-container-animated"); }, [width, height]); if (naked) { return ( ); } return ( ); }