Skip to content

Commit 2b23cdb

Browse files
authored
Gallery 0.4.0 (sc-9559): text option and deep links (#292)
* Gallery 0.4.0 (sc-9559): the text option for every interface word, and deepLinks for the tab, screen and values in the URL hash; both off until set - text: label, open, previous, next, close, back, forward, credit, and; {title} and {link} placeholders; the default title is text.label - deepLinks: data-vg-links; #<id>[/<tab>][/<screen>][?dim=value&…], written with replaceState after the reader changes something, read on load and hashchange, unknown parts ignored - SPEC, fixtures (text, strip-themes) and option errors; JS reference, Ruby, Python, Rust ports; docs and changelog * Gallery 0.4.0: the Rails example's lockfiles keep base64 at 0.3.0 (the version bump's replace caught it) * Hugo gallery: the text and deepLinks options, and 0.4.0 (sc-9559) The Go-template port of #292's contract changes: text (every word the gallery writes, TEXT(key) with {title} and {link}, the alt joiner) and deepLinks (data-vg-links), in the model, the markup, the option checks and the option names; version.html and the pins at 0.4.0.
1 parent f35b2f1 commit 2b23cdb

101 files changed

Lines changed: 1160 additions & 185 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎clients/gallery/astro/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Gallery from "visualci-astro-gallery";
2020
```
2121

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

‎clients/gallery/astro/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "visualci-astro-gallery",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "An Astro component for a screenshots page from VisualCI's public gallery: rendered at build time, hydrated by visualci-gallery.",
55
"keywords": [
66
"astro-component",

‎clients/gallery/astro/src/Gallery.astro‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// <Gallery manifest="https://app.visualci.com/g/acme/web.json" screens={{ overview: { title: "Overview" } }} />
77
//
88
// The props are the library's options (title, headingLevel, id, screens, order, groups, groupOrder, credit, layout,
9-
// themeSwitch, seeAll, preload) and load()'s (manifest, timeout, attempts, fetch). The default stylesheet comes with it; set the
9+
// themeSwitch, seeAll, preload, deepLinks, text) and load()'s (manifest, timeout, attempts, fetch). The default stylesheet comes with it; set the
1010
// --vg-* variables on .vg (or an ancestor) to give it the site's look.
1111
import { load, render, type LoadOptions } from "visualci-gallery/render";
1212
import "visualci-gallery/gallery.css";

‎clients/gallery/contract/SPEC.md‎

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ change, and regenerate the fixtures (`UPDATE_GOLDEN=1 pnpm test` in `../js`), re
2020

2121
| Option | Default | Meaning |
2222
| --- | --- | --- |
23-
| `title` | `"Screenshots"` | The gallery's heading and accessible name. `null`: no heading, the name stays "Screenshots". |
23+
| `title` | `text.label` | The gallery's heading and accessible name. `null`: no heading, the name stays `text.label`. |
2424
| `headingLevel` | `2` | The heading's level, clamped to 1–4 (truncated to an integer). |
2525
| `id` | `"vg"` | The prefix of every id in the markup. |
2626
| `dimensions` | `[]` | The ways a screen's shots differ, over the two built in (Dimensions, below): `[{key, label?, missing?, values?: [{key, label?, below?}]}]`. |
@@ -33,11 +33,32 @@ change, and regenerate the fixtures (`UPDATE_GOLDEN=1 pnpm test` in `../js`), re
3333
| `themeSwitch` | `true` | The theme's switch. Always false for the strip. Without it the gallery follows the page. |
3434
| `seeAll` | `null` | `{href, text?}`: a link under the gallery; `text` defaults to "See all screenshots". |
3535
| `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). |
36+
| `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. |
37+
| `text` | `{}` | The gallery's own words, for another language or another tone (Text, below): any of its keys, each a string. |
3638

3739
An option set to `null` is the same as leaving it out, except `title`, where `null` means no heading. An empty
3840
string is kept as it is. Each language takes them in its own spelling (`heading_level`, `group_order`, `theme_switch`, `see_all` in Ruby,
3941
Python and Rust) with the same meaning.
4042

43+
### Text
44+
45+
Every word the gallery itself writes, visible or for screen readers, comes from `text`. A key that's absent or null
46+
keeps its default:
47+
48+
| key | default | where |
49+
| --- | --- | --- |
50+
| `label` | `Screenshots` | The default `title`, and the gallery's accessible name when `title` is null. |
51+
| `open` | `{title}: view full size` | A card's link; `{title}` is the screen's title. |
52+
| `previous` | `Previous screen` | The full-size view's previous button. |
53+
| `next` | `Next screen` | Its next button. |
54+
| `close` | `Close` | Its close button. |
55+
| `back` | `Scroll back` | The strip's button that scrolls back. |
56+
| `forward` | `Scroll forward` | The strip's button that scrolls forward. |
57+
| `credit` | `Screenshots by {link}` | The credit line, when `credit` is true; `{link}` is the link to VisualCI. |
58+
| `and` | ` and ` | Between the values an image stands for in its alt text (`Light and Dark`). |
59+
60+
The words of the dimensions' switches are their labels (`dimensions`); the see-all link's is `seeAll.text`.
61+
4162
### Dimensions
4263

4364
A dimension is one way a screen's shots differ: its theme, its size, or one a site adds (a language, a plan). Each has
@@ -96,10 +117,11 @@ word for word, in every language. An invalid option's message names it in the co
96117
`fit` (null, `"cover"` or `"contain"`); `order` and `groupOrder` arrays of strings; `credit` and
97118
`themeSwitch` booleans; `layout` `"grid"` or `"strip"`; `seeAll` an object with a string `href` and a `text` that's
98119
absent, null or a string; `preload` a boolean or an object with only `fold`, `count` and `bytes` (null or a whole
99-
number from 0 to 10^12) and `parallel` (null or a whole number from 1 to 8). `seeAll.href` is an absolute URL as above, or a relative one: not empty, no character from
120+
number from 0 to 10^12) and `parallel` (null or a whole number from 1 to 8); `deepLinks` a boolean; `text` an object
121+
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
100122
U+0000 to U+0020 or U+007F, and not starting with a scheme (`^[A-Za-z][A-Za-z0-9+.-]*:`).
101123
- The manifest is checked first, then the options in this order, and the first problem is the error: `headingLevel`,
102-
`title`, `id`, `dimensions`, `screens`, `groups`, `order`, `groupOrder`, `credit`, `themeSwitch`, `layout`, `seeAll`, `preload`.
124+
`title`, `id`, `dimensions`, `screens`, `groups`, `order`, `groupOrder`, `credit`, `themeSwitch`, `layout`, `seeAll`, `preload`, `deepLinks`, `text`.
103125
- Other fields, in the manifest or the options, are ignored.
104126

105127
## Reading the manifest
@@ -120,7 +142,8 @@ order below, a newline at the end). Renderers in other languages compare it as d
120142

121143
```
122144
{layout, themeSwitch, seeAll: {href, text} | null, title: string | null, label, headingLevel, id, credit,
123-
preload: null | "off" | {fold, count, bytes, parallel},
145+
preload: null | "off" | {fold, count, bytes, parallel}, deepLinks,
146+
text: {label, open, previous, next, close, back, forward, credit, and},
124147
dimensions: [{key, label, missing, values: [{key, label, below | null, shape: "landscape" | "portrait" | null}]}],
125148
groups: [{name, title, slug, fit, values: {"<dimension key>": ["<value key>", …], …}, screens: [{key, title,
126149
caption | null, variants: [{values: {"<dimension key>": "<value key>", …}, url, url2x | null, width, height,
@@ -207,9 +230,10 @@ For each manifest group, in order:
207230

208231
### The rest
209232

210-
`title` is the option (`"Screenshots"` when absent), `label` is the title or "Screenshots" when it's null,
233+
`text` has every key of Text, filled in from the defaults. `title` is the option (`text.label` when absent), `label`
234+
is the title or `text.label` when it's null,
211235
`layout`, `themeSwitch` (`layout == "grid"` and the option isn't false), `seeAll` (`null`, or `{href, text}` with
212-
the default text), `headingLevel`, `id`, `credit` as above. `preload`: `null` when the option is absent, null or
236+
the default text), `headingLevel`, `id`, `credit`, `deepLinks` as above. `preload`: `null` when the option is absent, null or
213237
true; `"off"` when false; else the caps with every key filled in from the defaults.
214238

215239
## The markup
@@ -222,6 +246,9 @@ true; `"off"` when false; else the caps with every key filled in from the defaul
222246
integers.
223247
- The output is lines joined with `\n`, ending with `\n`. No indentation. Each line below is one line of output; a
224248
line in brackets is present only when its condition holds.
249+
- `TEXT(key)` is `text`'s value for that key, escaped, with `{title}` (in `open`) or `{link}` (in `credit`) replaced,
250+
everywhere it appears, by what it stands for: the escaped screen title, or
251+
`<a href="https://visualci.com">VisualCI</a>`. Other braces are kept as they are.
225252
- `h(n)` is the heading element `h<min(headingLevel + n, 6)>`. `B` is 0 when `title` is null, else 1.
226253
- The starting choice `C`, one value per dimension: for the grid, the first group's first value of each; for the
227254
strip, the first value of each dimension, in its order, that any group has. A group starts at `C(g)`: `C`'s value
@@ -237,11 +264,11 @@ true; `"off"` when false; else the caps with every key filled in from the defaul
237264
size values whose shape is `portrait`, joined with a space.
238265

239266
```
240-
<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]>
267+
<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]>
241268
[<h(0) class="vg-title">{title}</h(0)> when title isn't null]
242269
… the grid's or the strip's lines …
243270
[<p class="vg-see-all"><a href="{seeAll.href}">{seeAll.text}</a></p> when seeAll]
244-
[<p class="vg-credit">Screenshots by <a href="https://visualci.com">VisualCI</a></p> when credit]
271+
[<p class="vg-credit">{TEXT(credit)}</p> when credit]
245272
<dialog class="vg-box" aria-labelledby="{id}-box-title">
246273
<div class="vg-box-bar"><h(B) class="vg-box-title" id="{id}-box-title"></h(B)><div class="vg-controls">{BOX SWITCHES}{STEP(-1)}{STEP(1)}</div>{CLOSE}</div>
247274
<div class="vg-box-view"></div>
@@ -265,9 +292,9 @@ with these fragments (no newlines inside them):
265292
theme when `themeSwitch` is false.
266293
- `BOX SWITCHES`: for the grid, `SWITCHES` of every value any group has, in each dimension's order, at `box`, current
267294
each dimension's first of them; for the strip, nothing.
268-
- `STEP(-1)`: `<button type="button" class="vg-icon" data-vg-step="-1" aria-label="Previous screen">‹</button>`;
269-
`STEP(1)`: the same with `1`, `Next screen` and `›`; `CLOSE`:
270-
`<button type="button" class="vg-icon" data-vg-close aria-label="Close">×</button>`.
295+
- `STEP(-1)`: `<button type="button" class="vg-icon" data-vg-step="-1" aria-label="{TEXT(previous)}">‹</button>`;
296+
`STEP(1)`: the same with `1`, `{TEXT(next)}` and `›`; `CLOSE`:
297+
`<button type="button" class="vg-icon" data-vg-close aria-label="{TEXT(close)}">×</button>`.
271298

272299
### The grid
273300

@@ -296,11 +323,11 @@ Every screen of every group, in order, that isn't off for `C`, in one row:
296323

297324
```
298325
<div class="vg-panel" id="{id}-strip" data-vg-shape="{the shape of C's size}">
299-
<div class="vg-strip"><button type="button" class="vg-icon vg-strip-prev" data-vg-scroll="-1" aria-label="Scroll back">‹</button>
326+
<div class="vg-strip"><button type="button" class="vg-icon vg-strip-prev" data-vg-scroll="-1" aria-label="{TEXT(back)}">‹</button>
300327
<ul class="vg-grid vg-track">
301328
{CARD(screen, C, the variants whose values are the card's combination for C but for the theme, h(B), without caption)} (one line per screen)
302329
</ul>
303-
<button type="button" class="vg-icon vg-strip-next" data-vg-scroll="1" aria-label="Scroll forward">›</button></div>
330+
<button type="button" class="vg-icon vg-strip-next" data-vg-scroll="1" aria-label="{TEXT(forward)}">›</button></div>
304331
</div>
305332
```
306333

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

312339
```
313-
<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="{title}: view full size">{IMAGES}</a><heading class="vg-card-title">{title}</heading>[<p class="vg-caption">{caption}</p> when wanted and not null]</li>
340+
<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>
314341
```
315342

316343
An image, for its variants (`v` the first of them):
@@ -326,7 +353,7 @@ An image, for its variants (`v` the first of them):
326353
`light dark` (the CSS follows the page, Behaviour). Otherwise the card's image for `choice` gets the empty string.
327354
Other images have no `data-vg-shown`.
328355
- `ALT`: the screen's title, then for each dimension the group has two or more values of, `, ` and the labels of the
329-
image's values of it (in the dimension's order) joined with ` and ` (`Billing, Light and Dark, Desktop`).
356+
image's values of it (in the dimension's order) joined with `text.and` (`Billing, Light and Dark, Desktop`).
330357

331358
`width` and `height` stay the original's: a thumbnail has the same shape, and the full-size view and its fit rule use
332359
them. The card's link is the original.
@@ -367,6 +394,23 @@ them. The card's link is the original.
367394
checked again when its width changes.
368395
- An image that can't load is replaced by its alt text, in the same place.
369396

397+
### Deep links
398+
399+
With `data-vg-links` (the `deepLinks` option), the page's URL hash names what the gallery shows:
400+
`#{id}[/{tab slug}][/{screen key}][?{dimension key}={value key}&…]`, each part percent-encoded (a screen key keeps its
401+
`/`). The tab is there when the gallery has tabs; the screen while the full-size view is open; the values for every
402+
dimension the gallery has two or more values of, in the dimensions' order, except the theme when the gallery follows
403+
the page (`#vg/iphone/ios/approval?theme=dark&size=phone`).
404+
405+
- **Written** with `history.replaceState` (no new history entry, no `hashchange`) when the reader changes something:
406+
a tab, a switch, the full-size view opening, stepping or closing. Never on load, and never because the page's theme
407+
changed.
408+
- **Read** on load and on `hashchange`, when the hash's first part is the gallery's `id` (another gallery's, or a
409+
heading's, is left alone): its values are chosen, its tab is shown, and its screen opened in the full-size view
410+
(closed when the hash names none). A tab, screen, dimension or value the gallery doesn't have is ignored, as is
411+
a screen that's off for the choice. On load, a hash that names the gallery but no screen scrolls the gallery into
412+
view.
413+
370414
### Preloading
371415

372416
Unless the section has `data-vg-preload="off"` (or `hydrate(el, {preload: false})`), the gallery preloads the images a

‎clients/gallery/contract/fixtures/dimensions/model.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
"id": "vg",
99
"credit": false,
1010
"preload": null,
11+
"deepLinks": false,
12+
"text": {
13+
"label": "Screenshots",
14+
"open": "{title}: view full size",
15+
"previous": "Previous screen",
16+
"next": "Next screen",
17+
"close": "Close",
18+
"back": "Scroll back",
19+
"forward": "Scroll forward",
20+
"credit": "Screenshots by {link}",
21+
"and": " and "
22+
},
1123
"dimensions": [
1224
{
1325
"key": "theme",

‎clients/gallery/contract/fixtures/duplicates/model.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
"id": "vg",
99
"credit": false,
1010
"preload": null,
11+
"deepLinks": false,
12+
"text": {
13+
"label": "Screenshots",
14+
"open": "{title}: view full size",
15+
"previous": "Previous screen",
16+
"next": "Next screen",
17+
"close": "Close",
18+
"back": "Scroll back",
19+
"forward": "Scroll forward",
20+
"credit": "Screenshots by {link}",
21+
"and": " and "
22+
},
1123
"dimensions": [
1224
{
1325
"key": "theme",

‎clients/gallery/contract/fixtures/escaping/model.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
"id": "vg",
99
"credit": false,
1010
"preload": null,
11+
"deepLinks": false,
12+
"text": {
13+
"label": "Screenshots",
14+
"open": "{title}: view full size",
15+
"previous": "Previous screen",
16+
"next": "Next screen",
17+
"close": "Close",
18+
"back": "Scroll back",
19+
"forward": "Scroll forward",
20+
"credit": "Screenshots by {link}",
21+
"and": " and "
22+
},
1123
"dimensions": [
1224
{
1325
"key": "theme",

‎clients/gallery/contract/fixtures/fleetlayer/model.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
"id": "vg",
99
"credit": false,
1010
"preload": null,
11+
"deepLinks": false,
12+
"text": {
13+
"label": "Screenshots",
14+
"open": "{title}: view full size",
15+
"previous": "Previous screen",
16+
"next": "Next screen",
17+
"close": "Close",
18+
"back": "Scroll back",
19+
"forward": "Scroll forward",
20+
"credit": "Screenshots by {link}",
21+
"and": " and "
22+
},
1123
"dimensions": [
1224
{
1325
"key": "theme",

‎clients/gallery/contract/fixtures/group-order/model.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
"id": "vg",
99
"credit": false,
1010
"preload": null,
11+
"deepLinks": false,
12+
"text": {
13+
"label": "Screenshots",
14+
"open": "{title}: view full size",
15+
"previous": "Previous screen",
16+
"next": "Next screen",
17+
"close": "Close",
18+
"back": "Scroll back",
19+
"forward": "Scroll forward",
20+
"credit": "Screenshots by {link}",
21+
"and": " and "
22+
},
1123
"dimensions": [
1224
{
1325
"key": "theme",

‎clients/gallery/contract/fixtures/light-only/model.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
"id": "vg",
99
"credit": false,
1010
"preload": null,
11+
"deepLinks": false,
12+
"text": {
13+
"label": "Screenshots",
14+
"open": "{title}: view full size",
15+
"previous": "Previous screen",
16+
"next": "Next screen",
17+
"close": "Close",
18+
"back": "Scroll back",
19+
"forward": "Scroll forward",
20+
"credit": "Screenshots by {link}",
21+
"and": " and "
22+
},
1123
"dimensions": [
1224
{
1325
"key": "theme",

0 commit comments

Comments
 (0)