Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

clean up

Abi Raja56b9e8bf5052
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 4bb07280..6455999d 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -29,7 +29,7 @@ import { OnboardingNote } from "./components/OnboardingNote";
import { usePersistedState } from "./hooks/usePersistedState";
import { UrlInputSection } from "./components/UrlInputSection";
import TermsOfServiceDialog from "./components/TermsOfServiceDialog";
-import html2canvas from 'html2canvas';
+import html2canvas from "html2canvas";
import { USER_CLOSE_WEB_SOCKET_CODE } from "./constants";
function App() {
@@ -53,15 +53,17 @@ function App() {
const wsRef = useRef<WebSocket>(null);
const takeScreenshot = async (): Promise<string> => {
- const iframeElement = document.querySelector('#preview-desktop') as HTMLIFrameElement;
+ const iframeElement = document.querySelector(
+ "#preview-desktop"
+ ) as HTMLIFrameElement;
if (!iframeElement?.contentWindow?.document.body) {
- return '';
+ return "";
}
const canvas = await html2canvas(iframeElement.contentWindow.document.body);
- const png = canvas.toDataURL('image/png');
+ const png = canvas.toDataURL("image/png");
return png;
- }
+ };
const downloadCode = () => {
// Create a blob from the generated code
@@ -91,8 +93,8 @@ function App() {
const stop = () => {
wsRef.current?.close?.(USER_CLOSE_WEB_SOCKET_CODE);
// make sure stop can correct the state even if the websocket is already closed
- setAppState(AppStatus.CODE_READY);
- }
+ setAppState(AppState.CODE_READY);
+ };
function doGenerateCode(params: CodeGenerationParams) {
setExecutionConsole([]);
@@ -204,13 +206,11 @@ function App() {
{appState === AppState.CODE_READY && (
<div>
<div className="grid w-full gap-2">
- <div className="flex justify-between items-center gap-x-2">
- <div className="font-500">
- Auto Image Comparison
- </div>
+ <div className="flex justify-between items-center gap-x-2">
+ <div className="font-500">Auto Image Comparison</div>
<Switch
- checked={isImgCompare}
- onCheckedChange={setIsImgCompare}
+ checked={isImgCompare}
+ onCheckedChange={setIsImgCompare}
/>
</div>
<Textarea
diff --git a/frontend/src/generateCode.ts b/frontend/src/generateCode.ts
index 893164e6..6dbe547c 100644
--- a/frontend/src/generateCode.ts
+++ b/frontend/src/generateCode.ts
@@ -53,7 +53,6 @@ export function generateCode(
} else if (event.code !== 1000) {
console.error("WebSocket error code", event);
toast.error(ERROR_MESSAGE);
- onComplete();
}
onComplete();
});