Files
open-design/apps/web/tests/runtime/srcdoc-deck-bridge-visible-reveal.test.ts
eb749841b4 fix(home): surface community slide decks on Home with letterbox-free 16:9 previews (#4350)
* fix(plugins): surface slides decks on Home instead of marketplace sources

The 23 community slides/deck plugins from #4127 were registered as a
restricted community marketplace source, so they showed up as installable
"available sources" cards (受限 + Install) instead of on Home. Relocate them
to plugins/_official/examples so they ship bundled — appearing in the Home
Community gallery and the deck example-prompt rail, exactly like the existing
zhangzara / swiss / guizang decks — and drop their community-registry entries.

- Move 23 plugins/community/<slug> → plugins/_official/examples/<slug>
  (upstream LICENSE / author / homepage / "Based on" attribution preserved)
- Rename manifest name community-<slug> → example-<slug> (bundled convention)
- Remove the 23 entries from plugins/registry/community/open-design-marketplace.json
  (the 3 pre-existing community entries stay)
- HomeHero: uncap the deck example-prompt rail (other chips keep the curated 18)
  so every bundled slide template is reachable straight from "All"
- curatedPriority: pin the 23 slides to the front of both the deck example rail
  and the Community Slides shelf

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(home): drop provenance tail from deck seeds & fix deck preview letterbox

Two polish fixes for the slide/deck plugins now surfaced on Home:

1. Example-prompt seed: strip a trailing source-attribution sentence
   ("…。移植自 foo/bar 的 baz 模板。" / "Based on …") from the composer seed so
   the prompt doesn't end on provenance boilerplate. Conservative — only fires
   when the final sentence opens with an attribution marker and real text
   precedes it; attribution woven mid-description (followed by a use-case
   sentence) and the gallery/detail descriptions are left intact. Latin '.'
   only ends a sentence at whitespace/EOL so "STYLE_PRESETS.md" / "github.com/…"
   don't mis-split.

2. Deck gallery preview: decks ship a fixed 16:9 stage that scales to its
   viewport, so the tall scroll-preview frame letterboxed it and showed a dark
   --stage-bg band above/below the slide. Tag deck cards with data-od-mode and
   give them a 16:9 frame the iframe fills natively (no transform, no pan), so
   the stage sits edge-to-edge with no band.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(home): deck preview frame to 16:9 so no white strip below the slide

The deck preview override targeted the inner html-frame while the gallery frame
kept its fixed 300px height, leaving a white strip under the 16:9 slide. Make
the gallery frame itself 16:9 for deck cards so the stage fills it exactly —
title bar + slide, nothing left over.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(decks): hide the page-counter chrome on all 23 community slide decks

The five upstream deck families each render a different page-counter ("1 / 10")
— a center pill (.deck-controls), an id="counter" badge, a fixed .deck-counter,
or a .count span inside a Shadow-DOM rail — so the home gallery thumbnails
showed it inconsistently. Per maintainer request, drop it everywhere rather
than unify: inject a display:none rule for the light-DOM counters and inline-
hide the Shadow-DOM .count span. Keyboard/touch navigation is untouched; only
the visual counter is removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(home): fix deck letterbox band in the example-prompt rail tiles too

The earlier 16:9 deck-preview fix only covered the Community gallery cards; the
hero example-prompt rail tiles render the deck in a 4:3 (1440×1080) preview and
still showed a dark --stage-bg band on top. Tag deck preset tiles with
data-od-mode and give them a 16:9 preview the iframe fills natively, matching
the gallery treatment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(home): remove the ↗ open-external button from community gallery cards

The ↗ only rendered when a tile's preview was an HTML source, so it
appeared on some cards (most decks, a few prototypes) and not others
(images, srcless tiles) — inconsistent chrome across the shelf. Drop it
and the whole onOpenExternal pass-through (PluginCard → PluginsHomeSection
→ HomeView) plus the now-dead .plugins-home__gallery-open styles.

* fix(home): make the community search clear (×) button visible

The clear button uses the shared <Button> component, whose CSS-module
class set padding 6/12 and crushed the 12px × glyph to zero width inside
the 26px button (a blank grey square). The .plugins-home__search-clear
reset only out-specified the global `button {}` element rule, not the
component class — scope it under .plugins-home__search so the padding:0 /
20x20 sizing actually wins.

* fix(home): align deck example-prompt tile title row with other tiles

Deck preset tiles used a 16:9 `auto` preview row, so their card was
shorter than the fixed-150px sibling tiles; the flex rail stretched them
back up and the slack leaked into the title row, making deck titles ~6px
taller. Keep deck tiles on the standard 150px preview cell and center the
native 16:9 stage inside it (neutral margin, no dark band), so card and
title-row heights match prototype/HyperFrames/image tiles.

* fix(deck-bridge): mirror the visible class so reveal animations fire on navigation

Reveal-animation decks (the frontend-slides family) gate staggered
entrances on a separate `.slide.visible` class that the deck's own show()
adds alongside `.active`. The host bridge's setActive() flipped only the
active class, so bridge-driven page turns showed slide chrome but left
every .reveal child at opacity:0 — the body rendered blank. Mirror
`.visible` in lock-step with the active slide (only for decks that use it,
a no-op elsewhere). Adds a red→green regression test.

* fix(home): unpin the bare Frontend Slides template from the slides shelf

example-frontend-slides is the family-root template with a generic cover;
pinned first it read as filler leading the Slides shelf and deck chip.
Drop it from PINNED_SLIDE_PLUGIN_IDS so it falls to the uncurated tail
while the styled variants (Creative Voltage, Electric Studio, …) keep the
lead.

---------

Co-authored-by: free666799 <293857035+free666799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 09:32:15 +00:00

71 lines
3.0 KiB
TypeScript

// @vitest-environment node
// Regression: reveal-animation decks (the frontend-slides family — Creative
// Voltage, Electric Studio, …) gate their staggered entrances on a SEPARATE
// `.visible` class (`.slide.visible .reveal { opacity: 1 }`) that the deck's own
// show() adds alongside `.active`. The host deck bridge drives navigation by
// class mutation (setActive); before the fix it flipped only `.active`, so the
// target slide showed its chrome but every .reveal child stayed at opacity:0 —
// the body rendered blank. setActive must mirror `.visible` in lock-step with
// the active slide so the entrance animations fire on bridge-driven page turns.
import { describe, expect, it, vi } from 'vitest';
import { JSDOM } from 'jsdom';
import { buildSrcdoc } from '../../src/runtime/srcdoc';
function extractDeckBridgeScript(srcdoc: string): string {
const match = srcdoc.match(/<script data-od-deck-bridge>([\s\S]*?)<\/script>/);
if (!match || !match[1]) {
throw new Error('deck bridge script not found in srcdoc');
}
return match[1];
}
function setupVisibleRevealDeck() {
// Inactive slides are hidden inline so the bridge takes its class-mutation
// (setActive) path deterministically under JSDOM; the active slide carries the
// `.active visible` pairing the real templates ship with.
const bodyHtml = `
<section class="slide active visible" style="display:flex"><p class="reveal">One</p></section>
<section class="slide" style="display:none"><p class="reveal">Two</p></section>
<section class="slide" style="display:none"><p class="reveal">Three</p></section>
`;
const srcdoc = buildSrcdoc(`<!doctype html><html><body>${bodyHtml}</body></html>`, {
deck: true,
});
const script = extractDeckBridgeScript(srcdoc);
const dom = new JSDOM(`<!doctype html><html><body>${bodyHtml}</body></html>`, {
runScripts: 'outside-only',
pretendToBeVisual: true,
});
const win = dom.window;
const parentPostMessage = vi.fn();
Object.defineProperty(win, 'parent', {
configurable: true,
value: { postMessage: parentPostMessage },
});
const evaluate = new win.Function(script);
evaluate.call(win);
const slides = Array.from(win.document.querySelectorAll<HTMLElement>('.slide'));
return { win, slides };
}
describe('deck bridge - visible-gated reveal decks', () => {
it('mirrors the `visible` class onto the target slide when navigating by class mutation', () => {
const { win, slides } = setupVisibleRevealDeck();
win.dispatchEvent(
new win.MessageEvent('message', { data: { type: 'od:slide', action: 'next' } }),
);
const [first, second] = slides;
if (!first || !second) throw new Error('expected at least two slides');
// Target slide is now both active and visible (so its .reveal children fire);
// the previously-active slide drops `visible` so it does not bleed through.
expect(second.classList.contains('active')).toBe(true);
expect(second.classList.contains('visible')).toBe(true);
expect(first.classList.contains('visible')).toBe(false);
});
});