From 67f710521d46fdae3a6d9456faa768efb03c5d7d Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Thu, 16 Nov 2023 11:56:54 -0500 Subject: [PATCH] support desktop and mobile preview --- frontend/src/App.tsx | 28 ++++++++++++++++++-------- frontend/src/components/CodeMirror.tsx | 2 +- frontend/src/components/Preview.tsx | 16 +++++++++++---- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 452e0be..c34d5cd 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -5,7 +5,13 @@ import Preview from "./components/Preview"; import { CodeGenerationParams, generateCode } from "./generateCode"; import Spinner from "./components/Spinner"; import classNames from "classnames"; -import { FaCode, FaDownload, FaEye, FaUndo } from "react-icons/fa"; +import { + FaCode, + FaDesktop, + FaDownload, + FaMobile, + FaUndo, +} from "react-icons/fa"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs"; @@ -83,7 +89,7 @@ function App() { } return ( -
+

Screenshot to Code

@@ -181,11 +187,14 @@ function App() { {(appState === "CODING" || appState === "CODE_READY") && (
- -
+ +
- - Preview + + Desktop + + + Mobile @@ -193,8 +202,11 @@ function App() {
- - + + + + + diff --git a/frontend/src/components/CodeMirror.tsx b/frontend/src/components/CodeMirror.tsx index 7c6d9df..3ba1c51 100644 --- a/frontend/src/components/CodeMirror.tsx +++ b/frontend/src/components/CodeMirror.tsx @@ -60,6 +60,6 @@ function CodeMirror({ code }: Props) { } }, [code]); - return
; + return
; } export default CodeMirror; diff --git a/frontend/src/components/Preview.tsx b/frontend/src/components/Preview.tsx index 4728a73..de0134f 100644 --- a/frontend/src/components/Preview.tsx +++ b/frontend/src/components/Preview.tsx @@ -1,19 +1,27 @@ +import classNames from "classnames"; import useThrottle from "../hooks/useThrottle"; interface Props { code: string; + device: "mobile" | "desktop"; } -function Preview({ code }: Props) { +function Preview({ code, device }: Props) { const throttledCode = useThrottle(code, 200); return ( -
+
);