Skip to content

end to end app store screenshot creation using AI

feat: add richer screenshot editor controls

DQa5e36de3dd97
diff --git a/skills/app-store-screenshots/SKILL.md b/skills/app-store-screenshots/SKILL.md
index a35a86f..a31ca36 100644
--- a/skills/app-store-screenshots/SKILL.md
+++ b/skills/app-store-screenshots/SKILL.md
@@ -18,6 +18,9 @@ Scaffold a pre-built Next.js + ShadCN editor that lets the user design and expor
- One-click bulk PNG export at every Apple/Google-required resolution via `html-to-image`
- Light/dark variant toggle per slide, a toolbar theme picker (one palette preset per named style), locale select
- A **Copy ideas** menu next to the headline field with formulas for hero, differentiator, feature, proof, and closer slides
+- Per-slide custom background colors, a live font picker, and importing licensed WOFF2/WOFF/TTF/OTF fonts
+- Image overlay elements with drag/resize/rotation/layering controls and directional edge fades
+- Toolbar Undo/Redo with 25-step in-session history
- Guided in-place migration for older projects created by this skill; passive and explicit migrations keep legacy decks isolated until the user intentionally opts into connected canvas
Supported devices out of the box:
diff --git a/skills/app-store-screenshots/template/README.md b/skills/app-store-screenshots/template/README.md
index c530646..1caf84c 100644
--- a/skills/app-store-screenshots/template/README.md
+++ b/skills/app-store-screenshots/template/README.md
@@ -13,6 +13,9 @@ bun dev # http://localhost:3000
- **Connected canvas editor** (`src/components/editor/`) — every screen sits on one horizontal canvas, so phones, captions, and other elements can be dragged across screen boundaries and exported as split crops when Connected mode is enabled.
- **Screen controls** — drag-to-reorder screens, click-to-edit text, screenshot drop targets, per-screen layout switcher, dark/light toggle.
+- **Image overlays** — add PNG/JPG elements, then upload or replace them, drag, resize, rotate, layer, crop, and apply a one-sided edge fade. See [Image Elements](docs/image-elements.md).
+- **Edit history** — undo or redo up to 25 recent changes from the toolbar or keyboard. See [Edit History](docs/edit-history.md).
+- **Live themes, fonts, and backgrounds** — change the deck theme or font live; set each slide to its theme background, alternate, or custom color. Fonts can be imported from WOFF2, WOFF, TTF, or OTF files. See [Themes](docs/themes.md), [Screenshot Fonts](docs/screenshot-fonts.md), and [Background Controls](docs/background-controls.md).
- **Device frames** (`src/components/editor/device-frames.tsx`) — iPhone (PNG mockup), iPad, Apple TV, Apple Watch, CarPlay head unit, Mac window, Android phone, Android tablet (portrait + landscape), feature graphic.
- **Auto-save (git-trackable)** — every change is persisted within ~600ms to **`app-store-screenshots.json`** at the project root (via `/api/project`) **and** mirrored to `localStorage` as an instant-paint cache. Commit `app-store-screenshots.json` and you can `git clone` to another machine and resume exactly where you left off.
- **Multi-device decks** — iOS (iPhone, iPad, Apple TV, Apple Watch, CarPlay), Mac, and Android decks live side by side; switching the platform tab keeps each tab's last device.
diff --git a/skills/app-store-screenshots/template/docs/background-controls.md b/skills/app-store-screenshots/template/docs/background-controls.md
new file mode 100644
index 0000000..72aa7c9
--- /dev/null
+++ b/skills/app-store-screenshots/template/docs/background-controls.md
@@ -0,0 +1,15 @@
+# Background Controls
+
+Each slide has its own **Background** control in the right-hand Screen settings panel.
+
+- **Theme background** uses the deck’s active theme color.
+- **Theme alternate** uses the second background color from that theme. This is the per-slide light/dark variation.
+- **Custom color** opens a color picker and hex input. The color only applies to the selected slide and overrides the theme background there.
+
+Switching back to either theme option removes the custom override. Background choices are saved with the slide in `app-store-screenshots.json` and included in exports.
+
+## Relevant code
+
+- `src/components/editor/background-controls.tsx` provides the editor controls.
+- `src/components/editor/slide-canvas.tsx` renders the selected background.
+- `src/lib/storage.ts` validates saved custom hex colors during load.
diff --git a/skills/app-store-screenshots/template/docs/edit-history.md b/skills/app-store-screenshots/template/docs/edit-history.md
new file mode 100644
index 0000000..fc363c8
--- /dev/null
+++ b/skills/app-store-screenshots/template/docs/edit-history.md
@@ -0,0 +1,17 @@
+# Edit History
+
+The screenshot editor keeps the 25 most recent canvas and project edits available during the current browser session.
+
+## Using it
+
+- Select **Undo** in the toolbar, or press `Command + Z` on macOS (`Ctrl + Z` on Windows/Linux).
+- Select **Redo** in the toolbar, or press `Command + Shift + Z` on macOS (`Ctrl + Shift + Z` on Windows/Linux). `Ctrl + Y` also redoes an edit on Windows/Linux.
+- The buttons are unavailable when there is nothing left to undo or redo.
+
+Typing and slider adjustments made in quick succession are combined into one history step, so a single Undo reverses the full small adjustment rather than one character or slider tick at a time. The history resets when the editor reloads.
+
+## Relevant code
+
+- `src/lib/storage.ts` owns the 25-step in-memory history stacks and state restoration.
+- `src/components/editor/toolbar.tsx` renders the Undo and Redo buttons.
+- `src/components/editor/screenshot-editor.tsx` connects the editor’s state history to the toolbar and keyboard shortcuts.
diff --git a/skills/app-store-screenshots/template/docs/image-elements.md b/skills/app-store-screenshots/template/docs/image-elements.md
new file mode 100644
index 0000000..0aa410c
--- /dev/null
+++ b/skills/app-store-screenshots/template/docs/image-elements.md
@@ -0,0 +1,22 @@
+# Image Elements
+
+The screenshot editor supports image overlays on every non-feature-graphic slide. Use them for a logo, bowling photo, decorative asset, or other visual that should sit above or beside the device frame.
+
+## Use
+
+1. Select a screen in the editor.
+2. In **Elements**, click **Image**.
+3. Select the new image placeholder on the canvas.
+4. Use **Pick** or drag a PNG/JPG into the Image control.
+5. Drag, resize, rotate, and reorder the image. Choose **Fill frame** to crop or **Keep whole image** to preserve its full shape.
+6. Use **Edge fade** to feather the image into the background from the top, bottom, left, or right. **Fade strength** controls the feather. The opposite edge always stays fully visible. At 100%, the selected edge is fully transparent through its outer quarter, then it feathers into a fully solid opposite quarter.
+
+The editor saves uploaded assets under `public/screenshots/uploaded/` when its local API is available. Each image element is saved in `app-store-screenshots.json`, so its source, placement, rotation, layering, and fit mode are retained across refreshes and included in exports.
+
+## Implementation
+
+- `src/lib/types.ts` defines the persisted `ImageElement` shape.
+- `src/components/editor/image-element-canvas.tsx` renders an individual overlay and applies its gradient mask during preview and export.
+- `src/components/editor/inspector.tsx` adds upload, fit, layering, and delete controls.
+- `src/components/editor/slide-canvas.tsx` includes image overlays in preview and export rendering.
+- `src/lib/storage.ts` validates image elements when loading project data.
diff --git a/skills/app-store-screenshots/template/docs/screenshot-fonts.md b/skills/app-store-screenshots/template/docs/screenshot-fonts.md
new file mode 100644
index 0000000..8784b2c
--- /dev/null
+++ b/skills/app-store-screenshots/template/docs/screenshot-fonts.md
@@ -0,0 +1,26 @@
+# Screenshot Fonts
+
+Use the **Font** menu in the toolbar to change the typeface used on the screenshot canvas and in exported images. It does not change the editor’s controls.
+
+## Included choices
+
+- **Editorial Serif** uses Georgia.
+- **Modern Sans** uses the device’s clean system sans-serif font.
+- **Classic Serif** uses Georgia.
+- **Avenir Next**, **Helvetica Neue**, **American Typewriter**, **Baskerville**, **Optima**, **Palatino**, and **Futura** use their macOS-native versions when available, with sensible fallbacks elsewhere.
+- **Import a font** accepts your WOFF2, WOFF, TTF, or OTF file directly.
+
+## Adding your own font
+
+1. Choose **Import a font** in the toolbar, then select **Import font**.
+2. Choose a licensed WOFF2, WOFF, TTF, or OTF file. It is copied to `public/fonts/imported/` and used immediately in previews and exports.
+3. You can also add a WOFF2, WOFF, TTF, or OTF file manually as `public/fonts/imported/custom-screenshot-font.<extension>`, choose **Import a font**, and the editor uses it when no imported file has been selected.
+
+The selected font is saved in `app-store-screenshots.json` as `fontId`.
+
+## Relevant code
+
+- `src/lib/constants.ts` defines the available screenshot fonts.
+- `src/components/editor/toolbar.tsx` provides the font selector.
+- `src/components/editor/slide-canvas.tsx` applies the font to previews and exports.
+- `src/app/globals.css` registers the self-hosted font location.
diff --git a/skills/app-store-screenshots/template/docs/themes.md b/skills/app-store-screenshots/template/docs/themes.md
new file mode 100644
index 0000000..9121d09
--- /dev/null
+++ b/skills/app-store-screenshots/template/docs/themes.md
@@ -0,0 +1,20 @@
+# Themes
+
+Use the **Theme** menu in the toolbar to preview and apply a color system across the entire screenshot deck. Each option shows its background and accent colors before you choose it.
+
+Changing a theme updates every slide immediately and saves the selected theme in `app-store-screenshots.json`. It changes the canvas background, text colors, muted text, accent details, and each slide’s alternate background. It does not change screenshot images, text, layouts, or element placement.
+
+## Included themes
+
+- **Mark & Carry**: warm near-black with cream text and muted rose accents.
+- **Clean Light**: warm off-white with blue accents.
+- **Dark Bold**: deep navy with violet accents.
+- **Warm Editorial**: soft peach with amber accents.
+- **Ocean Fresh**: pale blue with ocean-blue accents.
+- **Bloom Roast**: light stone with forest-green and warm brown accents.
+
+## Relevant code
+
+- `src/lib/constants.ts` defines the available theme colors.
+- `src/components/editor/toolbar.tsx` renders the live theme menu.
+- `src/components/editor/slide-canvas.tsx` applies the active theme to the exported and previewed canvas.
diff --git a/skills/app-store-screenshots/template/public/fonts/imported/.gitkeep b/skills/app-store-screenshots/template/public/fonts/imported/.gitkeep
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/skills/app-store-screenshots/template/public/fonts/imported/.gitkeep
@@ -0,0 +1 @@
+
diff --git a/skills/app-store-screenshots/template/src/app/api/upload-font/route.ts b/skills/app-store-screenshots/template/src/app/api/upload-font/route.ts
new file mode 100644
index 0000000..3f190a9
--- /dev/null
+++ b/skills/app-store-screenshots/template/src/app/api/upload-font/route.ts
@@ -0,0 +1,33 @@
+import { createHash } from "node:crypto";
+import { promises as fs } from "node:fs";
+import path from "node:path";
+import { NextResponse } from "next/server";
+
+export const dynamic = "force-dynamic";
+
+const FONT_TYPES = {
+ woff2: { format: "woff2", mime: "font/woff2" },
+ woff: { format: "woff", mime: "font/woff" },
+ ttf: { format: "truetype", mime: "font/ttf" },
+ otf: { format: "opentype", mime: "font/otf" },
+} as const;
+
+export async function POST(request: Request) {
+ const form = await request.formData().catch(() => null);
+ const file = form?.get("font");
+ if (!(file instanceof File)) return NextResponse.json({ ok: false, error: "Choose a font file first." }, { status: 400 });
+
+ const extension = file.name.split(".").pop()?.toLowerCase() as keyof typeof FONT_TYPES | undefined;
+ const fontType = extension ? FONT_TYPES[extension] : undefined;
+ if (!fontType) return NextResponse.json({ ok: false, error: "Use a WOFF2, WOFF, TTF, or OTF font file." }, { status: 400 });
+ if (file.size > 16 * 1024 * 1024) return NextResponse.json({ ok: false, error: "Font file is too large (16MB maximum)." }, { status: 413 });
+
+ const bytes = Buffer.from(await file.arrayBuffer());
+ const hash = createHash("sha1").update(bytes).digest("hex").slice(0, 16);
+ const directory = path.join(process.cwd(), "public", "fonts", "imported");
+ const filename = `${hash}.${extension}`;
+
+ await fs.mkdir(directory, { recursive: true });
+ await fs.writeFile(path.join(directory, filename), bytes);
+ return NextResponse.json({ ok: true, font: { src: `/fonts/imported/${filename}`, format: fontType.format } });
+}
diff --git a/skills/app-store-screenshots/template/src/app/globals.css b/skills/app-store-screenshots/template/src/app/globals.css
index 06e9603..c98257c 100644
--- a/skills/app-store-screenshots/template/src/app/globals.css
+++ b/skills/app-store-screenshots/template/src/app/globals.css
@@ -2,6 +2,16 @@
@tailwind components;
@tailwind utilities;
+@font-face {
+ font-family: "CustomScreenshotFont";
+ src:
+ url("/fonts/imported/custom-screenshot-font.woff2") format("woff2"),
+ url("/fonts/imported/custom-screenshot-font.woff") format("woff"),
+ url("/fonts/imported/custom-screenshot-font.ttf") format("truetype"),
+ url("/fonts/imported/custom-screenshot-font.otf") format("opentype");
+ font-display: swap;
+}
+
@layer base {
:root {
--background: 240 14% 99%;
diff --git a/skills/app-store-screenshots/template/src/components/editor/background-controls.tsx b/skills/app-store-screenshots/template/src/components/editor/background-controls.tsx
new file mode 100644
index 0000000..f134423
--- /dev/null
+++ b/skills/app-store-screenshots/template/src/components/editor/background-controls.tsx
@@ -0,0 +1,61 @@
+"use client";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import type { Slide, Theme } from "@/lib/types";
+
+type Props = {
+ slide: Slide;
+ theme: Theme;
+ onChange: (patch: Partial<Slide>) => void;
+};
+
+export function BackgroundControls({ slide, theme, onChange }: Props) {
+ const mode = slide.backgroundColor ? "custom" : slide.inverted ? "alternate" : "theme";
+ const customColor = slide.backgroundColor || theme.bg;
+
+ return (
+ <div className="space-y-1.5">
+ <Label className="text-xs">Background</Label>
+ <Select
+ value={mode}
+ onValueChange={(nextMode) => {
+ if (nextMode === "theme") onChange({ inverted: false, backgroundColor: undefined });
+ if (nextMode === "alternate") onChange({ inverted: true, backgroundColor: undefined });
+ if (nextMode === "custom") onChange({ inverted: false, backgroundColor: customColor });
+ }}
+ >
+ <SelectTrigger><SelectValue /></SelectTrigger>
+ <SelectContent>
+ <SelectItem value="theme">Theme background</SelectItem>
+ <SelectItem value="alternate">Theme alternate</SelectItem>
+ <SelectItem value="custom">Custom color</SelectItem>
+ </SelectContent>
+ </Select>
+ {mode === "custom" && (
+ <div className="flex items-center gap-2">
+ <input
+ type="color"
+ value={customColor}
+ onChange={(event) => onChange({ backgroundColor: event.target.value.toUpperCase() })}
+ className="h-8 w-10 cursor-pointer rounded border bg-transparent p-0.5"
+ aria-label="Custom background color"
+ />
+ <Input
+ value={customColor}
+ onChange={(event) => onChange({ backgroundColor: event.target.value.toUpperCase() })}
+ placeholder="#0B0908"
+ className="h-8 font-mono text-xs uppercase"
+ aria-label="Custom background hex color"
+ />
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/skills/app-store-screenshots/template/src/components/editor/create-image-mask.ts b/skills/app-store-screenshots/template/src/components/editor/create-image-mask.ts
new file mode 100644
index 0000000..4e17abe
--- /dev/null
+++ b/skills/app-store-screenshots/template/src/components/editor/create-image-mask.ts
@@ -0,0 +1,18 @@
+import type { ImageElement } from "@/lib/types";
+
+export function createImageMask(fade: ImageElement["fade"]): string | undefined {
+ if (!fade || fade.amount <= 0) return undefined;
+
+ const amount = Math.max(1, Math.min(100, fade.amount));
+
+ const direction = {
+ top: "to bottom",
+ bottom: "to top",
+ left: "to right",
+ right: "to left",
+ }[fade.edge];
+ const transparentEdge = amount * 0.25;
+ const solidOppositeEdge = amount * 0.75;
+
+ return `linear-gradient(${direction}, transparent 0%, transparent ${transparentEdge}%, #000 ${solidOppositeEdge}%, #000 100%)`;
+}
diff --git a/skills/app-store-screenshots/template/src/components/editor/font-importer.tsx b/skills/app-store-screenshots/template/src/components/editor/font-importer.tsx
new file mode 100644
index 0000000..9e6c388
--- /dev/null
+++ b/skills/app-store-screenshots/template/src/components/editor/font-importer.tsx
@@ -0,0 +1,63 @@
+"use client";
+import * as React from "react";
+import { Upload } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import type { ImportedFont } from "@/lib/types";
+
+type Props = {
+ disabled: boolean;
+ importedFont?: ImportedFont;
+ onImported: (font: ImportedFont) => void;
+};
+
+export function FontImporter({ disabled, importedFont, onImported }: Props) {
+ const inputRef = React.useRef<HTMLInputElement>(null);
+ const [uploading, setUploading] = React.useState(false);
+ const [error, setError] = React.useState<string | null>(null);
+
+ async function importFont(file: File) {
+ setUploading(true);
+ setError(null);
+ const form = new FormData();
+ form.append("font", file);
+ try {
+ const response = await fetch("/api/upload-font", { method: "POST", body: form });
+ const data = (await response.json()) as { ok: boolean; error?: string; font?: ImportedFont };
+ if (!data.ok || !data.font) throw new Error(data.error || "Could not import that font.");
+ onImported(data.font);
+ } catch (caught) {
+ setError(caught instanceof Error ? caught.message : "Could not import that font.");
+ } finally {
+ setUploading(false);
+ }
+ }
+
+ return (
+ <span className="flex items-center gap-1.5">
+ <input
+ ref={inputRef}
+ type="file"
+ accept=".woff2,.woff,.ttf,.otf,font/woff2,font/woff,font/ttf,font/otf"
+ className="sr-only"
+ onChange={(event) => {
+ const file = event.target.files?.[0];
+ if (file) void importFont(file);
+ event.target.value = "";
+ }}
+ />
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ className="h-8 gap-1 px-2 text-xs"
+ disabled={disabled || uploading}
+ onClick={() => inputRef.current?.click()}
+ title="Import a WOFF2, WOFF, TTF, or OTF font"
+ >
+ <Upload className="h-3.5 w-3.5" />
+ {uploading ? "Importing" : importedFont ? "Replace font" : "Import font"}
+ </Button>
+ {error && <span className="max-w-32 truncate text-[10px] text-destructive" title={error}>{error}</span>}
+ </span>
+ );
+}
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
new file mode 100644
index 0000000..92b6adc
--- /dev/null
+++ b/skills/app-store-screenshots/template/src/components/editor/image-element-canvas.tsx
@@ -0,0 +1,87 @@
+"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";
+
+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;
+ const source = img(element.src);
+ const maskImage = createImageMask(element.fade);
+
+ 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();
+ }}
+ 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/inspector.tsx b/skills/app-store-screenshots/template/src/components/editor/inspector.tsx
index a6ee7ce..c15c216 100644
--- a/skills/app-store-screenshots/template/src/components/editor/inspector.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/inspector.tsx
@@ -8,6 +8,7 @@ import {
ArrowUpToLine,
ChevronDown,
ChevronUp,
+ ImagePlus,
Lightbulb,
Plus,
RotateCcw,
@@ -39,7 +40,10 @@ import { COPY_IDEA_SLOTS } from "@/lib/copy-ideas";
import { nid } from "@/lib/defaults";
import {
isBuiltInElementId,
+ imageElementKey,
+ isImageElementId,
isTextElementId,
+ toImageElementId,
textElementKey,
toTextElementId,
} from "@/lib/elements";
@@ -59,12 +63,15 @@ import type {
Device,
ElementId,
ElementTransform,
+ ImageElement,
Orientation,
Slide,
SlideLayout,
SlideTypography,
TextElement,
+ Theme,
} from "@/lib/types";
+import { BackgroundControls } from "./background-controls";
import { ScreenshotPicker } from "./screenshot-picker";
import { getCanvas, getElementTransform } from "./slide-canvas";
@@ -72,6 +79,7 @@ type Props = {
slide: Slide;
device: Device;
orientation: Orientation;
+ theme: Theme;
locale: string;
selectedElementId: ElementId | null;
onChange: (patch: Partial<Slide>) => void;
@@ -88,6 +96,7 @@ export function Inspector({
slide,
device,
orientation,
+ theme,
locale,
selectedElementId,
onChange,
@@ -159,6 +168,8 @@ export function Inspector({
</Select>
</div>
+ {!isFeatureGraphic && <BackgroundControls slide={slide} theme={theme} onChange={onChange} />}
+
{!isFeatureGraphic && (
<div className="space-y-1.5">
<Label className="text-xs">Label</Label>
@@ -296,6 +307,7 @@ function ElementTransformControls({
if (slide.layout !== "no-device") present.push("device");
if (slide.layout === "two-devices") present.push("deviceSecondary");
for (const element of slide.textElements || []) present.push(toTextElementId(element.id));
+ for (const element of slide.imageElements || []) present.push(toImageElementId(element.id));
const transforms = slide.transforms || {};
const activeId =
@@ -308,6 +320,10 @@ function ElementTransformControls({
activeId && isTextElementId(activeId)
? slide.textElements?.find((element) => element.id === textElementKey(activeId))
: null;
+ const activeImageElement =
+ activeId && isImageElementId(activeId)
+ ? slide.imageElements?.find((element) => element.id === imageElementKey(activeId))
+ : null;
function getTransform(id: ElementId) {
return getElementTransform(slide, device, orientation, id);
@@ -327,6 +343,17 @@ function ElementTransformControls({
});
return;
}
+ if (isImageElementId(id)) {
+ const imageId = imageElementKey(id);
+ onChange({
+ imageElements: (slide.imageElements || []).map((element) =>
+ element.id === imageId
+ ? { ...element, transform: { ...element.transform, ...patch } }
+ : element,
+ ),
+ });
+ return;
+ }
if (!isBuiltInElementId(id)) return;
onChange({
transforms: { ...transforms, [id]: { ...cur, ...patch } },
@@ -353,6 +380,20 @@ function ElementTransformControls({
onSelectElement(null);
}
+ function patchImageElement(id: string, patch: Partial<ImageElement>) {
+ onChange({
+ imageElements: (slide.imageElements || []).map((element) =>
+ element.id === id ? { ...element, ...patch } : element,
+ ),
+ });
+ }
+
+ function deleteImageElement(element: ImageElement) {
+ const nextImageElements = (slide.imageElements || []).filter((item) => item.id !== element.id);
+ onChange({ imageElements: nextImageElements.length > 0 ? nextImageElements : undefined });
+ onSelectElement(null);
+ }
+
function addTextElement() {
const id = nid();
const zIndex =
@@ -378,6 +419,27 @@ function ElementTransformControls({
onSelectElement(toTextElementId(id));
}
+ function addImageElement() {
+ const { cW, cH } = getCanvas(device, orientation);
+ const id = nid();
+ const zIndex = Math.max(5, ...present.map((elementId) => getTransform(elementId)?.zIndex ?? defaultZ(elementId))) + 1;
+ const element: ImageElement = {
+ id,
+ src: "",
+ transform: {
+ x: cW * 0.25,
+ y: cH * 0.36,
+ width: cW * 0.5,
+ height: cW * 0.5,
+ rotation: 0,
+ zIndex,
+ },
+ fit: "cover",
+ };
+ onChange({ imageElements: [...(slide.imageElements || []), element] });
+ onSelectElement(toImageElementId(id));
+ }
+
// Z-order: re-rank zIndex among present elements so they remain contiguous.
function reorder(id: ElementId, dir: "front" | "back" | "up" | "down") {
const ranked = [...present].sort((a, b) => {
@@ -400,6 +462,10 @@ function ElementTransformControls({
...element,
transform: { ...element.transform },
}));
+ const nextImageElements = (slide.imageElements || []).map((element) => ({
+ ...element,
+ transform: { ...element.transform },
+ }));
ranked.forEach((eid, i) => {
const cur = getTransform(eid);
if (!cur) return;
@@ -407,11 +473,15 @@ function ElementTransformControls({
const textId = textElementKey(eid);
const textElement = nextTextElements.find((element) => element.id === textId);
if (textElement) textElement.transform = { ...textElement.transform, zIndex: i + 1 };
+ } else if (isImageElementId(eid)) {
+ const imageId = imageElementKey(eid);
+ const imageElement = nextImageElements.find((element) => element.id === imageId);
+ if (imageElement) imageElement.transform = { ...imageElement.transform, zIndex: i + 1 };
} else if (isBuiltInElementId(eid)) {
nextTransforms[eid] = { ...cur, zIndex: i + 1 };
}
});
- onChange({ transforms: nextTransforms, textElements: nextTextElements });
+ onChange({ transforms: nextTransforms, textElements: nextTextElements, imageElements: nextImageElements });
}
return (
@@ -435,6 +505,16 @@ function ElementTransformControls({
<Plus className="h-3.5 w-3.5" />
Text
</Button>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="h-7 shrink-0 px-2 text-xs"
+ onClick={addImageElement}
+ >
+ <ImagePlus className="h-3.5 w-3.5" />
+ Image
+ </Button>
</div>
{activeId ? (
@@ -442,6 +522,7 @@ function ElementTransformControls({
activeId={activeId}
transform={activeTransform}
textElement={activeTextElement || undefined}
+ imageElement={activeImageElement || undefined}
locale={locale}
canvas={{ cW, cH }}
onRotate={(rotation) => patchElement(activeId, { rotation })}
@@ -455,6 +536,12 @@ function ElementTransformControls({
onDeleteText={() => {
if (activeTextElement) deleteTextElement(activeTextElement);
}}
+ onImagePatch={(patch) => {
+ if (activeImageElement) patchImageElement(activeImageElement.id, patch);
+ }}
+ onDeleteImage={() => {
+ if (activeImageElement) deleteImageElement(activeImageElement);
+ }}
/>
) : (
<div className="rounded border border-dashed bg-background/40 p-4 text-center text-[11px] text-muted-foreground">
@@ -469,6 +556,7 @@ function ActiveElementPanel({
activeId,
transform,
textElement,
+ imageElement,
locale,
canvas,
onRotate,
@@ -476,10 +564,13 @@ function ActiveElementPanel({
onTextChange,
onTextPatch,
onDeleteText,
+ onImagePatch,
+ onDeleteImage,
}: {
activeId: ElementId;
transform: ElementTransform | undefined;
textElement?: TextElement;
+ imageElement?: ImageElement;
locale: string;
canvas: { cW: number; cH: number };
onRotate: (rotation: number) => void;
@@ -487,6 +578,8 @@ function ActiveElementPanel({
onTextChange: (value: string) => void;
onTextPatch: (patch: Partial<TextElement>) => void;
onDeleteText: () => void;
+ onImagePatch: (patch: Partial<ImageElement>) => void;
+ onDeleteImage: () => void;
}) {
const engaged = !!transform;
const rotation = transform?.rotation ?? 0;
@@ -496,17 +589,18 @@ function ActiveElementPanel({
<div className="flex items-center justify-between">
<span className="flex items-center gap-1 text-xs font-medium">
{textElement && <Type className="h-3.5 w-3.5" />}
+ {imageElement && <ImagePlus className="h-3.5 w-3.5" />}
{label}
</span>
- {textElement ? (
+ {textElement || imageElement ? (
<Button
type="button"
variant="ghost"
size="icon"
className="h-6 w-6 hover:text-destructive"
- onClick={onDeleteText}
- title="Delete text element"
- aria-label="Delete text element"
+ onClick={textElement ? onDeleteText : onDeleteImage}
+ title={textElement ? "Delete text element" : "Delete image element"}
+ aria-label={textElement ? "Delete text element" : "Delete image element"}
>
<Trash2 className="h-3.5 w-3.5" />
</Button>
@@ -526,6 +620,8 @@ function ActiveElementPanel({
/>
)}
+ {imageElement && <ImageElementPanel element={imageElement} onPatch={onImagePatch} />}
+
<div className="space-y-1">
<div className="flex items-center justify-between">
<Label className="flex items-center gap-1 text-[11px] text-muted-foreground">
@@ -569,6 +665,73 @@ function ActiveElementPanel({
);
}
+function ImageElementPanel({
+ element,
+ onPatch,
+}: {
+ element: ImageElement;
+ onPatch: (patch: Partial<ImageElement>) => void;
+}) {
+ return (
+ <div className="space-y-2 rounded border bg-muted/30 p-2">
+ <div className="space-y-1">
+ <Label className="text-[11px] text-muted-foreground">Image</Label>
+ <ScreenshotPicker label="Overlay image" value={element.src} onChange={(src) => onPatch({ src })} />
+ </div>
+ <div className="space-y-1">
+ <Label className="text-[11px] text-muted-foreground">Fit</Label>
+ <Select value={element.fit || "cover"} onValueChange={(fit) => onPatch({ fit: fit as ImageElement["fit"] })}>
+ <SelectTrigger><SelectValue /></SelectTrigger>
+ <SelectContent>
+ <SelectItem value="cover">Fill frame</SelectItem>
+ <SelectItem value="contain">Keep whole image</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
+ <div className="space-y-1">
+ <Label className="text-[11px] text-muted-foreground">Edge fade</Label>
+ <Select
+ value={element.fade?.edge || "none"}
+ onValueChange={(edge) =>
+ onPatch({
+ fade:
+ edge === "none"
+ ? undefined
+ : { edge: edge as NonNullable<ImageElement["fade"]>["edge"], amount: element.fade?.amount || 35 },
+ })
+ }
+ >
+ <SelectTrigger><SelectValue /></SelectTrigger>
+ <SelectContent>
+ <SelectItem value="none">No fade</SelectItem>
+ <SelectItem value="top">Fade from top</SelectItem>
+ <SelectItem value="bottom">Fade from bottom</SelectItem>
+ <SelectItem value="left">Fade from left</SelectItem>
+ <SelectItem value="right">Fade from right</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
+ {element.fade && (
+ <div className="space-y-1">
+ <div className="flex items-center justify-between">
+ <Label className="text-[11px] text-muted-foreground">Fade strength</Label>
+ <span className="text-[11px] tabular-nums text-muted-foreground">{Math.round(element.fade.amount)}%</span>
+ </div>
+ <input
+ type="range"
+ min={1}
+ max={100}
+ value={element.fade.amount}
+ onChange={(event) => onPatch({ fade: { ...element.fade!, amount: Number(event.target.value) } })}
+ className="w-full"
+ aria-label="Image edge fade reach"
+ />
+ </div>
+ )}
+ </div>
+ );
+}
+
function TextElementPanel({
element,
locale,
@@ -875,11 +1038,13 @@ function ResetButton({
function elementLabel(id: ElementId): string {
if (isBuiltInElementId(id)) return ELEMENT_LABEL[id];
+ if (isImageElementId(id)) return "Image";
return "Text";
}
function defaultZ(id: ElementId): number {
if (isTextElementId(id)) return 5;
+ if (isImageElementId(id)) return 5;
if (id === "deviceSecondary") return 2;
if (id === "device") return 3;
return 4; // caption on top
diff --git a/skills/app-store-screenshots/template/src/components/editor/preview-stage.tsx b/skills/app-store-screenshots/template/src/components/editor/preview-stage.tsx
index 2058810..ecfcdda 100644
--- a/skills/app-store-screenshots/template/src/components/editor/preview-stage.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/preview-stage.tsx
@@ -23,6 +23,8 @@ type Props = {
locale: string;
appName?: string;
appIcon?: string;
+ fontFamily: string;
+ fontFaceCss?: string;
connectedCanvas: boolean;
selectedElement: SelectedElement | null;
onActiveSlideChange: (id: string) => void;
@@ -44,6 +46,8 @@ export function PreviewStage({
locale,
appName,
appIcon,
+ fontFamily,
+ fontFaceCss,
connectedCanvas,
selectedElement,
onActiveSlideChange,
@@ -138,6 +142,8 @@ export function PreviewStage({
locale={locale}
appName={appName}
appIcon={appIcon}
+ fontFamily={fontFamily}
+ fontFaceCss={fontFaceCss}
connectedCanvas={connectedCanvas}
editable
previewScale={scale}
diff --git a/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx b/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx
index 9dd4da5..4f16391 100644
--- a/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx
@@ -5,11 +5,12 @@ import { Toaster, toast } from "sonner";
import {
getExportSizes,
hasTheme,
+ SCREENSHOT_FONTS,
supportsLandscape,
themeById,
} from "@/lib/constants";
import { detectPlatform, nid } from "@/lib/defaults";
-import { isBuiltInElementId, isTextElementId, textElementKey } from "@/lib/elements";
+import { imageElementKey, isBuiltInElementId, isImageElementId, isTextElementId, textElementKey } from "@/lib/elements";
import { renderSlide } from "@/lib/export-render";
import { preloadImages } from "@/lib/image-cache";
import { resolveScreenshot, writeLocalized } from "@/lib/locale";
@@ -19,6 +20,7 @@ import type {
Device,
ElementId,
ElementTransform,
+ ImageElement,
SelectedElement,
Slide,
} from "@/lib/types";
@@ -29,7 +31,7 @@ import { DeckCanvas, getCanvas } from "./slide-canvas";
import { Toolbar } from "./toolbar";
export function ScreenshotEditor() {
- const { state, setState, hydrated, savedAt, saveError, reset, resetDevice, undo, redo } = useProject();
+ const { state, setState, hydrated, savedAt, saveError, reset, resetDevice, undo, redo, canUndo, canRedo } = useProject();
const [activeSlideId, setActiveSlideId] = React.useState<string | null>(null);
const [selectedElement, setSelectedElement] = React.useState<SelectedElement | null>(null);
const [exporting, setExporting] = React.useState<string | null>(null);
@@ -42,6 +44,12 @@ export function ScreenshotEditor() {
const activeSlide =
currentSlides.find((s) => s.id === activeSlideId) || currentSlides[0] || null;
const theme = themeById(state.themeId);
+ const fontFamily = state.fontId === "self-hosted" && state.importedFont
+ ? '"ImportedScreenshotFont", Georgia, serif'
+ : SCREENSHOT_FONTS[state.fontId || "system-sans"].family;
+ const fontFaceCss = state.importedFont
+ ? `@font-face { font-family: "ImportedScreenshotFont"; src: url("${state.importedFont.src}") format("${state.importedFont.format}"); font-display: swap; }`
+ : undefined;
React.useEffect(() => {
if (selectedElement && selectedElement.slideId !== activeSlide?.id) {
@@ -86,6 +94,9 @@ export function ScreenshotEditor() {
paths.add(raw);
}
}
+ for (const imageElement of s.imageElements || []) {
+ if (imageElement.src && !imageElement.src.startsWith("data:")) paths.add(imageElement.src);
+ }
}
return Array.from(paths).sort();
}, [state.slidesByDevice, state.appIcon, state.locales]);
@@ -216,6 +227,15 @@ export function ScreenshotEditor() {
),
};
}
+ if (isImageElementId(elementId)) {
+ const imageId = imageElementKey(elementId);
+ return {
+ ...slide,
+ imageElements: (slide.imageElements || []).map((element) =>
+ element.id === imageId ? { ...element, transform } : element,
+ ),
+ };
+ }
if (!isBuiltInElementId(elementId)) return slide;
return {
...slide,
@@ -280,6 +300,11 @@ export function ScreenshotEditor() {
text: { ...element.text },
transform: { ...element.transform },
})),
+ imageElements: src.imageElements?.map((element): ImageElement => ({
+ ...element,
+ id: nid(),
+ transform: { ...element.transform },
+ })),
};
const next = [...slides.slice(0, idx + 1), copy, ...slides.slice(idx + 1)];
return {
@@ -560,6 +585,10 @@ export function ScreenshotEditor() {
setThemeId={(v) => setState((p) => ({ ...p, themeId: v }))}
connectedCanvas={state.connectedCanvas}
setConnectedCanvas={(v) => setState((p) => ({ ...p, connectedCanvas: v }))}
+ fontId={state.fontId || "system-sans"}
+ setFontId={(v) => setState((p) => ({ ...p, fontId: v }))}
+ importedFont={state.importedFont}
+ setImportedFont={(importedFont) => setState((p) => ({ ...p, fontId: "self-hosted", importedFont }))}
locale={state.locale}
setLocale={(v) => setState((p) => ({ ...p, locale: v }))}
locales={state.locales}
@@ -578,6 +607,10 @@ export function ScreenshotEditor() {
setActiveSlideId(null);
toast.success(`Reset ${state.device} to defaults`);
}}
+ onUndo={undo}
+ onRedo={redo}
+ canUndo={canUndo}
+ canRedo={canRedo}
exporting={exporting}
savedAt={savedAt}
saveError={saveError}
@@ -616,6 +649,8 @@ export function ScreenshotEditor() {
locale={state.locale}
appName={state.appName}
appIcon={state.appIcon}
+ fontFamily={fontFamily}
+ fontFaceCss={fontFaceCss}
connectedCanvas={state.connectedCanvas}
selectedElement={selectedElement}
onActiveSlideChange={setActiveSlideId}
@@ -639,6 +674,7 @@ export function ScreenshotEditor() {
slide={activeSlide}
device={state.device}
orientation={state.orientation}
+ theme={theme}
locale={state.locale}
selectedElementId={
selectedElement?.slideId === activeSlide.id ? selectedElement.elementId : null
@@ -698,6 +734,8 @@ export function ScreenshotEditor() {
locale={exportLocaleOverride ?? state.locale}
appName={state.appName}
appIcon={state.appIcon}
+ fontFamily={fontFamily}
+ fontFaceCss={fontFaceCss}
connectedCanvas={state.connectedCanvas}
hideEmpty
/>
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 a8550f7..6c58105 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
@@ -7,6 +7,7 @@ import type {
Device,
ElementId,
ElementTransform,
+ ImageElement,
Orientation,
SelectedElement,
Slide,
@@ -31,7 +32,7 @@ import {
tvW,
watchW,
} from "@/lib/constants";
-import { toTextElementId } from "@/lib/elements";
+import { imageElementKey, isImageElementId, toImageElementId, toTextElementId } from "@/lib/elements";
import { img } from "@/lib/image-cache";
import { pickText, resolveScreenshot } from "@/lib/locale";
import { defaultTextElementFontSize, slideFontScales } from "@/lib/typography";
@@ -46,6 +47,7 @@ import {
MacWindow,
Phone,
} from "./device-frames";
+import { ImageElementCanvas } from "./image-element-canvas";
type FrameComp = React.ComponentType<{
src: string;
@@ -125,6 +127,8 @@ type Props = {
locale: string;
appName?: string;
appIcon?: string;
+ fontFamily?: string;
+ fontFaceCss?: string;
editable?: boolean;
edit?: EditHandlers;
selectedElementId?: ElementId | null;
@@ -152,6 +156,8 @@ type DeckCanvasProps = {
locale: string;
appName?: string;
appIcon?: string;
+ fontFamily?: string;
+ fontFaceCss?: string;
connectedCanvas?: boolean;
editable?: boolean;
edit?: DeckEditHandlers;
@@ -303,7 +309,10 @@ function Caption({
// ---------- Background ----------
-function backgroundFor(theme: Theme, inverted?: boolean) {
+function backgroundFor(theme: Theme, inverted?: boolean, customColor?: string) {
+ if (customColor) {
+ return `linear-gradient(160deg, ${customColor} 0%, ${shade(customColor, -6)} 100%)`;
+ }
if (inverted) {
return `linear-gradient(160deg, ${theme.bgAlt} 0%, ${shade(theme.bgAlt, -8)} 100%)`;
}
@@ -515,6 +524,10 @@ export function getElementTransform(
const textElement = slide.textElements?.find((element) => element.id === textId);
return textElement?.transform;
}
+ if (isImageElementId(id)) {
+ const imageId = imageElementKey(id);
+ return slide.imageElements?.find((element) => element.id === imageId)?.transform;
+ }
const { defaults } = getSlideGeometry(slide, device, orientation);
const rect = rectFor(id as BuiltInElementId, slide, defaults);
if (!rect) return undefined;
@@ -545,6 +558,8 @@ export function SlideCanvas({
locale,
appName,
appIcon,
+ fontFamily,
+ fontFaceCss,
editable,
edit,
selectedElementId = null,
@@ -582,8 +597,10 @@ export function SlideCanvas({
height: "100%",
position: "relative",
overflow: "hidden",
+ fontFamily,
}}
>
+ {fontFaceCss && <style>{fontFaceCss}</style>}
<SlideBackground slide={slide} cW={cW} cH={cH} theme={theme} />
<SlideElements
slide={slide}
@@ -615,6 +632,8 @@ export function DeckCanvas({
locale,
appName,
appIcon,
+ fontFamily,
+ fontFaceCss,
connectedCanvas = true,
editable,
edit,
@@ -634,8 +653,10 @@ export function DeckCanvas({
height: cH,
position: "relative",
overflow: "hidden",
+ fontFamily,
}}
>
+ {fontFaceCss && <style>{fontFaceCss}</style>}
{slides.map((slide, index) => {
const screenX = index * cW;
const active = activeSlideId === slide.id;
@@ -771,7 +792,7 @@ function SlideBackground({
position: "absolute",
inset: 0,
overflow: "hidden",
- background: backgroundFor(theme, inverted),
+ background: backgroundFor(theme, inverted, slide.backgroundColor),
color: inverted ? theme.fgAlt : theme.fg,
}}
>
@@ -1117,6 +1138,31 @@ function SlideElements({
);
}
+ function renderImageElement(imageElement: ImageElement, index: number) {
+ const elementId = toImageElementId(imageElement.id);
+ const rect = imageElement.transform;
+ const rotation = rect.rotation ?? 0;
+ const zIndex = rect.zIndex ?? 5 + index;
+ return (
+ <ImageElementCanvas
+ key={imageElement.id}
+ element={imageElement}
+ rect={toGlobal(rect)}
+ editable={editable}
+ previewScale={previewScale}
+ selected={selectedElementId === elementId}
+ allowOverflow={allowCrossScreen}
+ onChange={(transform) =>
+ edit?.onElementChange?.(
+ elementId,
+ toLocal({ ...transform, rotation: transform.rotation ?? rotation, zIndex: transform.zIndex ?? zIndex }),
+ )
+ }
+ onSelect={() => edit?.onSelectElement?.(elementId)}
+ />
+ );
+ }
+
return (
<>
{secondaryRect &&
@@ -1128,6 +1174,7 @@ function SlideElements({
)}
{deviceRect && renderDevice("device", deviceRect, screenshot)}
{renderCaption()}
+ {(slide.imageElements || []).map(renderImageElement)}
{(slide.textElements || []).map(renderTextElement)}
</>
);
diff --git a/skills/app-store-screenshots/template/src/components/editor/toolbar.tsx b/skills/app-store-screenshots/template/src/components/editor/toolbar.tsx
index 791618e..68848f9 100644
--- a/skills/app-store-screenshots/template/src/components/editor/toolbar.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/toolbar.tsx
@@ -1,6 +1,6 @@
"use client";
import * as React from "react";
-import { AlertTriangle, Check, Cloud, Download, UnfoldHorizontal, RotateCcw } from "lucide-react";
+import { AlertTriangle, Check, Cloud, Download, Redo2, RotateCcw, Undo2, UnfoldHorizontal } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -21,12 +21,14 @@ import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import {
DEVICE_LABEL,
PLATFORM_DEVICES,
+ SCREENSHOT_FONTS,
THEMES,
supportsLandscape,
themeById,
} from "@/lib/constants";
import { detectPlatform } from "@/lib/defaults";
-import type { Device, Orientation, Platform, Theme } from "@/lib/types";
+import type { Device, ImportedFont, Orientation, Platform, ScreenshotFontId, Theme } from "@/lib/types";
+import { FontImporter } from "./font-importer";
type Props = {
appName: string;
@@ -35,6 +37,10 @@ type Props = {
setThemeId: (v: string) => void;
connectedCanvas: boolean;
setConnectedCanvas: (v: boolean) => void;
+ fontId: ScreenshotFontId;
+ setFontId: (v: ScreenshotFontId) => void;
+ importedFont?: ImportedFont;
+ setImportedFont: (font: ImportedFont) => void;
locale: string;
setLocale: (v: string) => void;
locales: string[];
@@ -45,6 +51,10 @@ type Props = {
onExport: () => void;
onResetAll: () => void;
onResetDevice: () => void;
+ onUndo: () => void;
+ onRedo: () => void;
+ canUndo: boolean;
+ canRedo: boolean;
exporting: string | null;
savedAt: number | null;
saveError: string | null;
@@ -119,6 +129,20 @@ export function Toolbar(props: Props) {
</SelectContent>
</Select>
+ <Select value={props.fontId} onValueChange={(fontId) => props.setFontId(fontId as ScreenshotFontId)} disabled={props.busy}>
+ <SelectTrigger className="h-8 w-44 text-xs" aria-label="Screenshot font">
+ <SelectValue placeholder="Font" />
+ </SelectTrigger>
+ <SelectContent>
+ {Object.entries(SCREENSHOT_FONTS).map(([id, font]) => (
+ <SelectItem key={id} value={id}>{font.name}</SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ {props.fontId === "self-hosted" && (
+ <FontImporter disabled={props.busy} importedFont={props.importedFont} onImported={props.setImportedFont} />
+ )}
+
<span aria-hidden className="mx-1 h-5 w-px bg-border" />
<Tabs
@@ -194,6 +218,30 @@ export function Toolbar(props: Props) {
<div className="ml-auto flex shrink-0 items-center gap-2">
<SaveStatus savedAt={props.savedAt} saveError={props.saveError} />
<span aria-hidden className="h-5 w-px bg-border" />
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="h-8 w-8"
+ onClick={props.onUndo}
+ title="Undo (⌘Z)"
+ aria-label="Undo"
+ disabled={props.busy || !props.canUndo}
+ >
+ <Undo2 className="h-4 w-4" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="h-8 w-8"
+ onClick={props.onRedo}
+ title="Redo (⌘⇧Z)"
+ aria-label="Redo"
+ disabled={props.busy || !props.canRedo}
+ >
+ <Redo2 className="h-4 w-4" />
+ </Button>
<Button
variant="ghost"
size="icon"
diff --git a/skills/app-store-screenshots/template/src/lib/clean-hex-color.ts b/skills/app-store-screenshots/template/src/lib/clean-hex-color.ts
new file mode 100644
index 0000000..4192554
--- /dev/null
+++ b/skills/app-store-screenshots/template/src/lib/clean-hex-color.ts
@@ -0,0 +1,5 @@
+export function cleanHexColor(value: unknown): string | undefined {
+ if (typeof value !== "string") return undefined;
+ const color = value.trim();
+ return /^#[0-9a-f]{6}$/i.test(color) ? color.toUpperCase() : undefined;
+}
diff --git a/skills/app-store-screenshots/template/src/lib/clean-imported-font.ts b/skills/app-store-screenshots/template/src/lib/clean-imported-font.ts
new file mode 100644
index 0000000..08cb951
--- /dev/null
+++ b/skills/app-store-screenshots/template/src/lib/clean-imported-font.ts
@@ -0,0 +1,10 @@
+import type { ImportedFont } from "./types";
+
+export function cleanImportedFont(value: unknown): ImportedFont | undefined {
+ if (!value || typeof value !== "object") return undefined;
+ const font = value as Partial<ImportedFont>;
+ const formats = ["woff2", "woff", "truetype", "opentype"] as const;
+ if (typeof font.src !== "string" || !/^\/fonts\/imported\/[a-z0-9]+\.(woff2|woff|ttf|otf)$/i.test(font.src)) return undefined;
+ if (!formats.includes(font.format as ImportedFont["format"])) return undefined;
+ return { src: font.src, format: font.format as ImportedFont["format"] };
+}
diff --git a/skills/app-store-screenshots/template/src/lib/constants.ts b/skills/app-store-screenshots/template/src/lib/constants.ts
index 4b39b15..c9e8e35 100644
--- a/skills/app-store-screenshots/template/src/lib/constants.ts
+++ b/skills/app-store-screenshots/template/src/lib/constants.ts
@@ -1,4 +1,4 @@
-import type { Device, Orientation, Platform, SlideLayout, Theme, ThemeId } from "./types";
+import type { Device, Orientation, Platform, ScreenshotFontId, SlideLayout, Theme, ThemeId } from "./types";
// ---------- Canvas dimensions (design at largest required resolution) ----------
export const CANVAS: Record<Device, { w: number; h: number; wL?: number; hL?: number }> = {
@@ -160,6 +160,34 @@ export function macW(cW: number, cH: number, clamp = 0.86) {
// ---------- Themes ----------
export const DEFAULT_THEME_ID: ThemeId = "clean-light";
+export const DEFAULT_SCREENSHOT_FONT_ID: ScreenshotFontId = "system-sans";
+
+export const SCREENSHOT_FONTS: Record<ScreenshotFontId, { name: string; family: string }> = {
+ "template-serif": {
+ name: "Editorial Serif",
+ family: "Georgia, 'Times New Roman', serif",
+ },
+ "system-sans": {
+ name: "Modern Sans",
+ family: "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif",
+ },
+ "classic-serif": {
+ name: "Classic Serif",
+ family: "Georgia, 'Times New Roman', serif",
+ },
+ "avenir-next": { name: "Avenir Next", family: '"Avenir Next", Avenir, sans-serif' },
+ "helvetica-neue": { name: "Helvetica Neue", family: '"Helvetica Neue", Helvetica, Arial, sans-serif' },
+ "american-typewriter": { name: "American Typewriter", family: '"American Typewriter", Georgia, serif' },
+ "baskerville": { name: "Baskerville", family: "Baskerville, Georgia, serif" },
+ "optima": { name: "Optima", family: "Optima, 'Palatino Linotype', serif" },
+ "palatino": { name: "Palatino", family: "Palatino, 'Palatino Linotype', serif" },
+ "futura": { name: "Futura", family: "Futura, 'Trebuchet MS', sans-serif" },
+ "self-hosted": {
+ name: "Import a font",
+ family: '"CustomScreenshotFont", Georgia, serif',
+ },
+};
+
export const THEMES: Record<string, Theme> = {
"clean-light": {
id: "clean-light",
diff --git a/skills/app-store-screenshots/template/src/lib/defaults.ts b/skills/app-store-screenshots/template/src/lib/defaults.ts
index 374f37f..0e50a1a 100644
--- a/skills/app-store-screenshots/template/src/lib/defaults.ts
+++ b/skills/app-store-screenshots/template/src/lib/defaults.ts
@@ -1,5 +1,5 @@
import { DEFAULT_LOCALE } from "./locale";
-import { DEFAULT_THEME_ID, PLATFORM_DEVICES, PROJECT_SCHEMA_VERSION } from "./constants";
+import { DEFAULT_SCREENSHOT_FONT_ID, DEFAULT_THEME_ID, PLATFORM_DEVICES, PROJECT_SCHEMA_VERSION } from "./constants";
import type { Device, Platform, ProjectState, Slide } from "./types";
let _id = 0;
@@ -149,6 +149,7 @@ export const DEFAULT_PROJECT: ProjectState = {
schemaVersion: PROJECT_SCHEMA_VERSION,
appName: "My App",
themeId: DEFAULT_THEME_ID,
+ fontId: DEFAULT_SCREENSHOT_FONT_ID,
connectedCanvas: true,
locales: [DEFAULT_LOCALE],
locale: DEFAULT_LOCALE,
diff --git a/skills/app-store-screenshots/template/src/lib/elements.ts b/skills/app-store-screenshots/template/src/lib/elements.ts
index 6aec63f..4e71d15 100644
--- a/skills/app-store-screenshots/template/src/lib/elements.ts
+++ b/skills/app-store-screenshots/template/src/lib/elements.ts
@@ -1,4 +1,4 @@
-import type { BuiltInElementId, ElementId, TextElementId } from "./types";
+import type { BuiltInElementId, ElementId, ImageElementId, TextElementId } from "./types";
export const BUILT_IN_ELEMENT_IDS: BuiltInElementId[] = [
"caption",
@@ -7,6 +7,7 @@ export const BUILT_IN_ELEMENT_IDS: BuiltInElementId[] = [
];
export const TEXT_ELEMENT_PREFIX = "text:";
+export const IMAGE_ELEMENT_PREFIX = "image:";
export function isBuiltInElementId(id: ElementId | string): id is BuiltInElementId {
return (BUILT_IN_ELEMENT_IDS as string[]).includes(id);
@@ -16,10 +17,22 @@ export function isTextElementId(id: ElementId | string | null | undefined): id i
return typeof id === "string" && id.startsWith(TEXT_ELEMENT_PREFIX);
}
+export function isImageElementId(id: ElementId | string | null | undefined): id is ImageElementId {
+ return typeof id === "string" && id.startsWith(IMAGE_ELEMENT_PREFIX);
+}
+
export function toTextElementId(id: string): TextElementId {
return `${TEXT_ELEMENT_PREFIX}${id}` as TextElementId;
}
+export function toImageElementId(id: string): ImageElementId {
+ return `${IMAGE_ELEMENT_PREFIX}${id}` as ImageElementId;
+}
+
export function textElementKey(id: TextElementId | ElementId): string {
return isTextElementId(id) ? id.slice(TEXT_ELEMENT_PREFIX.length) : id;
}
+
+export function imageElementKey(id: ImageElementId | ElementId): string {
+ return isImageElementId(id) ? id.slice(IMAGE_ELEMENT_PREFIX.length) : id;
+}
diff --git a/skills/app-store-screenshots/template/src/lib/storage.ts b/skills/app-store-screenshots/template/src/lib/storage.ts
index 4f0f128..23dd7d8 100644
--- a/skills/app-store-screenshots/template/src/lib/storage.ts
+++ b/skills/app-store-screenshots/template/src/lib/storage.ts
@@ -1,12 +1,14 @@
"use client";
import { useCallback, useEffect, useRef, useState } from "react";
-import { PROJECT_SCHEMA_VERSION, STORAGE_KEY } from "./constants";
+import { DEFAULT_SCREENSHOT_FONT_ID, PROJECT_SCHEMA_VERSION, SCREENSHOT_FONTS, STORAGE_KEY } from "./constants";
+import { cleanHexColor } from "./clean-hex-color";
+import { cleanImportedFont } from "./clean-imported-font";
import { DEFAULT_PROJECT } from "./defaults";
import { coerceLocalized } from "./locale";
import { cleanTypography } from "./typography";
-import type { Device, ElementTransform, ProjectState, Slide, TextElement } from "./types";
+import type { Device, ElementTransform, ImageElement, ProjectState, Slide, TextElement } from "./types";
-const HISTORY_LIMIT = 50;
+const HISTORY_LIMIT = 25;
// Coalesce rapid edits (typing, slider drags) into a single undo step.
const COALESCE_MS = 500;
// Debounce file/localStorage writes — frequent enough to feel instant, infrequent enough not to thrash disk.
@@ -54,9 +56,36 @@ function cleanTextElement(value: unknown): TextElement | undefined {
};
}
+function cleanImageElement(value: unknown): ImageElement | undefined {
+ if (!value || typeof value !== "object") return undefined;
+ const raw = value as Partial<ImageElement>;
+ if (typeof raw.id !== "string" || !raw.id.trim() || typeof raw.src !== "string") return undefined;
+ const transform = cleanTransform(raw.transform);
+ if (!transform) return undefined;
+ return {
+ id: raw.id,
+ src: raw.src,
+ transform,
+ ...(raw.fit === "cover" || raw.fit === "contain" ? { fit: raw.fit } : {}),
+ ...(raw.fade &&
+ typeof raw.fade === "object" &&
+ ["top", "bottom", "left", "right"].includes(raw.fade.edge as string) &&
+ typeof raw.fade.amount === "number" &&
+ Number.isFinite(raw.fade.amount)
+ ? {
+ fade: {
+ edge: raw.fade.edge,
+ amount: Math.max(0, Math.min(100, raw.fade.amount)),
+ },
+ }
+ : {}),
+ };
+}
+
// Migrate older projects into the current schema while keeping legacy decks
// visually stable until they explicitly opt into connected canvas.
function migrateSlide(slide: Slide): Slide {
+ const backgroundColor = cleanHexColor(slide.backgroundColor);
const transforms = slide.transforms
? Object.fromEntries(
Object.entries(slide.transforms)
@@ -67,14 +96,19 @@ function migrateSlide(slide: Slide): Slide {
const textElements = Array.isArray(slide.textElements)
? slide.textElements.map(cleanTextElement).filter((t): t is TextElement => !!t)
: undefined;
+ const imageElements = Array.isArray(slide.imageElements)
+ ? slide.imageElements.map(cleanImageElement).filter((image): image is ImageElement => !!image)
+ : undefined;
return {
...slide,
label: coerceLocalized(slide.label as unknown),
headline: coerceLocalized(slide.headline as unknown),
typography: cleanTypography(slide.typography),
+ ...(backgroundColor ? { backgroundColor } : { backgroundColor: undefined }),
...(transforms && Object.keys(transforms).length > 0 ? { transforms } : { transforms: undefined }),
...(textElements && textElements.length > 0 ? { textElements } : { textElements: undefined }),
+ ...(imageElements && imageElements.length > 0 ? { imageElements } : { imageElements: undefined }),
};
}
@@ -87,6 +121,10 @@ function mergeWithDefaults(parsed: Partial<ProjectState>): ProjectState {
typeof parsed.themeId === "string" && parsed.themeId.trim()
? parsed.themeId
: DEFAULT_PROJECT.themeId;
+ const fontId = parsed.fontId && parsed.fontId in SCREENSHOT_FONTS
+ ? parsed.fontId
+ : DEFAULT_SCREENSHOT_FONT_ID;
+ const importedFont = cleanImportedFont(parsed.importedFont);
const slidesByDevice = parsed.slidesByDevice
? Object.fromEntries(
Object.entries(parsed.slidesByDevice).map(([device, slides]) => [
@@ -100,6 +138,8 @@ function mergeWithDefaults(parsed: Partial<ProjectState>): ProjectState {
...parsed,
schemaVersion: PROJECT_SCHEMA_VERSION,
themeId,
+ fontId,
+ ...(importedFont ? { importedFont } : { importedFont: undefined }),
connectedCanvas,
slidesByDevice: {
...DEFAULT_PROJECT.slidesByDevice,
@@ -313,5 +353,7 @@ export function useProject() {
resetDevice,
undo,
redo,
+ canUndo: pastRef.current.length > 0,
+ canRedo: futureRef.current.length > 0,
};
}
diff --git a/skills/app-store-screenshots/template/src/lib/types.ts b/skills/app-store-screenshots/template/src/lib/types.ts
index b909a67..4bc6d0f 100644
--- a/skills/app-store-screenshots/template/src/lib/types.ts
+++ b/skills/app-store-screenshots/template/src/lib/types.ts
@@ -36,7 +36,8 @@ export type ElementTransform = {
export type BuiltInElementId = "caption" | "device" | "deviceSecondary";
export type TextElementId = `text:${string}`;
-export type ElementId = BuiltInElementId | TextElementId;
+export type ImageElementId = `image:${string}`;
+export type ElementId = BuiltInElementId | TextElementId | ImageElementId;
export type SelectedElement = {
slideId: string;
@@ -68,6 +69,17 @@ export type SlideTypography = {
appNameScale?: number;
};
+export type ImageElement = {
+ id: string;
+ src: string;
+ transform: ElementTransform;
+ fit?: "cover" | "contain";
+ fade?: {
+ edge: "top" | "bottom" | "left" | "right";
+ amount: number;
+ };
+};
+
export type Slide = {
id: string;
layout: SlideLayout;
@@ -78,9 +90,11 @@ export type Slide = {
inverted?: boolean; // dark background variant
/** Optional relative font-size scales for built-in caption text. */
typography?: SlideTypography;
+ backgroundColor?: string; // per-slide hex color override
// Per-element overrides; when present, replaces layout default placement.
transforms?: Partial<Record<BuiltInElementId, ElementTransform>>;
textElements?: TextElement[];
+ imageElements?: ImageElement[];
};
export type ThemeId =
@@ -109,6 +123,24 @@ export type ThemeId =
| "quiet-japandi"
| "vintage-travel-poster";
+export type ScreenshotFontId =
+ | "template-serif"
+ | "system-sans"
+ | "classic-serif"
+ | "avenir-next"
+ | "helvetica-neue"
+ | "american-typewriter"
+ | "baskerville"
+ | "optima"
+ | "palatino"
+ | "futura"
+ | "self-hosted";
+
+export type ImportedFont = {
+ src: string;
+ format: "woff2" | "woff" | "truetype" | "opentype";
+};
+
export type Theme = {
id: string;
name: string;
@@ -125,6 +157,8 @@ export type ProjectState = {
schemaVersion?: number;
appName: string;
themeId: string;
+ fontId?: ScreenshotFontId;
+ importedFont?: ImportedFont;
// v1 projects render as isolated screens until the user opts into connected crops.
connectedCanvas: boolean;
// Locales this project targets. Drives the toolbar dropdown and bulk export.