Skip to content

end to end app store screenshot creation using AI

fix: render image overlays through Movable and skip empty placeholders on export

Parth Jadhavcb5c19335adb
diff --git a/skills/app-store-screenshots/template/src/components/editor/image-element-canvas.tsx b/skills/app-store-screenshots/template/src/components/editor/image-element-canvas.tsx
index 92b6adc..a3388bb 100644
--- a/skills/app-store-screenshots/template/src/components/editor/image-element-canvas.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/image-element-canvas.tsx
@@ -1,87 +1,46 @@
"use client";
import * as React from "react";
import { ImagePlus } from "lucide-react";
-import { Rnd } from "react-rnd";
import { createImageMask } from "@/components/editor/create-image-mask";
import { img } from "@/lib/image-cache";
-import type { ElementTransform, ImageElement } from "@/lib/types";
+import type { ImageElement } from "@/lib/types";
type Props = {
element: ImageElement;
- rect: ElementTransform;
editable?: boolean;
- previewScale: number;
- selected: boolean;
- allowOverflow: boolean;
- onChange: (transform: ElementTransform) => void;
- onSelect: () => void;
};
-export function ImageElementCanvas({
- element,
- rect,
- editable,
- previewScale,
- selected,
- allowOverflow,
- onChange,
- onSelect,
-}: Props) {
- const rotation = rect.rotation ?? 0;
- const zIndex = rect.zIndex ?? 5;
+// Image overlay content. Placement, rotation, and drag/resize handles come from
+// the shared Movable wrapper in slide-canvas so overlays behave like text.
+export function ImageElementCanvas({ element, editable }: Props) {
const source = img(element.src);
const maskImage = createImageMask(element.fade);
+ if (!source) {
+ // The empty placeholder is an editing affordance only; never export it.
+ if (!editable) return null;
+ return (
+ <div className="flex h-full w-full items-center justify-center border border-dashed border-current/40 bg-black/10 text-current/70">
+ <ImagePlus className="h-6 w-6" aria-hidden />
+ <span className="sr-only">Pick an image in the inspector</span>
+ </div>
+ );
+ }
+
return (
- <Rnd
- size={{ width: rect.width, height: rect.height }}
- position={{ x: rect.x, y: rect.y }}
- scale={previewScale}
- bounds={allowOverflow ? undefined : "parent"}
- disableDragging={!editable}
- enableResizing={editable}
- onMouseDown={(event) => {
- event.stopPropagation();
- onSelect();
+ // eslint-disable-next-line @next/next/no-img-element
+ <img
+ src={source}
+ alt=""
+ draggable={false}
+ style={{
+ width: "100%",
+ height: "100%",
+ display: "block",
+ objectFit: element.fit || "cover",
+ maskImage,
+ WebkitMaskImage: maskImage,
}}
- onDragStop={(_, position) => onChange({ ...rect, x: position.x, y: position.y, rotation, zIndex })}
- onResizeStop={(_, __, ref, ___, position) =>
- onChange({
- ...rect,
- x: position.x,
- y: position.y,
- width: Math.max(1, ref.offsetWidth),
- height: Math.max(1, ref.offsetHeight),
- rotation,
- zIndex,
- })
- }
- className={editable ? `rnd-editable${selected ? " rnd-selected" : ""}` : ""}
- style={{ zIndex }}
- >
- <div style={{ width: "100%", height: "100%", transform: `rotate(${rotation}deg)` }}>
- {source ? (
- // eslint-disable-next-line @next/next/no-img-element
- <img
- src={source}
- alt=""
- draggable={false}
- style={{
- width: "100%",
- height: "100%",
- display: "block",
- objectFit: element.fit || "cover",
- maskImage,
- WebkitMaskImage: maskImage,
- }}
- />
- ) : (
- <div className="flex h-full w-full items-center justify-center border border-dashed border-current/40 bg-black/10 text-current/70">
- <ImagePlus className="h-6 w-6" aria-hidden />
- <span className="sr-only">Pick an image in the inspector</span>
- </div>
- )}
- </div>
- </Rnd>
+ />
);
}
diff --git a/skills/app-store-screenshots/template/src/components/editor/slide-canvas.tsx b/skills/app-store-screenshots/template/src/components/editor/slide-canvas.tsx
index 6c58105..52c2b45 100644
--- a/skills/app-store-screenshots/template/src/components/editor/slide-canvas.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/slide-canvas.tsx
@@ -1144,22 +1144,31 @@ function SlideElements({
const rotation = rect.rotation ?? 0;
const zIndex = rect.zIndex ?? 5 + index;
return (
- <ImageElementCanvas
+ <Movable
key={imageElement.id}
- element={imageElement}
rect={toGlobal(rect)}
+ boundsW={boundsW}
+ boundsH={boundsH}
editable={editable}
previewScale={previewScale}
- selected={selectedElementId === elementId}
- allowOverflow={allowCrossScreen}
- onChange={(transform) =>
+ rotation={rotation}
+ onChange={(t) =>
edit?.onElementChange?.(
elementId,
- toLocal({ ...transform, rotation: transform.rotation ?? rotation, zIndex: transform.zIndex ?? zIndex }),
+ toLocal({
+ ...t,
+ rotation: t.rotation ?? rotation,
+ zIndex: t.zIndex ?? zIndex,
+ }),
)
}
+ zIndex={zIndex}
+ selected={selectedElementId === elementId}
onSelect={() => edit?.onSelectElement?.(elementId)}
- />
+ allowOverflow={allowCrossScreen}
+ >
+ <ImageElementCanvas element={imageElement} editable={editable} />
+ </Movable>
);
}