feat: one design for the pages around the player, shipped as page.css

Merged
AL
9d ago
+774-434

Closes #170.

The pages that hold the player outside the demo looked nothing like it: the verifier's preview in the browser's system styles, the extension's page a white page with the player on it. This ships the demo's page design with the player and has every page import it, so none can drift.

Changes

  • @missing-elements/h5p-offline-player/page.css, source in packages/player/page/, copied to dist/ by build-workers.mjs with mark.svg, the brand mark. It holds what moved out of the demo's player-page.css, verbatim: the tokens for light and dark, the base rules, the bar with the brand and its nav and actions, the icon button, buttons, the status strip with its badge and timer, the player's box while it loads, cards and messages. Two additions: .button beside button, so a link can be a button (the verifier's Download), and the bar's three-column grid applies to a bar with a nav (.topbar:has(nav)), so a bar of a brand and its actions keeps the actions at the end.
  • The demo imports it at the top of player-page.css (1113 → 721 lines) and keeps its own rules. The config aliases the package path to the source, as it does the element's, so the demo needs no build of the player for it.
  • The verifier's preview is now that page: the bar with the mark, the file name and a byline, Download as a button, the theme switch (the demo's pin-or-follow logic), the status strip with READY/ERROR, the message and the timer. Its texts, ids and the end-of-preview behaviour are unchanged; the file name stays the page's h1, and the live region is the message, not the strip with its timer.
  • The extension carries page.css and mark.svg with the player's files, and its page links the stylesheet: the player's box while it loads, and the page's colours follow VS Code's theme, which the webview reads from its body and passes to the page in the address and, when it changes, as a message the page takes only from its own webview. The bar above keeps VS Code's own theme colours.
  • Design notes in design/demo.md, design/verify.md, design/vscode.md, the files in design/layout.md, a section in docs/setup.md.

Testing

  • pnpm build: dist/page.css 13.5 kB, dist/mark.svg 12.9 kB.
  • Verifier: 9/9 preview tests pass, with new assertions: the file name as the page's only h1, #message as the only live region, a theme switched in one tab followed by another tab of the same preview (fails without the storage listener), /page.css served as text/css, /mark.svg as image/svg+xml, the bar sticky, the strip at data-state="ready" before Download is clicked; the existing download and end-of-preview checks still pass.
  • Extension: 30/30 Node tests pass, with new ones on the page linking /page.css and on VS Code's theme: from the webview's body classes (high-contrast light as light) to the address, to data-theme on the page's <html>, live by message, and refused from any other window or origin or as any other value (fails without the origin check). test:vscode (a downloaded VS Code) was not run.
  • Typecheck passes for the demo, the verifier and the extension.
  • The demo is unchanged: the built site, served with vite preview, against the live site, 7 pages × 2 widths × 2 themes, 42 selectors × 39 computed properties: 720 element snapshots, no difference in any colour, font, border, spacing or layout property. The only differences were load-timing ones (the player's box on xapi.html before and after ready, the Star count's width before and after its fetch), and a second run of those pages with a longer wait had 0 differences. The bundled CSS has the shared rules inlined and no @import left.
  • The preview page opened from this branch, light and dark, no console errors: rivers-of-europe-book-from-bundle.h5p · preview, the strip reads "READY · Close this tab to end the preview. · 0.5 s".

Not verified

The extension's page inside a real VS Code, light and dark. The change there is a stylesheet link and two body rules.

Release

The player gets a new export, so a minor: 1.6.0. The verifier's preview needs a player that ships /page.css, so its dependency moves to that version when it is published; the extension bundles its own copy of the player's files. The extension's CHANGELOG is written at its bump, as before.


Summary by cubic

Ships the demo's page design as a shared stylesheet exported by the player, so the verifier's preview and the extension's page look like the demo and none of them can drift from it.

Closes #170.

  • Adds @missing-elements/h5p-offline-player/page.css and dist/mark.svg, built from packages/player/page/ and serving the demo's tokens, bar, buttons, status strip, player box, cards and messages.
  • The demo imports the package path by alias to the source, the verifier's preview and the extension link the built file; the demo's own sheet keeps only its site-specific rules.
  • The verifier's preview is now the demo's page: sticky bar with the mark, the file name as the page's only h1, Download as a button, theme switch with the pinned choice shared across tabs, and a status strip whose live region is the message alone, not the timer.
  • The extension's page takes VS Code's theme, light or dark, in its address and as a message when it changes, rather than following the system's; its bar above keeps VS Code's own colours.
  • The player gets a new export, so the next release is a minor (1.6.0); the verifier's dependency moves to that version when published.