Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/gallery/astro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Gallery from "visualci-astro-gallery";
```

The props are `visualci-gallery`'s options (`title`, `headingLevel`, `id`, `screens`, `order`, `groups`,
`groupOrder`, `credit`, `layout`, `themeSwitch`, `seeAll`, `preload`, `deepLinks`, `text`) and `load()`'s (`manifest`, `timeout`, `attempts`,
`groupOrder`, `credit`, `layout`, `themeSwitch`, `seeAll`, `preload`, `deepLinks`, `text`, `search`, `zoom`, `newBadges`) and `load()`'s (`manifest`, `timeout`, `attempts`,
`fetch`). Give the gallery your site's look with the `--vg-*` CSS variables, set on `.vg` or any element around it.
They win over the component's defaults in any stylesheet order:

Expand Down
2 changes: 1 addition & 1 deletion clients/gallery/astro/src/Gallery.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// <Gallery manifest="https://app.visualci.com/g/acme/web.json" screens={{ overview: { title: "Overview" } }} />
//
// The props are the library's options (title, headingLevel, id, screens, order, groups, groupOrder, credit, layout,
// themeSwitch, seeAll, preload, deepLinks, text) and load()'s (manifest, timeout, attempts, fetch). The default stylesheet comes with it; set the
// themeSwitch, seeAll, preload, deepLinks, text, search, zoom, newBadges) and load()'s (manifest, timeout, attempts, fetch). The default stylesheet comes with it; set the
// --vg-* variables on .vg (or an ancestor) to give it the site's look.
import { load, render, type LoadOptions } from "visualci-gallery/render";
import "visualci-gallery/gallery.css";
Expand Down
63 changes: 55 additions & 8 deletions clients/gallery/contract/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ change, and regenerate the fixtures (`UPDATE_GOLDEN=1 pnpm test` in `../js`), re

1. **The manifest**, `https://app.visualci.com/g/<org>/<project>.json` (https://visualci.com/docs/gallery/):
`{project, groups: [{name, title?, items: [{name, platform, url, width, height, sha256, since, bytes?, thumb?}]}]}`.
Only `name`, `title`, `items`, and each item's `name`, `url`, `width`, `height`, `bytes` and `thumb` are read.
Only `name`, `title`, `items`, and each item's `name`, `url`, `width`, `height`, `bytes`, `thumb` and `since` are
read. `since` is when that picture was approved, an RFC 3339 time in UTC (it changes only when the image does);
one that isn't a string is ignored, never an error.
`bytes` is the image's size; `thumb` is a small copy for the cards, `{url, width, height, bytes?}` (VisualCI serves
a 640 px WebP of each published shot wider than that). Both are optional: a manifest without them shows the
originals in the cards and the preloader estimates sizes.
Expand All @@ -35,6 +37,9 @@ change, and regenerate the fixtures (`UPDATE_GOLDEN=1 pnpm test` in `../js`), re
| `preload` | `true` | Predictive preloading (Behaviour). `false` turns it off; `{fold?, count?, bytes?, parallel?}` sets its caps, the rest keeping their defaults (250, 500, 50000000, 4). |
| `deepLinks` | `false` | The URL's hash names the shown tab, the open screen and the chosen values, so a link opens them (Deep links). Off, the gallery never changes the page's URL. |
| `text` | `{}` | The gallery's own words, for another language or another tone (Text, below): any of its keys, each a string. |
| `search` | `40` | The grid's search box, which filters the cards by title and caption across tabs (Search). A number: shown once the gallery has that many screens (in every group); `true`, always; `false`, never. The strip never has one. |
| `zoom` | `true` | Zoom in the full-size view, by gestures and keys only (Zoom). `false` turns it off. |
| `newBadges` | `false` | A New badge on each screen whose picture changed in the last so many days (New badges): `true` for 30, or a whole number of days from 1 to 3650. |

An option set to `null` is the same as leaving it out, except `title`, where `null` means no heading. An empty
string is kept as it is. Each language takes them in its own spelling (`heading_level`, `group_order`, `theme_switch`, `see_all` in Ruby,
Expand All @@ -56,6 +61,9 @@ keeps its default:
| `forward` | `Scroll forward` | The strip's button that scrolls forward. |
| `credit` | `Screenshots by {link}` | The credit line, when `credit` is true; `{link}` is the link to VisualCI. |
| `and` | ` and ` | Between the values an image stands for in its alt text (`Light and Dark`). |
| `search` | `Search screens` | The search box's accessible name and placeholder. |
| `empty` | `No screens match` | What the grid says when no screen matches the search. |
| `new` | `New` | The New badge. |

The words of the dimensions' switches are their labels (`dimensions`); the see-all link's is `seeAll.text`.

Expand Down Expand Up @@ -118,10 +126,12 @@ word for word, in every language. An invalid option's message names it in the co
`themeSwitch` booleans; `layout` `"grid"` or `"strip"`; `seeAll` an object with a string `href` and a `text` that's
absent, null or a string; `preload` a boolean or an object with only `fold`, `count` and `bytes` (null or a whole
number from 0 to 10^12) and `parallel` (null or a whole number from 1 to 8); `deepLinks` a boolean; `text` an object
with only the keys of Text, each null or a string. `seeAll.href` is an absolute URL as above, or a relative one: not empty, no character from
with only the keys of Text, each null or a string; `search` a boolean or a whole number from 0 to 1000000; `zoom` a
boolean; `newBadges` a boolean or a whole number from 1 to 3650. `seeAll.href` is an absolute URL as above, or a relative one: not empty, no character from
U+0000 to U+0020 or U+007F, and not starting with a scheme (`^[A-Za-z][A-Za-z0-9+.-]*:`).
- The manifest is checked first, then the options in this order, and the first problem is the error: `headingLevel`,
`title`, `id`, `dimensions`, `screens`, `groups`, `order`, `groupOrder`, `credit`, `themeSwitch`, `layout`, `seeAll`, `preload`, `deepLinks`, `text`.
`title`, `id`, `dimensions`, `screens`, `groups`, `order`, `groupOrder`, `credit`, `themeSwitch`, `layout`, `seeAll`, `preload`, `deepLinks`, `text`, `search`,
`zoom`, `newBadges`.
- Other fields, in the manifest or the options, are ignored.

## Reading the manifest
Expand All @@ -143,10 +153,11 @@ order below, a newline at the end). Renderers in other languages compare it as d
```
{layout, themeSwitch, seeAll: {href, text} | null, title: string | null, label, headingLevel, id, credit,
preload: null | "off" | {fold, count, bytes, parallel}, deepLinks,
text: {label, open, previous, next, close, back, forward, credit, and},
text: {label, open, previous, next, close, back, forward, credit, and, search, empty, new},
search: boolean, zoom: boolean, newBadges: number | null,
dimensions: [{key, label, missing, values: [{key, label, below | null, shape: "landscape" | "portrait" | null}]}],
groups: [{name, title, slug, fit, values: {"<dimension key>": ["<value key>", …], …}, screens: [{key, title,
caption | null, variants: [{values: {"<dimension key>": "<value key>", …}, url, url2x | null, width, height,
caption | null, since | null, variants: [{values: {"<dimension key>": "<value key>", …}, url, url2x | null, width, height,
bytes | null, bytes2x | null, thumb: {url, width, height, bytes | null} | null}]}]}]}
```

Expand Down Expand Up @@ -214,6 +225,9 @@ For each manifest group, in order:
character (`screenshots/app/billing/free` among `screenshots/app/…` keys: "Billing, free"). Upper-casing uses the
language's Unicode-aware upper case of that one character.
- **Caption:** `options.screens[key].caption`, else `null`.
- **Since:** the greatest `since`, comparing strings by code point, of the manifest items whose name gives the
screen's key (2x copies included); items whose `since` is absent, not a string or empty don't count. `null` when
none has one.
- **Order:** keys in `options.order` first, in that order; then the rest, by key, comparing strings by code point.

### Groups
Expand All @@ -234,7 +248,10 @@ For each manifest group, in order:
is the title or `text.label` when it's null,
`layout`, `themeSwitch` (`layout == "grid"` and the option isn't false), `seeAll` (`null`, or `{href, text}` with
the default text), `headingLevel`, `id`, `credit`, `deepLinks` as above. `preload`: `null` when the option is absent, null or
true; `"off"` when false; else the caps with every key filled in from the defaults.
true; `"off"` when false; else the caps with every key filled in from the defaults. `search` is true when the layout
is `grid` and the option is true, or a number no greater than the number of screens in every group (absent or null:
40); else false. `zoom` is the option, true when absent or null. `newBadges` is null when the option is absent, null
or false; 30 when true; else the number.

## The markup

Expand Down Expand Up @@ -264,8 +281,9 @@ true; `"off"` when false; else the caps with every key filled in from the defaul
size values whose shape is `portrait`, joined with a space.

```
<section class="vg" data-vg data-vg-layout="{layout}" aria-label="{label}" data-vg-dims="{DIMS}"[ data-vg-portrait="{PORTRAIT}" when not empty][ data-vg-theme-source="page" when !themeSwitch][ data-vg-preload="off" when preload is "off"][ data-vg-preload="fold={fold} count={count} bytes={bytes} parallel={parallel}" when preload has caps][ data-vg-links when deepLinks]>
<section class="vg" data-vg data-vg-layout="{layout}" aria-label="{label}" data-vg-dims="{DIMS}"[ data-vg-portrait="{PORTRAIT}" when not empty][ data-vg-theme-source="page" when !themeSwitch][ data-vg-preload="off" when preload is "off"][ data-vg-preload="fold={fold} count={count} bytes={bytes} parallel={parallel}" when preload has caps][ data-vg-links when deepLinks][ data-vg-zoom="off" when !zoom][ data-vg-new="{newBadges}" when newBadges]>
[<h(0) class="vg-title">{title}</h(0)> when title isn't null]
[<div class="vg-search"><input type="search" class="vg-search-input" id="{id}-search" aria-label="{TEXT(search)}" placeholder="{TEXT(search)}" autocomplete="off"></div> when search]
… the grid's or the strip's lines …
[<p class="vg-see-all"><a href="{seeAll.href}">{seeAll.text}</a></p> when seeAll]
[<p class="vg-credit">{TEXT(credit)}</p> when credit]
Expand Down Expand Up @@ -317,6 +335,12 @@ Then for each group, `i` its index:
</div>
```

After the last panel, when `search`:

```
<p class="vg-empty" role="status" hidden>{TEXT(empty)}</p>
```

### The strip

Every screen of every group, in order, that isn't off for `C`, in one row:
Expand All @@ -337,7 +361,7 @@ Every screen of every group, in order, that isn't off for `C`, in one row:
`url`, `url2x` and thumb `url`, in the order of each set's first variant; `first` is the card's image for `choice`.

```
<li class="vg-card" data-vg-screen="{key}"[ data-vg-off when off for choice][ data-vg-fit="contain" when the group's fit is contain]><a class="vg-thumb" href="{first's url}" data-vg-open aria-label="{TEXT(open)}">{IMAGES}</a><heading class="vg-card-title">{title}</heading>[<p class="vg-caption">{caption}</p> when wanted and not null]</li>
<li class="vg-card" data-vg-screen="{key}"[ data-vg-off when off for choice][ data-vg-fit="contain" when the group's fit is contain][ data-vg-since="{since}" when newBadges and since]><a class="vg-thumb" href="{first's url}" data-vg-open aria-label="{TEXT(open)}">{IMAGES}</a>[<span class="vg-new" hidden>{TEXT(new)}</span> when newBadges and since]<heading class="vg-card-title">{title}</heading>[<p class="vg-caption">{caption}</p> when wanted and not null]</li>
```

An image, for its variants (`v` the first of them):
Expand Down Expand Up @@ -394,6 +418,29 @@ them. The card's link is the original.
checked again when its width changes.
- An image that can't load is replaced by its alt text, in the same place.

### Search

With a `.vg-search-input` (the `search` option), every word typed (split on white space) must appear in a card's title
or caption, ignoring case and accents (Unicode NFD with the combining marks dropped). A card that doesn't match gets
`data-vg-unmatched` and isn't shown, a tab none of whose shown cards match is hidden, and when the shown tab is hidden
the first tab with a match is shown. When no tab has a match, `.vg-empty` shows. Previous and next step only through
the cards that match. An empty box shows everything again; the switches keep filtering what they did.

### Zoom

Unless the section has `data-vg-zoom="off"`, the full-size view's image zooms from 1 to 8 times, with no buttons: the
wheel with ctrl or cmd held (a trackpad's pinch), two fingers on a touch screen, a double-click on the image (2 times,
or back to 1), and `+` (or `=`), `-` and `0` while the view has focus. The point under the pointer stays where it
is. The image grows in the layout and the view scrolls, so a finger or the wheel pans it, and a mouse drags it while
zoomed (the view gets `data-vg-zoomed`). Zoom is instant, so there's no motion to reduce. Another screen, or closing
the view, starts at 1 again.

### New badges

With `data-vg-new="{days}"`, each card's `.vg-new` badge shows when its `data-vg-since` is in the past and less than
that many days ago, by the reader's clock. It's decided in the browser, so a page built long ago never calls an old
screen new. `since` changes whenever a screen's picture does, so a restyle that changes every screen marks them all.

### Deep links

With `data-vg-links` (the `deepLinks` option), the page's URL hash names what the gallery shows:
Expand Down
12 changes: 11 additions & 1 deletion clients/gallery/contract/fixtures/dimensions/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
"back": "Scroll back",
"forward": "Scroll forward",
"credit": "Screenshots by {link}",
"and": " and "
"and": " and ",
"search": "Search screens",
"empty": "No screens match",
"new": "New"
},
"search": false,
"zoom": true,
"newBadges": null,
"dimensions": [
{
"key": "theme",
Expand Down Expand Up @@ -132,6 +138,7 @@
"key": "pricing",
"title": "Pricing",
"caption": null,
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down Expand Up @@ -307,6 +314,7 @@
"key": "home",
"title": "Home",
"caption": null,
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down Expand Up @@ -818,6 +826,7 @@
"key": "settings",
"title": "Settings",
"caption": null,
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down Expand Up @@ -930,6 +939,7 @@
"key": "docs/start",
"title": "Start",
"caption": null,
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down
13 changes: 12 additions & 1 deletion clients/gallery/contract/fixtures/duplicates/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
"back": "Scroll back",
"forward": "Scroll forward",
"credit": "Screenshots by {link}",
"and": " and "
"and": " and ",
"search": "Search screens",
"empty": "No screens match",
"new": "New"
},
"search": false,
"zoom": true,
"newBadges": null,
"dimensions": [
{
"key": "theme",
Expand Down Expand Up @@ -80,6 +86,7 @@
"key": "a/b/home",
"title": "Home",
"caption": null,
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down Expand Up @@ -130,6 +137,7 @@
"key": "ios/home",
"title": "Home",
"caption": null,
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down Expand Up @@ -180,6 +188,7 @@
"key": "web2/x",
"title": "X",
"caption": null,
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down Expand Up @@ -230,6 +239,7 @@
"key": "x/١٤٤٠",
"title": "X, ١٤٤٠",
"caption": null,
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down Expand Up @@ -263,6 +273,7 @@
"key": "y",
"title": "Y",
"caption": "",
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down
11 changes: 10 additions & 1 deletion clients/gallery/contract/fixtures/escaping/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
"back": "Scroll back",
"forward": "Scroll forward",
"credit": "Screenshots by {link}",
"and": " and "
"and": " and ",
"search": "Search screens",
"empty": "No screens match",
"new": "New"
},
"search": false,
"zoom": true,
"newBadges": null,
"dimensions": [
{
"key": "theme",
Expand Down Expand Up @@ -80,6 +86,7 @@
"key": "q&a",
"title": "Q&a",
"caption": "Ask & answer <fast>",
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down Expand Up @@ -130,6 +137,7 @@
"key": "café",
"title": "Café",
"caption": null,
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down Expand Up @@ -180,6 +188,7 @@
"key": "x",
"title": "X",
"caption": null,
"since": "2026-12-01T09:00:00+00:00",
"variants": [
{
"values": {
Expand Down
Loading
Loading