@open-slide/core 1.15.2 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +1 -1
  2. package/dist/{build-CTCrO_M-.js → build-DaL4Gjn-.js} +1 -1
  3. package/dist/cli/bin.js +3 -3
  4. package/dist/{config-HXg3KTTo.js → config-CCHio3pk.js} +39 -11
  5. package/dist/{config-CE2sKgqH.d.ts → config-DIvIP8vY.d.ts} +1 -1
  6. package/dist/{dev-2FgsKkoD.js → dev-DLRQoCkT.js} +1 -1
  7. package/dist/{format-afijk371.js → format-CxmsgcBh.js} +8 -0
  8. package/dist/index.d.ts +15 -14
  9. package/dist/index.js +9 -6
  10. package/dist/locale/index.d.ts +1 -1
  11. package/dist/locale/index.js +1 -1
  12. package/dist/{preview-Bdzz3PTc.js → preview-D3qVGc0S.js} +1 -1
  13. package/dist/{types-GA4ekcYB.d.ts → types-Di7nvL8V.d.ts} +2 -0
  14. package/dist/vite/index.d.ts +2 -2
  15. package/dist/vite/index.js +1 -1
  16. package/package.json +3 -3
  17. package/skills/apply-comments/SKILL.md +7 -8
  18. package/skills/create-slide/SKILL.md +9 -9
  19. package/skills/create-theme/SKILL.md +8 -5
  20. package/skills/current-slide/SKILL.md +1 -1
  21. package/skills/slide-authoring/SKILL.md +40 -315
  22. package/skills/slide-authoring/references/assets.md +52 -0
  23. package/skills/slide-authoring/references/design-system.md +48 -0
  24. package/skills/slide-authoring/references/morph.md +67 -0
  25. package/skills/slide-authoring/references/page-numbers.md +16 -0
  26. package/skills/slide-authoring/references/steps.md +43 -0
  27. package/skills/slide-authoring/references/transitions.md +175 -0
  28. package/skills/slide-authoring/references/webfonts.md +20 -0
  29. package/src/app/components/{shared-element.tsx → morph-element.tsx} +8 -13
  30. package/src/app/components/slide-transition-layer.tsx +61 -57
  31. package/src/app/lib/step-context.tsx +9 -1
  32. package/src/app/lib/transition.ts +2 -2
  33. package/src/app/routes/presenter.tsx +75 -17
  34. package/src/locale/en.ts +2 -0
  35. package/src/locale/ja.ts +2 -0
  36. package/src/locale/types.ts +2 -0
  37. package/src/locale/zh-cn.ts +2 -0
  38. package/src/locale/zh-tw.ts +2 -0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: slide-authoring
3
- description: Technical reference for writing or editing open-slide pages — file contract, 1920×1080 canvas, type scale, layout, palette/visual direction, and assets. Consult this whenever you are about to write or modify any file under `slides/<id>/`, including from inside the `create-slide` or `apply-comments` workflows, or for any ad-hoc slide edit. Triggers on phrases like "edit slide", "tweak this page", "fix the layout", "change the palette", "investigate the slide framework", "how do slides work here".
3
+ description: Technical reference for writing or editing open-slide pages — file contract, 1920×1080 canvas, type scale, layout, palette/visual direction, assets, stepped reveals, page transitions, and morph transitions. Consult this whenever you are about to write or modify any file under `slides/<id>/`, including from inside the `create-slide` or `apply-comments` workflows, or for any ad-hoc slide edit. Triggers on phrases like "edit slide", "tweak this page", "fix the layout", "change the palette", "reveal one by one", "add a transition", "morph transition", "investigate the slide framework", "how do slides work here".
4
4
  ---
5
5
 
6
6
  # Authoring open-slide pages
@@ -14,12 +14,26 @@ This skill is the **technical reference** for everything that happens inside `sl
14
14
 
15
15
  When any of those paths reach the point of *writing React code for a page*, this is the source of truth. Do not duplicate the knowledge below into other skills — link here instead.
16
16
 
17
+ ## Primitive references
18
+
19
+ Each framework primitive has a full reference file under `references/` in this skill — contract, worked examples, and its own anti-patterns. This file keeps only the always-on rules and a short summary per primitive. **Read the relevant reference file before using a primitive on a page**:
20
+
21
+ | Primitive | Read before | File |
22
+ | --- | --- | --- |
23
+ | `design` const + `var(--osd-X)` tokens | writing any new slide (default baseline) | `references/design-system.md` |
24
+ | Assets + `<ImagePlaceholder>` | importing images/videos or leaving a placeholder | `references/assets.md` |
25
+ | Webfonts | loading any non-system font | `references/webfonts.md` |
26
+ | `useSlidePageNumber()` | rendering a page-number footer | `references/page-numbers.md` |
27
+ | `<Steps>` / `<Step>` | staging a page's reveal | `references/steps.md` |
28
+ | `SlideTransition` | declaring any enter/exit animation | `references/transitions.md` |
29
+ | `MorphElement` + `morph` | morphing a shared element across pages | `references/morph.md` |
30
+
17
31
  ## Hard rules
18
32
 
19
33
  - Put the slide under `slides/<kebab-case-id>/`.
20
34
  - Entry is `slides/<id>/index.tsx`. Images/videos/fonts go under `slides/<id>/assets/`.
21
35
  - Do **not** touch `package.json`, `open-slide.config.ts`, or other slides.
22
- - Do not add dependencies. Only `react` and standard web APIs are available.
36
+ - Do not add dependencies. Only `react`, `@open-slide/core`, and standard web APIs are available.
23
37
  - A slide is **one `index.tsx` plus `assets/`** — nothing else. Do not create sibling `.tsx`/`.ts` files (`Card.tsx`, `components/`, `helpers.ts`, etc.); helper components and constants go inside `index.tsx`. Do not create `README.md` or other prose files either.
24
38
 
25
39
  ## File contract
@@ -80,7 +94,7 @@ Every page renders into a fixed **1920 × 1080** canvas. The framework scales it
80
94
 
81
95
  ### Vertical budget — content MUST fit 1080px
82
96
 
83
- The canvas does **not** scroll. Anything below 1080px is silently cropped. Before writing JSX, do the math on paper and confirm the page fits. This is the #1 cause of broken slides — assume you will overflow unless you've checked.
97
+ The canvas does **not** scroll. Anything past the 1080px bottom edge is silently cropped. Before writing JSX, do the math on paper and confirm the page fits. This is the #1 cause of broken slides — assume you will overflow unless you've checked.
84
98
 
85
99
  **Usable height** = `1080 − top_padding − bottom_padding`. With 120px padding on each side that's **840px**. With 160px each side, **760px**. Pick the padding first, then design within that budget.
86
100
 
@@ -106,7 +120,7 @@ Swap the heading to 120px or add a 6th bullet and you're over. **Verify every pa
106
120
  - A bullet should fit on one line at the chosen font size. If it wraps, either shorten the copy or move it to its own page.
107
121
  - Hero title pages (140–200px) carry a title + 1 subtitle + maybe an eyebrow — nothing else.
108
122
  - Section headings (80–120px) need almost nothing else on the page.
109
- - If you find yourself raising padding, shrinking type below the scale's lower bound, or tightening line-height under 1.4 to make things fit — **split into two pages instead**. Splitting is always the right answer when the budget is tight.
123
+ - If you find yourself raising padding, shrinking type below the scale's lower bound, or tightening body line-height under 1.4 to make things fit — **split into two pages instead**. Splitting is always the right answer when the budget is tight.
110
124
 
111
125
  **Never** use `overflow: auto/scroll`, negative margins, or transforms to hide overflow. The canvas is fixed; cropped content is gone.
112
126
 
@@ -114,32 +128,16 @@ Swap the heading to 120px or add a 6th bullet and you're over. **Verify every pa
114
128
 
115
129
  Pick a coherent look and hold it across every page:
116
130
 
117
- - **Palette** — 1 background, 1 primary text, 1 accent, 1 muted. Define as constants at the top of the file.
131
+ - **Palette** — 1 background, 1 primary text, 1 accent, 1 muted. Put bg/text/accent in the `design` const (see Design system below); extra colors like muted stay as plain consts.
118
132
  - **Typography** — one display font + one body font. System stack unless the user specifies. Heavy weight for headlines (800–900), normal for body (400–500).
119
133
  - **Layout grid** — pick a single content padding (e.g. 120px) and stick to it. Left-aligned content feels editorial; centered feels ceremonial.
120
134
  - **Aesthetic commitment** — choose ONE: minimal, maximalist, editorial, retro, brutalist, soft/pastel, neon, paper/print. Don't mix.
121
135
 
122
- Consult the `frontend-design` skill for deeper aesthetic guidance if the user wants something bold.
136
+ If the `frontend-design` skill is available, consult it for deeper aesthetic guidance when the user wants something bold.
123
137
 
124
138
  ## Webfonts
125
139
 
126
- The default is a system font stack — prefer it. When a deck genuinely needs a webfont (a brand font, or CJK / Thai / Arabic where system coverage is poor):
127
-
128
- - **Load the stylesheet once, in `<head>` — never inside a per-page component.** Every page is mounted live at the same time (thumbnail rail, overview grid, and the PDF print root), so a `<style>@import>` / `<link>` rendered inside a `Page` registers the whole `@font-face` set once *per page*. Inject it once, idempotently:
129
-
130
- ```tsx
131
- const FONT_HREF = 'https://fonts.googleapis.com/css2?family=...&display=swap';
132
- if (typeof document !== 'undefined' && !document.getElementById('osd-webfont')) {
133
- const link = document.createElement('link');
134
- link.id = 'osd-webfont';
135
- link.rel = 'stylesheet';
136
- link.href = FONT_HREF;
137
- document.head.appendChild(link);
138
- }
139
- ```
140
-
141
- - **List only the weights you actually use.** Each extra weight multiplies the number of `@font-face` rules.
142
- - **CJK fonts are large.** A Google Fonts CJK family registers hundreds of `unicode-range` subset faces (Noto Sans TC ≈ 105 subsets × each weight), and PDF export waits on fonts before printing. If the deck's text is fixed, add `&text=<unique chars>` to the URL to request a tiny single-face subset instead of the full set.
140
+ The default is a system font stack — prefer it. When a deck genuinely needs a webfont (a brand font, or CJK / Thai / Arabic where system coverage is poor), read `references/webfonts.md` first — loading the stylesheet inside a page component registers the whole `@font-face` set once per mounted page, and CJK families need subsetting.
143
141
 
144
142
  ## Themes
145
143
 
@@ -149,47 +147,11 @@ Themes are produced by the `create-theme` skill and are pure documentation: copy
149
147
 
150
148
  ## Design system (opt-in, per-slide)
151
149
 
152
- A slide can declare its own typed design tokens at the top of `index.tsx`:
150
+ A slide can declare typed design tokens at the top of `index.tsx` — `export const design: DesignSystem = { palette, fonts, typeScale, radius }` — and consume them via `var(--osd-X)` in inline styles. The framework injects the CSS variables at the canvas root, and the dev UI's Design panel can live-tweak them.
153
151
 
154
- ```tsx
155
- import type { DesignSystem, Page } from '@open-slide/core';
152
+ **Default to using it.** Every new slide should declare a `design` const so it stays tweakable from the panel after generation. Only fall back to plain palette constants for a one-off slide whose palette is intentionally locked (`references/design-system.md` covers the fallback).
156
153
 
157
- export const design: DesignSystem = {
158
- palette: { bg: '#f7f5f0', text: '#1a1814', accent: '#6d4cff' },
159
- fonts: {
160
- display: 'Georgia, "Times New Roman", serif',
161
- body: '-apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif',
162
- },
163
- typeScale: { hero: 168, body: 36 },
164
- radius: 12,
165
- };
166
- ```
167
-
168
- `export` it (rather than plain `const`) so the framework can read the object and inject CSS variables at the canvas root automatically.
169
-
170
- The shape is intentionally minimal — it only covers what the Design panel can currently tweak. Anything outside this set (heading sizes, spacing, motion, extra palette colors) belongs as plain hard-coded constants in the slide file.
171
-
172
- There are **two consumption surfaces**, and you should mix them inside the same slide:
173
-
174
- - **`var(--osd-X)` for visual properties (color, font, font-size, radius)** — these get instant updates while the user drags a slider in the Design panel, before any file write.
175
- ```tsx
176
- <div style={{ background: 'var(--osd-bg)', color: 'var(--osd-text)', borderRadius: 'var(--osd-radius)', fontFamily: 'var(--osd-font-body)', fontSize: 'var(--osd-size-body)' }}>
177
- ```
178
- Available vars: `--osd-bg`, `--osd-text`, `--osd-accent`, `--osd-font-display`, `--osd-font-body`, `--osd-size-hero`, `--osd-size-body`, `--osd-radius`.
179
-
180
- - **Direct `design.X` reads** — when you need a JS number for arithmetic or to label something in the UI. These update via HMR after the panel commits the file, not while dragging.
181
- ```tsx
182
- <p>{design.typeScale.hero}px</p>
183
- ```
184
-
185
- The dev UI has a **Design** button in the slide header (next to Inspect). Edits update an in-memory draft and the live-preview overlay; a floating Save / Discard bar at the bottom of the canvas commits or reverts. The const stays the single source of truth — production builds bake the saved values.
186
-
187
- **Default to using it.** Every new slide should declare a `design` const so it stays tweakable from the panel after generation — this is the expected baseline. Only fall back to the local `palette` constants pattern (see starter template) for a one-off slide whose palette is intentionally locked and not meant to be re-themed. Both styles can coexist across slides — the panel only operates on the *currently viewed* slide.
188
-
189
- Format constraints (for the panel's AST writer):
190
- - Must be `[export] const design: DesignSystem = { … }` (or `as DesignSystem` / `satisfies DesignSystem`) at module top level.
191
- - Object initializer must be a literal — no spreads, no helper calls. Plain values only.
192
- - `DesignSystem` must be imported from `@open-slide/core` (the panel adds the import automatically when creating a fresh block).
154
+ `references/design-system.md` has the full token shape, the two consumption surfaces (`var(--osd-X)` vs direct `design.X` reads), Design panel behavior, and the format constraints the panel's AST writer requires. Read it before writing the const.
193
155
 
194
156
  ## Starter template
195
157
 
@@ -269,271 +231,37 @@ export default [Cover, Content] satisfies Page[];
269
231
 
270
232
  ## Assets
271
233
 
272
- **Slide-local assets** live under `slides/<id>/assets/` — anything one-off to a single slide. Import them as ES modules:
273
-
274
- ```tsx
275
- import hero from './assets/hero.jpg';
276
- // …
277
- <img src={hero} style={{ width: '100%', height: '100%', objectFit: 'cover' }} />
278
- ```
234
+ Slide-local assets live under `slides/<id>/assets/` and are imported as ES modules (`import hero from './assets/hero.jpg'`). Global assets shared across decks (logos, avatars, recurring icons) live in the project root `assets/` and are imported via the `@assets` alias. For a pure-text slide, don't create `slides/<id>/assets/` at all.
279
235
 
280
- For URL-only access:
281
-
282
- ```tsx
283
- const videoUrl = new URL('./assets/intro.mp4', import.meta.url).href;
284
- ```
285
-
286
- **Global assets** — anything reused across decks or themes (company logos, presenter avatars, recurring icons) — live in the project root `assets/` folder. Import them via the `@assets` alias:
287
-
288
- ```tsx
289
- import logo from '@assets/logos/acme.svg';
290
- ```
291
-
292
- A `themes/*.md` file may name an asset path in its prose (e.g. "use `@assets/logos/acme.svg` in the title slot"); the slide imports it explicitly.
293
-
294
- Skip the `assets/` folder entirely for pure-text slides.
236
+ `references/assets.md` covers import forms (module vs `new URL(...)`), the `@assets` alias, and how themes name asset paths.
295
237
 
296
238
  ## Image placeholders
297
239
 
298
- When a page genuinely needs a real image **the user has to provide** — a product screenshot, a team photo, a chart from their data — leave a typed placeholder instead of inventing a stand-in:
299
-
300
- ```tsx
301
- import { ImagePlaceholder } from '@open-slide/core';
302
-
303
- <ImagePlaceholder hint="Product hero screenshot" width={1280} height={720} />
304
- ```
305
-
306
- The user uploads the real file via the Assets panel, then clicks the placeholder in the inspector and picks "Replace…" — the JSX is rewritten to a real `<img>` with the import added.
240
+ When a page genuinely needs a real image **the user has to provide** (product screenshot, team photo, chart from their data), leave a typed `<ImagePlaceholder hint="…" />` from `@open-slide/core` instead of inventing a stand-in — the user replaces it via the Assets panel + inspector. **Do not** use placeholders for decoration or generic stock-photo filler; if type, layout, and color can carry the page, do that.
307
241
 
308
- **Use a placeholder only when** a specific concrete image is required by the deck's topic. Examples that warrant one: a product-intro deck (product screenshot per feature), an offsite recap (team photo), a case study (customer logo, dashboard screenshot).
309
-
310
- **Do not use a placeholder** for decoration, generic "stock photo" filler, hero imagery on a text-heavy slide, or anywhere a typographic / iconographic / illustrative solution would do. If you can carry the page with type, layout, and color — do that. Empty placeholders the user has to fill are friction; only spend that friction when the alternative is worse.
311
-
312
- Size the placeholder to the slot it occupies. Pass `width`/`height` when the layout has a fixed image box; omit them when the placeholder fills a flex/grid cell. The `hint` should describe the *content* the user needs ("Q3 revenue chart") not the *role* ("hero image").
242
+ `references/assets.md` has the full usage rules, sizing guidance, and examples of when a placeholder is (and isn't) warranted.
313
243
 
314
244
  ## Page numbers
315
245
 
316
- If a footer shows the current page (`03 / 12`, `Page 3`, etc.), read it from `useSlidePageNumber()` — **never hardcode** `n` / `TOTAL`. Inserting, reordering, or deleting a page would otherwise force you to retouch every footer.
317
-
318
- ```tsx
319
- import { useSlidePageNumber } from '@open-slide/core';
320
-
321
- const Footer = () => {
322
- const { current, total } = useSlidePageNumber();
323
- return (
324
- <span>{String(current).padStart(2, '0')} / {String(total).padStart(2, '0')}</span>
325
- );
326
- };
327
- ```
328
-
329
- `current` is 1-indexed (matches what readers see) and `total` is the slide's page count. The hook works in every render context (main viewer, thumbnails, overview grid, present mode, presenter window, HTML/PDF export) — the same `<Footer />` JSX is correct everywhere. Call the hook inside a component that's used **per page**; don't try to call it at module top level.
246
+ If a footer shows the current page (`03 / 12`), read it from `useSlidePageNumber()` — **never hardcode** `n` / `TOTAL`. See `references/page-numbers.md` for the hook's contract and where it can be called.
330
247
 
331
248
  ## Stepped reveals (`<Steps>` / `<Step>`)
332
249
 
333
- Reveal a page one beat at a time instead of showing everything at once. Wrap the deferred parts in `<Step>`, wrap the group in `<Steps>`. Each `→` reveals the next `<Step>`; `→` after the last one advances to the next page. `←` peels the last reveal back. Use it to stage attention — show framing first, then the consequence, then the turn — so the audience reads at the speaker's pace, not ahead.
250
+ Reveal a page one beat at a time: wrap deferred parts in `<Step>`, the group in `<Steps>`; each `→` reveals the next step. Use it when the *order* of ideas is the point — not reflexively on every page. Two rules are load-bearing: `<Step>` must be a **direct child** of `<Steps>` (otherwise it silently renders fully revealed), and a page must still read as complete when jumped to via the overview grid (jumping in shows all steps revealed).
334
251
 
335
- `slides/build-on-reveal/` is the canonical worked example; study it before authoring a stepped page.
336
-
337
- ```tsx
338
- import { Step, Steps } from '@open-slide/core';
339
-
340
- <Steps>
341
- <Step><div style={BULLET_ROW}>An audience reads faster than a presenter speaks.</div></Step>
342
- <Step><div style={BULLET_ROW}>Showing every bullet at once invites pre-reading.</div></Step>
343
- <Step><div style={BULLET_ROW}>Revealing in time stages attention.</div></Step>
344
- </Steps>
345
- ```
346
-
347
- ### Rules
348
-
349
- - **`<Step>` must be a *direct* child of `<Steps>`.** A `<Step>` nested deeper (or used without a `<Steps>` parent) renders fully revealed and defers nothing.
350
- - **Non-`Step` children render immediately.** Put a headline or intro paragraph *inside* `<Steps>` as a plain element and it shows from the start; only the `<Step>` blocks wait. This is the "headline always, body in turn" pattern:
351
- ```tsx
352
- <Steps>
353
- <h2>Not everything has to wait.</h2>{/* visible immediately */}
354
- <Step><p>First, set the stage…</p></Step>
355
- <Step><p>Then, layer the consequence…</p></Step>
356
- </Steps>
357
- ```
358
- - **Multiple `<Steps>` blocks on one page compose in document order.** The first block reveals all its steps before the second begins; `←` unwinds in reverse. Use this for two columns that build left-then-right, each column owning its own `<Steps>`:
359
- ```tsx
360
- <div style={COL}><Steps><Step>…</Step><Step>…</Step></Steps></div>{/* finishes first */}
361
- <div style={COL}><Steps><Step>…</Step><Step>…</Step></Steps></div>{/* then this */}
362
- ```
363
- - **Entry direction decides the starting state — same content, two rhythms.** Entering forward (`→` from the previous page) starts empty and builds up. Jumping in via the overview grid, or arriving backward from a later page, shows the page **fully composed** with every step already revealed. Design the page to read well both ways: a thumbnail or overview jump should look complete, not blank.
364
- - **`<Step>` fades in over `duration` ms (default 180).** Pass `<Step duration={...}>` to adjust. `prefers-reduced-motion: reduce` collapses it to an instant cut automatically — don't write a fallback.
365
-
366
- ### When to reach for it
367
-
368
- Use stepped reveals when the *order* of ideas is the point — a list whose payoff is the last item, a build-up to a conclusion, a before/after. Don't wrap every page's content in `<Step>` reflexively: a page the audience should take in at a glance (a hero title, a single quote, a diagram) is stronger shown whole. Reveals are timing, not decoration — same restraint as transitions.
252
+ Read `references/steps.md` before authoring a stepped page — it covers composition order across multiple `<Steps>` blocks, the "headline always, body in turn" pattern, and entry-direction behavior. If `slides/build-on-reveal/` exists in this project, it is the canonical worked example.
369
253
 
370
254
  ## Page transitions
371
255
 
372
- The framework can run an enter/exit animation between every slide change. There's **no default** — pages snap unless you declare a `SlideTransition`. Snap-swap is a perfectly tasteful default; only opt in when motion adds something.
373
-
374
- `prefers-reduced-motion: reduce` is honored automatically. You don't write a fallback.
375
-
376
- ### Contract
377
-
378
- Module-level for the whole deck; per-page to override. The **incoming page wins**: navigating A → B uses `pages[B].transition ?? module.transition`. Its `exit` plays on A, its `enter` plays on B. Going back B → A uses A's transition.
379
-
380
- ```tsx
381
- import type { Page, SlideTransition } from '@open-slide/core';
382
-
383
- const Cover: Page = () => <section>…</section>;
384
- const Body: Page = () => <section>…</section>;
385
-
386
- // Module-level default — every page inherits unless it overrides.
387
- export const transition: SlideTransition = { /* … */ };
388
-
389
- // Per-page override.
390
- Cover.transition = { /* … */ };
391
-
392
- export default [Cover, Body];
393
- ```
394
-
395
- ```ts
396
- type TransitionPhase = {
397
- keyframes: Keyframe[] | PropertyIndexedKeyframes; // WAAPI keyframes
398
- duration?: number; // ms (falls back to top-level duration)
399
- easing?: string; // CSS easing
400
- delay?: number; // ms — use to overlap exit + enter
401
- };
402
- type SlideTransition = {
403
- duration: number; // top-level fallback
404
- easing?: string; // top-level fallback
405
- enter?: TransitionPhase; // runs on incoming page
406
- exit?: TransitionPhase; // runs on outgoing page
407
- };
408
- ```
409
-
410
- The framework also exposes `--osd-dir` (`1` forward, `-1` backward) and `data-osd-dir` on the wrapper, so a single keyframe can mirror direction without a JS callback.
411
-
412
- ### Design principles (hold the line)
413
-
414
- The single loudest signal of "made in PowerPoint" is six different transitions in one deck. Restraint is the rhythm.
256
+ The framework can run an enter/exit animation between slide changes, declared as a `SlideTransition` (module-level default, per-page override; the **incoming page wins**). There's **no default** — pages snap unless you opt in, and snap-swap is a perfectly tasteful default. If you do opt in: one motion DNA per deck, 140–280 ms, magnitude under 12 px / 3% scale, opacity always part of it.
415
257
 
416
- - **Pick one DNA, hold it across the deck.** Same duration band, same easing pair, same out-then-in stagger. Variation lives only in *which property* gets the small nudge — Y, X, opacity, scale, blur.
417
- - **Duration: 140–280 ms.** Exit 140–180 ms, enter 200–280 ms, enter delayed ~80 ms so they overlap but don't fight. Past 350 ms is video-editor territory; reserve for genuine state changes.
418
- - **Magnitude ceiling: 12 px or 3% scale.** A 6 px Y-rise reads as "next thought." A 1920 px translateX reads as "different document." Premium tools move barely enough to register.
419
- - **Opacity is always part of it.** Pure-transform transitions look stiff; pure-opacity transitions are the safest possible default.
420
- - **Easing: ease-in for exit, ease-out for enter.** `cubic-bezier(0.4, 0, 1, 1)` going out, `cubic-bezier(0, 0, 0.2, 1)` coming in. Never `linear` (feels like a slideshow). Reserve symmetric `ease-in-out` for state-anchored morphs only.
421
-
422
- ### Tasteful family — six members, one DNA
423
-
424
- Use this set as a starting point. Pick one as the deck's house transition; optionally reserve a second for hero/cover slides and a third for genuine section breaks. The CSS-`calc` + `--osd-dir` trick lets a single definition mirror itself on backward navigation when needed.
425
-
426
- ```tsx
427
- const EASE_OUT = 'cubic-bezier(0, 0, 0.2, 1)';
428
- const EASE_IN = 'cubic-bezier(0.4, 0, 1, 1)';
429
-
430
- // RISE — house quiet. 6 px Y. Use as module default.
431
- export const transition: SlideTransition = {
432
- duration: 200,
433
- exit: { duration: 140, easing: EASE_IN,
434
- keyframes: [
435
- { opacity: 1, transform: 'translateY(0)' },
436
- { opacity: 0, transform: 'translateY(-4px)' },
437
- ] },
438
- enter: { duration: 200, delay: 80, easing: EASE_OUT,
439
- keyframes: [
440
- { opacity: 0, transform: 'translateY(6px)' },
441
- { opacity: 1, transform: 'translateY(0)' },
442
- ] },
443
- };
444
-
445
- // DISSOLVE — pure opacity. The quietest possible.
446
- const dissolve: SlideTransition = {
447
- duration: 240,
448
- exit: { duration: 200, easing: EASE_IN,
449
- keyframes: [{ opacity: 1 }, { opacity: 0 }] },
450
- enter: { duration: 240, delay: 40, easing: EASE_OUT,
451
- keyframes: [{ opacity: 0 }, { opacity: 1 }] },
452
- };
453
-
454
- // SETTLE — cover-grade. Rise + a hair of blur on enter only.
455
- Cover.transition = {
456
- duration: 280,
457
- exit: { duration: 160, easing: EASE_IN,
458
- keyframes: [
459
- { opacity: 1, transform: 'translateY(0)' },
460
- { opacity: 0, transform: 'translateY(-6px)' },
461
- ] },
462
- enter: { duration: 280, delay: 100, easing: EASE_OUT,
463
- keyframes: [
464
- { opacity: 0, transform: 'translateY(12px)', filter: 'blur(4px)' },
465
- { opacity: 1, transform: 'translateY(0)', filter: 'blur(0)' },
466
- ] },
467
- };
468
-
469
- // BLOOM — scale 0.97 → 1, no translate. Materializes in place.
470
- const bloom: SlideTransition = {
471
- duration: 240,
472
- exit: { duration: 160, easing: EASE_IN,
473
- keyframes: [
474
- { opacity: 1, transform: 'scale(1)' },
475
- { opacity: 0, transform: 'scale(1.01)' },
476
- ] },
477
- enter: { duration: 240, delay: 80, easing: EASE_OUT,
478
- keyframes: [
479
- { opacity: 0, transform: 'scale(0.97)' },
480
- { opacity: 1, transform: 'scale(1)' },
481
- ] },
482
- };
483
-
484
- // FALL — mirrored Rise. Incoming page comes down from above.
485
- const fall: SlideTransition = {
486
- duration: 200,
487
- exit: { duration: 140, easing: EASE_IN,
488
- keyframes: [
489
- { opacity: 1, transform: 'translateY(0)' },
490
- { opacity: 0, transform: 'translateY(4px)' },
491
- ] },
492
- enter: { duration: 200, delay: 80, easing: EASE_OUT,
493
- keyframes: [
494
- { opacity: 0, transform: 'translateY(-6px)' },
495
- { opacity: 1, transform: 'translateY(0)' },
496
- ] },
497
- };
498
-
499
- // BREATH — section break. Exit fully, hold 120 ms, then enter.
500
- // Reserve for genuine chapter dividers; use at most 1–2× per deck.
501
- const breath: SlideTransition = {
502
- duration: 460,
503
- exit: { duration: 180, easing: EASE_IN,
504
- keyframes: [{ opacity: 1 }, { opacity: 0 }] },
505
- enter: { duration: 240, delay: 300, easing: EASE_OUT,
506
- keyframes: [
507
- { opacity: 0, transform: 'translateY(8px)' },
508
- { opacity: 1, transform: 'translateY(0)' },
509
- ] },
510
- };
511
- ```
512
-
513
- All six share the same DNA — they only differ in which property carries the small nudge. The reader perceives variety; the eye still reads one consistent hand.
514
-
515
- ### Direction-aware keyframes (use sparingly)
516
-
517
- Most tasteful tools don't mirror on backward navigation. When you genuinely need to — e.g. a horizontal slide that should reverse — use `--osd-dir` inside `calc()`:
518
-
519
- ```tsx
520
- { transform: 'translateX(calc(var(--osd-dir, 1) * 8px))' },
521
- { transform: 'translateX(0)' },
522
- ```
258
+ Read `references/transitions.md` before declaring one — it has the full type contract, design principles, a six-member "tasteful family" of ready-to-use transitions sharing one DNA, direction-aware keyframes, and the anti-pattern list.
523
259
 
524
- If you find yourself reaching for this on every transition, you're probably over-designing. Forward = backward is the more refined default.
260
+ ## Morph transitions
525
261
 
526
- ### Transition anti-patterns
262
+ When the *same visual object* exists on two adjacent pages, wrap it on both pages in `MorphElement` with the same `id` and enable `morph` on the incoming page's transition — position, size, radius, and colors interpolate in one continuous move (Keynote's "Magic Move"). Morph is for **state continuity** (a toggle sliding, a card expanding, a box joining a row); don't morph decoration.
527
263
 
528
- - ❌ Six different transitions across six pages — the single loudest "made in PowerPoint" tell.
529
- - ❌ `translateX(100%)` slide-from-side — iOS modal / PowerPoint Push; not a slide change.
530
- - ❌ Aggressive scale-pop (e.g. `0.85 → 1`) + blur — lightbox / photo-viewer vocabulary; implies zooming *into* something.
531
- - ❌ `clip-path: inset(…)` reveals — After Effects vocabulary; theatrical.
532
- - ❌ Parallel blur on both layers at once — visual mush; the eye can't fixate.
533
- - ❌ Duration > 350 ms for a standard slide change — drags.
534
- - ❌ Translate > 12 px or scale > 3% — reads as rupture, not continuity.
535
- - ❌ `linear` easing — feels like a slideshow, not a product.
536
- - ❌ Declaring a transition on every deck. **If you don't have a clear reason, omit it.** Snap-swap is fine.
264
+ Read `references/morph.md` before writing one — the seven rules there (opacity-only enter/exit, deterministic geometry, no `transform` on the morph node, `useIsActivePage()` gating, …) were each earned on a real deck, and violating any of them produces a visibly broken morph.
537
265
 
538
266
  ## Repeated elements: component, not `map`
539
267
 
@@ -601,7 +329,8 @@ This applies whenever the *visual element* repeats, not whenever the *data* does
601
329
  - [ ] All imported assets exist on disk — slide-local under `slides/<id>/assets/`, or global under `assets/` (imported via `@assets/...`).
602
330
  - [ ] Every `<ImagePlaceholder>` corresponds to a real image the user must supply — not decorative filler. If it could be replaced by typography or layout, it should be.
603
331
  - [ ] If a page uses `<Steps>`/`<Step>`, every `<Step>` is a direct child of a `<Steps>`, and the page still reads as complete when jumped to via the overview grid (entering forward builds up; jumping in shows it fully revealed).
604
- - [ ] If a `SlideTransition` is declared, every page sits in one family — same duration band (140–280 ms), same easing pair, same out-then-in stagger, magnitude under 12 px / 3%. No six-different-vocabularies decks. When in doubt, omit transitions entirely.
332
+ - [ ] If a `SlideTransition` is declared, every page sits in one family — same duration band (140–280 ms), same easing pair, same out-then-in stagger, magnitude under 12 px / 3%. No six-different-vocabularies decks. When in doubt, omit transitions entirely. (Pages that opt into `morph` may exceed the band to match the morph — see `references/morph.md`.)
333
+ - [ ] If a transition opts into `morph`: every morph `id` is unique per page and stable across the pair, morph geometry is pixel-constant (never measured after mount), no `transform` sits on the morph node, and entrance animations are gated behind `useIsActivePage()`.
605
334
  - [ ] Nothing outside `slides/<id>/` was edited.
606
335
 
607
336
  ## Anti-patterns
@@ -614,12 +343,8 @@ This applies whenever the *visual element* repeats, not whenever the *data* does
614
343
  - ❌ Bullets that wrap to a second line — either shorten or move to its own page.
615
344
  - ❌ Body type under 28px — unreadable on a projector.
616
345
  - ❌ Inconsistent palette across pages.
617
- - ❌ Installing packages. Only `react` and standard web APIs are available.
346
+ - ❌ Installing packages. Only `react`, `@open-slide/core`, and standard web APIs are available.
618
347
  - ❌ Writing CSS to a shared file. Inline styles or scoped classnames only.
619
348
  - ❌ Creating `README.md` or other prose files inside the slide folder.
620
349
  - ❌ Editing `package.json`, `open-slide.config.ts`, or other slides.
621
- - ❌ Sprinkling `<ImagePlaceholder>` across pages "for visual interest". Placeholders are for content the user owns; they're not stock-photo slots.
622
- - ❌ Using a placeholder for an icon or decorative shape — those are typography/SVG problems, not asset problems.
623
- - ❌ Rendering visually repeated elements with `array.map(...)` over a data array. Define a component and instantiate it explicitly per item (`<Card />`, `<Card />`, `<Card />`) so the inspector can edit each independently — a shared `map` body mutates every instance at once.
624
- - ❌ Wrapping every page's content in `<Step>` reflexively. Stepped reveals are for content whose *order* is the point; a glance-and-get-it page (hero title, single quote, diagram) is stronger shown whole.
625
- - ❌ A `<Step>` that isn't a direct child of `<Steps>` (nested deeper, or with no `<Steps>` parent). It renders fully revealed and defers nothing — the reveal silently does nothing.
350
+ - ❌ Using a primitive without reading its reference file — each `references/*.md` carries the primitive's own anti-pattern list (placeholder misuse, transition vocabulary, `<Step>` nesting, morph geometry).
@@ -0,0 +1,52 @@
1
+ # Assets & image placeholders
2
+
3
+ ## Slide-local assets
4
+
5
+ **Slide-local assets** live under `slides/<id>/assets/` — anything one-off to a single slide. Import them as ES modules:
6
+
7
+ ```tsx
8
+ import hero from './assets/hero.jpg';
9
+ // …
10
+ <img src={hero} style={{ width: '100%', height: '100%', objectFit: 'cover' }} />
11
+ ```
12
+
13
+ For URL-only access:
14
+
15
+ ```tsx
16
+ const videoUrl = new URL('./assets/intro.mp4', import.meta.url).href;
17
+ ```
18
+
19
+ ## Global assets
20
+
21
+ **Global assets** — anything reused across decks or themes (company logos, presenter avatars, recurring icons) — live in the project root `assets/` folder. Import them via the `@assets` alias:
22
+
23
+ ```tsx
24
+ import logo from '@assets/logos/acme.svg';
25
+ ```
26
+
27
+ A `themes/*.md` file may name an asset path in its prose (e.g. "use `@assets/logos/acme.svg` in the title slot"); the slide imports it explicitly.
28
+
29
+ For a pure-text slide, don't create `slides/<id>/assets/` at all.
30
+
31
+ ## Image placeholders (`<ImagePlaceholder>`)
32
+
33
+ When a page genuinely needs a real image **the user has to provide** — a product screenshot, a team photo, a chart from their data — leave a typed placeholder instead of inventing a stand-in:
34
+
35
+ ```tsx
36
+ import { ImagePlaceholder } from '@open-slide/core';
37
+
38
+ <ImagePlaceholder hint="Product hero screenshot" width={1280} height={720} />
39
+ ```
40
+
41
+ The user uploads the real file via the Assets panel, then clicks the placeholder in the inspector and picks "Replace…" — the JSX is rewritten to a real `<img>` with the import added.
42
+
43
+ **Use a placeholder only when** a specific concrete image is required by the deck's topic. Examples that warrant one: a product-intro deck (product screenshot per feature), an offsite recap (team photo), a case study (customer logo, dashboard screenshot).
44
+
45
+ **Do not use a placeholder** for decoration, generic "stock photo" filler, hero imagery on a text-heavy slide, or anywhere a typographic / iconographic / illustrative solution would do. If you can carry the page with type, layout, and color — do that. Empty placeholders the user has to fill are friction; only spend that friction when the alternative is worse.
46
+
47
+ Size the placeholder to the slot it occupies. Pass `width`/`height` when the layout has a fixed image box; omit them when the placeholder fills a flex/grid cell. The `hint` should describe the *content* the user needs ("Q3 revenue chart") not the *role* ("hero image").
48
+
49
+ ### Placeholder anti-patterns
50
+
51
+ - ❌ Sprinkling `<ImagePlaceholder>` across pages "for visual interest". Placeholders are for content the user owns; they're not stock-photo slots.
52
+ - ❌ Using a placeholder for an icon or decorative shape — those are typography/SVG problems, not asset problems.
@@ -0,0 +1,48 @@
1
+ # Design system (`design` const + `var(--osd-X)`)
2
+
3
+ A slide can declare its own typed design tokens at the top of `index.tsx`:
4
+
5
+ ```tsx
6
+ import type { DesignSystem, Page } from '@open-slide/core';
7
+
8
+ export const design: DesignSystem = {
9
+ palette: { bg: '#f7f5f0', text: '#1a1814', accent: '#6d4cff' },
10
+ fonts: {
11
+ display: 'Georgia, "Times New Roman", serif',
12
+ body: '-apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif',
13
+ },
14
+ typeScale: { hero: 168, body: 36 },
15
+ radius: 12,
16
+ };
17
+ ```
18
+
19
+ `export` it (rather than plain `const`) so the framework can read the object and inject CSS variables at the canvas root automatically.
20
+
21
+ The shape is intentionally minimal — it only covers what the Design panel can currently tweak. Anything outside this set (heading sizes, spacing, motion, extra palette colors) belongs as plain hard-coded constants in the slide file.
22
+
23
+ ## Two consumption surfaces
24
+
25
+ There are **two consumption surfaces**; both may appear in the same slide:
26
+
27
+ - **`var(--osd-X)` for visual properties (color, font, font-size, radius)** — these get instant updates while the user drags a slider in the Design panel, before any file write.
28
+ ```tsx
29
+ <div style={{ background: 'var(--osd-bg)', color: 'var(--osd-text)', borderRadius: 'var(--osd-radius)', fontFamily: 'var(--osd-font-body)', fontSize: 'var(--osd-size-body)' }}>
30
+ ```
31
+ Available vars: `--osd-bg`, `--osd-text`, `--osd-accent`, `--osd-font-display`, `--osd-font-body`, `--osd-size-hero`, `--osd-size-body`, `--osd-radius`.
32
+
33
+ - **Direct `design.X` reads** — when you need a JS number for arithmetic or to label something in the UI. These update via HMR after the panel commits the file, not while dragging.
34
+ ```tsx
35
+ <p>{design.typeScale.hero}px</p>
36
+ ```
37
+
38
+ ## The Design panel
39
+
40
+ The dev UI has a **Design** button in the slide header (next to Inspect). Edits update an in-memory draft and the live-preview overlay; a floating Save / Discard bar at the bottom of the canvas commits or reverts. The const stays the single source of truth — production builds bake the saved values.
41
+
42
+ **Default to using it.** Every new slide should declare a `design` const so it stays tweakable from the panel after generation — this is the expected baseline. Only fall back to plain top-of-file constants (`const palette = { bg: …, text: …, accent: … }`, referenced directly in styles) for a one-off slide whose palette is intentionally locked and not meant to be re-themed. Both styles can coexist across slides — the panel only operates on the *currently viewed* slide.
43
+
44
+ ## Format constraints (for the panel's AST writer)
45
+
46
+ - Must be `export const design: DesignSystem = { … }` (or `as DesignSystem` / `satisfies DesignSystem`) at module top level. (The panel's parser also tolerates a non-exported const, but the runtime reads `design` off the module's exports — without `export`, every `var(--osd-X)` is unresolved.)
47
+ - Object initializer must be a literal — no spreads, no helper calls. Plain values only.
48
+ - `DesignSystem` must be imported from `@open-slide/core` (the panel adds the import automatically when creating a fresh block).
@@ -0,0 +1,67 @@
1
+ # Morph transitions (`MorphElement`)
2
+
3
+ > Morph builds on the `SlideTransition` contract — read `transitions.md` first if you haven't.
4
+
5
+ When the *same visual object* exists on two adjacent pages, the runtime can morph it across the cut — position, size, border-radius, and colors interpolate in one continuous move (Keynote calls this "Magic Move") — instead of fading out and back in. Two parts opt in:
6
+
7
+ 1. Wrap the object on **both** pages in `MorphElement` with the **same `id`**.
8
+ 2. Enable `morph` on the incoming page's transition.
9
+
10
+ ```tsx
11
+ import { MorphElement, type Page, type SlideTransition } from '@open-slide/core';
12
+ import type { CSSProperties } from 'react';
13
+
14
+ // Morph transition — opacity-only enter/exit keeps all the motion on the clones (see rules).
15
+ const morphTransition: SlideTransition = {
16
+ duration: 280,
17
+ exit: { duration: 224, easing: 'cubic-bezier(0.4, 0, 1, 1)', keyframes: [{ opacity: 1 }, { opacity: 0 }] },
18
+ enter: { duration: 308, delay: 112, easing: 'cubic-bezier(0, 0, 0.2, 1)', keyframes: [{ opacity: 0 }, { opacity: 1 }] },
19
+ morph: { duration: 868, easing: 'cubic-bezier(0.4, 0, 0.2, 1)' },
20
+ };
21
+
22
+ const stage: CSSProperties = { width: '100%', height: '100%', position: 'relative', background: '#000000', overflow: 'hidden' };
23
+
24
+ const Narrow: Page = () => (
25
+ <div style={stage}>
26
+ <MorphElement id="pill"><div style={{ position: 'absolute', left: 842, top: 479, width: 236, height: 122, borderRadius: 999, background: '#ffffff' }} /></MorphElement>
27
+ </div>
28
+ );
29
+ const Wide: Page = () => (
30
+ <div style={stage}>
31
+ <MorphElement id="pill"><div style={{ position: 'absolute', left: 721, top: 479, width: 478, height: 122, borderRadius: 999, background: '#0a0a0a' }} /></MorphElement>
32
+ </div>
33
+ );
34
+
35
+ Wide.transition = morphTransition; // forward: Narrow → Wide morphs the pill
36
+ Narrow.transition = morphTransition; // backward: Wide → Narrow morphs it back
37
+ ```
38
+
39
+ ## Contract
40
+
41
+ - `morph: true` inherits the transition's top-level `duration`/`easing`; pass `{ duration?, easing?, delay? }` to time the morph independently of the page cross-fade. Morphs usually read best 2–4× longer than the fade (e.g. 280 ms fade, 868 ms morph). Fade phases on morphing pages may run past the 140–280 ms band in `transitions.md` — they're timed against the longer morph, not the standard cut; the band still binds non-morph pages.
42
+ - Elements pair by `id` across the cut. A matched pair FLIP-morphs: the runtime measures both rects, clones the outgoing element into an overlay above both pages, hides the originals, and animates transform + border-radius + colors (border widths ride a separate frame so they don't stretch with the box). Keep each `id` unique within a page; don't nest one `MorphElement` inside another.
43
+ - An `id` present on only one side fades in/out **in place**. This is how "a third box joins the row" reads: carried boxes glide to their new slots, the new one materializes.
44
+ - Colors on the morph node *and its descendants* interpolate too — a label that flips black → white mid-glide just works.
45
+ - The transition lives on the **incoming** page. For a morph that also plays when stepping backward, assign the same transition object to both pages (as above).
46
+
47
+ ## Rules — each one earned on a real deck
48
+
49
+ 1. **Prefer opacity-only enter/exit on morphing pages.** Any transition family composes correctly with the morph (shared rects are measured before the phases start), but while clones glide, a transform-bearing enter also slides the rest of the page — two competing motions. Giving the clones all the motion and fading everything else is what makes a morph read as one confident gesture.
50
+ 2. **Morph geometry must be deterministic at mount.** Rects are snapshotted once at the cut. Position morph elements with pixel constants — never with a value measured in an effect after mount (the re-render shifts the target mid-morph and the move jumps). If text inside a morph box grows over time (typewriter etc.), render a hidden full-width spacer so the measured box never changes size.
51
+ 3. **No `transform` on the morph node itself.** A percentage translate (`translate(-50%, -50%)`) gets mis-scaled by the morph and lands the clone tens of px off. Put centering/positioning transforms on a plain wrapper `<div>` *around* the `MorphElement`.
52
+ 4. **`MorphElement` merges `className`/`style` onto its single host child** (it adds no wrapper when the child is a lone DOM element). A crop box (`overflow: hidden` + fixed width) therefore needs an explicit nested `<div>` — otherwise the box collapses onto the `<img>` inside and squishes it.
53
+ 5. **Gate entrance animations behind `useIsActivePage()`.** During the cut the runtime mounts a *fresh instance* of the outgoing page to snapshot its exit state (and the dev UI mounts every page for thumbnails/overview). If an intro replays there, the snapshot is mid-animation and the morph starts from garbage. The hook returns `true` only for the instance the audience is watching; every other instance (outgoing snapshot, thumbnails, overview, presenter preview, print) should render the final, settled state — no intro, full text.
54
+
55
+ ```tsx
56
+ import { useIsActivePage } from '@open-slide/core';
57
+
58
+ // Inside the page component:
59
+ const animate = useIsActivePage();
60
+ ```
61
+
62
+ 6. **Clones travel above everything.** The morph overlay sits over both pages, so an incoming element that should appear only when a clone "lands" will otherwise pop early. Give such reveals a delay equal to the morph: `animation: 'osd-fade 0.63s ease-out 0.868s both'` where `0.868s` is `morph.duration` (`osd-fade` is not framework-provided — define `@keyframes osd-fade { from { opacity: 0 } to { opacity: 1 } }` in the slide yourself). Keep that number in one shared const so the two can't drift.
63
+ 7. **A "hold" page is a separate component.** Transitions attach to the incoming page, so to follow a morph cut with a plain cut of the same content, mint a second page component without `.transition` (e.g. `const Flow4Hold: Page = () => <Flow count={4} />`).
64
+
65
+ ## When to reach for it
66
+
67
+ Morph is for **state continuity**: a toggle whose thumb slides to the next option, a card that expands into a detail view, a logo that glides from center stage into the next page's diagram, a row that gains one more box. The object *is the story* across the cut. Don't morph decoration, and don't tag elements "just in case" — every morph id is a promise to the audience that it's the same object. One or two morphing sequences per chapter is plenty; the surrounding pages should cut or fade quietly.