Skip to content

end to end app store screenshot creation using AI

Codex/cross screen canvas (#24)

Parth Jadhav98302f1d4869
diff --git a/.gitignore b/.gitignore
index 4876882..ab2dffe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,10 @@ Thumbs.db
!.vscode/extensions.json
!.vscode/settings.json
+# Skill template user assets
+skills/app-store-screenshots/template/public/app-icon.png
+skills/app-store-screenshots/template/public/screenshots/**/*.png
+
# Temporary files
*.tmp
*.temp
diff --git a/README.md b/README.md
index 6d449e0..192eff2 100644
--- a/README.md
+++ b/README.md
@@ -138,16 +138,18 @@ project/
│ ├── screenshots/ # iOS screenshots (locale folders optional)
│ │ └── android/ # Android screenshots (when targeting both)
│ └── screenshots-ipad/ # Optional iPad screenshots
+├── app-store-screenshots.json # Git-trackable project state
├── src/app/
│ ├── layout.tsx # Font setup
-│ └── page.tsx # Screenshot generator (single file)
+│ └── page.tsx # Editor entry point
+├── src/components/editor/ # Connected canvas editor, inspector, export UI
├── package.json
└── ...
```
When targeting both stores, the skill uses a platform-based folder structure to keep iOS and Android screenshots separated.
-The entire generator is a **single `page.tsx` file**. Run the dev server, open the browser, click any screenshot to export it as a PNG.
+Run the dev server, open the browser, edit the connected canvas, then use **Export bundle** to download every required PNG size for the current device. The editor autosaves to `app-store-screenshots.json` so the deck can be committed and resumed later.
The latest version of the skill also guides the agent to generate:
@@ -155,6 +157,7 @@ The latest version of the skill also guides the agent to generate:
- reusable theme presets backed by design tokens
- RTL-aware layouts for languages like Arabic and Hebrew
- bulk export flows for locale/device/theme combinations
+- connected cross-screen compositions where devices or decorative elements can intentionally span adjacent screenshots
## Export sizes
@@ -270,4 +273,4 @@ If you want to contribute, start with `CONTRIBUTING.md`. Bug reports and feature
## License
-MIT
\ No newline at end of file
+MIT
diff --git a/skills/app-store-screenshots/SKILL.md b/skills/app-store-screenshots/SKILL.md
index 2253358..2ad920c 100644
--- a/skills/app-store-screenshots/SKILL.md
+++ b/skills/app-store-screenshots/SKILL.md
@@ -9,13 +9,15 @@ description: Use when building App Store or Google Play screenshot pages, genera
Scaffold a pre-built Next.js + ShadCN editor that lets the user design and export App Store **and** Google Play screenshots as **advertisements** (not UI showcases). The editor handles all the heavy lifting:
-- Live preview at the canvas's true resolution (scaled to fit)
-- Drag-to-reorder slides, inline text editing, layout switcher per slide
+- Connected live preview at the canvas's true resolution (scaled to fit)
+- Drag-to-reorder screens, inline text editing, layout switcher per screen
+- Cross-screen mockups: phone/device frames, captions, and layered elements can be moved across adjacent screens, then exported as clipped crops
- Drop-target screenshot picker (file → saved to `public/screenshots/uploaded/<hash>.png`)
- Auto-save to **`app-store-screenshots.json`** at the project root (git-trackable) + `localStorage` mirror
- Easy iOS ↔ Android platform switch — separate slide decks live side by side
- One-click bulk PNG export at every Apple/Google-required resolution via `html-to-image`
- Light/dark variant toggle per slide, theme presets, locale select
+- 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:
- **iPhone** (portrait) — Apple App Store
@@ -34,11 +36,279 @@ Supported devices out of the box:
1. **Copies a pre-built template** from `template/` (co-located with this `SKILL.md`) into the user's working directory.
2. Installs dependencies with the user's package manager.
3. Drops the user's screenshots into `public/screenshots/...` and their app icon into `public/`.
-4. (Optionally) prefills `src/lib/defaults.ts` with the user's app name and starting copy so the first preview is meaningful.
+4. (Optionally) prefills `app-store-screenshots.json` with the user's app name, starting copy, screenshots, and connected-canvas preference so the first preview is meaningful.
5. Starts the dev server and tells the user to open the editor in the browser.
You should NOT write `page.tsx`, device frames, or export logic by hand. They live in the template.
+## Step 0: Probe for Existing Screenshot Projects
+
+Before asking the new-project questions in Step 1, always inspect the current working directory for an existing app-store-screenshots implementation.
+
+Run lightweight probes:
+
+```bash
+test -f package.json && sed -n '1,220p' package.json
+test -f app-store-screenshots.json && sed -n '1,120p' app-store-screenshots.json
+rg -n "app-store-screenshots|html-to-image|toPng|ScreenshotEditor|DeckCanvas|connectedCanvas|EXPORT_SIZES|mockup.png|PHONE_SCREEN" package.json src app public 2>/dev/null
+find public -maxdepth 4 \( -path "*/screenshots*" -o -name "mockup.png" -o -name "app-icon.png" \) -print 2>/dev/null
+```
+
+Treat the project as an older implementation when any of these are true:
+
+- `app-store-screenshots.json` exists but has no `schemaVersion`, has `schemaVersion < 2`, or lacks `connectedCanvas`.
+- `src/components/editor/screenshot-editor.tsx` exists but the editor does not reference `DeckCanvas` or `connectedCanvas`.
+- `src/app/page.tsx` contains a previous all-in-one generator (`html-to-image`, `toPng`, `EXPORT_SIZES`, `PHONE_SCREEN`, hardcoded slide arrays/themes).
+- The repo contains the old screenshot asset layout (`public/mockup.png`, `public/screenshots...`) plus a screenshot generator package setup.
+
+If an older implementation is detected, ask exactly one question before doing anything else:
+
+> I found an older App Store screenshots project here. Do you want me to migrate this existing project to the new connected-canvas editor?
+>
+> 1. Yes — migrate the existing project to the new editor
+> 2. No — set up or modify a project another way
+
+If the user chooses **Yes**, do **not** ask the Step 1 questionnaire. Run the migration path below using the files already in the repo. If the user chooses **No**, continue to Step 1.
+
+### Migration Path (When User Says Yes)
+
+The goal is an in-place UI/template upgrade, not a redesign. Preserve the user's existing app name, copy, screenshot paths, app icon, uploaded assets, locales, and device decks wherever they already exist. Replace the old UI implementation with the current template. Keep legacy decks in isolated export mode unless the project already explicitly opted into connected canvas.
+
+Migration rules:
+
+1. **Do not ask further product/design questions.** The user already has a project. Infer from existing files and report any non-blocking gaps at the end.
+2. **Never delete user assets.** Preserve `public/screenshots/`, `public/app-icon.png`, uploaded screenshots, and any existing `app-store-screenshots.json`.
+3. **Preserve recoverability.** If the worktree is not clean, do not revert unrelated changes. Before overwriting template files, copy replaced project-state/assets/code snapshots to a temporary backup outside the repo (for example `/tmp/app-store-screenshots-migration-<timestamp>/`) and mention the path in the final response.
+4. **Prefer structured migration.** Read and write `app-store-screenshots.json` with JSON tooling. Do not regex-edit JSON.
+5. **Set `schemaVersion: 2` and keep legacy `connectedCanvas` safe.** If the existing project already has an explicit boolean `connectedCanvas`, preserve it. If the project is pre-v2 or lacks the flag, write `"connectedCanvas": false` so offscreen/clipped legacy mockups do not leak into neighboring exports. New projects still default to connected canvas.
+6. **Keep screenshots pointed at existing files.** Do not rename screenshot files unless the old project already depended on numeric names and the migration needs them. Existing static paths are fine.
+7. **Handle custom themes without asking.** If the old project references a custom `themeId`, merge the matching theme object into the new `src/lib/constants.ts` when it can be found. If it cannot be recovered, leave the `themeId` in project JSON; the editor will fall back to `clean-light` and warn, and you should note that a custom theme needs manual restoration.
+8. **Merge package metadata when possible.** The template's dependencies and scripts must win for the screenshot editor, but preserve unrelated existing `dependencies`, `devDependencies`, and useful scripts unless they directly conflict.
+9. **Do not import template sample decks into real migrations.** If the old project already has decks or screenshots, use the template for UI/code only. Keep template sample screenshots/decks out of the migrated project so the user's app does not inherit unrelated example content.
+10. **Use a disposable copy for dogfooding.** If the user asks to test or review the migration instead of actually migrating their project, copy the app to a temp directory or worktree and run the migration there. Only touch the real checkout when the user explicitly asks for the real migration and answers **Yes**.
+
+Recommended migration sequence:
+
+```bash
+# 1. Snapshot useful old files outside the repo.
+STAMP=$(date +%Y%m%d-%H%M%S)
+BACKUP_DIR="/tmp/app-store-screenshots-migration-$STAMP"
+mkdir -p "$BACKUP_DIR"
+cp -R app-store-screenshots.json public src package.json tailwind.config.ts next.config.mjs "$BACKUP_DIR/" 2>/dev/null || true
+
+# 2. Preserve project state and assets that must survive template copy.
+PRESERVE_DIR="$BACKUP_DIR/preserve"
+mkdir -p "$PRESERVE_DIR"
+cp app-store-screenshots.json "$PRESERVE_DIR/" 2>/dev/null || true
+cp -R public/screenshots "$PRESERVE_DIR/screenshots" 2>/dev/null || true
+cp public/app-icon.png "$PRESERVE_DIR/app-icon.png" 2>/dev/null || true
+
+# 3. Copy the current template over the old UI implementation.
+cp -R "<SKILL_DIR>/template/." "$PWD/"
+cp app-store-screenshots.json "$BACKUP_DIR/template-app-store-screenshots.json" 2>/dev/null || true
+
+# 4. Restore preserved user state/assets over template samples.
+cp "$PRESERVE_DIR/app-store-screenshots.json" app-store-screenshots.json 2>/dev/null || true
+mkdir -p public
+if [ -d "$PRESERVE_DIR/screenshots" ]; then
+ mkdir -p "$BACKUP_DIR/template-samples/public"
+ mv public/screenshots "$BACKUP_DIR/template-samples/public/screenshots" 2>/dev/null || true
+ cp -R "$PRESERVE_DIR/screenshots" public/screenshots
+else
+ mkdir -p public/screenshots
+fi
+cp "$PRESERVE_DIR/app-icon.png" public/app-icon.png 2>/dev/null || true
+```
+
+After copying, upgrade or create `app-store-screenshots.json`. If an existing project file exists, coerce it in place. If no project file exists but old slide data is embedded in `src/lib/defaults.ts` or `src/app/page.tsx`, extract it best-effort into the template's project JSON before falling back to starter slides. Prefer old arrays or objects named `slides`, `screens`, `features`, `defaultSlides`, `appName`, `tagline`, `theme`, and screenshot paths. If the old implementation only has image files, sort `public/screenshots/**` by path and seed slides from those files.
+
+Use a small JSON script like this for the final project-state coercion:
+
+```bash
+BACKUP_DIR="$BACKUP_DIR" node <<'NODE'
+const fs = require("fs");
+const path = require("path");
+
+const PROJECT_FILE = "app-store-screenshots.json";
+const DEFAULT_LOCALE = "en";
+const DEVICE_KEYS = ["iphone", "ipad", "android", "android-7", "android-10", "feature-graphic"];
+const LAYOUTS = ["hero", "device-bottom", "device-top", "two-devices", "no-device", "split-landscape", "feature-graphic"];
+
+function readJson(file) {
+ try {
+ return JSON.parse(fs.readFileSync(file, "utf8"));
+ } catch {
+ return null;
+ }
+}
+
+const templateState =
+ readJson(path.join(process.env.BACKUP_DIR || "", "template-app-store-screenshots.json")) ||
+ readJson(PROJECT_FILE) ||
+ {};
+const existingState = readJson(PROJECT_FILE) || {};
+const hasExplicitConnectedCanvas = typeof existingState.connectedCanvas === "boolean";
+const existingDecks =
+ existingState.slidesByDevice && typeof existingState.slidesByDevice === "object"
+ ? existingState.slidesByDevice
+ : {};
+const hasExistingDecks = Object.keys(existingDecks).length > 0;
+const state = {
+ ...templateState,
+ ...existingState,
+ slidesByDevice: hasExistingDecks ? existingDecks : templateState.slidesByDevice || {},
+};
+
+const legacySlides =
+ Array.isArray(existingState.slides) ? existingState.slides :
+ Array.isArray(existingState.screens) ? existingState.screens :
+ Array.isArray(existingState.features) ? existingState.features :
+ null;
+
+if (legacySlides && !hasExistingDecks) {
+ state.slidesByDevice = {
+ iphone: legacySlides,
+ };
+}
+
+function localized(value) {
+ if (typeof value === "string") return { [DEFAULT_LOCALE]: value };
+ if (value && typeof value === "object") return value;
+ return {};
+}
+
+function cleanTransform(value) {
+ if (!value || typeof value !== "object") return undefined;
+ const { x, y, width, height, rotation, zIndex } = value;
+ if (![x, y, width, height].every((n) => typeof n === "number" && Number.isFinite(n))) return undefined;
+ return {
+ x,
+ y,
+ width: Math.max(1, width),
+ height: Math.max(1, height),
+ ...(typeof rotation === "number" && Number.isFinite(rotation) ? { rotation } : {}),
+ ...(typeof zIndex === "number" && Number.isFinite(zIndex) ? { zIndex } : {}),
+ };
+}
+
+function firstString(...values) {
+ return values.find((value) => typeof value === "string") || "";
+}
+
+function migrateSlide(slide) {
+ if (!slide || typeof slide !== "object") return null;
+ const transforms = {};
+ const rawTransforms = slide.transforms && typeof slide.transforms === "object" ? slide.transforms : {};
+ for (const [id, transform] of Object.entries(rawTransforms)) {
+ const cleaned = cleanTransform(transform);
+ if (cleaned) transforms[id] = cleaned;
+ }
+ const textElements = Array.isArray(slide.textElements)
+ ? slide.textElements
+ .map((element) => {
+ const transform = cleanTransform(element.transform);
+ if (!element || typeof element.id !== "string" || !transform) return null;
+ return {
+ ...element,
+ text: localized(element.text),
+ transform,
+ };
+ })
+ .filter(Boolean)
+ : undefined;
+
+ return {
+ ...slide,
+ id: typeof slide.id === "string" ? slide.id : `migrated-${Math.random().toString(36).slice(2, 10)}`,
+ layout: LAYOUTS.includes(slide.layout) ? slide.layout : "device-bottom",
+ label: localized(slide.label),
+ headline: localized(slide.headline || slide.title || slide.caption || slide.copy),
+ screenshot: firstString(slide.screenshot, slide.image, slide.src, slide.path),
+ ...(Object.keys(transforms).length ? { transforms } : { transforms: undefined }),
+ ...(textElements && textElements.length ? { textElements } : { textElements: undefined }),
+ };
+}
+
+state.schemaVersion = 2;
+state.connectedCanvas = hasExplicitConnectedCanvas ? existingState.connectedCanvas : false;
+state.locales = Array.isArray(state.locales) && state.locales.length ? state.locales : [DEFAULT_LOCALE];
+state.locale = state.locales.includes(state.locale) ? state.locale : state.locales[0];
+state.device = DEVICE_KEYS.includes(state.device) ? state.device : "iphone";
+
+if (state.slidesByDevice && typeof state.slidesByDevice === "object") {
+ for (const [device, slides] of Object.entries(state.slidesByDevice)) {
+ if (!DEVICE_KEYS.includes(device)) continue;
+ state.slidesByDevice[device] = Array.isArray(slides) ? slides.map(migrateSlide).filter(Boolean) : [];
+ }
+}
+
+if (!state.slidesByDevice[state.device]) {
+ const firstDeviceWithSlides = DEVICE_KEYS.find((device) => state.slidesByDevice[device]?.length);
+ if (firstDeviceWithSlides) state.device = firstDeviceWithSlides;
+}
+
+fs.writeFileSync(PROJECT_FILE, JSON.stringify(state, null, 2) + "\n");
+NODE
+```
+
+If `package.json` existed before the template copy, merge it after the project-state coercion instead of leaving a blind overwrite. Keep the template's `dev`, `build`, and `start` scripts and all editor dependencies, then add any old non-conflicting scripts and dependencies from the backed-up `package.json`.
+
+```bash
+BACKUP_DIR="$BACKUP_DIR" node <<'NODE'
+const fs = require("fs");
+const path = require("path");
+
+function readJson(file) {
+ try {
+ return JSON.parse(fs.readFileSync(file, "utf8"));
+ } catch {
+ return null;
+ }
+}
+
+const oldPkg = readJson(path.join(process.env.BACKUP_DIR || "", "package.json"));
+const templatePkg = readJson("package.json");
+
+if (oldPkg && templatePkg) {
+ const merged = {
+ ...oldPkg,
+ ...templatePkg,
+ scripts: {
+ ...(oldPkg.scripts || {}),
+ ...(templatePkg.scripts || {}),
+ },
+ dependencies: {
+ ...(oldPkg.dependencies || {}),
+ ...(templatePkg.dependencies || {}),
+ },
+ devDependencies: {
+ ...(oldPkg.devDependencies || {}),
+ ...(templatePkg.devDependencies || {}),
+ },
+ };
+
+ fs.writeFileSync("package.json", JSON.stringify(merged, null, 2) + "\n");
+}
+NODE
+```
+
+Then install/update dependencies and verify:
+
+```bash
+bun install # or pnpm install / yarn / npm install
+set -o pipefail
+bun run build 2>&1 | tee "$BACKUP_DIR/build.log" # or the detected package-manager equivalent
+```
+
+Start the dev server and verify in the browser:
+
+- The toolbar shows **Isolated** for migrated pre-v2 decks, unless the project file already explicitly had `"connectedCanvas": true`.
+- Existing screens, copy, screenshot paths, and app icon are present.
+- Referenced screenshot files exist for every configured locale, or the final report lists the missing paths.
+- Device decks retained from the old project do not silently become template placeholders. If a retained deck has empty screenshots or lacks active-locale copy, report it as a follow-up instead of removing it.
+- A bundle export succeeds for the active device.
+- `app-store-screenshots.json` contains `"schemaVersion": 2` and a boolean `"connectedCanvas"` value.
+
## Step 1: Gather Input (Before Scaffolding)
Ask the user these. Do not proceed until you have answers:
@@ -56,7 +326,7 @@ Ask the user these. Do not proceed until you have answers:
2. **App icon** — "Where is your app icon PNG?"
3. **App name** — "What's the app called?"
4. **Feature list** — "List your app's features in priority order. What's the #1 thing your app does?"
-5. **Style direction** — "What style do you want? You can either (a) pick one of the named deep-spec styles, or (b) describe your own vibe in your own words (warm/organic, dark/moody, clean/minimal, bold/colorful, plus any reference apps you like) and I'll build a custom palette. The template also ships with `clean-light`, `dark-bold`, `warm-editorial`, and `ocean-fresh` palette presets you can start from. The named deep specs live in `style-prompts/` — see `style-prompts.md` for the full index. Currently available: Retro Rubberhose Mascot, Moody Curated Dating, Paper Sticker Skeuomorphic, Dreamy Pastel Couples, Hand-Drawn Editorial Tasks, Glossy 3D K-Beauty Creator. If the user names one of these — or describes something that clearly matches one — read `style-prompts/_QUALITY_BAR.md` first, then the matching deep spec file, and apply its entire spec (palette, gradients, shadows, rotations, per-slide breakdown). If the user describes a fully custom style, fall back to the General Visual Design Principles below and pick the closest deep spec as a starting reference."
+5. **Style direction** — "What style do you want? You can either (a) pick one of the named deep-spec styles, or (b) describe your own vibe in your own words (warm/organic, dark/moody, clean/minimal, bold/colorful, plus any reference apps you like) and I'll build a custom palette. The template also ships with `clean-light`, `dark-bold`, `warm-editorial`, `ocean-fresh`, and `bloom-roast` palette presets you can start from. The named deep specs live in `style-prompts/` — see `style-prompts.md` for the full index. Currently available: Retro Rubberhose Mascot, Moody Curated Dating, Paper Sticker Skeuomorphic, Dreamy Pastel Couples, Hand-Drawn Editorial Tasks, Glossy 3D K-Beauty Creator. If the user names one of these — or describes something that clearly matches one — read `style-prompts/_QUALITY_BAR.md` first, then the matching deep spec file, and apply its entire spec (palette, gradients, shadows, rotations, per-slide breakdown). If the user describes a fully custom style, fall back to the General Visual Design Principles below and pick the closest deep spec as a starting reference."
### Optional
@@ -65,7 +335,7 @@ Ask the user these. Do not proceed until you have answers:
8. **Feature Graphic** — Want a 1024×500 Play Store banner too?
9. **Localized screenshots** — Languages? (e.g. en, de, es, pt, ja, ar, he)
10. **Number of slides** — Apple allows up to 10, Google Play up to 8.
-11. **Brand colors / font** — If they want a custom theme beyond the four presets.
+11. **Brand colors / font** — If they want a custom theme beyond the built-in presets.
12. **Additional instructions** — Anything specific.
**IMPORTANT:** If the user gives instructions at any point, follow them. They override skill defaults.
@@ -89,7 +359,7 @@ The template lives at `<this skill dir>/template/` — when the skill is install
cp -R "<SKILL_DIR>/template/." "$PWD/"
```
-If the target directory already has a `package.json`, ask the user before overwriting. For an in-place upgrade, copy only the files the user hasn't customized.
+If the target directory already has a `package.json`, ask the user before overwriting during a new scaffold. If Step 0 detected an old implementation and the user chose **Yes**, do not ask this again; follow the migration path, preserve recoverability with the backup directory, and merge package metadata after the template copy.
### Install Dependencies
@@ -115,14 +385,14 @@ public/
└── tablet-10/{portrait|landscape}/{locale}/...
```
-The default sample slides reference filenames `01.png`–`05.png` per device under `en/`. If the user names their screenshots differently, either rename them or update `src/lib/defaults.ts` so the initial deck points at the right files. The user can also drag-drop files directly into the editor at runtime — those become embedded data URIs and don't need to live on disk.
+The starter project state lives in `app-store-screenshots.json`, not `src/lib/defaults.ts`. If the user names their screenshots differently, either rename them or update the relevant slide `screenshot` fields in `app-store-screenshots.json` so the initial deck points at the right files. The user can also drag-drop files directly into the editor at runtime — those uploads are written to `public/screenshots/uploaded/<hash>.png` when the dev server is running.
### (Optional) Seed Initial Copy
-If the user provided headlines, edit `src/lib/defaults.ts` to set:
+If the user provided headlines, edit `app-store-screenshots.json` to set:
- `appName`
-- `tagline`
-- `themeId` (one of `"clean-light" | "dark-bold" | "warm-editorial" | "ocean-fresh"`, or add a new entry to `THEMES` in `src/lib/constants.ts`)
+- `themeId` (one of `"clean-light" | "dark-bold" | "warm-editorial" | "ocean-fresh" | "bloom-roast"`, or add a matching entry to `THEMES` in `src/lib/constants.ts`)
+- `connectedCanvas` (`true` for new connected decks; migrated legacy decks should stay `false` until the user opts in)
- Starter slides per device with the user's `label` + `headline` + screenshot paths
Otherwise, leave the defaults — the user can rewrite copy in the editor.
@@ -188,6 +458,32 @@ Vary the `layout` field across slides. The editor exposes:
Never repeat the same layout twice in a row. Use 1-2 `inverted` (dark) slides for visual rhythm.
+### Cross-Screen / Cross-Canvas Composition
+
+Use the connected canvas as a design tool during Step 3, after the narrative arc and layout rhythm are chosen and before final export. For most decks with **5+ slides**, plan **one** tasteful cross-screen moment by default. For 8-10 slide decks, use at most **two**. For short, formal, or compliance-heavy decks, zero is fine. The goal is "these screenshots belong together," not "one giant poster chopped into pieces."
+
+Good cross-screen patterns:
+- An oversized phone, tablet, or screenshot mosaic bridges two adjacent screens by 10-30% of its width, while each exported crop still reads as a complete ad.
+- A background horizon, photo, gradient, doodle path, waveform, starfield, sticker trail, or map route continues across the seam.
+- A mascot, 3D object, floating chip, or notification peeks from one screen into the next as a secondary visual, not the whole message.
+- Related ideas form a pair: problem → solution, before → after, overview → detail, plan → result.
+- The seam passes through negative space, a soft shadow, a simple object body, or a non-critical decorative area.
+
+Bad cross-screen patterns:
+- Splitting headlines, app names, prices, legal text, ratings, CTAs, or critical UI across a seam.
+- Centering one giant phone on the seam so each crop shows only a half-device and no clear benefit.
+- Using cross-screen movement on every slide; it becomes a gimmick and makes the deck harder to scan.
+- Cutting through faces, mascot eyes, key chart numbers, product claims, or app-store-required information.
+- Requiring the viewer to understand the carousel as one uninterrupted poster. Every exported PNG must still pass the one-second standalone test.
+- Letting shadows, stickers, or partial objects look accidentally clipped. If it crosses a boundary, make the bleed deliberate with scale, shadow, rotation, or continuation.
+
+Placement rules:
+- Use adjacent screens only unless a deliberate 3-screen panorama is the entire concept.
+- Keep all text fully inside a single exported screen with safe margins.
+- Let 10-30% of a non-critical visual cross the seam; go beyond 40% only for backgrounds, paths, or abstract decoration.
+- If adjacent screens have different background colors, bridge them with a shared object, matching shadow direction, or a designed transition band.
+- Review both views: the zoomed-out connected canvas must look cohesive, and each individual export must still sell one idea.
+
## Visual Design Principles
These rules are derived from studying the best app store screenshots in the wild (Superlist, Headspace, CRED, (Not Boring) Camera, Arc Search, Linktree, Gentler Streak, etc.). They apply regardless of which style preset the user picks. Style-specific tokens (fonts, palette, accents) live in `style-prompts.md` — point the user there.
@@ -270,7 +566,7 @@ The project state file (`app-store-screenshots.json`) carries a `locales: string
**After scaffolding, edit `app-store-screenshots.json` to set `locales` to the user's chosen list, e.g.** `"locales": ["en", "de", "ja"]`. Also set `"locale": "en"` (or whichever is the source-of-truth language) so the editor opens on it.
-The editor stores headlines and labels per-locale on each slide — switch to a locale and type to fill it in; unfilled locales fall back to `en` at preview time. Screenshots are a single string per slide; put `{locale}` anywhere in the path and the editor substitutes the active locale at render and export (e.g. `/screenshots/iphone/{locale}/01.png`).
+The editor stores headlines and labels per-locale on each slide — switch to a locale and type to fill it in; unfilled locales fall back to `en` at preview time. Screenshots are a single string per slide; put `{locale}` anywhere in the path and the editor substitutes the active locale at render and export (e.g. `/screenshots/apple/iphone/{locale}/01.png`).
- Don't literally translate — rewrite for the target market.
- Re-check line breaks per locale; German/French/Portuguese often need shorter claims.
@@ -280,12 +576,16 @@ The editor stores headlines and labels per-locale on each slide — switch to a
Inside the editor, the user picks a device, then hits **Export bundle**. A single zip downloads with every required size × every project locale for that device, organized as `<platform>/<device>/<WxH>/<locale>/NN-<layout>.png`. Repeat per device.
+When `connectedCanvas` is enabled, exports are crops of the connected canvas, not isolated screen renders. If a mockup sits halfway across screen 2 and screen 3, screen 2's PNG contains its left crop and screen 3's PNG contains its right crop exactly as placed. Legacy decks should start with `connectedCanvas: false`, including Step 0 migrations, so old offscreen/clipped elements export as they did before. The user can turn on **Connected** after intentionally composing cross-screen elements.
+
+Before export, zoom out to inspect the connected canvas as a strip, then inspect the individual cropped screens. Cross-screen elements should feel intentional in the strip and harmless in isolation.
+
Project locales come from `app-store-screenshots.json` `locales` field — set during scaffolding (Step 4). Single-locale projects produce a flat per-size structure with just the one locale folder.
If exports come out blank or with black screen rectangles:
- Verify source screenshots are RGB (not RGBA). The template flattens via `objectFit: cover`, but truly transparent sources can still produce black regions.
-- Confirm preload completed — check the browser console for `preloadImages` errors.
-- The export double-call (`toPng` twice in a row) is built-in; do not remove it.
+- Confirm the referenced screenshot paths exist under `public/`; export retries paths that were previously missing before it starts rendering.
+- Keep export scaling inside `html-to-image` via `canvasWidth`/`canvasHeight`; CSS `transform: scale(...)` can leave transparent gutters when App Store sizes differ slightly in aspect ratio.
## Step 6: Final QA Gate
@@ -298,9 +598,13 @@ If exports come out blank or with black screen rectangles:
- No two adjacent slides share the same layout
- Landscape tablet slides use `split-landscape` — never two devices side-by-side
- At least one contrast (`inverted: true`) slide when the deck is long enough
+- For decks with 5+ slides, either one cross-screen/cross-canvas moment exists or there is a clear reason to keep every screen isolated
+- Cross-screen moments are limited to adjacent screens and never split text, required info, faces, or critical UI
### Export Quality
- No clipped text or assets after scaling to export size
+- No transparent gutters or blank edge pixels in the generated PNGs
+- Cross-screen elements split cleanly across adjacent PNGs
- Screenshots correctly aligned inside every device frame
- Filenames sort correctly (zero-padded numeric prefixes)
- Feature Graphic exports cleanly at 1024×500 (no device frame)
@@ -317,6 +621,24 @@ If exports come out blank or with black screen rectangles:
| Export is blank | Source PNGs probably have alpha — flatten to RGB |
| `bun dev` port collision | Template defaults to `next dev`; let Next pick the next free port (3001+) |
+## Project Migration
+
+The current template writes `schemaVersion: 2`. Existing projects made by earlier versions of this skill usually have no `schemaVersion` and may still store string `label` / `headline` values. Do not hand-edit those projects unless the JSON is invalid. On load, `src/lib/storage.ts`:
+
+1. Converts legacy string copy to localized `{ "en": "..." }` objects.
+2. Sanitizes existing element transforms.
+3. Preserves every existing slide/screen and device deck.
+4. Keeps pre-v2 decks in isolated-screen mode by setting `connectedCanvas: false`, so already-clipped phones or captions do not suddenly appear in neighboring exports.
+5. Lets the user opt into connected crops with the toolbar's Connected/Isolated control when they are ready to use cross-screen placement.
+6. Saves the upgraded state back to `app-store-screenshots.json` and `localStorage` only after the file endpoint has loaded successfully, so stale browser cache cannot overwrite the canonical project file during dev-server restarts.
+
+There are two migration modes:
+
+- **Passive runtime migration:** when a user opens an old project in the current editor, keep `connectedCanvas: false` for pre-v2 JSON so old exports remain visually stable.
+- **Explicit skill migration:** when Step 0 detects an old implementation and the user answers **Yes**, upgrade the UI in place and write `schemaVersion: 2`. Preserve an existing explicit `connectedCanvas` boolean; otherwise write `connectedCanvas: false` without asking more product/design questions.
+
+For explicit in-place upgrades, copy the current template's `src/components/editor/`, `src/lib/`, app routes, config, and package files into the project while preserving user assets and project JSON. If the old project had custom themes, merge those `THEMES` entries into `src/lib/constants.ts`; otherwise the editor falls back to `clean-light` and warns in the browser. Then run the app once and confirm `schemaVersion: 2` and a boolean `connectedCanvas` are present.
+
## Template Reference
The template structure (after copy):
@@ -342,12 +664,12 @@ project/
│ ├── editor/
│ │ ├── screenshot-editor.tsx # Top-level editor (state, autosave, export)
│ │ ├── toolbar.tsx # Platform tabs, device select, theme, locale, export
- │ │ ├── sidebar.tsx # Slide list with @dnd-kit reordering
- │ │ ├── slide-thumb.tsx # Draggable slide card
- │ │ ├── preview-stage.tsx # ResizeObserver-scaled live preview
+ │ │ ├── sidebar.tsx # Screen list with @dnd-kit reordering
+ │ │ ├── slide-thumb.tsx # Draggable screen card
+ │ │ ├── preview-stage.tsx # ResizeObserver-scaled connected canvas
│ │ ├── inspector.tsx # Right-pane controls for active slide
│ │ ├── screenshot-picker.tsx # File drop + picker
- │ │ ├── slide-canvas.tsx # Data-driven slide renderer (all layouts)
+ │ │ ├── slide-canvas.tsx # Data-driven screen/deck renderer (all layouts)
│ │ └── device-frames.tsx # Phone, AndroidPhone, IPad, tablets
│ └── ui/ # Minimal ShadCN primitives (button, select, etc.)
└── lib/
diff --git a/skills/app-store-screenshots/style-prompts.md b/skills/app-store-screenshots/style-prompts.md
index 8e74f62..fa76255 100644
--- a/skills/app-store-screenshots/style-prompts.md
+++ b/skills/app-store-screenshots/style-prompts.md
@@ -34,8 +34,9 @@ When a user invokes a style by name (e.g. "use the Hand-Drawn Editorial style"):
3. Set the font family for headline + body to the listed stack.
4. Match the listed headline emphasis behavior.
5. Apply the listed layout rhythm (which slide types and in what order).
-6. Add the listed decorative accents on at least 60% of slides.
-7. Rewrite the copy tone to match the listed voice rules.
+6. Decide whether the deck should include a cross-screen/cross-canvas moment. For 5+ slide decks, include one tasteful adjacent-screen bridge when the style supports it; keep minimal or photo-led styles subtle.
+7. Add the listed decorative accents on at least 60% of slides.
+8. Rewrite the copy tone to match the listed voice rules.
If the style and a user-supplied brand color clash, keep the brand color and adjust adjacent palette entries to be analogous.
@@ -46,6 +47,7 @@ If the style and a user-supplied brand color clash, keep the brand color and adj
- If the user names a style **and** gives custom brand colors, swap the palette colors closest in lightness to the brand colors but keep the typography and accent rules intact.
- If the user names a style **and** a layout (e.g. "style 05 but with style 04's layout rhythm"), keep the named style's typography + accents, swap only the layout rhythm.
- If two styles are named, pick the first as primary and pull at most one element (typography OR decoration) from the second.
+- Cross-screen moments inherit the primary style's rules. In a moody/photo style, continue a photograph, vignette, or notification across the seam; in an editorial style, use a tilted phone, doodle, or sticker trail; in a maximalist style, let chips, mascots, or 3D objects bridge the pair. Never use the cross-screen device as an excuse to break type contrast, phone sizing, or standalone readability.
## Adding new styles
diff --git a/skills/app-store-screenshots/style-prompts/_QUALITY_BAR.md b/skills/app-store-screenshots/style-prompts/_QUALITY_BAR.md
index c11f680..662077c 100644
--- a/skills/app-store-screenshots/style-prompts/_QUALITY_BAR.md
+++ b/skills/app-store-screenshots/style-prompts/_QUALITY_BAR.md
@@ -14,7 +14,21 @@ These rules apply to **every** style in this folder. They override slide-specifi
- **Use up to 3 visual layers max per slide**: background → phone/illustration → headline + 1 accent. Above this becomes noise.
- **Never center-vertically a phone with empty bands above AND below**. Anchor the phone to one edge (top bleed, bottom bleed, or flush bottom).
-## 2. Illustration & SVG quality bar (anti-clipart)
+## 2. Cross-screen / cross-canvas moments
+
+The template exports crops from one connected canvas. Use that power sometimes, not constantly:
+
+- **Default frequency:** in a 5+ slide deck, include **one** adjacent-screen cross-canvas moment unless the user's brief is strict, formal, or every screen must stand alone for legal/compliance reasons. In 8-10 slide decks, use at most **two**. In 3-4 slide decks, use it only when the concept obviously benefits.
+- **Standalone rule:** every exported PNG must still read as one complete advertisement at thumbnail size. The neighbor may add delight, but it must not be required for comprehension.
+- **Good seam-crossers:** oversized non-critical phone edges, screenshot mosaics, background gradients/photos, map routes, doodle paths, waveforms, sticker trails, glow/starfields, mascot limbs, 3D props, notification cards, and soft shadows.
+- **Bad seam-crossers:** headline text, app name, legal copy, price, rating, CTA, required store info, faces/eyes, key chart numbers, primary product claim, or UI the headline depends on.
+- **Amount:** let 10-30% of a visual cross the seam. Above 40% is allowed only for backgrounds, abstract paths, or deliberate panoramas; otherwise each crop feels like an accident.
+- **Style fit:** minimal/photo-led styles should use background/photo continuation or one quiet card crossing the seam. Editorial and maximalist styles can use tilted devices, doodles, stickers, chips, mascots, or 3D objects, but still obey the style's density rules.
+- **Seam placement:** put the boundary through negative space, a simple shape, or a shadow/texture transition. Never cut through detailed anatomy, text, or the focal point of a screenshot.
+
+If a cross-screen element makes either individual crop feel broken, remove it or turn it into a contained single-screen element.
+
+## 3. Illustration & SVG quality bar (anti-clipart)
The single biggest failure mode is "Figma-quick-draw" mascots and props that read as clipart. Every illustrated element must clear at least **3 of these 5 polish gates**:
@@ -26,7 +40,7 @@ The single biggest failure mode is "Figma-quick-draw" mascots and props that rea
A 30-second sanity test: if you cropped the mascot/illustration out and put it next to a piece of art from the style's named inspiration (Cancoco, Mate, Superlist, etc.), would it look like it belongs in the same product, or would it look like a knock-off? If knock-off, re-render.
-## 3. Mascot & illustration sizing minimums
+## 4. Mascot & illustration sizing minimums
When a style features a mascot/character/object, it must be **physically large on the canvas** — viewers see thumbnails:
@@ -41,7 +55,7 @@ When a style features a mascot/character/object, it must be **physically large o
If the spec gives a specific size, that size wins. Otherwise, use these minimums.
-## 4. Typography contrast & legibility
+## 5. Typography contrast & legibility
- All headline text must clear **WCAG AA 4.5:1** against the local pixel underneath it. If your headline sits over a gradient or photo, sample the **worst** pixel under the letter shapes — not the average — and verify against that.
- **The "emphasis word" trap.** Accent / italic / colored emphasis words are the most common contrast failure point: they're often a pale tint of the brand color (lilac on cream, mustard on sage, peach on tan) chosen for *style* without measuring contrast. **Every emphasis color must independently clear 4.5:1 against its slide bg.** If it doesn't, swap to a darker variant of the same hue family — never just "hope the user catches it." Examples that historically failed:
@@ -54,7 +68,7 @@ If the spec gives a specific size, that size wins. Otherwise, use these minimums
- **Subtitle / body copy on textured bg** (cork mosaic, paper grain, photo, gradient) must be either (a) larger than 36px equivalent at 1320px canvas width AND ≥ 4.5:1, OR (b) sit on a clean rounded scrim card. Small navy text on cork mosaic at 28px = unreadable at thumbnail size.
- Never use pure `#FFFFFF` text on a pure-saturated mid-tone background (e.g., white on `#7BC9F5` cyan) — drop to a near-white tinted with the bg's complement, or add a scrim.
-## 5. Headline composition rules
+## 6. Headline composition rules
- **Max characters per line, soft cap by canvas width**: `floor(canvasWidth / fontSize × 0.45)` chars. For a 96px Inter Bold headline on 1320px canvas, that's ~13 chars/line including spaces. Going over forces clipping risk.
- **Max 3 lines** for any headline. 2 is better. 1 is allowed only if the line fits comfortably in < 80% canvas width.
@@ -62,7 +76,7 @@ If the spec gives a specific size, that size wins. Otherwise, use these minimums
- **Trailing punctuation**: follow the style's spec. Default to a single period at end of full sentences; never a question mark in marketing headlines unless the spec allows it; never multiple exclamation marks.
- **Tracking and leading for big display type**: leading should be ≤ 1.05 (lines should kiss), tracking should be slightly negative (`-0.01em` to `-0.03em`). Loose default browser leading at display size always looks amateur.
-## 6. Phone treatment
+## 7. Phone treatment
- **Bezel sizing matches the iPhone 15 Pro silhouette**: corner radius scales with phone width. At 920px phone width (≈70% canvas), use a 52–56px outer radius and a 36–42px inner screen radius.
- **Phone screenshot fill**: the user-supplied screenshot must fill the inner screen edge-to-edge with no white margin and no visible status-bar duplication. If the screenshot has a transparent background, that's a bug — flatten it first.
@@ -70,13 +84,13 @@ If the spec gives a specific size, that size wins. Otherwise, use these minimums
- **Phone drop shadow tinted with the bg**: pure black shadow on a colored bg looks pasted-in. Tint the shadow with the bg complement at 10–20% opacity. Two-shadow stack always (a long soft shadow + a tight contact shadow).
- **Use the default iPhone bezel.** Every phone-bearing slide MUST render the user's screenshot inside the template's default `Phone` device frame (the iPhone mockup PNG at `public/mockup.png` driven by the `Phone` component in `src/components/editor/device-frames.tsx`). **Do NOT** replace it with a bezelless rounded rectangle, a paper cutout, a cream paper border, or any custom-drawn frame. The bezel is the unifying visual across the whole skill output — strip it and the screenshots lose the iPhone read at thumbnail size. Per-style spec sheets may tint or shadow the area around the bezel, but they must NOT replace the bezel itself.
-## 7. Background quality
+## 8. Background quality
- **No accidental gradient on flat-color slides** — if the spec says "flat" the bg must be a single hex, no gradient at all. Inverse: if the spec calls for a gradient, the gradient must use at least 3 stops with intentional hue shift, not a 2-stop near-identical-color gradient.
- **Noise / grain texture** at the opacity the spec requires. 0% noise on styles that demand grain (Retro Rubberhose, Hand-Drawn Editorial, Moody Curated Dating) is a fail.
- **Vignette only when the spec calls for it**. Adding a vignette to a Glassy Iridescent slide kills the brightness; omitting it on Moody Curated Dating kills the atmosphere. Follow the spec.
-## 8. Decoration density discipline
+## 9. Decoration density discipline
Per slide:
- **Minimal styles** (Crisp Teal Bezelless Wallet, Editorial Minimal, Moody Curated Dating): **0** floating decorations.
@@ -85,11 +99,13 @@ Per slide:
Decoration density wrong-side either way (sparse maximalist or dense minimalist) reads as a style misfire.
-## 9. Auto-reject checks (run before declaring done)
+## 10. Auto-reject checks (run before declaring done)
Before exporting, run through this list. Any "yes" means re-render:
- [ ] Any text running off-canvas or clipped by a slide edge?
+- [ ] Any cross-screen element making an individual export incomprehensible, accidentally clipped, or dependent on its neighbor?
+- [ ] Any seam cutting through headline text, legal/store info, faces/eyes, key UI, or the primary product claim?
- [ ] Any phone smaller than 65% of canvas height (on a phone-bearing slide)?
- [ ] Any empty band wider than 22% of canvas height?
- [ ] Any mascot/object below the minimum size for its role?
@@ -102,7 +118,7 @@ Before exporting, run through this list. Any "yes" means re-render:
The agent's job is not done until all of the above are "no."
-## 10. The thumbnail test (mandatory)
+## 11. The thumbnail test (mandatory)
Shrink the rendered PNG to **220px wide** (App Store search-result thumbnail). Squint. Answer in one sentence:
1. What style is this?
diff --git a/skills/app-store-screenshots/template/README.md b/skills/app-store-screenshots/template/README.md
index c81d4d9..7cb72e6 100644
--- a/skills/app-store-screenshots/template/README.md
+++ b/skills/app-store-screenshots/template/README.md
@@ -11,11 +11,14 @@ bun dev # http://localhost:3000
## What's inside
-- **Visual editor** (`src/components/editor/`) — drag-to-reorder, click-to-edit text, screenshot drop targets, per-slide layout switcher, dark/light toggle.
+- **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.
- **Device frames** (`src/components/editor/device-frames.tsx`) — iPhone (PNG mockup), iPad, 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 and Android slide decks live side by side; switching the platform tab preserves both.
-- **One-click export** — bulk PNG export at any required App Store / Play Store resolution using `html-to-image`.
+- **One-click export** — bulk PNG export at any required App Store / Play Store resolution using `html-to-image`; each PNG is rendered from the current connected or isolated deck mode.
+- **Project migration** — older `app-store-screenshots.json` files are migrated on load. Existing per-slide transforms remain valid, and connected crops become available without rewriting the deck by hand.
+- **Legacy-safe mode** — pre-v2 projects opened directly in the editor start in isolated-screen mode first, then can opt into connected crops with the toolbar's Connected/Isolated control. Skill-run in-place migrations keep legacy decks isolated unless the project had already explicitly opted into connected canvas.
## Adding screenshots
@@ -23,27 +26,32 @@ Two ways:
1. **Drop a file in the inspector** — drag-and-drop or click Pick. The file is sent to `/api/upload`, hashed, and written to `public/screenshots/uploaded/<hash>.png`. The slide stores the resulting `/screenshots/uploaded/...` path, so commit those files alongside `app-store-screenshots.json` and the screenshots survive a `git clone`.
2. **Reference a static file** — put PNGs under `public/screenshots/{platform}/{device}/{locale}/` and reference them by path. Default sample slides expect:
- - `public/screenshots/apple/iphone/en/01.png` … `05.png`
- - `public/screenshots/android/phone/en/01.png` … `05.png`
- - `public/screenshots/apple/ipad/en/01.png`
+ - `public/screenshots/apple/iphone/en/...`
+ - `public/screenshots/android/phone/en/...`
+ - `public/screenshots/apple/ipad/en/...`
+
+Update the matching `screenshot` fields in `app-store-screenshots.json` to point at whatever filenames you choose.
## Exporting
-The toolbar dropdown lists every Apple/Google-required size for the current device. Click **Export all** to download a numbered set of PNGs (e.g. `01-hero-iphone-en-1320x2868.png`).
+The toolbar dropdown lists every Apple/Google-required size for the current device. Click **Export bundle** to download a zip. In Connected mode, each PNG is clipped from the connected canvas, so an element that straddles two screens appears split exactly where you placed it. In Isolated mode, each screen clips its own elements and legacy offscreen content cannot leak into neighboring exports.
## Customizing
| Where | What |
|-------|------|
| `src/lib/constants.ts` | Canvas dimensions, export sizes, frame ratios, themes, locales |
-| `src/lib/defaults.ts` | Initial slides shown when localStorage is empty |
-| `src/components/editor/slide-canvas.tsx` | Add new layouts (factory in `renderLayout`) |
+| `app-store-screenshots.json` | Canonical starter project: app name, current device, connected-canvas mode, slide copy, screenshots, and transforms |
+| `src/lib/defaults.ts` | Fallback/reset state used when no project file or local cache exists |
+| `src/components/editor/slide-canvas.tsx` | Add new layouts and connected-canvas element rendering |
| `src/components/editor/device-frames.tsx` | Tweak device chrome (bezel radii, camera dots) |
| `src/app/layout.tsx` | Swap the font (`next/font/google`) |
## Notes
- `mockup.png` is the iPhone bezel overlay; replacing it requires re-measuring the `PHONE_SCREEN` constants.
-- Image preloading converts every static path to a base64 data URI before exports run — this prevents the html-to-image race where some slide screenshots come out black.
-- Reset via the toolbar's circular arrow icon clears in-memory state and reloads the default slides. To wipe disk state too, delete `app-store-screenshots.json`.
-- **Persistence model** — the canonical state lives in `app-store-screenshots.json` (git-tracked). On load, the editor reads localStorage first for instant paint, then overwrites with the file contents if present. On save, both are written. If you ever see a conflict, the file always wins.
+- Image preloading converts every static path to a base64 data URI before exports run, and export retries paths that were previously missing — this prevents the html-to-image race where some slide screenshots come out black.
+- Reset via the toolbar's circular arrow icon clears in-memory state and reloads the default screens. To wipe disk state too, delete `app-store-screenshots.json`.
+- **Persistence model** — the canonical state lives in `app-store-screenshots.json` (git-tracked). On load, the editor reads localStorage first for instant paint, then overwrites with the file contents if present; if the file endpoint is unavailable, autosave is blocked so stale cache cannot overwrite disk. On save, both are written. If you ever see a conflict, the file always wins.
+- **Migration model** — schema v1 projects do not need a manual conversion. On first load, the editor upgrades localized text and transform records, writes `schemaVersion: 2`, preserves all existing screens, and keeps `connectedCanvas: false` so old offscreen/clipped elements export exactly as isolated screens. Turn on **Connected** in the toolbar when you want elements to cross screen edges. Explicit skill migrations preserve an existing `connectedCanvas` choice, otherwise they keep legacy decks isolated too.
+- **Custom themes** — if a project file references a theme id that is not present in `src/lib/constants.ts`, the editor falls back to `clean-light` and shows a warning. Merge custom `THEMES` entries during in-place upgrades.
diff --git a/skills/app-store-screenshots/template/app-store-screenshots.json b/skills/app-store-screenshots/template/app-store-screenshots.json
new file mode 100644
index 0000000..4d50fa1
--- /dev/null
+++ b/skills/app-store-screenshots/template/app-store-screenshots.json
@@ -0,0 +1,369 @@
+{
+ "schemaVersion": 2,
+ "appName": "My App",
+ "themeId": "clean-light",
+ "connectedCanvas": true,
+ "locales": [
+ "en"
+ ],
+ "locale": "en",
+ "device": "iphone",
+ "orientation": "portrait",
+ "appIcon": "",
+ "slidesByDevice": {
+ "iphone": [
+ {
+ "id": "s_mppgoot8_1",
+ "layout": "device-bottom",
+ "label": {
+ "en": "FEATURE 01"
+ },
+ "headline": {
+ "en": "Your headline\nlives here."
+ },
+ "screenshot": "",
+ "transforms": {
+ "device": {
+ "x": -450.80914890045335,
+ "y": 955.2104098119215,
+ "width": 977,
+ "height": 1991,
+ "rotation": 0,
+ "zIndex": 3
+ }
+ }
+ },
+ {
+ "id": "s_mppgoot8_2",
+ "layout": "two-devices",
+ "label": {
+ "en": "FEATURE 02"
+ },
+ "headline": {
+ "en": "Show two\nscreens at once."
+ },
+ "screenshot": "",
+ "screenshotSecondary": "",
+ "transforms": {
+ "deviceSecondary": {
+ "x": 688.4726540204801,
+ "y": 1027.8020089177937,
+ "width": 871.2,
+ "height": 1774.7929549902153,
+ "rotation": 9,
+ "zIndex": 2
+ },
+ "caption": {
+ "x": 112.3403055229146,
+ "y": 87.89358401880148,
+ "width": 1108.8,
+ "height": 803.0400000000001,
+ "rotation": 0,
+ "zIndex": 4
+ },
+ "device": {
+ "x": -499.3230870111943,
+ "y": 928.1034802753068,
+ "width": 912.27195389049,
+ "height": 1858.4640000000002,
+ "rotation": 0,
+ "zIndex": 3
+ }
+ }
+ },
+ {
+ "id": "s_mppgoot8_3",
+ "layout": "device-top",
+ "label": {
+ "en": "FEATURE 03"
+ },
+ "headline": {
+ "en": "Flip the contrast\nfor visual rhythm."
+ },
+ "screenshot": "",
+ "inverted": true,
+ "transforms": {
+ "device": {
+ "x": 741.2739047128944,
+ "y": 899.4937720329012,
+ "width": 1013.6355043227666,
+ "height": 2064.96,
+ "rotation": 0,
+ "zIndex": 3
+ }
+ }
+ },
+ {
+ "id": "s_mppgoot8_4",
+ "layout": "no-device",
+ "label": {
+ "en": "MORE"
+ },
+ "headline": {
+ "en": "And so\nmuch more."
+ },
+ "screenshot": "",
+ "transforms": {
+ "caption": {
+ "x": 190.97767332549847,
+ "y": 2159.762397179791,
+ "width": 1056,
+ "height": 860.4,
+ "rotation": 0,
+ "zIndex": 4
+ }
+ }
+ },
+ {
+ "id": "s_mpptmmaa_i",
+ "layout": "device-bottom",
+ "label": {
+ "en": "NEW"
+ },
+ "headline": {
+ "en": "Edit this\nheadline."
+ },
+ "screenshot": "",
+ "transforms": {
+ "device": {
+ "x": -517.4781516913463,
+ "y": 846.7845828437136,
+ "width": 1013.6355043227666,
+ "height": 2064.96,
+ "rotation": 0,
+ "zIndex": 3
+ },
+ "caption": {
+ "x": 103.91492361927885,
+ "y": 195.738472385429,
+ "width": 1108.8,
+ "height": 803.0400000000001,
+ "rotation": 0,
+ "zIndex": 4
+ }
+ }
+ },
+ {
+ "id": "s_mpptvxsc_i",
+ "layout": "device-bottom",
+ "label": {
+ "en": "NEW"
+ },
+ "headline": {
+ "en": "Edit this\nheadline."
+ },
+ "screenshot": ""
+ }
+ ],
+ "android": [
+ {
+ "id": "s_mppgoot8_5",
+ "layout": "hero",
+ "label": {
+ "en": "MEET YOUR APP"
+ },
+ "headline": {
+ "en": "Sell one\nidea per slide."
+ },
+ "screenshot": "",
+ "transforms": {
+ "device": {
+ "x": 221.0133038940457,
+ "y": 677.042167580437,
+ "width": 678.5844380403457,
+ "height": 1470.266282420749,
+ "rotation": 0,
+ "zIndex": 3
+ }
+ }
+ },
+ {
+ "id": "s_mppgoot8_6",
+ "layout": "device-bottom",
+ "label": {
+ "en": "FEATURE 01"
+ },
+ "headline": {
+ "en": "Your headline\nlives here."
+ },
+ "screenshot": "",
+ "transforms": {
+ "device": {
+ "x": 191.68310412906385,
+ "y": 659.512330975256,
+ "width": 678.5844380403457,
+ "height": 1470.266282420749,
+ "rotation": 0,
+ "zIndex": 3
+ }
+ }
+ },
+ {
+ "id": "s_mppgoot8_7",
+ "layout": "two-devices",
+ "label": {
+ "en": "FEATURE 02"
+ },
+ "headline": {
+ "en": "Show two\nscreens at once."
+ },
+ "screenshot": "",
+ "screenshotSecondary": "",
+ "transforms": {
+ "deviceSecondary": {
+ "x": 280.3938895417132,
+ "y": 525.2025777437636,
+ "width": 678.5844380403457,
+ "height": 1470.266282420749,
+ "rotation": 0,
+ "zIndex": 2
+ },
+ "device": {
+ "x": 143.75673196815296,
+ "y": 569.6411918847805,
+ "width": 610.7259942363112,
+ "height": 1323.239654178674,
+ "rotation": 0,
+ "zIndex": 3
+ }
+ }
+ },
+ {
+ "id": "s_mppgoot8_8",
+ "layout": "device-top",
+ "label": {
+ "en": "FEATURE 03"
+ },
+ "headline": {
+ "en": "Flip the contrast\nfor visual rhythm."
+ },
+ "screenshot": "",
+ "inverted": true
+ },
+ {
+ "id": "s_mppgoot8_9",
+ "layout": "no-device",
+ "label": {
+ "en": "MORE"
+ },
+ "headline": {
+ "en": "And so\nmuch more."
+ },
+ "screenshot": ""
+ }
+ ],
+ "ipad": [
+ {
+ "id": "s_mppgoot8_a",
+ "layout": "hero",
+ "label": {
+ "en": "MEET YOUR APP"
+ },
+ "headline": {
+ "en": "Made for\nthe big screen."
+ },
+ "screenshot": "",
+ "transforms": {
+ "device": {
+ "x": 68.64736263219729,
+ "y": 818.7701245593419,
+ "width": 1525.7087999999999,
+ "height": 1981.4399999999998,
+ "rotation": 0,
+ "zIndex": 3
+ }
+ }
+ },
+ {
+ "id": "s_mppgoot8_b",
+ "layout": "device-bottom",
+ "label": {
+ "en": "FEATURE 01"
+ },
+ "headline": {
+ "en": "Built for\nfocus."
+ },
+ "screenshot": ""
+ },
+ {
+ "id": "s_mppgoot8_c",
+ "layout": "device-top",
+ "label": {
+ "en": "FEATURE 02"
+ },
+ "headline": {
+ "en": "Always within reach."
+ },
+ "screenshot": "",
+ "inverted": true
+ }
+ ],
+ "android-7": [
+ {
+ "id": "s_mppgoot8_d",
+ "layout": "hero",
+ "label": {
+ "en": "MEET YOUR APP"
+ },
+ "headline": {
+ "en": "Pocket-sized\npower."
+ },
+ "screenshot": ""
+ },
+ {
+ "id": "s_mppgoot8_e",
+ "layout": "split-landscape",
+ "label": {
+ "en": "FEATURE 01"
+ },
+ "headline": {
+ "en": "Wide canvas,\nbigger ideas."
+ },
+ "screenshot": ""
+ }
+ ],
+ "android-10": [
+ {
+ "id": "s_mppgoot8_f",
+ "layout": "hero",
+ "label": {
+ "en": "MEET YOUR APP"
+ },
+ "headline": {
+ "en": "Made for\nthe big screen."
+ },
+ "screenshot": ""
+ },
+ {
+ "id": "s_mppgoot8_g",
+ "layout": "split-landscape",
+ "label": {
+ "en": "FEATURE 01"
+ },
+ "headline": {
+ "en": "Wide canvas,\nbigger ideas."
+ },
+ "screenshot": ""
+ }
+ ],
+ "feature-graphic": [
+ {
+ "id": "s_mppgoot8_h",
+ "layout": "feature-graphic",
+ "label": {},
+ "headline": {
+ "en": "Your tagline goes here."
+ },
+ "screenshot": ""
+ }
+ ]
+ },
+ "crossScreenMockupsByDevice": {
+ "iphone": [],
+ "ipad": [],
+ "android": [],
+ "android-7": [],
+ "android-10": [],
+ "feature-graphic": []
+ }
+}
diff --git a/skills/app-store-screenshots/template/src/app/globals.css b/skills/app-store-screenshots/template/src/app/globals.css
index 783225d..06e9603 100644
--- a/skills/app-store-screenshots/template/src/app/globals.css
+++ b/skills/app-store-screenshots/template/src/app/globals.css
@@ -81,9 +81,45 @@
outline-style: solid;
}
+.rnd-rotate-handle {
+ position: absolute;
+ right: -14px;
+ top: -14px;
+ z-index: 20;
+ display: flex;
+ height: 28px;
+ width: 28px;
+ align-items: center;
+ justify-content: center;
+ border-radius: 999px;
+ border: 1px solid rgba(91, 124, 250, 0.65);
+ background: rgba(255, 255, 255, 0.92);
+ color: rgba(30, 41, 59, 0.92);
+ box-shadow: 0 8px 22px rgba(15, 23, 42, 0.2);
+ cursor: grab;
+ opacity: 0;
+ transition:
+ opacity 120ms ease,
+ transform 120ms ease;
+}
+
+.rnd-editable:hover .rnd-rotate-handle,
+.rnd-editable.rnd-selected .rnd-rotate-handle,
+.rnd-rotate-handle:focus-visible {
+ opacity: 1;
+}
+
+.rnd-rotate-handle:hover,
+.rnd-rotate-handle:focus-visible {
+ transform: scale(1.05);
+}
+
+.rnd-rotate-handle:active {
+ cursor: grabbing;
+}
+
/* Show a visible cursor outline on contenteditable text inside Rnd while focused. */
.rnd-editable [contenteditable]:focus {
box-shadow: 0 0 0 2px rgba(91, 124, 250, 0.45);
border-radius: 2px;
}
-
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 0be1cc7..a404322 100644
--- a/skills/app-store-screenshots/template/src/components/editor/inspector.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/inspector.tsx
@@ -1,6 +1,18 @@
"use client";
import * as React from "react";
-import { ArrowDownToLine, ArrowUpToLine, ChevronDown, ChevronUp, RotateCw } from "lucide-react";
+import {
+ AlignCenter,
+ AlignLeft,
+ AlignRight,
+ ArrowDownToLine,
+ ArrowUpToLine,
+ ChevronDown,
+ ChevronUp,
+ Plus,
+ RotateCw,
+ Trash2,
+ Type,
+} from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
@@ -13,26 +25,58 @@ import {
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
import { LAYOUT_HINT, LAYOUT_LABEL } from "@/lib/constants";
+import { nid } from "@/lib/defaults";
+import {
+ isBuiltInElementId,
+ isTextElementId,
+ textElementKey,
+ toTextElementId,
+} from "@/lib/elements";
import { pickText, writeLocalized } from "@/lib/locale";
-import type { ElementId, ElementTransform, Slide, SlideLayout } from "@/lib/types";
+import type {
+ BuiltInElementId,
+ Device,
+ ElementId,
+ ElementTransform,
+ Orientation,
+ Slide,
+ SlideLayout,
+ TextElement,
+} from "@/lib/types";
import { ScreenshotPicker } from "./screenshot-picker";
+import { getCanvas, getElementTransform } from "./slide-canvas";
type Props = {
slide: Slide;
+ device: Device;
+ orientation: Orientation;
locale: string;
selectedElementId: ElementId | null;
onChange: (patch: Partial<Slide>) => void;
+ onSelectElement: (id: ElementId | null) => void;
};
-const ELEMENT_LABEL: Record<ElementId, string> = {
+const ELEMENT_LABEL: Record<BuiltInElementId, string> = {
caption: "Headline",
device: "Device",
deviceSecondary: "Back device",
};
-export function Inspector({ slide, locale, selectedElementId, onChange }: Props) {
- const isFeatureGraphic = slide.layout === "feature-graphic";
+export function Inspector({
+ slide,
+ device,
+ orientation,
+ locale,
+ selectedElementId,
+ onChange,
+ onSelectElement,
+}: Props) {
+ const isFeatureGraphic = device === "feature-graphic" || slide.layout === "feature-graphic";
const isNoDevice = slide.layout === "no-device";
+ const layoutValue = device === "feature-graphic" ? "feature-graphic" : slide.layout;
+ const layoutOptions = Object.entries(LAYOUT_LABEL).filter(([layout]) =>
+ device === "feature-graphic" ? layout === "feature-graphic" : layout !== "feature-graphic",
+ );
const localeLabel = slide.label?.[locale] ?? "";
const localeHeadline = slide.headline?.[locale] ?? "";
// When the active locale is empty, surface the fallback (typically en) as
@@ -47,23 +91,29 @@ export function Inspector({ slide, locale, selectedElementId, onChange }: Props)
onChange({ [key]: writeLocalized(slide[key], locale, value) } as Partial<Slide>);
}
+ React.useEffect(() => {
+ if (device === "feature-graphic" && slide.layout !== "feature-graphic") {
+ onChange({ layout: "feature-graphic", transforms: undefined, screenshotSecondary: undefined });
+ }
+ }, [device, onChange, slide.layout]);
+
return (
<div className="flex h-full flex-col">
<div className="border-b p-3">
<div className="flex items-baseline justify-between gap-2">
- <h2 className="text-sm font-semibold">Slide settings</h2>
+ <h2 className="text-sm font-semibold">Screen settings</h2>
<span className="text-[10px] uppercase tracking-wide text-muted-foreground">
editing · {locale.toUpperCase()}
</span>
</div>
- <p className="text-xs text-muted-foreground">{LAYOUT_HINT[slide.layout]}</p>
+ <p className="text-xs text-muted-foreground">{LAYOUT_HINT[layoutValue]}</p>
</div>
<div className="flex-1 space-y-4 overflow-y-auto p-3">
<div className="space-y-1.5">
<Label className="text-xs">Layout</Label>
<Select
- value={slide.layout}
+ value={layoutValue}
onValueChange={(layout) => {
const next = layout as SlideLayout;
onChange({
@@ -78,7 +128,7 @@ export function Inspector({ slide, locale, selectedElementId, onChange }: Props)
<SelectValue />
</SelectTrigger>
<SelectContent>
- {Object.entries(LAYOUT_LABEL).map(([layout, label]) => (
+ {layoutOptions.map(([layout, label]) => (
<SelectItem key={layout} value={layout}>
{label}
</SelectItem>
@@ -119,6 +169,7 @@ export function Inspector({ slide, locale, selectedElementId, onChange }: Props)
<ScreenshotPicker
label="Primary"
value={slide.screenshot}
+ locale={locale}
onChange={(v) => onChange({ screenshot: v })}
/>
</div>
@@ -130,6 +181,7 @@ export function Inspector({ slide, locale, selectedElementId, onChange }: Props)
<ScreenshotPicker
label="Secondary (back layer)"
value={slide.screenshotSecondary || ""}
+ locale={locale}
onChange={(v) => onChange({ screenshotSecondary: v })}
/>
</div>
@@ -138,8 +190,12 @@ export function Inspector({ slide, locale, selectedElementId, onChange }: Props)
{!isFeatureGraphic && (
<ElementTransformControls
slide={slide}
+ device={device}
+ orientation={orientation}
+ locale={locale}
selectedElementId={selectedElementId}
onChange={onChange}
+ onSelectElement={onSelectElement}
/>
)}
@@ -155,34 +211,113 @@ export function Inspector({ slide, locale, selectedElementId, onChange }: Props)
function ElementTransformControls({
slide,
+ device,
+ orientation,
+ locale,
selectedElementId,
onChange,
+ onSelectElement,
}: {
slide: Slide;
+ device: Device;
+ orientation: Orientation;
+ locale: string;
selectedElementId: ElementId | null;
onChange: (patch: Partial<Slide>) => void;
+ onSelectElement: (id: ElementId | null) => void;
}) {
const present: ElementId[] = ["caption"];
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));
const transforms = slide.transforms || {};
const activeId =
selectedElementId && present.includes(selectedElementId) ? selectedElementId : null;
+ const activeTransform = activeId
+ ? getElementTransform(slide, device, orientation, activeId)
+ : undefined;
+ const activeTextElement =
+ activeId && isTextElementId(activeId)
+ ? slide.textElements?.find((element) => element.id === textElementKey(activeId))
+ : null;
+
+ function getTransform(id: ElementId) {
+ return getElementTransform(slide, device, orientation, id);
+ }
function patchElement(id: ElementId, patch: Partial<ElementTransform>) {
- const cur = transforms[id];
- if (!cur) return; // can only adjust after user moves/resizes (default rect lives in slide-canvas)
+ const cur = getTransform(id);
+ if (!cur) return;
+ if (isTextElementId(id)) {
+ const textId = textElementKey(id);
+ onChange({
+ textElements: (slide.textElements || []).map((element) =>
+ element.id === textId
+ ? { ...element, transform: { ...element.transform, ...patch } }
+ : element,
+ ),
+ });
+ return;
+ }
+ if (!isBuiltInElementId(id)) return;
onChange({
transforms: { ...transforms, [id]: { ...cur, ...patch } },
});
}
+ function patchTextElement(id: string, patch: Partial<TextElement>) {
+ onChange({
+ textElements: (slide.textElements || []).map((element) =>
+ element.id === id ? { ...element, ...patch } : element,
+ ),
+ });
+ }
+
+ function setTextElementValue(element: TextElement, value: string) {
+ patchTextElement(element.id, { text: writeLocalized(element.text, locale, value) });
+ }
+
+ function deleteTextElement(element: TextElement) {
+ const nextTextElements = (slide.textElements || []).filter((item) => item.id !== element.id);
+ onChange({
+ textElements: nextTextElements.length > 0 ? nextTextElements : undefined,
+ });
+ onSelectElement(null);
+ }
+
+ function addTextElement() {
+ 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: TextElement = {
+ id,
+ text: writeLocalized({}, locale, "New text"),
+ transform: {
+ x: cW * 0.18,
+ y: cH * 0.42,
+ width: cW * 0.64,
+ height: cH * 0.12,
+ rotation: 0,
+ zIndex,
+ },
+ fontSize: Math.round(Math.min(cW, cH) * 0.065),
+ fontWeight: 800,
+ align: "center",
+ };
+ onChange({ textElements: [...(slide.textElements || []), element] });
+ onSelectElement(toTextElementId(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) => {
- const za = transforms[a]?.zIndex ?? defaultZ(a);
- const zb = transforms[b]?.zIndex ?? defaultZ(b);
+ const za = getTransform(a)?.zIndex ?? defaultZ(a);
+ const zb = getTransform(b)?.zIndex ?? defaultZ(b);
return za - zb;
});
const idx = ranked.indexOf(id);
@@ -195,32 +330,65 @@ function ElementTransformControls({
if (target === idx) return;
ranked.splice(idx, 1);
ranked.splice(target, 0, id);
- const next = { ...transforms };
+ const nextTransforms = { ...transforms };
+ const nextTextElements = (slide.textElements || []).map((element) => ({
+ ...element,
+ transform: { ...element.transform },
+ }));
ranked.forEach((eid, i) => {
- const cur = next[eid];
- if (!cur) return; // skip if user hasn't engaged this element yet
- next[eid] = { ...cur, zIndex: i + 1 };
+ const cur = getTransform(eid);
+ if (!cur) return;
+ if (isTextElementId(eid)) {
+ const textId = textElementKey(eid);
+ const textElement = nextTextElements.find((element) => element.id === textId);
+ if (textElement) textElement.transform = { ...textElement.transform, zIndex: i + 1 };
+ } else if (isBuiltInElementId(eid)) {
+ nextTransforms[eid] = { ...cur, zIndex: i + 1 };
+ }
});
- onChange({ transforms: next });
+ onChange({ transforms: nextTransforms, textElements: nextTextElements });
}
return (
<div className="space-y-3 rounded-md border bg-muted/30 p-3">
- <div>
- <Label className="text-xs font-semibold">Elements</Label>
- <p className="text-[11px] text-muted-foreground">
- {activeId
- ? "Fine-tune the selected element's rotation and stacking."
- : "Click an element on the canvas to fine-tune its rotation and stacking."}
- </p>
+ <div className="flex items-start justify-between gap-2">
+ <div>
+ <Label className="text-xs font-semibold">Elements</Label>
+ <p className="text-[11px] text-muted-foreground">
+ {activeId
+ ? "Fine-tune the selected element's rotation and stacking."
+ : "Click an element on the canvas to fine-tune its rotation and stacking."}
+ </p>
+ </div>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="h-7 shrink-0 px-2 text-xs"
+ onClick={addTextElement}
+ >
+ <Plus className="h-3.5 w-3.5" />
+ Text
+ </Button>
</div>
{activeId ? (
<ActiveElementPanel
activeId={activeId}
- transform={transforms[activeId]}
+ transform={activeTransform}
+ textElement={activeTextElement || undefined}
+ locale={locale}
onRotate={(rotation) => patchElement(activeId, { rotation })}
onReorder={(dir) => reorder(activeId, dir)}
+ onTextChange={(value) => {
+ if (activeTextElement) setTextElementValue(activeTextElement, value);
+ }}
+ onTextPatch={(patch) => {
+ if (activeTextElement) patchTextElement(activeTextElement.id, patch);
+ }}
+ onDeleteText={() => {
+ if (activeTextElement) deleteTextElement(activeTextElement);
+ }}
/>
) : (
<div className="rounded border border-dashed bg-background/40 p-4 text-center text-[11px] text-muted-foreground">
@@ -234,26 +402,60 @@ function ElementTransformControls({
function ActiveElementPanel({
activeId,
transform,
+ textElement,
+ locale,
onRotate,
onReorder,
+ onTextChange,
+ onTextPatch,
+ onDeleteText,
}: {
activeId: ElementId;
transform: ElementTransform | undefined;
+ textElement?: TextElement;
+ locale: string;
onRotate: (rotation: number) => void;
onReorder: (dir: "front" | "back" | "up" | "down") => void;
+ onTextChange: (value: string) => void;
+ onTextPatch: (patch: Partial<TextElement>) => void;
+ onDeleteText: () => void;
}) {
const engaged = !!transform;
const rotation = transform?.rotation ?? 0;
- const label = ELEMENT_LABEL[activeId];
+ const label = elementLabel(activeId);
return (
<div className="space-y-2 rounded border bg-background/60 p-2.5">
<div className="flex items-center justify-between">
- <span className="text-xs font-medium">{label}</span>
- {!engaged && (
+ <span className="flex items-center gap-1 text-xs font-medium">
+ {textElement && <Type className="h-3.5 w-3.5" />}
+ {label}
+ </span>
+ {textElement ? (
+ <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"
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ </Button>
+ ) : !engaged ? (
<span className="text-[10px] text-muted-foreground">drag to enable</span>
- )}
+ ) : null}
</div>
+ {textElement && (
+ <TextElementPanel
+ element={textElement}
+ locale={locale}
+ onTextChange={onTextChange}
+ onTextPatch={onTextPatch}
+ />
+ )}
+
<div className="space-y-1">
<div className="flex items-center justify-between">
<Label className="flex items-center gap-1 text-[11px] text-muted-foreground">
@@ -297,6 +499,77 @@ function ActiveElementPanel({
);
}
+function TextElementPanel({
+ element,
+ locale,
+ onTextChange,
+ onTextPatch,
+}: {
+ element: TextElement;
+ locale: string;
+ onTextChange: (value: string) => void;
+ onTextPatch: (patch: Partial<TextElement>) => void;
+}) {
+ const text = element.text?.[locale] ?? pickText(element.text, locale);
+ 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">Text</Label>
+ <Textarea
+ value={text}
+ rows={2}
+ onChange={(event) => onTextChange(event.target.value)}
+ placeholder="Overlay text"
+ />
+ </div>
+ <div className="grid grid-cols-[1fr_76px] gap-2">
+ <div className="space-y-1">
+ <Label className="text-[11px] text-muted-foreground">Size</Label>
+ <Input
+ type="number"
+ min={12}
+ max={400}
+ value={Math.round(element.fontSize || 72)}
+ onChange={(event) => onTextPatch({ fontSize: Number(event.target.value) || 72 })}
+ />
+ </div>
+ <div className="space-y-1">
+ <Label className="text-[11px] text-muted-foreground">Color</Label>
+ <Input
+ type="color"
+ value={element.color || "#171717"}
+ className="h-9 p-1"
+ onChange={(event) => onTextPatch({ color: event.target.value })}
+ />
+ </div>
+ </div>
+ <div className="grid grid-cols-3 gap-1">
+ <LayerButton
+ disabled={false}
+ onClick={() => onTextPatch({ align: "left" })}
+ label="Align left"
+ >
+ <AlignLeft className="h-3.5 w-3.5" />
+ </LayerButton>
+ <LayerButton
+ disabled={false}
+ onClick={() => onTextPatch({ align: "center" })}
+ label="Align center"
+ >
+ <AlignCenter className="h-3.5 w-3.5" />
+ </LayerButton>
+ <LayerButton
+ disabled={false}
+ onClick={() => onTextPatch({ align: "right" })}
+ label="Align right"
+ >
+ <AlignRight className="h-3.5 w-3.5" />
+ </LayerButton>
+ </div>
+ </div>
+ );
+}
+
function LayerButton({
disabled,
onClick,
@@ -324,7 +597,13 @@ function LayerButton({
);
}
+function elementLabel(id: ElementId): string {
+ if (isBuiltInElementId(id)) return ELEMENT_LABEL[id];
+ return "Text";
+}
+
function defaultZ(id: ElementId): number {
+ if (isTextElementId(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 88729f9..2058810 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
@@ -1,59 +1,77 @@
"use client";
import * as React from "react";
+import { Maximize2, ZoomIn, ZoomOut } from "lucide-react";
+import { Button } from "@/components/ui/button";
import { DEVICE_LABEL, LAYOUT_LABEL } from "@/lib/constants";
import type {
Device,
ElementId,
ElementTransform,
Orientation,
+ SelectedElement,
Slide,
Theme,
} from "@/lib/types";
-import { getCanvas, SlideCanvas } from "./slide-canvas";
+import { DeckCanvas, getCanvas } from "./slide-canvas";
type Props = {
- slide: Slide;
+ slides: Slide[];
+ activeSlideId: string | null;
device: Device;
orientation: Orientation;
theme: Theme;
locale: string;
appName?: string;
appIcon?: string;
- selectedElementId: ElementId | null;
- onLabelChange: (v: string) => void;
- onHeadlineChange: (v: string) => void;
- onElementChange: (id: ElementId, t: ElementTransform) => void;
- onSelectElement: (id: ElementId | null) => void;
+ connectedCanvas: boolean;
+ selectedElement: SelectedElement | null;
+ onActiveSlideChange: (id: string) => void;
+ onLabelChange: (slide: Slide, v: string) => void;
+ onHeadlineChange: (slide: Slide, v: string) => void;
+ onTextElementTextChange: (slideId: string, id: string, v: string) => void;
+ onElementChange: (slideId: string, id: ElementId, t: ElementTransform) => void;
+ onSelectElement: (element: SelectedElement | null) => void;
};
-// Fits the full-resolution canvas inside its container by measuring the
-// container and applying transform: scale().
+// Fits one full-resolution screen inside the viewport while keeping the whole
+// deck horizontally scrollable as one connected canvas.
export function PreviewStage({
- slide,
+ slides,
+ activeSlideId,
device,
orientation,
theme,
locale,
appName,
appIcon,
- selectedElementId,
+ connectedCanvas,
+ selectedElement,
+ onActiveSlideChange,
onLabelChange,
onHeadlineChange,
+ onTextElementTextChange,
onElementChange,
onSelectElement,
}: Props) {
const containerRef = React.useRef<HTMLDivElement>(null);
- const [scale, setScale] = React.useState(0.2);
+ const scrollerRef = React.useRef<HTMLDivElement>(null);
+ const suppressNextActiveScreenPanRef = React.useRef(false);
+ const [fitScale, setFitScale] = React.useState(0.2);
+ const [zoom, setZoom] = React.useState(1);
const { cW, cH } = getCanvas(device, orientation);
+ const totalW = Math.max(1, slides.length) * cW;
+ const scale = fitScale * zoom;
+ const activeIndex = Math.max(0, slides.findIndex((slide) => slide.id === activeSlideId));
+ const activeSlide = slides[activeIndex] || slides[0] || null;
React.useEffect(() => {
const el = containerRef.current;
if (!el) return;
const update = () => {
const rect = el.getBoundingClientRect();
- const sx = (rect.width - 48) / cW;
- const sy = (rect.height - 48) / cH;
- setScale(Math.max(0.05, Math.min(sx, sy)));
+ const sx = (rect.width - 96) / cW;
+ const sy = (rect.height - 96) / cH;
+ setFitScale(Math.max(0.05, Math.min(sx, sy)));
};
update();
const ro = new ResizeObserver(update);
@@ -61,55 +79,153 @@ export function PreviewStage({
return () => ro.disconnect();
}, [cW, cH]);
+ React.useEffect(() => {
+ setZoom(1);
+ }, [device, orientation]);
+
+ React.useEffect(() => {
+ if (suppressNextActiveScreenPanRef.current) {
+ suppressNextActiveScreenPanRef.current = false;
+ return;
+ }
+
+ const scroller = scrollerRef.current;
+ if (!scroller || !activeSlide) return;
+ const screenLeft = activeIndex * cW * scale;
+ const screenWidth = cW * scale;
+ const targetLeft = Math.max(0, screenLeft - (scroller.clientWidth - screenWidth) / 2);
+ scroller.scrollTo({ left: targetLeft, behavior: "smooth" });
+ }, [activeIndex, activeSlide, cW, scale]);
+
+ const handleCanvasActiveSlideChange = React.useCallback(
+ (id: string) => {
+ if (id !== activeSlideId) {
+ suppressNextActiveScreenPanRef.current = true;
+ }
+ onActiveSlideChange(id);
+ },
+ [activeSlideId, onActiveSlideChange],
+ );
+
return (
<div
ref={containerRef}
- className="relative flex h-full w-full items-center justify-center overflow-hidden bg-[radial-gradient(60%_60%_at_50%_40%,_hsl(var(--background))_0%,_hsl(var(--muted))_100%)]"
+ className="relative h-full w-full overflow-hidden bg-[radial-gradient(70%_70%_at_50%_35%,_hsl(var(--background))_0%,_hsl(var(--muted))_100%)]"
>
- <div
- style={{
- width: cW,
- height: cH,
- transform: `scale(${scale})`,
- transformOrigin: "center center",
- flexShrink: 0,
- boxShadow: "0 40px 80px -30px rgba(0,0,0,0.32), 0 10px 24px -12px rgba(0,0,0,0.18)",
- background: "white",
- borderRadius: 12 / scale,
- overflow: "hidden",
- }}
- >
- <SlideCanvas
- slide={slide}
- device={device}
- orientation={orientation}
- theme={theme}
- locale={locale}
- appName={appName}
- appIcon={appIcon}
- editable
- previewScale={scale}
- selectedElementId={selectedElementId}
- edit={{ onLabelChange, onHeadlineChange, onElementChange, onSelectElement }}
- />
+ <div ref={scrollerRef} className="h-full w-full overflow-auto p-12">
+ <div
+ style={{
+ width: totalW * scale,
+ height: cH * scale,
+ position: "relative",
+ flexShrink: 0,
+ filter: "drop-shadow(0 32px 42px rgba(15, 23, 42, 0.18))",
+ }}
+ >
+ <div
+ style={{
+ width: totalW,
+ height: cH,
+ transform: `scale(${scale})`,
+ transformOrigin: "top left",
+ }}
+ >
+ <DeckCanvas
+ slides={slides}
+ device={device}
+ orientation={orientation}
+ theme={theme}
+ locale={locale}
+ appName={appName}
+ appIcon={appIcon}
+ connectedCanvas={connectedCanvas}
+ editable
+ previewScale={scale}
+ selectedElement={selectedElement}
+ activeSlideId={activeSlide?.id || null}
+ showGuides
+ edit={{
+ onLabelChange: (slideId, value) => {
+ const slide = slides.find((s) => s.id === slideId);
+ if (slide) onLabelChange(slide, value);
+ },
+ onHeadlineChange: (slideId, value) => {
+ const slide = slides.find((s) => s.id === slideId);
+ if (slide) onHeadlineChange(slide, value);
+ },
+ onTextElementTextChange,
+ onElementChange,
+ onSelectElement,
+ onSelectScreen: handleCanvasActiveSlideChange,
+ }}
+ />
+ </div>
+ </div>
</div>
- <div className="pointer-events-none absolute left-4 top-4 flex items-center gap-1.5 text-[11px] text-muted-foreground">
+ <div className="pointer-events-none absolute left-4 top-4 flex items-center gap-1.5 rounded-md bg-background/80 px-2 py-1 text-[11px] text-muted-foreground shadow-sm backdrop-blur">
<span className="font-medium text-foreground">{DEVICE_LABEL[device]}</span>
- <span aria-hidden>·</span>
- <span>{LAYOUT_LABEL[slide.layout]}</span>
+ {activeSlide && (
+ <>
+ <span aria-hidden>·</span>
+ <span>Screen {activeIndex + 1}</span>
+ <span aria-hidden>·</span>
+ <span>{LAYOUT_LABEL[activeSlide.layout]}</span>
+ </>
+ )}
{orientation === "landscape" && (
<>
<span aria-hidden>·</span>
<span>landscape</span>
</>
)}
+ {!connectedCanvas && (
+ <>
+ <span aria-hidden>·</span>
+ <span>isolated</span>
+ </>
+ )}
</div>
- <div className="pointer-events-none absolute bottom-4 right-4 flex items-center gap-1.5 text-[10px] tabular-nums text-muted-foreground">
- <span>{cW}×{cH}</span>
- <span aria-hidden>·</span>
- <span>{(scale * 100).toFixed(0)}%</span>
+ <div className="absolute bottom-4 right-4 flex items-center gap-1.5 rounded-md bg-background/85 px-1.5 py-1 text-[10px] tabular-nums text-muted-foreground shadow-sm backdrop-blur">
+ <span className="px-1">{slides.length}× {cW}×{cH}</span>
+ <span aria-hidden className="text-border">|</span>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="h-6 w-6"
+ onClick={() => setZoom((value) => Math.max(0.25, Number((value - 0.1).toFixed(2))))}
+ disabled={zoom <= 0.25}
+ title="Zoom out"
+ aria-label="Zoom out"
+ >
+ <ZoomOut className="h-3.5 w-3.5" />
+ </Button>
+ <span className="min-w-10 text-center">{(scale * 100).toFixed(0)}%</span>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="h-6 w-6"
+ onClick={() => setZoom((value) => Math.min(2, Number((value + 0.1).toFixed(2))))}
+ disabled={zoom >= 2}
+ title="Zoom in"
+ aria-label="Zoom in"
+ >
+ <ZoomIn className="h-3.5 w-3.5" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="h-6 w-6"
+ onClick={() => setZoom(1)}
+ title="Fit active screen"
+ aria-label="Fit active screen"
+ >
+ <Maximize2 className="h-3.5 w-3.5" />
+ </Button>
</div>
</div>
);
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 1f036c1..8abf6bf 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,37 +5,49 @@ import { toPng } from "html-to-image";
import { Toaster, toast } from "sonner";
import {
getExportSizes,
+ hasTheme,
supportsLandscape,
- THEMES,
+ themeById,
} from "@/lib/constants";
import { detectPlatform, nid } from "@/lib/defaults";
+import { isBuiltInElementId, isTextElementId, textElementKey } from "@/lib/elements";
import { preloadImages } from "@/lib/image-cache";
import { resolveScreenshot, writeLocalized } from "@/lib/locale";
import { useProject } from "@/lib/storage";
-import type { Device, ElementId, Slide } from "@/lib/types";
+import type {
+ BuiltInElementId,
+ Device,
+ ElementId,
+ ElementTransform,
+ SelectedElement,
+ Slide,
+} from "@/lib/types";
import { Inspector } from "./inspector";
import { PreviewStage } from "./preview-stage";
import { Sidebar } from "./sidebar";
-import { SlideCanvas, getCanvas } from "./slide-canvas";
+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 [activeSlideId, setActiveSlideId] = React.useState<string | null>(null);
- const [selectedElementId, setSelectedElementId] = React.useState<ElementId | null>(null);
+ const [selectedElement, setSelectedElement] = React.useState<SelectedElement | null>(null);
const [exporting, setExporting] = React.useState<string | null>(null);
const [ready, setReady] = React.useState(false);
const [exportLocaleOverride, setExportLocaleOverride] = React.useState<string | null>(null);
- const exportRefs = React.useRef<Record<string, HTMLDivElement | null>>({});
+ const [exportSlideIndex, setExportSlideIndex] = React.useState(0);
+ const exportRef = React.useRef<HTMLDivElement | null>(null);
const currentSlides = state.slidesByDevice[state.device] || [];
const activeSlide =
currentSlides.find((s) => s.id === activeSlideId) || currentSlides[0] || null;
- const theme = THEMES[state.themeId];
+ const theme = themeById(state.themeId);
React.useEffect(() => {
- setSelectedElementId(null);
- }, [activeSlide?.id]);
+ if (selectedElement && selectedElement.slideId !== activeSlide?.id) {
+ setSelectedElement(null);
+ }
+ }, [activeSlide?.id, selectedElement]);
React.useEffect(() => {
if (!hydrated) return;
@@ -50,6 +62,15 @@ export function ScreenshotEditor() {
}
}, [state.device, state.orientation, setState]);
+ React.useEffect(() => {
+ if (hydrated && state.themeId && !hasTheme(state.themeId)) {
+ toast.warning("Using fallback theme", {
+ description: `Theme "${state.themeId}" is not defined in src/lib/constants.ts.`,
+ duration: 8000,
+ });
+ }
+ }, [hydrated, state.themeId]);
+
const assetPaths = React.useMemo(() => {
const paths = new Set<string>();
paths.add("/mockup.png");
@@ -81,7 +102,7 @@ export function ScreenshotEditor() {
// Surface storage failures (quota exceeded etc.) so the user knows their work isn't safe.
React.useEffect(() => {
if (saveError) {
- toast.error("Couldn't save changes locally", {
+ toast.error("Couldn't load or save project file", {
description: saveError,
duration: 8000,
});
@@ -132,9 +153,8 @@ export function ScreenshotEditor() {
};
});
setActiveSlideId((cur) => (cur === id ? fallback?.id || null : cur));
- delete exportRefs.current[id];
- toast("Slide deleted", {
+ toast("Screen deleted", {
action: {
label: "Undo",
onClick: () => {
@@ -179,6 +199,62 @@ export function ScreenshotEditor() {
[patchSlide, state.locale],
);
+ const patchElementTransform = React.useCallback(
+ (slideId: string, elementId: ElementId, transform: ElementTransform) => {
+ setState((prev) => ({
+ ...prev,
+ slidesByDevice: {
+ ...prev.slidesByDevice,
+ [prev.device]: (prev.slidesByDevice[prev.device] || []).map((slide) => {
+ if (slide.id !== slideId) return slide;
+ if (isTextElementId(elementId)) {
+ const textId = textElementKey(elementId);
+ return {
+ ...slide,
+ textElements: (slide.textElements || []).map((element) =>
+ element.id === textId ? { ...element, transform } : element,
+ ),
+ };
+ }
+ if (!isBuiltInElementId(elementId)) return slide;
+ return {
+ ...slide,
+ transforms: {
+ ...(slide.transforms || {}),
+ [elementId]: transform,
+ } as Partial<Record<BuiltInElementId, ElementTransform>>,
+ };
+ }),
+ },
+ }));
+ },
+ [setState],
+ );
+
+ const patchTextElementText = React.useCallback(
+ (slideId: string, textId: string, value: string) => {
+ setState((prev) => ({
+ ...prev,
+ slidesByDevice: {
+ ...prev.slidesByDevice,
+ [prev.device]: (prev.slidesByDevice[prev.device] || []).map((slide) =>
+ slide.id === slideId
+ ? {
+ ...slide,
+ textElements: (slide.textElements || []).map((element) =>
+ element.id === textId
+ ? { ...element, text: writeLocalized(element.text, prev.locale, value) }
+ : element,
+ ),
+ }
+ : slide,
+ ),
+ },
+ }));
+ },
+ [setState],
+ );
+
const duplicateSlide = React.useCallback(
(id: string) => {
let newId: string | null = null;
@@ -188,7 +264,23 @@ export function ScreenshotEditor() {
if (idx === -1) return prev;
const src = slides[idx];
newId = nid();
- const copy: Slide = { ...src, id: newId };
+ const copy: Slide = {
+ ...src,
+ id: newId,
+ label: { ...src.label },
+ headline: { ...src.headline },
+ transforms: src.transforms
+ ? Object.fromEntries(
+ Object.entries(src.transforms).map(([key, value]) => [key, { ...value }]),
+ )
+ : undefined,
+ textElements: src.textElements?.map((element) => ({
+ ...element,
+ id: nid(),
+ text: { ...element.text },
+ transform: { ...element.transform },
+ })),
+ };
const next = [...slides.slice(0, idx + 1), copy, ...slides.slice(idx + 1)];
return {
...prev,
@@ -212,8 +304,16 @@ export function ScreenshotEditor() {
(target as HTMLElement).isContentEditable);
if (exporting) return;
- // Undo / redo and deselect work everywhere (including inside text
- // fields) so the shortcuts feel native.
+ if (e.key === "Escape") {
+ setSelectedElement(null);
+ if (target && "blur" in target && typeof target.blur === "function") target.blur();
+ return;
+ }
+
+ // Let focused inputs and contenteditable text keep their native undo,
+ // redo, selection, and deletion behavior.
+ if (inEditable) return;
+
if ((e.metaKey || e.ctrlKey) && (e.key === "z" || e.key === "Z")) {
e.preventDefault();
if (e.shiftKey) redo();
@@ -225,13 +325,6 @@ export function ScreenshotEditor() {
redo();
return;
}
- if (e.key === "Escape") {
- setSelectedElementId(null);
- if (target && "blur" in target && typeof target.blur === "function") target.blur();
- return;
- }
-
- if (inEditable) return;
if (!currentSlides.length) return;
const idx = activeSlide ? currentSlides.findIndex((s) => s.id === activeSlide.id) : -1;
if (e.key === "ArrowDown" || (e.key === "j" && !e.metaKey && !e.ctrlKey)) {
@@ -270,7 +363,7 @@ export function ScreenshotEditor() {
async function exportAll() {
if (!currentSlides.length) {
- toast.error("No slides to export");
+ toast.error("No screens to export");
return;
}
@@ -280,6 +373,35 @@ export function ScreenshotEditor() {
return;
}
const locales = state.locales;
+ await preloadImages(assetPaths, { retryFailed: true });
+ await waitForPaint();
+
+ const missingScreens = currentSlides
+ .map((slide, index) => ({ slide, index }))
+ .filter(({ slide }) => slideNeedsScreenshot(state.device, slide) && !slide.screenshot);
+ const reusedBackScreens = currentSlides
+ .map((slide, index) => ({ slide, index }))
+ .filter(
+ ({ slide }) =>
+ state.device !== "feature-graphic" &&
+ slide.layout === "two-devices" &&
+ slide.screenshot &&
+ !slide.screenshotSecondary,
+ );
+ if (missingScreens.length > 0 || reusedBackScreens.length > 0) {
+ const details = [
+ missingScreens.length
+ ? `${missingScreens.length} screen${missingScreens.length === 1 ? "" : "s"} will export with an empty device.`
+ : null,
+ reusedBackScreens.length
+ ? `${reusedBackScreens.length} two-device screen${reusedBackScreens.length === 1 ? "" : "s"} will reuse the primary screenshot in back.`
+ : null,
+ ].filter(Boolean);
+ toast.warning("Export includes placeholder screenshots", {
+ description: details.join(" "),
+ duration: 7000,
+ });
+ }
// Make sure custom fonts are loaded before snapshot so typography in PNG
// matches what's on screen.
@@ -305,22 +427,20 @@ export function ScreenshotEditor() {
await waitForPaint();
for (const size of sizes) {
- // Uniform downscale so smaller sizes shrink instead of getting cropped
- // by html-to-image.
- const scale = Math.min(size.w / cW, size.h / cH);
-
for (let i = 0; i < currentSlides.length; i++) {
const slide = currentSlides[i];
unit += 1;
setExporting(`${unit}/${totalUnits}`);
- const el = exportRefs.current[slide.id];
+ setExportSlideIndex(i);
+ await waitForPaint();
+ const el = exportRef.current;
if (!el) {
failed += 1;
- errors.push(`${locale} ${size.w}×${size.h} slide ${i + 1}: render target missing`);
+ errors.push(`${locale} ${size.w}×${size.h} screen ${i + 1}: render target missing`);
continue;
}
try {
- const dataUrl = await captureSlide(el, size.w, size.h, scale);
+ const dataUrl = await captureSlide(el, cW, cH, size.w, size.h);
const base64 = dataUrl.split(",")[1] || "";
const filename = `${String(i + 1).padStart(2, "0")}-${slide.layout}.png`;
const path = `${platform}/${state.device}/${size.w}x${size.h}/${locale}/${filename}`;
@@ -329,7 +449,7 @@ export function ScreenshotEditor() {
} catch (e) {
failed += 1;
const msg = e instanceof Error ? e.message : String(e);
- errors.push(`${locale} ${size.w}×${size.h} slide ${i + 1}: ${msg}`);
+ errors.push(`${locale} ${size.w}×${size.h} screen ${i + 1}: ${msg}`);
console.error("Export failed", { slideId: slide.id, locale, size }, e);
}
}
@@ -369,10 +489,16 @@ export function ScreenshotEditor() {
}
}
- async function captureSlide(el: HTMLElement, w: number, h: number, scale: number) {
- // html-to-image needs the node at (0,0) and uniformly scaled so the
- // captured pixel buffer matches the requested export size. Snapshot the
- // styles we touch so we can restore them after capture.
+ async function captureSlide(
+ el: HTMLElement,
+ sourceW: number,
+ sourceH: number,
+ exportW: number,
+ exportH: number,
+ ) {
+ // html-to-image needs the node at (0,0). Let the library scale the source
+ // canvas into the requested output dimensions; CSS transforms leave
+ // transparent gutters when export aspect ratios differ by a few pixels.
const prev = {
left: el.style.left,
top: el.style.top,
@@ -384,13 +510,15 @@ export function ScreenshotEditor() {
el.style.left = "0px";
el.style.top = "0px";
el.style.position = "absolute";
- el.style.transform = `scale(${scale})`;
+ el.style.transform = "none";
el.style.transformOrigin = "top left";
el.style.zIndex = "-1";
try {
const dataUrl = await toPng(el, {
- width: w,
- height: h,
+ width: sourceW,
+ height: sourceH,
+ canvasWidth: exportW,
+ canvasHeight: exportH,
pixelRatio: 1,
cacheBust: false,
backgroundColor: "#ffffff",
@@ -428,6 +556,8 @@ export function ScreenshotEditor() {
<Toolbar
appName={state.appName}
setAppName={(v) => setState((p) => ({ ...p, appName: v }))}
+ connectedCanvas={state.connectedCanvas}
+ setConnectedCanvas={(v) => setState((p) => ({ ...p, connectedCanvas: v }))}
locale={state.locale}
setLocale={(v) => setState((p) => ({ ...p, locale: v }))}
locales={state.locales}
@@ -463,6 +593,7 @@ export function ScreenshotEditor() {
locale={state.locale}
appName={state.appName}
appIcon={state.appIcon}
+ connectedCanvas={state.connectedCanvas}
disabled={busy}
onReorder={reorderSlides}
onSelect={setActiveSlideId}
@@ -473,29 +604,29 @@ export function ScreenshotEditor() {
</aside>
<main className="flex flex-1 items-stretch overflow-hidden min-h-0">
- {activeSlide ? (
+ {activeSlide && currentSlides.length > 0 ? (
<PreviewStage
- slide={activeSlide}
+ slides={currentSlides}
+ activeSlideId={activeSlide.id}
device={state.device}
orientation={state.orientation}
theme={theme}
locale={state.locale}
appName={state.appName}
appIcon={state.appIcon}
- selectedElementId={selectedElementId}
- onLabelChange={(v) => patchLocalized(activeSlide, "label", v)}
- onHeadlineChange={(v) => patchLocalized(activeSlide, "headline", v)}
- onElementChange={(id, t) =>
- patchSlide(activeSlide.id, {
- transforms: { ...(activeSlide.transforms || {}), [id]: t },
- })
- }
- onSelectElement={setSelectedElementId}
+ connectedCanvas={state.connectedCanvas}
+ selectedElement={selectedElement}
+ onActiveSlideChange={setActiveSlideId}
+ onLabelChange={(slide, v) => patchLocalized(slide, "label", v)}
+ onHeadlineChange={(slide, v) => patchLocalized(slide, "headline", v)}
+ onTextElementTextChange={patchTextElementText}
+ onElementChange={patchElementTransform}
+ onSelectElement={setSelectedElement}
/>
) : (
<div className="flex flex-1 flex-col items-center justify-center gap-2 p-8 text-center text-sm text-muted-foreground">
- <p className="font-medium text-foreground">No slide selected</p>
- <p>Add a slide on the left to get started.</p>
+ <p className="font-medium text-foreground">No screen selected</p>
+ <p>Add a screen on the left to get started.</p>
</div>
)}
</main>
@@ -504,14 +635,23 @@ export function ScreenshotEditor() {
{activeSlide ? (
<Inspector
slide={activeSlide}
+ device={state.device}
+ orientation={state.orientation}
locale={state.locale}
- selectedElementId={selectedElementId}
+ selectedElementId={
+ selectedElement?.slideId === activeSlide.id ? selectedElement.elementId : null
+ }
onChange={(patch) => patchSlide(activeSlide.id, patch)}
+ onSelectElement={(elementId) =>
+ setSelectedElement(
+ elementId ? { slideId: activeSlide.id, elementId } : null,
+ )
+ }
/>
) : (
<div className="flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground">
<p className="font-medium text-foreground">Nothing to inspect</p>
- <p className="text-xs">Slide settings will appear here once you add or select one.</p>
+ <p className="text-xs">Screen settings will appear here once you add or select one.</p>
</div>
)}
</aside>
@@ -527,27 +667,41 @@ export function ScreenshotEditor() {
pointerEvents: "none",
}}
>
- {currentSlides.map((slide) => (
+ {currentSlides.length > 0 && (
<div
- key={slide.id}
- ref={(el) => {
- if (el) exportRefs.current[slide.id] = el;
- else delete exportRefs.current[slide.id];
+ ref={exportRef}
+ style={{
+ width: cW,
+ height: cH,
+ overflow: "hidden",
+ position: "absolute",
+ left: -99999,
+ top: 0,
}}
- style={{ width: cW, height: cH, position: "absolute", left: -99999, top: 0 }}
>
- <SlideCanvas
- slide={slide}
- device={state.device}
- orientation={state.orientation}
- theme={theme}
- locale={exportLocaleOverride ?? state.locale}
- appName={state.appName}
- appIcon={state.appIcon}
- hideEmpty
- />
+ <div
+ style={{
+ position: "absolute",
+ left: -exportSlideIndex * cW,
+ top: 0,
+ width: cW * currentSlides.length,
+ height: cH,
+ }}
+ >
+ <DeckCanvas
+ slides={currentSlides}
+ device={state.device}
+ orientation={state.orientation}
+ theme={theme}
+ locale={exportLocaleOverride ?? state.locale}
+ appName={state.appName}
+ appIcon={state.appIcon}
+ connectedCanvas={state.connectedCanvas}
+ hideEmpty
+ />
+ </div>
</div>
- ))}
+ )}
</div>
</div>
);
@@ -562,6 +716,11 @@ function slugify(s: string) {
);
}
+function slideNeedsScreenshot(device: Device, slide: Slide) {
+ if (device === "feature-graphic") return false;
+ return slide.layout !== "no-device" && slide.layout !== "feature-graphic";
+}
+
function stamp() {
const d = new Date();
const pad = (n: number) => String(n).padStart(2, "0");
diff --git a/skills/app-store-screenshots/template/src/components/editor/screenshot-picker.tsx b/skills/app-store-screenshots/template/src/components/editor/screenshot-picker.tsx
index f1b48d0..eec98ca 100644
--- a/skills/app-store-screenshots/template/src/components/editor/screenshot-picker.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/screenshot-picker.tsx
@@ -3,10 +3,12 @@ import * as React from "react";
import { Image as ImageIcon, Upload, X } from "lucide-react";
import { Button } from "@/components/ui/button";
import { didFail, img, setImage } from "@/lib/image-cache";
+import { resolveScreenshot } from "@/lib/locale";
type Props = {
label: string;
value: string;
+ locale?: string;
onChange: (v: string) => void;
};
@@ -36,12 +38,16 @@ async function uploadDataUrl(dataUrl: string): Promise<string | null> {
}
}
-export function ScreenshotPicker({ label, value, onChange }: Props) {
+export function ScreenshotPicker({ label, value, locale, onChange }: Props) {
const inputRef = React.useRef<HTMLInputElement>(null);
const [dragging, setDragging] = React.useState(false);
const [error, setError] = React.useState<string | null>(null);
const [uploading, setUploading] = React.useState(false);
+ React.useEffect(() => {
+ setError(null);
+ }, [value, locale]);
+
async function handleFile(file: File) {
setError(null);
if (!ACCEPTED.includes(file.type)) {
@@ -76,9 +82,10 @@ export function ScreenshotPicker({ label, value, onChange }: Props) {
const hasValue = !!value;
const isData = hasValue && value.startsWith("data:");
- const previewSrc = isData ? value : hasValue ? img(value) : "";
+ const resolvedValue = hasValue && !isData && locale ? resolveScreenshot(value, locale) : value;
+ const previewSrc = isData ? value : hasValue ? img(resolvedValue) : "";
// Only flag "image not found" when the path is a real URL that we tried and failed.
- const knownMissing = hasValue && !isData && didFail(value);
+ const knownMissing = hasValue && !isData && didFail(resolvedValue);
const valueLabel = uploading
? "saving…"
: !hasValue
@@ -169,7 +176,7 @@ export function ScreenshotPicker({ label, value, onChange }: Props) {
{error ? (
<p className="text-[11px] text-destructive">{error}</p>
) : knownMissing ? (
- <p className="text-[11px] text-destructive">Image not found at {value}</p>
+ <p className="text-[11px] text-destructive">Image not found at {resolvedValue}</p>
) : null}
</div>
);
diff --git a/skills/app-store-screenshots/template/src/components/editor/sidebar.tsx b/skills/app-store-screenshots/template/src/components/editor/sidebar.tsx
index 43d7d13..d5b3e9e 100644
--- a/skills/app-store-screenshots/template/src/components/editor/sidebar.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/sidebar.tsx
@@ -30,6 +30,7 @@ type Props = {
locale: string;
appName?: string;
appIcon?: string;
+ connectedCanvas: boolean;
disabled?: boolean;
onReorder: (next: Slide[]) => void;
onSelect: (id: string) => void;
@@ -47,6 +48,7 @@ export function Sidebar({
locale,
appName,
appIcon,
+ connectedCanvas,
disabled,
onReorder,
onSelect,
@@ -71,9 +73,9 @@ export function Sidebar({
return (
<div className="flex h-full flex-col">
<div className="border-b p-3">
- <h2 className="text-sm font-semibold">Slides</h2>
+ <h2 className="text-sm font-semibold">Screens</h2>
<p className="text-xs text-muted-foreground">
- {slides.length} slide{slides.length === 1 ? "" : "s"} · drag to reorder
+ {slides.length} screen{slides.length === 1 ? "" : "s"} · drag to reorder
</p>
</div>
@@ -85,6 +87,7 @@ export function Sidebar({
<SlideThumb
key={slide.id}
slide={slide}
+ slides={slides}
index={i}
active={slide.id === activeId}
device={device}
@@ -93,6 +96,7 @@ export function Sidebar({
locale={locale}
appName={appName}
appIcon={appIcon}
+ connectedCanvas={connectedCanvas}
onSelect={() => onSelect(slide.id)}
onDelete={() => onDelete(slide.id)}
onDuplicate={() => onDuplicate(slide.id)}
@@ -100,9 +104,9 @@ export function Sidebar({
))}
{slides.length === 0 && (
<div className="rounded-lg border border-dashed p-6 text-center">
- <p className="text-xs font-medium text-foreground">No slides yet</p>
+ <p className="text-xs font-medium text-foreground">No screens yet</p>
<p className="mt-1 text-[11px] text-muted-foreground">
- Click <span className="font-semibold">Add slide</span> to get started.
+ Click <span className="font-semibold">Add screen</span> to get started.
</p>
</div>
)}
@@ -116,10 +120,10 @@ export function Sidebar({
type="button"
className="w-full"
variant="default"
- onClick={() => onAdd(newSlide("device-bottom"))}
+ onClick={() => onAdd(newSlide(device === "feature-graphic" ? "feature-graphic" : "device-bottom"))}
disabled={disabled}
>
- <Plus className="h-4 w-4" /> Add slide
+ <Plus className="h-4 w-4" /> Add screen
</Button>
</div>
</div>
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 937c4b7..1814067 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
@@ -1,12 +1,16 @@
"use client";
import * as React from "react";
import { Rnd } from "react-rnd";
+import { RotateCw } from "lucide-react";
import type {
+ BuiltInElementId,
Device,
ElementId,
ElementTransform,
Orientation,
+ SelectedElement,
Slide,
+ TextElement,
Theme,
} from "@/lib/types";
import {
@@ -19,6 +23,7 @@ import {
tabletLW,
tabletPW,
} from "@/lib/constants";
+import { toTextElementId } from "@/lib/elements";
import { img } from "@/lib/image-cache";
import { pickText, resolveScreenshot } from "@/lib/locale";
import {
@@ -82,6 +87,7 @@ export function getFrameForDevice(device: Device, orientation: Orientation): {
type EditHandlers = {
onLabelChange?: (v: string) => void;
onHeadlineChange?: (v: string) => void;
+ onTextElementTextChange?: (id: string, v: string) => void;
onElementChange?: (id: ElementId, t: ElementTransform) => void;
onSelectElement?: (id: ElementId | null) => void;
};
@@ -104,6 +110,33 @@ type Props = {
hideEmpty?: boolean;
};
+type DeckEditHandlers = {
+ onLabelChange?: (slideId: string, v: string) => void;
+ onHeadlineChange?: (slideId: string, v: string) => void;
+ onTextElementTextChange?: (slideId: string, id: string, v: string) => void;
+ onElementChange?: (slideId: string, id: ElementId, t: ElementTransform) => void;
+ onSelectElement?: (element: SelectedElement | null) => void;
+ onSelectScreen?: (slideId: string) => void;
+};
+
+type DeckCanvasProps = {
+ slides: Slide[];
+ device: Device;
+ orientation: Orientation;
+ theme: Theme;
+ locale: string;
+ appName?: string;
+ appIcon?: string;
+ connectedCanvas?: boolean;
+ editable?: boolean;
+ edit?: DeckEditHandlers;
+ selectedElement?: SelectedElement | null;
+ activeSlideId?: string | null;
+ previewScale?: number;
+ hideEmpty?: boolean;
+ showGuides?: boolean;
+};
+
// ---------- Editable text helpers ----------
function EditableText({
@@ -127,24 +160,16 @@ function EditableText({
React.useEffect(() => {
const el = ref.current;
if (!el) return;
- const incoming = multiline ? value.replace(/\n/g, "<br/>") : value;
- if (el.innerHTML !== incoming && document.activeElement !== el) {
- el.innerHTML = incoming || "";
+ const incoming = value || "";
+ if (el.textContent !== incoming && document.activeElement !== el) {
+ el.textContent = incoming;
}
- }, [value, multiline]);
+ }, [value]);
const handleInput = (e: React.FormEvent<HTMLDivElement>) => {
if (!onChange) return;
- const html = (e.currentTarget.innerHTML || "")
- .replace(/<div>/gi, "\n")
- .replace(/<\/div>/gi, "")
- .replace(/<br\s*\/?>/gi, "\n")
- .replace(/<[^>]+>/g, "")
- .replace(/&nbsp;/g, " ")
- .replace(/&amp;/g, "&")
- .replace(/&lt;/g, "<")
- .replace(/&gt;/g, ">");
- onChange(multiline ? html : html.replace(/\n/g, ""));
+ const text = (e.currentTarget.innerText || "").replace(/\u00a0/g, " ");
+ onChange(multiline ? text : text.replace(/\n/g, ""));
};
return (
@@ -155,6 +180,12 @@ function EditableText({
data-placeholder={placeholder}
onInput={handleInput}
onFocus={() => onFocus?.()}
+ onKeyDown={(e) => {
+ if (!multiline && e.key === "Enter") {
+ e.preventDefault();
+ e.currentTarget.blur();
+ }
+ }}
onMouseDown={(e) => {
// Allow text editing without starting an Rnd drag.
if (editable) {
@@ -402,7 +433,7 @@ function getDefaultRects(
}
function rectFor(
- id: ElementId,
+ id: BuiltInElementId,
slide: Slide,
defaults: LayoutRects,
): (Rect & { align?: "center" | "left" }) | undefined {
@@ -419,7 +450,48 @@ function rectFor(
};
}
-// ---------- Main canvas ----------
+function getSlideGeometry(slide: Slide, device: Device, orientation: Orientation) {
+ const { cW, cH } = getCanvas(device, orientation);
+ const { Comp: Frame, widthFn, smallWidthFn } = getFrameForDevice(device, orientation);
+ const frameAspect = getFrameAspect(device, orientation);
+ const fwFrac = widthFn(cW, cH);
+ const fwSmallFrac = smallWidthFn(cW, cH);
+ const defaults = getDefaultRects(slide.layout, cW, cH, frameAspect, fwFrac, fwSmallFrac);
+ return { cW, cH, Frame, frameAspect, defaults };
+}
+
+export function getElementTransform(
+ slide: Slide,
+ device: Device,
+ orientation: Orientation,
+ id: ElementId,
+): ElementTransform | undefined {
+ if (id.startsWith("text:")) {
+ const textId = id.slice("text:".length);
+ const textElement = slide.textElements?.find((element) => element.id === textId);
+ return textElement?.transform;
+ }
+ const { defaults } = getSlideGeometry(slide, device, orientation);
+ const rect = rectFor(id as BuiltInElementId, slide, defaults);
+ if (!rect) return undefined;
+ const saved = slide.transforms?.[id as BuiltInElementId];
+ return {
+ x: rect.x,
+ y: rect.y,
+ width: rect.width,
+ height: rect.height,
+ rotation: saved?.rotation ?? 0,
+ zIndex: saved?.zIndex ?? defaultElementZ(id as BuiltInElementId),
+ };
+}
+
+function defaultElementZ(id: BuiltInElementId): number {
+ if (id === "deviceSecondary") return 2;
+ if (id === "device") return 3;
+ return 4;
+}
+
+// ---------- Main single-screen canvas ----------
export function SlideCanvas({
slide,
@@ -436,90 +508,417 @@ export function SlideCanvas({
hideEmpty,
}: Props) {
const { cW, cH } = getCanvas(device, orientation);
- const screenshot = resolveScreenshot(slide.screenshot, locale);
- const screenshotSecondary = resolveScreenshot(slide.screenshotSecondary, locale);
- const { Comp: Frame, widthFn, smallWidthFn } = getFrameForDevice(device, orientation);
- const inverted = !!slide.inverted;
- const bg = backgroundFor(theme, inverted);
- const frameAspect = getFrameAspect(device, orientation);
- const fwFrac = widthFn(cW, cH);
- const fwSmallFrac = smallWidthFn(cW, cH);
- const defaults = getDefaultRects(slide.layout, cW, cH, frameAspect, fwFrac, fwSmallFrac);
- // Special: feature-graphic layout — its own composition (not draggable for now)
if (slide.layout === "feature-graphic" || device === "feature-graphic") {
return (
- <div
- style={{
- width: "100%",
- height: "100%",
- position: "relative",
- overflow: "hidden",
- background: `linear-gradient(135deg, ${theme.bgAlt} 0%, ${shade(theme.bgAlt, -10)} 50%, ${theme.accent} 200%)`,
- display: "flex",
- alignItems: "center",
- padding: `0 ${cW * 0.06}px`,
- color: theme.fgAlt,
- }}
- >
- <Blob cW={cW} color={theme.accent} x={70} y={20} size={50} opacity={0.45} />
- <div style={{ display: "flex", alignItems: "center", gap: cW * 0.03, zIndex: 2 }}>
- {appIcon && img(appIcon) ? (
- <img
- src={img(appIcon)}
- alt=""
- style={{
- width: cW * 0.13,
- height: cW * 0.13,
- borderRadius: cW * 0.022,
- boxShadow: "0 4px 16px rgba(0,0,0,0.3)",
- }}
- draggable={false}
- />
- ) : (
+ <FeatureGraphicCanvas
+ slide={slide}
+ cW={cW}
+ theme={theme}
+ locale={locale}
+ appName={appName}
+ appIcon={appIcon}
+ editable={editable}
+ edit={edit}
+ />
+ );
+ }
+
+ const handleBackgroundMouseDown = editable
+ ? (e: React.MouseEvent<HTMLDivElement>) => {
+ if (e.target === e.currentTarget) edit?.onSelectElement?.(null);
+ }
+ : undefined;
+
+ return (
+ <div
+ onMouseDown={handleBackgroundMouseDown}
+ style={{
+ width: "100%",
+ height: "100%",
+ position: "relative",
+ overflow: "hidden",
+ }}
+ >
+ <SlideBackground slide={slide} cW={cW} cH={cH} theme={theme} />
+ <SlideElements
+ slide={slide}
+ device={device}
+ orientation={orientation}
+ theme={theme}
+ locale={locale}
+ editable={editable}
+ edit={edit}
+ selectedElementId={selectedElementId}
+ previewScale={previewScale}
+ hideEmpty={hideEmpty}
+ screenX={0}
+ boundsW={cW}
+ boundsH={cH}
+ allowCrossScreen={false}
+ />
+ </div>
+ );
+}
+
+// ---------- Connected deck canvas ----------
+
+export function DeckCanvas({
+ slides,
+ device,
+ orientation,
+ theme,
+ locale,
+ appName,
+ appIcon,
+ connectedCanvas = true,
+ editable,
+ edit,
+ selectedElement = null,
+ activeSlideId = null,
+ previewScale = 1,
+ hideEmpty,
+ showGuides = false,
+}: DeckCanvasProps) {
+ const { cW, cH } = getCanvas(device, orientation);
+ const totalW = Math.max(1, slides.length) * cW;
+
+ return (
+ <div
+ style={{
+ width: totalW,
+ height: cH,
+ position: "relative",
+ overflow: "hidden",
+ }}
+ >
+ {slides.map((slide, index) => {
+ const screenX = index * cW;
+ const active = activeSlideId === slide.id;
+ if (slide.layout === "feature-graphic" || device === "feature-graphic") {
+ return (
<div
- aria-hidden
+ key={`${slide.id}-feature`}
+ onMouseDown={(e) => {
+ if (!editable || e.defaultPrevented) return;
+ edit?.onSelectScreen?.(slide.id);
+ edit?.onSelectElement?.(null);
+ }}
style={{
- width: cW * 0.13,
- height: cW * 0.13,
- borderRadius: cW * 0.022,
- background: `linear-gradient(135deg, ${theme.accent}55, ${theme.accent})`,
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- color: theme.fgAlt,
- fontWeight: 800,
- fontSize: cW * 0.07,
- boxShadow: "0 4px 16px rgba(0,0,0,0.3)",
+ position: "absolute",
+ left: screenX,
+ top: 0,
+ width: cW,
+ height: cH,
+ overflow: "hidden",
}}
>
- {(appName || "A").slice(0, 1).toUpperCase()}
+ <FeatureGraphicCanvas
+ slide={slide}
+ cW={cW}
+ theme={theme}
+ locale={locale}
+ appName={appName}
+ appIcon={appIcon}
+ editable={editable}
+ edit={{
+ onHeadlineChange: (v) => edit?.onHeadlineChange?.(slide.id, v),
+ }}
+ />
+ {showGuides && <ScreenGuide cW={cW} cH={cH} index={index} active={active} />}
</div>
- )}
- <div>
- <div style={{ fontSize: cW * 0.06, fontWeight: 800, lineHeight: 1.05 }}>{appName || "App"}</div>
- <EditableText
- value={pickText(slide.headline, locale)}
- editable={editable}
- multiline
- onChange={edit?.onHeadlineChange}
- style={{
- fontSize: cW * 0.028,
- color: "rgba(255,255,255,0.85)",
- marginTop: cW * 0.012,
- lineHeight: 1.25,
- }}
- />
+ );
+ }
+ return (
+ <div
+ key={`${slide.id}-bg`}
+ onMouseDown={(e) => {
+ if (!editable || e.defaultPrevented) return;
+ edit?.onSelectScreen?.(slide.id);
+ edit?.onSelectElement?.(null);
+ }}
+ style={{
+ position: "absolute",
+ left: screenX,
+ top: 0,
+ width: cW,
+ height: cH,
+ overflow: "hidden",
+ }}
+ >
+ <SlideBackground slide={slide} cW={cW} cH={cH} theme={theme} />
+ {showGuides && <ScreenGuide cW={cW} cH={cH} index={index} active={active} />}
+ </div>
+ );
+ })}
+
+ {slides.map((slide, index) => {
+ if (slide.layout === "feature-graphic" || device === "feature-graphic") return null;
+ const selectedElementId =
+ selectedElement?.slideId === slide.id ? selectedElement.elementId : null;
+ const perSlideEdit: EditHandlers | undefined = editable
+ ? {
+ onLabelChange: (v) => edit?.onLabelChange?.(slide.id, v),
+ onHeadlineChange: (v) => edit?.onHeadlineChange?.(slide.id, v),
+ onTextElementTextChange: (id, v) => edit?.onTextElementTextChange?.(slide.id, id, v),
+ onElementChange: (id, t) => edit?.onElementChange?.(slide.id, id, t),
+ onSelectElement: (id) => {
+ edit?.onSelectScreen?.(slide.id);
+ edit?.onSelectElement?.(id ? { slideId: slide.id, elementId: id } : null);
+ },
+ }
+ : undefined;
+
+ const elements = (
+ <SlideElements
+ key={`${slide.id}-elements`}
+ slide={slide}
+ device={device}
+ orientation={orientation}
+ theme={theme}
+ locale={locale}
+ editable={editable}
+ edit={perSlideEdit}
+ selectedElementId={selectedElementId}
+ previewScale={previewScale}
+ hideEmpty={hideEmpty}
+ screenX={connectedCanvas ? index * cW : 0}
+ boundsW={connectedCanvas ? totalW : cW}
+ boundsH={cH}
+ allowCrossScreen={connectedCanvas}
+ />
+ );
+ if (connectedCanvas) return elements;
+ return (
+ <div
+ key={`${slide.id}-elements-isolated`}
+ style={{
+ position: "absolute",
+ left: index * cW,
+ top: 0,
+ width: cW,
+ height: cH,
+ overflow: "hidden",
+ }}
+ >
+ {elements}
+ </div>
+ );
+ })}
+ </div>
+ );
+}
+
+function SlideBackground({
+ slide,
+ cW,
+ cH,
+ theme,
+}: {
+ slide: Slide;
+ cW: number;
+ cH: number;
+ theme: Theme;
+}) {
+ const inverted = !!slide.inverted;
+ return (
+ <div
+ style={{
+ position: "absolute",
+ inset: 0,
+ overflow: "hidden",
+ background: backgroundFor(theme, inverted),
+ color: inverted ? theme.fgAlt : theme.fg,
+ }}
+ >
+ <Blob cW={cW} color={theme.accent} x={-15} y={-10} size={55} opacity={inverted ? 0.25 : 0.32} />
+ <Blob cW={cW} color={theme.accent} x={70} y={75} size={45} opacity={inverted ? 0.18 : 0.25} />
+ </div>
+ );
+}
+
+function ScreenGuide({
+ cW,
+ cH,
+ index,
+ active,
+}: {
+ cW: number;
+ cH: number;
+ index: number;
+ active: boolean;
+}) {
+ return (
+ <div
+ aria-hidden
+ style={{
+ position: "absolute",
+ inset: 0,
+ pointerEvents: "none",
+ outline: `${active ? Math.max(4, cW * 0.003) : Math.max(2, cW * 0.0015)}px solid ${
+ active ? "rgba(91, 124, 250, 0.95)" : "rgba(15, 23, 42, 0.22)"
+ }`,
+ outlineOffset: active ? -Math.max(4, cW * 0.003) : -Math.max(2, cW * 0.0015),
+ boxShadow: active
+ ? "inset 0 0 0 9999px rgba(91, 124, 250, 0.03)"
+ : "inset 0 0 0 1px rgba(255, 255, 255, 0.22)",
+ }}
+ >
+ <div
+ style={{
+ position: "absolute",
+ left: cW * 0.035,
+ top: cH * 0.024,
+ borderRadius: cW * 0.018,
+ padding: `${cH * 0.006}px ${cW * 0.018}px`,
+ background: active ? "rgba(91, 124, 250, 0.92)" : "rgba(15, 23, 42, 0.72)",
+ color: "white",
+ fontSize: Math.max(24, cW * 0.022),
+ lineHeight: 1,
+ fontWeight: 700,
+ letterSpacing: 0,
+ }}
+ >
+ {index + 1}
+ </div>
+ </div>
+ );
+}
+
+function FeatureGraphicCanvas({
+ slide,
+ cW,
+ theme,
+ locale,
+ appName,
+ appIcon,
+ editable,
+ edit,
+}: {
+ slide: Slide;
+ cW: number;
+ theme: Theme;
+ locale: string;
+ appName?: string;
+ appIcon?: string;
+ editable?: boolean;
+ edit?: EditHandlers;
+}) {
+ return (
+ <div
+ style={{
+ width: "100%",
+ height: "100%",
+ position: "relative",
+ overflow: "hidden",
+ background: `linear-gradient(135deg, ${theme.bgAlt} 0%, ${shade(theme.bgAlt, -10)} 50%, ${theme.accent} 200%)`,
+ display: "flex",
+ alignItems: "center",
+ padding: `0 ${cW * 0.06}px`,
+ color: theme.fgAlt,
+ }}
+ >
+ <Blob cW={cW} color={theme.accent} x={70} y={20} size={50} opacity={0.45} />
+ <div style={{ display: "flex", alignItems: "center", gap: cW * 0.03, zIndex: 2 }}>
+ {appIcon && img(appIcon) ? (
+ <img
+ src={img(appIcon)}
+ alt=""
+ style={{
+ width: cW * 0.13,
+ height: cW * 0.13,
+ borderRadius: cW * 0.022,
+ boxShadow: "0 4px 16px rgba(0,0,0,0.3)",
+ }}
+ draggable={false}
+ />
+ ) : (
+ <div
+ aria-hidden
+ style={{
+ width: cW * 0.13,
+ height: cW * 0.13,
+ borderRadius: cW * 0.022,
+ background: `linear-gradient(135deg, ${theme.accent}55, ${theme.accent})`,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ color: theme.fgAlt,
+ fontWeight: 800,
+ fontSize: cW * 0.07,
+ boxShadow: "0 4px 16px rgba(0,0,0,0.3)",
+ }}
+ >
+ {(appName || "A").slice(0, 1).toUpperCase()}
</div>
+ )}
+ <div>
+ <div style={{ fontSize: cW * 0.06, fontWeight: 800, lineHeight: 1.05 }}>{appName || "App"}</div>
+ <EditableText
+ value={pickText(slide.headline, locale)}
+ editable={editable}
+ multiline
+ onChange={edit?.onHeadlineChange}
+ style={{
+ fontSize: cW * 0.028,
+ color: "rgba(255,255,255,0.85)",
+ marginTop: cW * 0.012,
+ lineHeight: 1.25,
+ }}
+ />
</div>
</div>
- );
- }
+ </div>
+ );
+}
+function SlideElements({
+ slide,
+ device,
+ orientation,
+ theme,
+ locale,
+ editable,
+ edit,
+ selectedElementId,
+ previewScale,
+ hideEmpty,
+ screenX,
+ boundsW,
+ boundsH,
+ allowCrossScreen,
+}: {
+ slide: Slide;
+ device: Device;
+ orientation: Orientation;
+ theme: Theme;
+ locale: string;
+ editable?: boolean;
+ edit?: EditHandlers;
+ selectedElementId: ElementId | null;
+ previewScale: number;
+ hideEmpty?: boolean;
+ screenX: number;
+ boundsW: number;
+ boundsH: number;
+ allowCrossScreen: boolean;
+}) {
+ const screenshot = resolveScreenshot(slide.screenshot, locale);
+ const screenshotSecondary = resolveScreenshot(slide.screenshotSecondary, locale);
+ const { cW, cH, Frame, frameAspect, defaults } = getSlideGeometry(slide, device, orientation);
+ const inverted = !!slide.inverted;
const captionRect = rectFor("caption", slide, defaults);
const deviceRect = rectFor("device", slide, defaults);
const secondaryRect = rectFor("deviceSecondary", slide, defaults);
+ function toGlobal(rect: Rect): Rect {
+ return { ...rect, x: rect.x + screenX };
+ }
+
+ function toLocal(t: ElementTransform): ElementTransform {
+ return { ...t, x: t.x - screenX };
+ }
+
function renderCaption() {
if (!captionRect) return null;
const saved = slide.transforms?.caption;
@@ -541,22 +940,26 @@ export function SlideCanvas({
);
return (
<Movable
- rect={captionRect}
- cW={cW}
- cH={cH}
+ rect={toGlobal(captionRect)}
+ boundsW={boundsW}
+ boundsH={boundsH}
editable={editable}
previewScale={previewScale}
rotation={rotation}
onChange={(t) =>
- edit?.onElementChange?.("caption", {
- ...t,
- rotation,
- zIndex,
- })
+ edit?.onElementChange?.(
+ "caption",
+ toLocal({
+ ...t,
+ rotation: t.rotation ?? rotation,
+ zIndex: t.zIndex ?? zIndex,
+ }),
+ )
}
zIndex={zIndex}
selected={selectedElementId === "caption"}
onSelect={() => edit?.onSelectElement?.("caption")}
+ allowOverflow={allowCrossScreen}
>
<div style={{ width: "100%", height: "100%", display: "flex", alignItems: "flex-start" }}>
{inner}
@@ -571,18 +974,21 @@ export function SlideCanvas({
const zIndex = saved?.zIndex ?? (id === "deviceSecondary" ? 2 : 3);
return (
<Movable
- rect={rect}
- cW={cW}
- cH={cH}
+ rect={toGlobal(rect)}
+ boundsW={boundsW}
+ boundsH={boundsH}
editable={editable}
previewScale={previewScale}
rotation={rotation}
onChange={(t) =>
- edit?.onElementChange?.(id, {
- ...t,
- rotation,
- zIndex,
- })
+ edit?.onElementChange?.(
+ id,
+ toLocal({
+ ...t,
+ rotation: t.rotation ?? rotation,
+ zIndex: t.zIndex ?? zIndex,
+ }),
+ )
}
lockAspectRatio={frameAspect}
zIndex={zIndex}
@@ -599,31 +1005,75 @@ export function SlideCanvas({
);
}
- // Click on empty background area deselects any active element. Movable
- // children sit absolutely-positioned inside this root; checking that the
- // event landed directly on the root (not bubbled up from a child) keeps
- // device/caption clicks from accidentally deselecting.
- const handleBackgroundMouseDown = editable
- ? (e: React.MouseEvent<HTMLDivElement>) => {
- if (e.target === e.currentTarget) edit?.onSelectElement?.(null);
- }
- : undefined;
+ function renderTextElement(textElement: TextElement, index: number) {
+ const elementId = toTextElementId(textElement.id);
+ const rect = textElement.transform;
+ const rotation = rect.rotation ?? 0;
+ const zIndex = rect.zIndex ?? 5 + index;
+ const textColor = textElement.color || (inverted ? theme.fgAlt : theme.fg);
+ return (
+ <Movable
+ key={textElement.id}
+ rect={toGlobal(rect)}
+ boundsW={boundsW}
+ boundsH={boundsH}
+ editable={editable}
+ previewScale={previewScale}
+ rotation={rotation}
+ onChange={(t) =>
+ edit?.onElementChange?.(
+ elementId,
+ toLocal({
+ ...t,
+ rotation: t.rotation ?? rotation,
+ zIndex: t.zIndex ?? zIndex,
+ }),
+ )
+ }
+ zIndex={zIndex}
+ selected={selectedElementId === elementId}
+ onSelect={() => edit?.onSelectElement?.(elementId)}
+ allowOverflow={allowCrossScreen}
+ >
+ <div
+ style={{
+ width: "100%",
+ height: "100%",
+ display: "flex",
+ alignItems: "center",
+ justifyContent:
+ textElement.align === "right"
+ ? "flex-end"
+ : textElement.align === "left"
+ ? "flex-start"
+ : "center",
+ padding: `${Math.min(cW, cH) * 0.012}px`,
+ }}
+ >
+ <EditableText
+ value={pickText(textElement.text, locale)}
+ editable={editable}
+ multiline
+ onChange={(value) => edit?.onTextElementTextChange?.(textElement.id, value)}
+ onFocus={() => edit?.onSelectElement?.(elementId)}
+ placeholder="Text"
+ style={{
+ width: "100%",
+ color: textColor,
+ fontSize: textElement.fontSize ?? Math.min(cW, cH) * 0.06,
+ fontWeight: textElement.fontWeight ?? 700,
+ lineHeight: 1.05,
+ textAlign: textElement.align ?? "center",
+ textShadow: inverted ? "0 2px 18px rgba(0,0,0,0.22)" : "0 2px 18px rgba(255,255,255,0.2)",
+ }}
+ />
+ </div>
+ </Movable>
+ );
+ }
return (
- <div
- onMouseDown={handleBackgroundMouseDown}
- style={{
- width: "100%",
- height: "100%",
- position: "relative",
- overflow: "hidden",
- background: bg,
- color: inverted ? theme.fgAlt : theme.fg,
- }}
- >
- <Blob cW={cW} color={theme.accent} x={-15} y={-10} size={55} opacity={inverted ? 0.25 : 0.32} />
- <Blob cW={cW} color={theme.accent} x={70} y={75} size={45} opacity={inverted ? 0.18 : 0.25} />
-
+ <>
{secondaryRect &&
renderDevice(
"deviceSecondary",
@@ -631,10 +1081,10 @@ export function SlideCanvas({
screenshotSecondary || screenshot,
{ opacity: 0.85 },
)}
- {deviceRect &&
- renderDevice("device", deviceRect, screenshot)}
+ {deviceRect && renderDevice("device", deviceRect, screenshot)}
{renderCaption()}
- </div>
+ {(slide.textElements || []).map(renderTextElement)}
+ </>
);
}
@@ -647,8 +1097,8 @@ const MIN_VISIBLE_FRAC = 0.1;
function clampRect(
r: { x: number; y: number; width: number; height: number },
- cW: number,
- cH: number,
+ boundsW: number,
+ boundsH: number,
allowOverflow = false,
) {
if (allowOverflow) {
@@ -656,21 +1106,21 @@ function clampRect(
const height = r.height;
const minVisX = Math.max(8, width * MIN_VISIBLE_FRAC);
const minVisY = Math.max(8, height * MIN_VISIBLE_FRAC);
- const x = Math.max(-(width - minVisX), Math.min(r.x, cW - minVisX));
- const y = Math.max(-(height - minVisY), Math.min(r.y, cH - minVisY));
+ const x = Math.max(-(width - minVisX), Math.min(r.x, boundsW - minVisX));
+ const y = Math.max(-(height - minVisY), Math.min(r.y, boundsH - minVisY));
return { x, y, width, height };
}
- const width = Math.min(r.width, cW);
- const height = Math.min(r.height, cH);
- const x = Math.max(0, Math.min(r.x, cW - width));
- const y = Math.max(0, Math.min(r.y, cH - height));
+ const width = Math.min(r.width, boundsW);
+ const height = Math.min(r.height, boundsH);
+ const x = Math.max(0, Math.min(r.x, boundsW - width));
+ const y = Math.max(0, Math.min(r.y, boundsH - height));
return { x, y, width, height };
}
function Movable({
rect,
- cW,
- cH,
+ boundsW,
+ boundsH,
editable,
previewScale,
onChange,
@@ -683,8 +1133,8 @@ function Movable({
onSelect,
}: {
rect: Rect;
- cW: number;
- cH: number;
+ boundsW: number;
+ boundsH: number;
editable?: boolean;
previewScale: number;
onChange: (t: ElementTransform) => void;
@@ -696,6 +1146,50 @@ function Movable({
selected?: boolean;
onSelect?: () => void;
}) {
+ const rotationRef = React.useRef(rotation);
+ React.useEffect(() => {
+ rotationRef.current = rotation;
+ }, [rotation]);
+
+ function startRotate(e: React.PointerEvent<HTMLButtonElement>) {
+ e.preventDefault();
+ e.stopPropagation();
+ onSelect?.();
+
+ const root = e.currentTarget.closest(".rnd-editable") as HTMLElement | null;
+ if (!root) return;
+ const box = root.getBoundingClientRect();
+ const centerX = box.left + box.width / 2;
+ const centerY = box.top + box.height / 2;
+ const startAngle = pointerAngle(e.clientX, e.clientY, centerX, centerY);
+ const startRotation = rotationRef.current;
+
+ const handleMove = (event: PointerEvent) => {
+ event.preventDefault();
+ const nextRotation = normalizeRotation(
+ startRotation + pointerAngle(event.clientX, event.clientY, centerX, centerY) - startAngle,
+ );
+ rotationRef.current = nextRotation;
+ onChange({
+ x: display.x,
+ y: display.y,
+ width: display.width,
+ height: display.height,
+ rotation: nextRotation,
+ zIndex,
+ });
+ };
+ const stopRotate = () => {
+ window.removeEventListener("pointermove", handleMove);
+ window.removeEventListener("pointerup", stopRotate);
+ window.removeEventListener("pointercancel", stopRotate);
+ };
+
+ window.addEventListener("pointermove", handleMove, { passive: false });
+ window.addEventListener("pointerup", stopRotate, { once: true });
+ window.addEventListener("pointercancel", stopRotate, { once: true });
+ }
+
// Rotation lives on the inner wrapper so the Rnd's axis-aligned rect remains
// the authoritative bounding box for drag/resize math. A bare mousedown
// listener (no stopPropagation — that would prevent react-rnd from starting
@@ -716,7 +1210,7 @@ function Movable({
</div>
);
- // Non-editable (export) path: plain absolute-positioned div, no Rnd.
+ // Non-editable (export/thumb) path: plain absolute-positioned div, no Rnd.
if (!editable) {
return (
<div
@@ -734,7 +1228,8 @@ function Movable({
);
}
- const display = clampRect(rect, cW, cH, allowOverflow);
+ const display = clampRect(rect, boundsW, boundsH, allowOverflow);
+ const controlScale = Math.max(0.05, previewScale);
return (
<Rnd
@@ -748,11 +1243,11 @@ function Movable({
onDragStop={(_e, d) => {
const next = clampRect(
{ x: d.x, y: d.y, width: display.width, height: display.height },
- cW,
- cH,
+ boundsW,
+ boundsH,
allowOverflow,
);
- onChange(next);
+ onChange({ ...next, rotation, zIndex });
}}
onResizeStop={(_e, _dir, ref, _delta, position) => {
const next = clampRect(
@@ -762,21 +1257,47 @@ function Movable({
width: parseFloat(ref.style.width),
height: parseFloat(ref.style.height),
},
- cW,
- cH,
+ boundsW,
+ boundsH,
allowOverflow,
);
- onChange(next);
+ onChange({ ...next, rotation, zIndex });
}}
style={{ zIndex }}
resizeHandleStyles={handleStyle}
className={selected ? "rnd-editable rnd-selected" : "rnd-editable"}
>
{rotated}
+ <button
+ type="button"
+ className="rnd-rotate-handle"
+ style={{
+ right: -14 / controlScale,
+ top: -14 / controlScale,
+ width: 28 / controlScale,
+ height: 28 / controlScale,
+ }}
+ onPointerDown={startRotate}
+ title="Rotate"
+ aria-label="Rotate element"
+ >
+ <RotateCw style={{ width: 14 / controlScale, height: 14 / controlScale }} />
+ </button>
</Rnd>
);
}
+function pointerAngle(x: number, y: number, centerX: number, centerY: number) {
+ return (Math.atan2(y - centerY, x - centerX) * 180) / Math.PI;
+}
+
+function normalizeRotation(degrees: number) {
+ let next = degrees;
+ while (next > 180) next -= 360;
+ while (next < -180) next += 360;
+ return Math.round(next);
+}
+
// Subtle resize handles (visible only on hover via globals.css).
const handleSize = 14;
const handleStyle: Record<string, React.CSSProperties> = {
diff --git a/skills/app-store-screenshots/template/src/components/editor/slide-thumb.tsx b/skills/app-store-screenshots/template/src/components/editor/slide-thumb.tsx
index 9ca6343..8b88ed9 100644
--- a/skills/app-store-screenshots/template/src/components/editor/slide-thumb.tsx
+++ b/skills/app-store-screenshots/template/src/components/editor/slide-thumb.tsx
@@ -8,10 +8,11 @@ import { LAYOUT_LABEL } from "@/lib/constants";
import { pickText } from "@/lib/locale";
import type { Device, Orientation, Slide, Theme } from "@/lib/types";
import { cn } from "@/lib/utils";
-import { SlideCanvas, getCanvas } from "./slide-canvas";
+import { DeckCanvas, SlideCanvas, getCanvas } from "./slide-canvas";
type Props = {
slide: Slide;
+ slides: Slide[];
index: number;
active: boolean;
device: Device;
@@ -20,6 +21,7 @@ type Props = {
locale: string;
appName?: string;
appIcon?: string;
+ connectedCanvas: boolean;
onSelect: () => void;
onDelete: () => void;
onDuplicate: () => void;
@@ -30,6 +32,7 @@ const THUMB_W = 60;
export function SlideThumb({
slide,
+ slides,
index,
active,
device,
@@ -38,6 +41,7 @@ export function SlideThumb({
locale,
appName,
appIcon,
+ connectedCanvas,
onSelect,
onDelete,
onDuplicate,
@@ -52,6 +56,9 @@ export function SlideThumb({
const aspect = cW / cH;
const tileH = Math.max(34, Math.min(120, Math.round(THUMB_W / aspect)));
const scale = THUMB_W / cW;
+ const start = connectedCanvas ? Math.max(0, index - 1) : index;
+ const visibleSlides = connectedCanvas ? slides.slice(start, Math.min(slides.length, index + 2)) : [slide];
+ const localIndex = index - start;
const style: React.CSSProperties = {
transform: CSS.Transform.toString(transform),
@@ -73,7 +80,7 @@ export function SlideThumb({
className="flex w-3 cursor-grab items-center justify-center text-muted-foreground/60 hover:text-foreground focus-visible:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring active:cursor-grabbing"
{...attributes}
{...listeners}
- aria-label={`Reorder slide ${index + 1} (press space, then arrow keys)`}
+ aria-label={`Reorder screen ${index + 1} (press space, then arrow keys)`}
>
<GripVertical className="h-4 w-4" />
</button>
@@ -84,36 +91,51 @@ export function SlideThumb({
className="flex flex-1 items-center gap-3 overflow-hidden text-left"
>
<div
+ aria-hidden
className="relative shrink-0 overflow-hidden rounded border bg-muted"
style={{ width: THUMB_W, height: tileH }}
>
<div
style={{
- width: cW,
+ width: cW * visibleSlides.length,
height: cH,
position: "absolute",
top: 0,
- left: 0,
+ left: -localIndex * cW * scale,
transformOrigin: "top left",
transform: `scale(${scale})`,
pointerEvents: "none",
}}
>
- <SlideCanvas
- slide={slide}
- device={device}
- orientation={orientation}
- theme={theme}
- locale={locale}
- appName={appName}
- appIcon={appIcon}
- editable={false}
- />
+ {connectedCanvas ? (
+ <DeckCanvas
+ slides={visibleSlides}
+ device={device}
+ orientation={orientation}
+ theme={theme}
+ locale={locale}
+ appName={appName}
+ appIcon={appIcon}
+ connectedCanvas
+ editable={false}
+ />
+ ) : (
+ <SlideCanvas
+ slide={slide}
+ device={device}
+ orientation={orientation}
+ theme={theme}
+ locale={locale}
+ appName={appName}
+ appIcon={appIcon}
+ editable={false}
+ />
+ )}
</div>
</div>
<div className="flex min-w-0 flex-1 flex-col">
<span className="truncate text-[10px] uppercase tracking-wide text-muted-foreground">
- {`Slide ${index + 1} · ${LAYOUT_LABEL[slide.layout]}`}
+ {`Screen ${index + 1} · ${LAYOUT_LABEL[slide.layout]}`}
</span>
<span className="truncate text-sm font-medium leading-tight">
{headline.split("\n")[0] || (
@@ -136,8 +158,8 @@ export function SlideThumb({
variant="ghost"
className="h-6 w-6"
onClick={onDuplicate}
- aria-label={`Duplicate slide ${index + 1}`}
- title="Duplicate slide"
+ aria-label={`Duplicate screen ${index + 1}`}
+ title="Duplicate screen"
>
<Copy className="h-3.5 w-3.5" />
</Button>
@@ -147,8 +169,8 @@ export function SlideThumb({
variant="ghost"
className="h-6 w-6 hover:text-destructive"
onClick={onDelete}
- aria-label={`Delete slide ${index + 1}`}
- title="Delete slide (undoable)"
+ aria-label={`Delete screen ${index + 1}`}
+ title="Delete screen (undoable)"
>
<Trash2 className="h-3.5 w-3.5" />
</Button>
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 6f59a70..ce15d91 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, RotateCcw } from "lucide-react";
+import { AlertTriangle, Check, Cloud, Download, UnfoldHorizontal, RotateCcw } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -28,6 +28,8 @@ import type { Device, Orientation } from "@/lib/types";
type Props = {
appName: string;
setAppName: (v: string) => void;
+ connectedCanvas: boolean;
+ setConnectedCanvas: (v: boolean) => void;
locale: string;
setLocale: (v: string) => void;
locales: string[];
@@ -76,6 +78,26 @@ export function Toolbar(props: Props) {
<span aria-hidden className="mx-1 h-5 w-px bg-border" />
+ <Button
+ type="button"
+ variant={props.connectedCanvas ? "secondary" : "outline"}
+ size="sm"
+ className="h-8 gap-1.5 px-2 text-xs"
+ onClick={() => props.setConnectedCanvas(!props.connectedCanvas)}
+ aria-pressed={props.connectedCanvas}
+ title={
+ props.connectedCanvas
+ ? "Connected canvas enabled"
+ : "Isolated screens; turn on to let elements cross screen edges"
+ }
+ disabled={props.busy}
+ >
+ <UnfoldHorizontal className="h-3.5 w-3.5" />
+ {props.connectedCanvas ? "Connected" : "Isolated"}
+ </Button>
+
+ <span aria-hidden className="mx-1 h-5 w-px bg-border" />
+
<Tabs
value={platform}
onValueChange={(p) => {
@@ -158,7 +180,7 @@ export function Toolbar(props: Props) {
size="icon"
className="h-8 w-8"
onClick={() => setResetOpen(true)}
- title="Reset slides to defaults"
+ title="Reset screens to defaults"
aria-label="Reset"
disabled={props.busy}
>
@@ -181,7 +203,7 @@ export function Toolbar(props: Props) {
<DialogHeader>
<DialogTitle>Reset to defaults?</DialogTitle>
<DialogDescription>
- Choose whether to reset just <span className="font-medium">{deviceLabel}</span> or every device deck. Your edits, uploaded screenshots, and copy will be lost.
+ Choose whether to reset just <span className="font-medium">{deviceLabel}</span> or every device deck. Your canvas edits, uploaded screenshots, and copy will be lost.
</DialogDescription>
</DialogHeader>
<div className="flex flex-wrap justify-end gap-2">
diff --git a/skills/app-store-screenshots/template/src/lib/constants.ts b/skills/app-store-screenshots/template/src/lib/constants.ts
index 3ba6d73..e9e63fc 100644
--- a/skills/app-store-screenshots/template/src/lib/constants.ts
+++ b/skills/app-store-screenshots/template/src/lib/constants.ts
@@ -81,7 +81,9 @@ export function ipadW(cW: number, cH: number, clamp = 0.75) {
}
// ---------- Themes ----------
-export const THEMES: Record<ThemeId, Theme> = {
+export const DEFAULT_THEME_ID: ThemeId = "clean-light";
+
+export const THEMES: Record<string, Theme> = {
"clean-light": {
id: "clean-light",
name: "Clean Light",
@@ -122,9 +124,28 @@ export const THEMES: Record<ThemeId, Theme> = {
accent: "#0284C7",
muted: "#475569",
},
+ "bloom-roast": {
+ id: "bloom-roast",
+ name: "Bloom Roast",
+ bg: "#F2ECE2",
+ bgAlt: "#24352F",
+ fg: "#1D2420",
+ fgAlt: "#FFF7EA",
+ accent: "#B8794A",
+ muted: "#65736B",
+ },
};
+export function themeById(themeId: string | undefined): Theme {
+ return THEMES[themeId || ""] || THEMES[DEFAULT_THEME_ID];
+}
+
+export function hasTheme(themeId: string | undefined): boolean {
+ return !!themeId && !!THEMES[themeId];
+}
+
export const STORAGE_KEY = "app-store-screenshots:project:v1";
+export const PROJECT_SCHEMA_VERSION = 2;
export const DEVICE_LABEL: Record<Device, string> = {
iphone: "iPhone",
diff --git a/skills/app-store-screenshots/template/src/lib/defaults.ts b/skills/app-store-screenshots/template/src/lib/defaults.ts
index 2719d5d..5ce5dc5 100644
--- a/skills/app-store-screenshots/template/src/lib/defaults.ts
+++ b/skills/app-store-screenshots/template/src/lib/defaults.ts
@@ -1,4 +1,5 @@
import { DEFAULT_LOCALE } from "./locale";
+import { DEFAULT_THEME_ID, PROJECT_SCHEMA_VERSION } from "./constants";
import type { Device, ProjectState, Slide } from "./types";
let _id = 0;
@@ -107,8 +108,10 @@ function fgStarter(): Slide[] {
}
export const DEFAULT_PROJECT: ProjectState = {
+ schemaVersion: PROJECT_SCHEMA_VERSION,
appName: "My App",
- themeId: "clean-light",
+ themeId: DEFAULT_THEME_ID,
+ connectedCanvas: true,
locales: [DEFAULT_LOCALE],
locale: DEFAULT_LOCALE,
device: "iphone",
diff --git a/skills/app-store-screenshots/template/src/lib/elements.ts b/skills/app-store-screenshots/template/src/lib/elements.ts
new file mode 100644
index 0000000..6aec63f
--- /dev/null
+++ b/skills/app-store-screenshots/template/src/lib/elements.ts
@@ -0,0 +1,25 @@
+import type { BuiltInElementId, ElementId, TextElementId } from "./types";
+
+export const BUILT_IN_ELEMENT_IDS: BuiltInElementId[] = [
+ "caption",
+ "device",
+ "deviceSecondary",
+];
+
+export const TEXT_ELEMENT_PREFIX = "text:";
+
+export function isBuiltInElementId(id: ElementId | string): id is BuiltInElementId {
+ return (BUILT_IN_ELEMENT_IDS as string[]).includes(id);
+}
+
+export function isTextElementId(id: ElementId | string | null | undefined): id is TextElementId {
+ return typeof id === "string" && id.startsWith(TEXT_ELEMENT_PREFIX);
+}
+
+export function toTextElementId(id: string): TextElementId {
+ return `${TEXT_ELEMENT_PREFIX}${id}` as TextElementId;
+}
+
+export function textElementKey(id: TextElementId | ElementId): string {
+ return isTextElementId(id) ? id.slice(TEXT_ELEMENT_PREFIX.length) : id;
+}
diff --git a/skills/app-store-screenshots/template/src/lib/image-cache.ts b/skills/app-store-screenshots/template/src/lib/image-cache.ts
index ba4b5ba..8acfddd 100644
--- a/skills/app-store-screenshots/template/src/lib/image-cache.ts
+++ b/skills/app-store-screenshots/template/src/lib/image-cache.ts
@@ -21,15 +21,22 @@ async function fetchAsDataUrl(path: string): Promise<string | null> {
}
}
-export async function preloadImages(paths: string[]): Promise<void> {
+export async function preloadImages(
+ paths: string[],
+ options: { retryFailed?: boolean } = {},
+): Promise<void> {
await Promise.all(
paths
.filter(Boolean)
- .filter((p) => !cache.has(p) && !failed.has(p))
+ .filter((p) => !cache.has(p) && (options.retryFailed || !failed.has(p)))
.map(async (p) => {
const data = await fetchAsDataUrl(p);
- if (data) cache.set(p, data);
- else failed.add(p);
+ if (data) {
+ cache.set(p, data);
+ failed.delete(p);
+ } else {
+ failed.add(p);
+ }
}),
);
}
diff --git a/skills/app-store-screenshots/template/src/lib/storage.ts b/skills/app-store-screenshots/template/src/lib/storage.ts
index 7633e00..f305b19 100644
--- a/skills/app-store-screenshots/template/src/lib/storage.ts
+++ b/skills/app-store-screenshots/template/src/lib/storage.ts
@@ -1,9 +1,9 @@
"use client";
import { useCallback, useEffect, useRef, useState } from "react";
-import { STORAGE_KEY } from "./constants";
+import { PROJECT_SCHEMA_VERSION, STORAGE_KEY } from "./constants";
import { DEFAULT_PROJECT } from "./defaults";
import { coerceLocalized } from "./locale";
-import type { Device, ProjectState, Slide } from "./types";
+import type { Device, ElementTransform, ProjectState, Slide, TextElement } from "./types";
const HISTORY_LIMIT = 50;
// Coalesce rapid edits (typing, slider drags) into a single undo step.
@@ -11,27 +11,94 @@ const COALESCE_MS = 500;
// Debounce file/localStorage writes — frequent enough to feel instant, infrequent enough not to thrash disk.
const SAVE_DEBOUNCE_MS = 600;
-// Migrate pre-locale string label/headline into { en: value }.
+function cleanTransform(value: unknown): ElementTransform | undefined {
+ if (!value || typeof value !== "object") return undefined;
+ const raw = value as Partial<ElementTransform>;
+ const required = [raw.x, raw.y, raw.width, raw.height];
+ if (!required.every((n) => typeof n === "number" && Number.isFinite(n))) return undefined;
+ return {
+ x: raw.x!,
+ y: raw.y!,
+ width: Math.max(1, raw.width!),
+ height: Math.max(1, raw.height!),
+ ...(typeof raw.rotation === "number" && Number.isFinite(raw.rotation)
+ ? { rotation: raw.rotation }
+ : {}),
+ ...(typeof raw.zIndex === "number" && Number.isFinite(raw.zIndex)
+ ? { zIndex: raw.zIndex }
+ : {}),
+ };
+}
+
+function cleanTextElement(value: unknown): TextElement | undefined {
+ if (!value || typeof value !== "object") return undefined;
+ const raw = value as Partial<TextElement>;
+ if (typeof raw.id !== "string" || !raw.id.trim()) return undefined;
+ const transform = cleanTransform(raw.transform);
+ if (!transform) return undefined;
+ return {
+ id: raw.id,
+ text: coerceLocalized(raw.text as unknown),
+ transform,
+ ...(typeof raw.fontSize === "number" && Number.isFinite(raw.fontSize)
+ ? { fontSize: raw.fontSize }
+ : {}),
+ ...(typeof raw.fontWeight === "number" && Number.isFinite(raw.fontWeight)
+ ? { fontWeight: raw.fontWeight }
+ : {}),
+ ...(typeof raw.color === "string" ? { color: raw.color } : {}),
+ ...(raw.align === "left" || raw.align === "center" || raw.align === "right"
+ ? { align: raw.align }
+ : {}),
+ };
+}
+
+// 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 transforms = slide.transforms
+ ? Object.fromEntries(
+ Object.entries(slide.transforms)
+ .map(([id, transform]) => [id, cleanTransform(transform)])
+ .filter((entry): entry is [string, ElementTransform] => !!entry[1]),
+ )
+ : undefined;
+ const textElements = Array.isArray(slide.textElements)
+ ? slide.textElements.map(cleanTextElement).filter((t): t is TextElement => !!t)
+ : undefined;
+
return {
...slide,
label: coerceLocalized(slide.label as unknown),
headline: coerceLocalized(slide.headline as unknown),
+ ...(transforms && Object.keys(transforms).length > 0 ? { transforms } : { transforms: undefined }),
+ ...(textElements && textElements.length > 0 ? { textElements } : { textElements: undefined }),
};
}
function mergeWithDefaults(parsed: Partial<ProjectState>): ProjectState {
+ const connectedCanvas =
+ typeof parsed.connectedCanvas === "boolean"
+ ? parsed.connectedCanvas
+ : false;
+ const themeId =
+ typeof parsed.themeId === "string" && parsed.themeId.trim()
+ ? parsed.themeId
+ : DEFAULT_PROJECT.themeId;
const slidesByDevice = parsed.slidesByDevice
? Object.fromEntries(
Object.entries(parsed.slidesByDevice).map(([device, slides]) => [
device,
- (slides || []).map(migrateSlide),
+ Array.isArray(slides) ? slides.map((slide) => migrateSlide(slide as Slide)) : [],
]),
)
: {};
const merged: ProjectState = {
...DEFAULT_PROJECT,
...parsed,
+ schemaVersion: PROJECT_SCHEMA_VERSION,
+ themeId,
+ connectedCanvas,
slidesByDevice: {
...DEFAULT_PROJECT.slidesByDevice,
...slidesByDevice,
@@ -59,16 +126,19 @@ function loadFromLocalStorage(): ProjectState | null {
}
}
-async function loadFromFile(): Promise<ProjectState | null> {
- if (typeof window === "undefined") return null;
+async function loadFromFile(): Promise<
+ { ok: true; state: ProjectState | null } | { ok: false; error: string }
+> {
+ if (typeof window === "undefined") return { ok: false, error: "Window is not available" };
try {
const resp = await fetch("/api/project", { cache: "no-store" });
- if (!resp.ok) return null;
+ if (!resp.ok) return { ok: false, error: `HTTP ${resp.status}` };
const json = (await resp.json()) as { ok: boolean; state: Partial<ProjectState> | null };
- if (!json.ok || !json.state) return null;
- return mergeWithDefaults(json.state);
+ if (!json.ok) return { ok: false, error: "Project response was not ok" };
+ if (!json.state) return { ok: true, state: null };
+ return { ok: true, state: mergeWithDefaults(json.state) };
} catch {
- return null;
+ return { ok: false, error: "Project file could not be loaded" };
}
}
@@ -111,6 +181,7 @@ function applyUpdater(updater: Updater, prev: ProjectState): ProjectState {
export function useProject() {
const [state, _setState] = useState<ProjectState>(DEFAULT_PROJECT);
const [hydrated, setHydrated] = useState(false);
+ const [fileReady, setFileReady] = useState(false);
const [savedAt, setSavedAt] = useState<number | null>(null);
const [saveError, setSaveError] = useState<string | null>(null);
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -131,8 +202,16 @@ export function useProject() {
void (async () => {
const fromFile = await loadFromFile();
if (cancelled) return;
- if (fromFile) {
- _setState(fromFile);
+ if (fromFile.ok) {
+ if (fromFile.state) {
+ _setState(fromFile.state);
+ } else {
+ _setState(DEFAULT_PROJECT);
+ }
+ setFileReady(true);
+ } else {
+ setFileReady(false);
+ setSaveError(fromFile.error);
}
pastRef.current = [];
futureRef.current = [];
@@ -147,7 +226,7 @@ export function useProject() {
// Debounced autosave to BOTH localStorage (fast, offline) and file (git-trackable).
useEffect(() => {
- if (!hydrated) return;
+ if (!hydrated || !fileReady) return;
if (timer.current) clearTimeout(timer.current);
timer.current = setTimeout(() => {
const localResult = saveToLocalStorage(state);
@@ -170,7 +249,7 @@ export function useProject() {
return () => {
if (timer.current) clearTimeout(timer.current);
};
- }, [state, hydrated]);
+ }, [state, hydrated, fileReady]);
const setState = useCallback((updater: Updater) => {
_setState((prev) => {
diff --git a/skills/app-store-screenshots/template/src/lib/types.ts b/skills/app-store-screenshots/template/src/lib/types.ts
index fcab254..01c174c 100644
--- a/skills/app-store-screenshots/template/src/lib/types.ts
+++ b/skills/app-store-screenshots/template/src/lib/types.ts
@@ -30,7 +30,14 @@ export type ElementTransform = {
zIndex?: number;
};
-export type ElementId = "caption" | "device" | "deviceSecondary";
+export type BuiltInElementId = "caption" | "device" | "deviceSecondary";
+export type TextElementId = `text:${string}`;
+export type ElementId = BuiltInElementId | TextElementId;
+
+export type SelectedElement = {
+ slideId: string;
+ elementId: ElementId;
+};
// Per-locale text keyed by locale code (e.g. "en", "de"). A locale is absent
// if the user hasn't typed anything for it; renderers fall back to en (see
@@ -38,6 +45,16 @@ export type ElementId = "caption" | "device" | "deviceSecondary";
// ProjectState.locales.
export type LocalizedText = Partial<Record<string, string>>;
+export type TextElement = {
+ id: string;
+ text: LocalizedText;
+ transform: ElementTransform;
+ fontSize?: number;
+ fontWeight?: number;
+ color?: string;
+ align?: "left" | "center" | "right";
+};
+
export type Slide = {
id: string;
layout: SlideLayout;
@@ -47,13 +64,19 @@ export type Slide = {
screenshotSecondary?: string; // for two-devices layout — may contain {locale}
inverted?: boolean; // dark background variant
// Per-element overrides; when present, replaces layout default placement.
- transforms?: Partial<Record<ElementId, ElementTransform>>;
+ transforms?: Partial<Record<BuiltInElementId, ElementTransform>>;
+ textElements?: TextElement[];
};
-export type ThemeId = "clean-light" | "dark-bold" | "warm-editorial" | "ocean-fresh";
+export type ThemeId =
+ | "clean-light"
+ | "dark-bold"
+ | "warm-editorial"
+ | "ocean-fresh"
+ | "bloom-roast";
export type Theme = {
- id: ThemeId;
+ id: string;
name: string;
bg: string; // primary background
bgAlt: string; // inverted background
@@ -64,8 +87,11 @@ export type Theme = {
};
export type ProjectState = {
+ schemaVersion?: number;
appName: string;
- themeId: ThemeId;
+ themeId: string;
+ // 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.
// Single-locale projects ship as ["en"] and hide the locale UI.
locales: string[];