Repository navigation
Gallery: the HTML contract and the browser library visualci-gallery (sc-9297) - #189
Merged
Merged
Conversation
VisualCIdocspring/visualci · build #655 · 20 added, 486 unchanged · approved by visualci coordinator agent (MCP) for Nathan Broadbent
This PR vs base: 28 changed, 72 added since #501, across 7 builds
docspring/visualci · journeys · build #653 · 50 unchanged · no changes This PR vs base: 2 changed, 8 added since #489, across 8 builds Updated as builds change. Agents can review with VisualCI's MCP tools. |
ndbroadbent
force-pushed
the
sc-9297-gallery-js
branch
2 times, most recently
from
December 4, 2026 09:10
bf71013 to
11adc64
Compare
…den fixtures) and the browser library @visualci/gallery (sc-9297) How a public gallery manifest becomes a screenshots page, written down so every renderer emits the same markup: names pair into screens as <screen>-<light|dark>[-<width>][-2x] or <screen>/<width>-<light|dark>[-2x]; under 768 wide (or a portrait image with no width) is a phone; an image wider than its name's width is shown at that width; titles default from the key without the group's shared folders. Golden model.json and gallery.html per fixture, and manifests every renderer must refuse. clients/gallery/js: vanilla TS, no dependencies. mount() fetches and renders into an empty element, hydrate() brings server-rendered markup to life, load() + render() render at build time and throw when the manifest can't be read or shows nothing (no 'updating' fallback: a site's build fails). Grid (tabs per group, theme and size switches) or strip (one row with scroll-snap, for a homepage band) layouts; a native <dialog> full-size view with previous/next and arrow keys; cards are links to their image, so no-JS and pre-<dialog> browsers still work; themeSwitch: false follows <html data-theme>; gallery.css styled through --vg-* variables, no :has(); dist/gallery.iife.js is one ES5 file for sites without a bundler. CI's clients job type-checks, builds and tests it; visual-capture screenshots it.
- The full-size view shows the image at its own size (it took the thumbnail's rendered width); the screenshot script now fails when it doesn't. - Validation in the contract and the library: the manifest's shape (names, items, integer sizes), http(s) item URLs with no control characters, and every option's type (null means absent; an unknown layout is an error); seeAll's href absolute or relative, never another scheme. errors/ and new option-errors/ fixtures. - Groups with the same name keep the manifest's order; default titles ignore screens dropped for having only a 2x copy; SPEC's patterns are whole-string, ASCII digits and any-character, so Python, Ruby and Rust match the same. - The view offers only the sizes the open screen has; opening a screen by key shows a size it has; stepping from a screen outside the list goes to the first or last. - Every attribute is data-vg-* (the gallery's theme and size, the buttons, the images), so a site's [data-theme] rules can't reach it. Alt text names the theme an image really is. - The strip's buttons sit inside it (no sideways page scroll at 390 px), follow its width (ResizeObserver), and long titles wrap; the overflow check runs with no page margin. The no-JS theme rule uses Level 3 media query syntax. - load() works without AbortSignal.timeout (Safari 15); mount() again destroys the gallery it replaces. - A duplicates fixture; tests for the image fallback, destroy, remounting and the view's sizes.
…elongs to another project; names in sc-9327)
One theme's image never stands in for the other's: the model refuses a screen with a light shot at a size and no dark one (or the reverse), naming the screen, group, size and missing theme. A shot whose name gives no theme still stands for both. Fixtures gain the missing shots; errors/one-theme.json is the new golden refusal.
groups[name].size sets the size of a group's shots whose names give no width (a Mac app's portrait window is still a desktop shot); groups[name].fit "contain" shows the group's images whole and centred in their cards (data-vg-fit="contain", --vg-contain-padding and --vg-contain-shadow). fleetlayer.ai's Mac approver tab needs both to move to the shared gallery without a visible change.
…nknown keys Every errors/ and option-errors/ file has a .message beside it that each renderer must match word for word; an invalid option's message names the option without echoing its value. groups entries refuse an unknown key even when its value is null, and the spec fixes the order the one-theme rule checks in (errors/one-theme-order.json).
ndbroadbent
force-pushed
the
sc-9297-gallery-js
branch
from
December 4, 2026 11:33
11adc64 to
9c8faf8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Story: sc-9297 (epic sc-9295).
This PR adds one screenshots page, built from a VisualCI public gallery manifest, that every site can use. It holds the shared contract and the reference renderer. The Astro component, Ruby gem, Python package and Rust crate come in later PRs and are tested against the same fixtures.
The contract (
clients/gallery/contract)SPEC.mdcovers:<screen>-<light|dark>[-<width>][-2x], as fleetlayer.ai names them, or<screen>/<width>-<light|dark>[-2x], as visualci.com does;fixtures/*/{manifest,options}.jsongive the goldenmodel.jsonandgallery.html.errors/*.jsonare manifests every renderer must refuse.The library (
clients/gallery/js,visualci-galleryon npm, not yet published: names and the go-ahead are in sc-9327)mount(el, {manifest})renders into an empty element.hydrate(el)brings markup a server rendered to life.load()andrender()render at build time; they're also exported asvisualci-gallery/render, which needs no DOM.<dialog>. It has previous and next buttons, arrow keys, Escape and a backdrop click to close, returns focus to the card on close, and uses the-2xcopy as a 2x source when there is one.<dialog>.themeSwitch: falsemakes the gallery follow<html data-theme>.:has(), and the gallery respects reduced motion.gallery.cssuses--vg-*variables, so each site keeps its own look.dist/gallery.iife.jsis one ES5 file, checked with acorn, for sites without a bundler (DocSpring's Sprockets pages).Tests and screenshots
clientsjob runs the type check, the build and the tests.scripts/screenshots/gallery.mjs, run byvisual.sh capture, screenshots the golden markup with made-up images:screenshots/gallery/**in this PR's VisualCI build. They aren't published to the public gallery.