Skip to content

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

Python

Full-viewport preview: remove chrome, fill iframe, distinct topbar

Abi Rajabda83e6b1e4b
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 5e5e176a..a00dfeae 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -532,7 +532,7 @@ function App() {
isHistoryOpen;
return (
- <div className="mt-2 dark:bg-black dark:text-white">
+ <div className={`dark:bg-black dark:text-white ${appState === AppState.CODING || appState === AppState.CODE_READY ? "h-screen overflow-hidden" : ""}`}>
{IS_RUNNING_ON_CLOUD && <PicoBadge />}
{IS_RUNNING_ON_CLOUD && (
<TermsOfServiceDialog
@@ -599,7 +599,7 @@ function App() {
)}
<main
- className={`py-2 ${showContentPanel ? "lg:pl-[28rem]" : "lg:pl-16"}`}
+ className={`${showContentPanel ? "lg:pl-[28rem] h-full flex flex-col" : "lg:pl-16"}`}
>
{appState === AppState.INITIAL && (
<StartPane
diff --git a/frontend/src/components/preview/PreviewComponent.tsx b/frontend/src/components/preview/PreviewComponent.tsx
index 80591254..c4a416e8 100644
--- a/frontend/src/components/preview/PreviewComponent.tsx
+++ b/frontend/src/components/preview/PreviewComponent.tsx
@@ -23,28 +23,37 @@ function PreviewComponent({ code, device, doUpdate }: Props) {
setClickEvent(event);
}, []);
- // Add scaling logic
+ // Add scaling logic (only for mobile - desktop fills the space)
useEffect(() => {
+ if (device === "desktop") {
+ const iframe = iframeRef.current;
+ if (iframe) {
+ iframe.style.transform = "";
+ iframe.style.transformOrigin = "";
+ }
+ setScale(1);
+ return;
+ }
+
const updateScale = () => {
const wrapper = wrapperRef.current;
const iframe = iframeRef.current;
if (!wrapper || !iframe) return;
const viewportWidth = wrapper.clientWidth;
- const baseWidth = device === "desktop" ? 1440 : 375;
- const scaleValue = Math.min(1, viewportWidth / baseWidth);
+ const viewportHeight = wrapper.clientHeight;
+ const baseWidth = 375;
+ const baseHeight = 812;
+ const scaleValue = Math.min(1, viewportWidth / baseWidth, viewportHeight / baseHeight);
setScale(scaleValue);
iframe.style.transform = `scale(${scaleValue})`;
iframe.style.transformOrigin = "top left";
- // Adjust wrapper height to account for scaling
- wrapper.style.height = `${iframe.offsetHeight * scaleValue}px`;
};
updateScale();
- // Add event listener for window resize
window.addEventListener("resize", updateScale);
return () => window.removeEventListener("resize", updateScale);
}, [device]);
@@ -79,19 +88,18 @@ function PreviewComponent({ code, device, doUpdate }: Props) {
}, [throttledCode]);
return (
- <div className="flex justify-center mr-4">
+ <div className={`flex-1 min-h-0 relative overflow-hidden ${device === "mobile" ? "flex justify-center bg-gray-100 dark:bg-zinc-900" : ""}`}>
<div
ref={wrapperRef}
- className="overflow-y-auto overflow-x-hidden w-full"
+ className="w-full h-full"
>
<iframe
id={`preview-${device}`}
ref={iframeRef}
title="Preview"
className={classNames(
- "border-[4px] border-black rounded-[20px] shadow-lg mx-auto",
{
- "w-[1440px] h-[900px]": device === "desktop",
+ "w-full h-full": device === "desktop",
"w-[375px] h-[812px]": device === "mobile",
}
)}
diff --git a/frontend/src/components/preview/PreviewPane.tsx b/frontend/src/components/preview/PreviewPane.tsx
index db9952d5..67d8ab0c 100644
--- a/frontend/src/components/preview/PreviewPane.tsx
+++ b/frontend/src/components/preview/PreviewPane.tsx
@@ -48,15 +48,15 @@ function PreviewPane({ doUpdate, reset, settings }: Props) {
: currentCode;
return (
- <div className="ml-4">
- <Tabs defaultValue="desktop">
- <div className="flex justify-between mr-8 mb-4">
+ <div className="flex-1 flex flex-col min-h-0">
+ <Tabs defaultValue="desktop" className="flex-1 flex flex-col min-h-0">
+ <div className="flex items-center justify-between px-4 py-2 shrink-0 border-b border-gray-200 dark:border-zinc-800 bg-white dark:bg-zinc-950">
<div className="flex items-center gap-x-2">
{appState === AppState.CODE_READY && (
<>
<Button
onClick={reset}
- className="flex items-center ml-4 gap-x-2 dark:text-white dark:bg-gray-700"
+ className="flex items-center gap-x-2 dark:text-white dark:bg-gray-700"
>
<FaUndo />
Reset
@@ -64,7 +64,7 @@ function PreviewPane({ doUpdate, reset, settings }: Props) {
<Button
onClick={() => downloadCode(previewCode)}
variant="secondary"
- className="flex items-center gap-x-2 mr-4 dark:text-white dark:bg-gray-700 download-btn"
+ className="flex items-center gap-x-2 dark:text-white dark:bg-gray-700 download-btn"
data-testid="download-code"
>
<FaDownload /> Download Code
@@ -116,21 +116,21 @@ function PreviewPane({ doUpdate, reset, settings }: Props) {
</Button>
</div>
</div>
- <TabsContent value="desktop">
+ <TabsContent value="desktop" className="flex-1 min-h-0 mt-0 data-[state=active]:flex data-[state=active]:flex-col">
<PreviewComponent
code={previewCode}
device="desktop"
doUpdate={doUpdate}
/>
</TabsContent>
- <TabsContent value="mobile">
+ <TabsContent value="mobile" className="flex-1 min-h-0 mt-0 data-[state=active]:flex data-[state=active]:flex-col">
<PreviewComponent
code={previewCode}
device="mobile"
doUpdate={doUpdate}
/>
</TabsContent>
- <TabsContent value="code">
+ <TabsContent value="code" className="flex-1 min-h-0 mt-0 overflow-auto">
<CodeTab
code={previewCode}
setCode={() => {}}
@@ -138,7 +138,7 @@ function PreviewPane({ doUpdate, reset, settings }: Props) {
/>
</TabsContent>
{referenceImages.length > 0 && (
- <TabsContent value="reference">
+ <TabsContent value="reference" className="flex-1 min-h-0 mt-0 overflow-auto">
<div className="flex flex-col items-center gap-4 p-4">
{inputMode === "video" ? (
<video
diff --git a/frontend/src/components/sidebar/Sidebar.tsx b/frontend/src/components/sidebar/Sidebar.tsx
index b27e6a48..8bdc90d4 100644
--- a/frontend/src/components/sidebar/Sidebar.tsx
+++ b/frontend/src/components/sidebar/Sidebar.tsx
@@ -116,8 +116,7 @@ function Sidebar({
return (
<div className="flex flex-col h-full">
{/* Scrollable content */}
- <div className="flex-1 min-h-0 overflow-y-auto sidebar-scrollbar-stable px-6 pt-4 flex flex-col">
- <div className="mt-auto" />
+ <div className="flex-1 min-h-0 overflow-y-auto sidebar-scrollbar-stable px-6 pt-4">
<AgentActivity />
{/* Regenerate button for first generation */}
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 5469bc49..d9b3de5c 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -154,7 +154,10 @@
* {
@apply border-border;
}
+ html, body, #root {
+ @apply h-full;
+ }
body {
- @apply bg-background text-foreground;
+ @apply bg-background text-foreground m-0;
}
}