feat: recover embed code

This commit is contained in:
TrèsAbhi committed 2024-10-26 14:33:04 -05:00
1 parent cee082ab67
commit 9daab37ba1
16 files changed
+746

No files matched your search

@@ -0,0 +1,36 @@
import { Box } from '@radix-ui/themes';
import { useEffect, useRef } from 'react';
import { previews } from '../../../constants/embeds';
import { useEmbedStateCurry } from '../../../stores/embedState/utilities';
import * as styles from './index.css';
interface PreviewWrapperProps {
name: keyof typeof previews;
}
export function PreviewWrapper({ name }: PreviewWrapperProps) {
const { useState } = useEmbedStateCurry();
const width = useState('width');
const height = useState('height');
const Preview = previews[name];
const wrapper = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!wrapper.current) return;
wrapper.current.classList.remove(styles.animated);
void wrapper.current.offsetWidth;
wrapper.current.classList.add(styles.animated);
}, [width, height]);
return (
<Box
ref={wrapper}
className={styles.wrapper}
width={`${width}px`}
height={`${height}px`}
>
<Preview />
</Box>
);
}