You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2b23cdb
Browse filesBrowse the repository at this point in the historyBrowse files
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.
Copy file name to clipboardExpand all lines: clients/gallery/contract/SPEC.md
+59-15Lines changed: 59 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ change, and regenerate the fixtures (`UPDATE_GOLDEN=1 pnpm test` in `../js`), re
20
20
21
21
| Option | Default | Meaning |
22
22
| --- | --- | --- |
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`. |
24
24
|`headingLevel`|`2`| The heading's level, clamped to 1–4 (truncated to an integer). |
25
25
|`id`|`"vg"`| The prefix of every id in the markup. |
26
26
|`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
33
33
|`themeSwitch`|`true`| The theme's switch. Always false for the strip. Without it the gallery follows the page. |
34
34
|`seeAll`|`null`|`{href, text?}`: a link under the gallery; `text` defaults to "See all screenshots". |
35
35
|`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. |
36
38
37
39
An option set to `null` is the same as leaving it out, except `title`, where `null` means no heading. An empty
38
40
string is kept as it is. Each language takes them in its own spelling (`heading_level`, `group_order`, `theme_switch`, `see_all` in Ruby,
39
41
Python and Rust) with the same meaning.
40
42
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
+
41
62
### Dimensions
42
63
43
64
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
96
117
`fit` (null, `"cover"` or `"contain"`); `order` and `groupOrder` arrays of strings; `credit` and
97
118
`themeSwitch` booleans; `layout``"grid"` or `"strip"`; `seeAll` an object with a string `href` and a `text` that's
98
119
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
100
122
U+0000 to U+0020 or U+007F, and not starting with a scheme (`^[A-Za-z][A-Za-z0-9+.-]*:`).
101
123
- The manifest is checked first, then the options in this order, and the first problem is the error: `headingLevel`,
@@ -207,9 +230,10 @@ For each manifest group, in order:
207
230
208
231
### The rest
209
232
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,
211
235
`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
213
237
true; `"off"` when false; else the caps with every key filled in from the defaults.
214
238
215
239
## The markup
@@ -222,6 +246,9 @@ true; `"off"` when false; else the caps with every key filled in from the defaul
222
246
integers.
223
247
- The output is lines joined with `\n`, ending with `\n`. No indentation. Each line below is one line of output; a
224
248
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.
225
252
-`h(n)` is the heading element `h<min(headingLevel + n, 6)>`. `B` is 0 when `title` is null, else 1.
226
253
- The starting choice `C`, one value per dimension: for the grid, the first group's first value of each; for the
227
254
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
237
264
size values whose shape is `portrait`, joined with a space.
238
265
239
266
```
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]>
241
268
[<h(0) class="vg-title">{title}</h(0)> when title isn't null]
242
269
… the grid's or the strip's lines …
243
270
[<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]
@@ -310,7 +337,7 @@ Every screen of every group, in order, that isn't off for `C`, in one row:
310
337
`url`, `url2x` and thumb `url`, in the order of each set's first variant; `first` is the card's image for `choice`.
311
338
312
339
```
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>
314
341
```
315
342
316
343
An image, for its variants (`v` the first of them):
@@ -326,7 +353,7 @@ An image, for its variants (`v` the first of them):
326
353
`light dark` (the CSS follows the page, Behaviour). Otherwise the card's image for `choice` gets the empty string.
327
354
Other images have no `data-vg-shown`.
328
355
-`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`).
330
357
331
358
`width` and `height` stay the original's: a thumbnail has the same shape, and the full-size view and its fit rule use
332
359
them. The card's link is the original.
@@ -367,6 +394,23 @@ them. The card's link is the original.
367
394
checked again when its width changes.
368
395
- An image that can't load is replaced by its alt text, in the same place.
369
396
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
+
370
414
### Preloading
371
415
372
416
Unless the section has `data-vg-preload="off"` (or `hydrate(el, {preload: false})`), the gallery preloads the images a
0 commit comments