Skip to content

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

Python

Improve preview chat layout

Abi Rajaf1ba57ac27cb
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index b2f21d53..022b5800 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -89,6 +89,7 @@ function App() {
const lastToolEventIdRef = useRef<Record<number, string>>({});
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
+ const [mobilePane, setMobilePane] = useState<"preview" | "chat">("preview");
const showSelectAndEditFeature =
settings.generatedCodeConfig === Stack.HTML_TAILWIND ||
settings.generatedCodeConfig === Stack.HTML_CSS;
@@ -530,9 +531,18 @@ function App() {
appState === AppState.CODING ||
appState === AppState.CODE_READY ||
isHistoryOpen;
+ const isCodingOrReady =
+ appState === AppState.CODING || appState === AppState.CODE_READY;
+ const showMobileChatPane = showContentPanel && mobilePane === "chat";
return (
- <div className={`dark:bg-black dark:text-white ${appState === AppState.CODING || appState === AppState.CODE_READY ? "h-screen overflow-hidden" : ""}`}>
+ <div
+ className={`dark:bg-black dark:text-white ${
+ appState === AppState.CODING || appState === AppState.CODE_READY
+ ? "flex h-dvh flex-col overflow-hidden lg:block lg:h-screen"
+ : "min-h-screen"
+ }`}
+ >
{IS_RUNNING_ON_CLOUD && <PicoBadge />}
{IS_RUNNING_ON_CLOUD && (
<TermsOfServiceDialog
@@ -542,27 +552,73 @@ function App() {
)}
{/* Icon strip - always visible */}
- <div className="lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-16 lg:flex-col">
+ <div
+ className="sticky top-0 z-50 lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-16 lg:flex-col"
+ >
<IconStrip
isHistoryOpen={isHistoryOpen}
isEditorOpen={!isHistoryOpen}
- showHistory={appState === AppState.CODING || appState === AppState.CODE_READY}
- showEditor={appState === AppState.CODING || appState === AppState.CODE_READY}
- onToggleHistory={() => setIsHistoryOpen((prev) => !prev)}
- onToggleEditor={() => setIsHistoryOpen(false)}
- onLogoClick={() => setIsHistoryOpen(false)}
+ showHistory={isCodingOrReady}
+ showEditor={isCodingOrReady}
+ onToggleHistory={() => {
+ setIsHistoryOpen((prev) => !prev);
+ setMobilePane("chat");
+ }}
+ onToggleEditor={() => {
+ setIsHistoryOpen(false);
+ setMobilePane("preview");
+ }}
+ onLogoClick={() => {
+ setIsHistoryOpen(false);
+ setMobilePane("preview");
+ }}
onNewProject={() => {
reset();
setIsHistoryOpen(false);
+ setMobilePane("preview");
}}
settings={settings}
setSettings={setSettings}
/>
</div>
+ {isCodingOrReady && (
+ <div className="border-b border-gray-200 bg-white px-4 py-2 dark:border-zinc-800 dark:bg-zinc-950 lg:hidden">
+ <div className="grid grid-cols-2 rounded-xl bg-gray-100 p-1 dark:bg-zinc-800">
+ <button
+ onClick={() => {
+ setIsHistoryOpen(false);
+ setMobilePane("preview");
+ }}
+ className={`rounded-lg px-3 py-2 text-sm font-medium transition-colors ${
+ mobilePane === "preview"
+ ? "bg-white text-gray-900 shadow-sm dark:bg-zinc-700 dark:text-white"
+ : "text-gray-500 dark:text-zinc-400"
+ }`}
+ >
+ Preview
+ </button>
+ <button
+ onClick={() => setMobilePane("chat")}
+ className={`rounded-lg px-3 py-2 text-sm font-medium transition-colors ${
+ mobilePane === "chat"
+ ? "bg-white text-gray-900 shadow-sm dark:bg-zinc-700 dark:text-white"
+ : "text-gray-500 dark:text-zinc-400"
+ }`}
+ >
+ Chat
+ </button>
+ </div>
+ </div>
+ )}
+
{/* Content panel - shows sidebar, history, or editor */}
{showContentPanel && (
- <div className="lg:fixed lg:inset-y-0 lg:left-16 lg:z-40 lg:flex lg:w-[calc(28rem-4rem)] lg:flex-col border-r border-gray-200 bg-white dark:bg-zinc-950 dark:text-white">
+ <div
+ className={`border-b border-gray-200 bg-white dark:bg-zinc-950 dark:text-white lg:fixed lg:inset-y-0 lg:left-16 lg:z-40 lg:flex lg:w-[calc(28rem-4rem)] lg:flex-col lg:border-b-0 lg:border-r ${
+ showMobileChatPane ? "block" : "hidden lg:flex"
+ }`}
+ >
{isHistoryOpen ? (
<div className="flex-1 overflow-y-auto sidebar-scrollbar-stable px-4">
<div className="mt-3">
@@ -604,7 +660,11 @@ function App() {
)}
<main
- className={`${showContentPanel ? "lg:pl-[28rem] h-full flex flex-col" : "lg:pl-16"}`}
+ className={`${
+ showContentPanel
+ ? "flex flex-1 min-h-0 flex-col lg:h-full lg:pl-[28rem]"
+ : "lg:pl-16"
+ } ${isCodingOrReady && mobilePane === "chat" ? "hidden lg:flex" : ""}`}
>
{appState === AppState.INITIAL && (
<StartPane
@@ -616,8 +676,15 @@ function App() {
/>
)}
- {(appState === AppState.CODING || appState === AppState.CODE_READY) && (
- <PreviewPane doUpdate={doUpdate} settings={settings} onOpenVersions={() => setIsHistoryOpen(true)} />
+ {isCodingOrReady && (
+ <PreviewPane
+ doUpdate={doUpdate}
+ settings={settings}
+ onOpenVersions={() => {
+ setIsHistoryOpen(true);
+ setMobilePane("chat");
+ }}
+ />
)}
</main>
</div>
diff --git a/frontend/src/components/preview/PreviewPane.tsx b/frontend/src/components/preview/PreviewPane.tsx
index 6b6be6ed..a75e374a 100644
--- a/frontend/src/components/preview/PreviewPane.tsx
+++ b/frontend/src/components/preview/PreviewPane.tsx
@@ -1,11 +1,17 @@
import { Tabs, TabsList, TabsTrigger, TabsContent } from "../ui/tabs";
import {
- FaDownload,
FaDesktop,
FaMobile,
FaCode,
} from "react-icons/fa";
-import { LuChevronLeft, LuChevronRight, LuExternalLink, LuImage, LuRefreshCw } from "react-icons/lu";
+import {
+ LuChevronLeft,
+ LuChevronRight,
+ LuExternalLink,
+ LuImage,
+ LuRefreshCw,
+ LuDownload,
+} from "react-icons/lu";
import { useMemo, useState } from "react";
import { AppState, Settings } from "../../types";
import CodeTab from "./CodeTab";
@@ -121,7 +127,7 @@ function PreviewPane({ doUpdate, settings, onOpenVersions }: Props) {
className="h-9 w-9"
data-testid="download-code"
>
- <FaDownload />
+ <LuDownload />
</Button>
)}
<Button
diff --git a/frontend/src/components/sidebar/IconStrip.tsx b/frontend/src/components/sidebar/IconStrip.tsx
index 3c8b2688..a037d71a 100644
--- a/frontend/src/components/sidebar/IconStrip.tsx
+++ b/frontend/src/components/sidebar/IconStrip.tsx
@@ -28,11 +28,11 @@ function IconStrip({
setSettings,
}: IconStripProps) {
return (
- <div className="flex h-full flex-col items-center w-16 py-4 gap-y-3 border-r border-gray-200 bg-gray-50 dark:bg-zinc-900 dark:border-zinc-800">
+ <div className="flex w-full items-center justify-between border-b border-gray-200 bg-gray-50 px-2 py-2 dark:border-zinc-800 dark:bg-zinc-900 lg:h-full lg:w-16 lg:flex-col lg:items-center lg:gap-y-3 lg:border-b-0 lg:border-r lg:px-0 lg:py-4">
{/* Logo */}
<button
onClick={onLogoClick}
- className="mb-2 rounded-lg p-1 transition-colors hover:bg-gray-200/70 dark:hover:bg-zinc-800"
+ className="rounded-lg p-2 transition-colors hover:bg-gray-200/70 dark:hover:bg-zinc-800 lg:mb-2 lg:p-1"
>
<img
src="/favicon/main.png"
@@ -41,47 +41,51 @@ function IconStrip({
/>
</button>
- {/* Editor */}
- {showEditor && (
- <button
- onClick={onToggleEditor}
- className={`flex flex-col items-center gap-1 rounded-lg px-2 py-1.5 transition-colors ${
- isEditorOpen
- ? "text-gray-900 dark:text-white"
- : "text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300"
- }`}
- >
- <LuCode className="w-[18px] h-[18px]" />
- <span className="text-[10px] leading-none">Editor</span>
- </button>
- )}
+ <div className="flex items-center gap-1 lg:flex-col lg:gap-0 lg:contents">
+ {/* Editor */}
+ {showEditor && (
+ <button
+ onClick={onToggleEditor}
+ className={`flex items-center justify-center rounded-lg p-2 transition-colors lg:flex-col lg:gap-1 lg:px-2 lg:py-1.5 ${
+ isEditorOpen
+ ? "text-gray-900 dark:text-white"
+ : "text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300"
+ }`}
+ title="Editor"
+ >
+ <LuCode className="w-[18px] h-[18px]" />
+ <span className="hidden text-[10px] leading-none lg:block">Editor</span>
+ </button>
+ )}
+
+ {/* Versions */}
+ {showHistory && (
+ <button
+ onClick={onToggleHistory}
+ className={`flex items-center justify-center rounded-lg p-2 transition-colors lg:flex-col lg:gap-1 lg:px-2 lg:py-1.5 ${
+ isHistoryOpen
+ ? "text-gray-900 dark:text-white"
+ : "text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300"
+ }`}
+ title="Versions"
+ >
+ <LuClock className="w-[18px] h-[18px]" />
+ <span className="hidden text-[10px] leading-none lg:block">Versions</span>
+ </button>
+ )}
- {/* Versions */}
- {showHistory && (
<button
- onClick={onToggleHistory}
- className={`flex flex-col items-center gap-1 rounded-lg px-2 py-1.5 transition-colors ${
- isHistoryOpen
- ? "text-gray-900 dark:text-white"
- : "text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300"
- }`}
+ onClick={onNewProject}
+ className="flex items-center justify-center rounded-lg p-2 transition-colors text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 lg:flex-col lg:gap-1 lg:px-2 lg:py-1.5"
+ title="Start a new project"
>
- <LuClock className="w-[18px] h-[18px]" />
- <span className="text-[10px] leading-none">Versions</span>
+ <LuPlus className="w-[18px] h-[18px]" />
+ <span className="hidden text-[10px] leading-none lg:block">New</span>
</button>
- )}
-
- <button
- onClick={onNewProject}
- className="flex flex-col items-center gap-1 rounded-lg px-2 py-1.5 transition-colors text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300"
- title="Start a new project"
- >
- <LuPlus className="w-[18px] h-[18px]" />
- <span className="text-[10px] leading-none">New</span>
- </button>
+ </div>
{/* Spacer pushes settings to bottom */}
- <div className="flex-1" />
+ <div className="hidden flex-1 lg:block" />
{/* Settings */}
<SettingsDialog
@@ -89,10 +93,11 @@ function IconStrip({
setSettings={setSettings}
trigger={
<button
- className="flex flex-col items-center gap-1 rounded-lg px-2 py-1.5 transition-colors text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300"
+ className="flex items-center justify-center rounded-lg p-2 transition-colors text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 lg:flex-col lg:gap-1 lg:px-2 lg:py-1.5"
+ title="Settings"
>
<LuSettings className="w-[18px] h-[18px]" />
- <span className="text-[10px] leading-none">Settings</span>
+ <span className="hidden text-[10px] leading-none lg:block">Settings</span>
</button>
}
/>