make layout better
This commit is contained in:
parent
51c7334c0e
commit
c4b99c125e
@ -21,6 +21,14 @@ function App() {
|
|||||||
setBlobUrl(url);
|
setBlobUrl(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const reset = () => {
|
||||||
|
setAppState("INITIAL");
|
||||||
|
setGeneratedCode("");
|
||||||
|
setReferenceImages([]);
|
||||||
|
setExecutionConsole([]);
|
||||||
|
setBlobUrl("");
|
||||||
|
};
|
||||||
|
|
||||||
function startCodeGeneration(referenceImages: string[]) {
|
function startCodeGeneration(referenceImages: string[]) {
|
||||||
setAppState("CODING");
|
setAppState("CODING");
|
||||||
setReferenceImages(referenceImages);
|
setReferenceImages(referenceImages);
|
||||||
@ -42,79 +50,91 @@ function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto mt-6 max-w-[1000px]">
|
<div className="mt-6">
|
||||||
<h1 className="text-4xl mb-2 text-center">Screenshot to Code</h1>
|
<div className="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-96 lg:flex-col">
|
||||||
<h1 className="text-base text-gray-500 mb-2 text-center">
|
<div className="flex grow flex-col gap-y-2 overflow-y-auto border-r border-gray-200 bg-white px-6">
|
||||||
drag & drop a screenshot below
|
<h1 className="text-2xl mt-10">Screenshot to Code</h1>
|
||||||
</h1>
|
<h2 className="text-sm text-gray-500 mb-2">
|
||||||
|
Drag & drop a screenshot to get started.
|
||||||
|
</h2>
|
||||||
|
|
||||||
{appState === "INITIAL" && (
|
{(appState === "CODING" || appState === "CODE_READY") && (
|
||||||
<>
|
|
||||||
<ImageUpload setReferenceImages={startCodeGeneration} />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{(appState === "CODING" || appState === "CODE_READY") && (
|
|
||||||
<>
|
|
||||||
<div className="flex gap-x-2 justify-around">
|
|
||||||
<div
|
|
||||||
className={classNames({
|
|
||||||
"scanning relative": appState === "CODING",
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
className="w-[300px]"
|
|
||||||
src={referenceImages[0]}
|
|
||||||
alt="Reference"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="bg-gray-400 px-4 py-2 rounded text-sm hidden">
|
|
||||||
<h2 className="text-lg mb-4 border-b border-gray-800">Console</h2>
|
|
||||||
{executionConsole.map((line, index) => (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
className="border-b border-gray-400 mb-2 text-gray-600 font-mono"
|
|
||||||
>
|
|
||||||
{line}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/* Show code preview only when coding */}
|
|
||||||
{appState === "CODING" && (
|
|
||||||
<>
|
<>
|
||||||
<div className="flex items-center gap-x-1">
|
{/* Show code preview only when coding */}
|
||||||
<Spinner />
|
{appState === "CODING" && (
|
||||||
{executionConsole.slice(-1)[0]}
|
<div className="flex flex-col">
|
||||||
|
<div className="flex items-center gap-x-1">
|
||||||
|
<Spinner />
|
||||||
|
{executionConsole.slice(-1)[0]}
|
||||||
|
</div>
|
||||||
|
<CodePreview code={generatedCode} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="flex gap-x-2">
|
||||||
|
<div
|
||||||
|
className={classNames({
|
||||||
|
"scanning relative": appState === "CODING",
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
className="w-[340px]"
|
||||||
|
src={referenceImages[0]}
|
||||||
|
alt="Reference"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="bg-gray-400 px-4 py-2 rounded text-sm hidden">
|
||||||
|
<h2 className="text-lg mb-4 border-b border-gray-800">
|
||||||
|
Console
|
||||||
|
</h2>
|
||||||
|
{executionConsole.map((line, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className="border-b border-gray-400 mb-2 text-gray-600 font-mono"
|
||||||
|
>
|
||||||
|
{line}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<CodePreview code={generatedCode} />
|
|
||||||
|
{appState === "CODE_READY" && (
|
||||||
|
<div className="flex items-center gap-x-2 mb-4">
|
||||||
|
<a
|
||||||
|
className="bg-button/70 hover:bg-highlight text-black
|
||||||
|
py-2 px-4 rounded transition duration-300"
|
||||||
|
onClick={createBlobUrl}
|
||||||
|
href={blobUrl}
|
||||||
|
download="index.html"
|
||||||
|
>
|
||||||
|
Download
|
||||||
|
</a>
|
||||||
|
<button
|
||||||
|
className="bg-button/70 hover:bg-highlight text-black
|
||||||
|
py-2 px-4 rounded transition duration-300"
|
||||||
|
onClick={reset}
|
||||||
|
>
|
||||||
|
Reset
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{appState === "CODE_READY" && (
|
</div>
|
||||||
<div className="flex items-center gap-x-2 mb-4 justify-end">
|
</div>
|
||||||
<a
|
|
||||||
className="bg-button/70 hover:bg-highlight text-black
|
<main className="py-2 lg:pl-96">
|
||||||
py-2 px-4 rounded transition duration-300"
|
{appState === "INITIAL" && (
|
||||||
onClick={createBlobUrl}
|
<>
|
||||||
href={blobUrl}
|
<ImageUpload setReferenceImages={startCodeGeneration} />
|
||||||
download="index.html"
|
</>
|
||||||
>
|
)}
|
||||||
Download code
|
|
||||||
</a>
|
{(appState === "CODING" || appState === "CODE_READY") && (
|
||||||
<a
|
<div className="ml-4">
|
||||||
className="bg-button/70 hover:bg-highlight text-black
|
<Preview code={generatedCode} />
|
||||||
py-2 px-4 rounded transition duration-300"
|
</div>
|
||||||
onClick={createBlobUrl}
|
)}
|
||||||
href={blobUrl}
|
</main>
|
||||||
download="index.html"
|
|
||||||
>
|
|
||||||
Reset
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<Preview code={generatedCode} />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { toast } from "react-hot-toast";
|
|||||||
|
|
||||||
const baseStyle = {
|
const baseStyle = {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
width: "50%",
|
width: "80%",
|
||||||
margin: "0 auto",
|
margin: "0 auto",
|
||||||
minHeight: "400px",
|
minHeight: "400px",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
|||||||
@ -28,6 +28,6 @@ body {
|
|||||||
transform: translateX(0px);
|
transform: translateX(0px);
|
||||||
}
|
}
|
||||||
50% {
|
50% {
|
||||||
transform: translateX(300px);
|
transform: translateX(340px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user