Skip to content

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

Python

Polish select-and-edit UI: purple theme, auto-focus, cleanup

Abi Rajad16879f6b65b
diff --git a/frontend/src/components/preview/PreviewComponent.tsx b/frontend/src/components/preview/PreviewComponent.tsx
index 176bef45..67a678b3 100644
--- a/frontend/src/components/preview/PreviewComponent.tsx
+++ b/frontend/src/components/preview/PreviewComponent.tsx
@@ -28,7 +28,6 @@ function PreviewComponent({
// Select and edit functionality
const [clickEvent, setClickEvent] = useState<MouseEvent | null>(null);
- const [scale, setScale] = useState(1);
const activeMode = viewMode ?? "fit";
const handleIframeClick = useCallback((event: MouseEvent) => {
setClickEvent(event);
@@ -91,7 +90,6 @@ function PreviewComponent({
: 1;
const iframeHeight = scaleValue > 0 ? viewportHeight / scaleValue : viewportHeight;
- setScale(scaleValue);
onScaleChange?.(scaleValue);
iframe.style.width = `${DESKTOP_VIEWPORT_WIDTH}px`;
iframe.style.height = `${iframeHeight}px`;
@@ -100,7 +98,6 @@ function PreviewComponent({
return;
}
- setScale(1);
onScaleChange?.(1);
iframe.style.width = `${MOBILE_VIEWPORT_WIDTH}px`;
iframe.style.height = `${viewportHeight}px`;
diff --git a/frontend/src/components/sidebar/Sidebar.tsx b/frontend/src/components/sidebar/Sidebar.tsx
index a98d6230..ab602070 100644
--- a/frontend/src/components/sidebar/Sidebar.tsx
+++ b/frontend/src/components/sidebar/Sidebar.tsx
@@ -206,6 +206,13 @@ function Sidebar({
}
}, [appState, isSelectedVariantComplete]);
+ // Focus the textarea when an element is selected in the preview
+ useEffect(() => {
+ if (selectedElement && textareaRef.current) {
+ textareaRef.current.focus();
+ }
+ }, [selectedElement]);
+
// Reset textarea height when instruction changes externally (e.g., cleared after submit)
useEffect(() => {
autoResize();
@@ -482,14 +489,14 @@ function Sidebar({
</button>
</div>
) : (
- <div className="flex items-center justify-between rounded-xl border border-gray-200 dark:border-zinc-700 bg-gray-50 dark:bg-zinc-900 px-3 py-2">
+ <div className="flex items-center justify-between rounded-xl border border-violet-200 dark:border-violet-700 bg-violet-50 dark:bg-violet-900/20 px-3 py-2">
<div className="flex items-center gap-2">
- <LuMousePointerClick className="w-3.5 h-3.5 text-gray-500 dark:text-gray-400 shrink-0" />
- <span className="text-sm text-gray-600 dark:text-gray-400">Click any element in the preview to edit it</span>
+ <LuMousePointerClick className="w-3.5 h-3.5 text-violet-500 dark:text-violet-400 shrink-0" />
+ <span className="text-sm font-medium text-violet-700 dark:text-violet-300">Click an element to edit it</span>
</div>
<button
onClick={toggleInSelectAndEditMode}
- className="shrink-0 ml-3 text-sm text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 transition-colors"
+ className="shrink-0 ml-3 text-sm text-violet-500 dark:text-violet-400 hover:text-violet-800 dark:hover:text-violet-200 transition-colors"
>
Exit
</button>
@@ -535,7 +542,7 @@ function Sidebar({
onClick={toggleInSelectAndEditMode}
className={`rounded-lg p-2 transition-colors ${
inSelectAndEditMode
- ? "bg-red-100 text-red-600 dark:bg-red-900/30 dark:text-red-400"
+ ? "bg-violet-100 text-violet-600 dark:bg-violet-900/30 dark:text-violet-400"
: "text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-300"
}`}
title={inSelectAndEditMode ? "Exit selection mode" : "Select an element in the preview to target your edit"}