diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index ba76b1e..437134b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,12 +1,13 @@ import { useState } from "react"; import ImageUpload from "./components/ImageUpload"; +import CodePreview from "./components/CodePreview"; function App() { const [referenceImages, setReferenceImages] = useState([]); return ( - <> -

Drag & Drop a Screenshot

+
+

Drag & Drop a Screenshot

{referenceImages.length > 0 && ( )} + + {referenceImages.length === 0 && ( <> )} - +
); } diff --git a/frontend/src/components/CodePreview.tsx b/frontend/src/components/CodePreview.tsx new file mode 100644 index 0000000..e906278 --- /dev/null +++ b/frontend/src/components/CodePreview.tsx @@ -0,0 +1,27 @@ +import { useRef, useEffect } from "react"; + +interface Props { + content: string; +} + +function CodePreview({ content }: Props) { + const scrollRef = useRef(null); + + useEffect(() => { + if (scrollRef.current) { + scrollRef.current.scrollLeft = scrollRef.current.scrollWidth; + } + }, [content]); + + return ( +
+ {content} +
+ ); +} + +export default CodePreview;