@uvalib/web-components 1.11.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +192 -54
  3. package/dist/base.css +56 -2
  4. package/dist/components/uvalib-audio/UvalibAudio.d.ts +186 -0
  5. package/dist/components/uvalib-audio/UvalibAudio.js +1154 -0
  6. package/dist/components/uvalib-audio/UvalibAudio.js.map +1 -0
  7. package/dist/components/uvalib-audio/uvalib-audio.d.ts +1 -0
  8. package/dist/components/uvalib-audio/uvalib-audio.js +4 -0
  9. package/dist/components/uvalib-audio/uvalib-audio.js.map +1 -0
  10. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +25 -5
  11. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +62 -9
  12. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  13. package/dist/custom-elements.json +8486 -7187
  14. package/dist/edition-epub.css +511 -0
  15. package/dist/edition-print.css +51 -0
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +1 -0
  18. package/dist/index.js.map +1 -1
  19. package/dist/styles/base.js +55 -1
  20. package/dist/styles/base.js.map +1 -1
  21. package/dist/styles/edition.d.ts +6 -0
  22. package/dist/styles/edition.js +20 -0
  23. package/dist/styles/edition.js.map +1 -1
  24. package/dist-cdn/base.css +56 -2
  25. package/dist-cdn/chunks/{base-DtkA4Pgg.js → base-D_oPO5cX.js} +56 -2
  26. package/dist-cdn/chunks/{base-DtkA4Pgg.js.map → base-D_oPO5cX.js.map} +1 -1
  27. package/dist-cdn/custom-elements.json +8486 -7187
  28. package/dist-cdn/edition-epub.css +511 -0
  29. package/dist-cdn/edition-print.css +51 -0
  30. package/dist-cdn/manifest.json +6 -3
  31. package/dist-cdn/site-page.js +1 -1
  32. package/dist-cdn/site-style.js +1 -1
  33. package/dist-cdn/skills/uvalib-web-components/SKILL.md +35 -4
  34. package/dist-cdn/skills/uvalib-web-components/reference/components.md +53 -1
  35. package/dist-cdn/uvalib-audio.js +747 -0
  36. package/dist-cdn/uvalib-audio.js.map +1 -0
  37. package/dist-cdn/uvalib-pagefind-search.js +70 -44
  38. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  39. package/package.json +7 -1
  40. package/skills/uvalib-web-components/SKILL.md +35 -4
  41. package/skills/uvalib-web-components/reference/components.md +53 -1
@@ -1,11 +1,13 @@
1
1
  ---
2
2
  name: uvalib-web-components
3
+ description: Use when building or editing UVA Library web pages or sites with @uvalib/web-components: page chrome (<site-page>, <site-header>, <site-main-nav>, <site-footer>, <site-alerts>, <site-analytics>/<uvalib-analytics>, <site-style>), and other uvalib-* components (breadcrumbs, cards, pager, tabs, contents, metadata, citation, chips, tags, results count, filter, filter drawer, dialog, date range, date histogram, combobox, list filter, map (Leaflet), lightbox, photo grid, image regions, back to top, audio by chapter, Pagefind search, edition.css for TEI texts and EPUB/PDF), the library hours, events and bento-box elements (e.g. <uvalib-card>, <library-weekly-hours>), base.css classes (incl. tables, sidebar layout), or script/link URLs on unpkg.internal.lib.virginia.edu (incl. old /web-components/latest/ or cdn-v URLs). Covers CDN vs npm, version pinning, shadow vs light DOM, theming with --uva-* tokens, WCAG 2.2 AA accessibility testing, requesting components via GitHub issues, and a verification checklist.
4
+ ||||||| /private/tmp/claude-505/-Users-dhc4z-workspace-reusable-web-library/ac44f07e-107d-46b0-9a3a-fad028810779/scratchpad/r1
3
5
  description: Use when building or editing UVA Library web pages or sites with @uvalib/web-components: page chrome (<site-page>, <site-header>, <site-main-nav>, <site-footer>, <site-alerts>, <site-analytics>/<uvalib-analytics>, <site-style>), and other uvalib-* components (breadcrumbs, cards, pager, tabs, contents, metadata, citation, chips, tags, results count, filter, filter drawer, dialog, date range, date histogram, combobox, list filter, map (Leaflet), lightbox, photo grid, image regions, back to top, Pagefind search, edition.css for TEI texts), the library hours, events and bento-box elements (e.g. <uvalib-card>, <uvalib-chip-group>, <library-weekly-hours>), base.css classes (incl. tables, sidebar layout), or script/link URLs on unpkg.internal.lib.virginia.edu (incl. old /web-components/latest/ or cdn-v URLs). Covers CDN vs npm, version pinning, shadow vs light DOM, theming with --uva-* tokens, WCAG 2.2 AA accessibility testing, requesting components via GitHub issues, and a verification checklist.
4
6
  ---
5
7
 
6
8
  # UVA Library web components
7
9
 
8
- `@uvalib/web-components` provides the UVA Library page chrome as custom elements: `<site-page>` (skip link, header with the library main navigation, one `<main>`, footer), `<site-header>`, `<site-main-nav>` (the main navigation, rendered by the header), `<site-footer>`, `<site-analytics>` (Matomo; also registered as `<uvalib-analytics>`) and `<site-style>` (legacy compatibility), plus `<uvalib-breadcrumbs>` (the breadcrumb trail), `<uvalib-contents>` (sub-navigation or a table of contents), `<uvalib-metadata>` (a record's details, credit, rights and how to cite) and `<uvalib-citation>` (a citation in several formats with Copy citation), all in section 2, `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>` (cards and paging, section 5), `<uvalib-tabs>` (tabbed panels), `<uvalib-back-to-top>` (a back-to-top button for long pages) and `<site-alerts>` (the live library alerts, which `<site-page>` shows itself). It also ships search-page components, `<uvalib-filter>`, `<uvalib-date-range>` and `<uvalib-date-histogram>`, `<uvalib-chip-group>` for segmented controls, filter chips and suggestion chips, `<uvalib-combobox>`, a text field that suggests values as you type, `<uvalib-list-filter>`, a field that filters a long list on the page as you type, and `<uvalib-filter-drawer>`, the filters as a sidebar or a modal panel on phones, and `<uvalib-dialog>`, a modal dialog for search tips, Cite and short forms (section 6), and three library-hours elements for library.virginia.edu, `<site-hours-section>`, `<library-weekly-hours>` and `<library-hours-setup>`, `<events-section>` for upcoming library events and `<bento-box>` for the library's search results page (section 7), and `pagefind.css` with `<uvalib-pagefind-search>` for a static site's Pagefind search, `edition.css` for reading TEI texts converted to HTML, and `<uvalib-tag-list>`, `<uvalib-results-count>` and `base.css`'s badge, toolbar, empty-state and skeleton classes for results lists (section 6), and `<uvalib-lightbox>`, `<uvalib-photo-grid>` and `<uvalib-image-regions>` for images and `<uvalib-map>` for a map of places over the page's own Leaflet, with a linked list (section 8). Tag names are stable.
10
+ `@uvalib/web-components` provides the UVA Library page chrome as custom elements: `<site-page>` (skip link, header with the library main navigation, one `<main>`, footer), `<site-header>`, `<site-main-nav>` (the main navigation, rendered by the header), `<site-footer>`, `<site-analytics>` (Matomo; also registered as `<uvalib-analytics>`) and `<site-style>` (legacy compatibility), plus `<uvalib-breadcrumbs>` (the breadcrumb trail), `<uvalib-contents>` (sub-navigation or a table of contents), `<uvalib-metadata>` (a record's details, credit, rights and how to cite) and `<uvalib-citation>` (a citation in several formats with Copy citation), all in section 2, `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>` (cards and paging, section 5), `<uvalib-tabs>` (tabbed panels), `<uvalib-back-to-top>` (a back-to-top button for long pages) and `<site-alerts>` (the live library alerts, which `<site-page>` shows itself). It also ships search-page components, `<uvalib-filter>`, `<uvalib-date-range>` and `<uvalib-date-histogram>`, `<uvalib-chip-group>` for segmented controls, filter chips and suggestion chips, `<uvalib-combobox>`, a text field that suggests values as you type, `<uvalib-list-filter>`, a field that filters a long list on the page as you type, and `<uvalib-filter-drawer>`, the filters as a sidebar or a modal panel on phones, and `<uvalib-dialog>`, a modal dialog for search tips, Cite and short forms (section 6), and three library-hours elements for library.virginia.edu, `<site-hours-section>`, `<library-weekly-hours>` and `<library-hours-setup>`, `<events-section>` for upcoming library events and `<bento-box>` for the library's search results page (section 7), and `pagefind.css` with `<uvalib-pagefind-search>` for a static site's Pagefind search, `edition.css` for reading TEI texts converted to HTML, `<uvalib-audio>` for a recording played by chapter (an audiobook), and `<uvalib-tag-list>`, `<uvalib-results-count>` and `base.css`'s badge, toolbar, empty-state and skeleton classes for results lists (section 6), and `<uvalib-lightbox>`, `<uvalib-photo-grid>` and `<uvalib-image-regions>` for images and `<uvalib-map>` for a map of places over the page's own Leaflet, with a linked list (section 8). Tag names are stable.
9
11
 
10
12
  Authority rule: https://www.library.virginia.edu and the UVA Library design system are the source of truth for how the chrome looks and what it says. Do not re-create, copy or restyle the header, footer, logo or links by hand. Use the components, and change appearance only through the theming surface below.
11
13
 
@@ -31,7 +33,7 @@ Loading rules:
31
33
 
32
34
  - One script is enough for the page chrome: `site-page.js` also loads the header (with its main navigation) and footer. For Matomo, give `<site-page>` a `matomo-id` (it loads the analytics code itself), or add `site-analytics.js` and a `<site-analytics>` (or `uvalib-analytics.js` and `<uvalib-analytics>`) element; never both, and never alongside a hand-written Matomo snippet.
33
35
  - Also link `.../v1/base.css` in `<head>` (npm: `@uvalib/web-components/base.css`), unless the page sets `no-global-styles`. `<site-page>` installs the same base styles only after the first paint, so without the link the page shifts once (the default body margin goes away, and a heading's margin stops collapsing through the not-yet-defined `<site-page>`). The link also keeps `<site-page>` invisible until it is defined, with a two-second fallback.
34
- - npm: the define entries (`@uvalib/web-components/site-page.js`, `site-header.js`, `site-main-nav.js`, `site-footer.js`, `site-analytics.js`, `uvalib-analytics.js`, `site-style.js`, `uvalib-breadcrumbs.js`, `uvalib-card.js`, `uvalib-card-grid.js`, `uvalib-pager.js`, `uvalib-contents.js`, `uvalib-metadata.js`, `site-alerts.js`, `uvalib-filter.js`, `uvalib-date-range.js`, `uvalib-date-histogram.js`, `site-hours-section.js`, `library-weekly-hours.js`, `library-hours-setup.js`, `events-section.js`, `bento-box.js`, `uvalib-pagefind-search.js`, `uvalib-lightbox.js`, `uvalib-photo-grid.js`, `uvalib-tabs.js`, `uvalib-chip-group.js`, `uvalib-tag-list.js`, `uvalib-results-count.js`, `uvalib-combobox.js`, `uvalib-image-regions.js`, `uvalib-map.js`, `uvalib-filter-drawer.js`, `uvalib-back-to-top.js`, `uvalib-dialog.js`, `uvalib-citation.js`, `uvalib-list-filter.js`) register the element (`bento-box.js` also registers its four sections, `<catalog-section>`, `<articles-section>`, `<libguides-section>` and `<website-section>`). Importing the package root (`@uvalib/web-components`) gives the classes only and registers nothing. If you use the `SitePage` class directly, also import the header and footer define entries.
36
+ - npm: the define entries (`@uvalib/web-components/site-page.js`, `site-header.js`, `site-main-nav.js`, `site-footer.js`, `site-analytics.js`, `uvalib-analytics.js`, `site-style.js`, `uvalib-breadcrumbs.js`, `uvalib-card.js`, `uvalib-card-grid.js`, `uvalib-pager.js`, `uvalib-contents.js`, `uvalib-metadata.js`, `site-alerts.js`, `uvalib-filter.js`, `uvalib-date-range.js`, `uvalib-date-histogram.js`, `site-hours-section.js`, `library-weekly-hours.js`, `library-hours-setup.js`, `events-section.js`, `bento-box.js`, `uvalib-pagefind-search.js`, `uvalib-lightbox.js`, `uvalib-photo-grid.js`, `uvalib-tabs.js`, `uvalib-chip-group.js`, `uvalib-tag-list.js`, `uvalib-results-count.js`, `uvalib-combobox.js`, `uvalib-image-regions.js`, `uvalib-map.js`, `uvalib-filter-drawer.js`, `uvalib-back-to-top.js`, `uvalib-dialog.js`, `uvalib-citation.js`, `uvalib-list-filter.js`, `uvalib-audio.js`) register the element (`bento-box.js` also registers its four sections, `<catalog-section>`, `<articles-section>`, `<libguides-section>` and `<website-section>`). Importing the package root (`@uvalib/web-components`) gives the classes only and registers nothing. If you use the `SitePage` class directly, also import the header and footer define entries.
35
37
  - Do not load the same component from both the CDN and npm on one page.
36
38
 
37
39
  ## 2. Required page structure
@@ -228,7 +230,7 @@ import '@uvalib/web-components/tokens.css'; // optional: tokens for your own CSS
228
230
 
229
231
  Analytics: only when the site needs Matomo, set `<site-page matomo-id="N">`, or add `site-analytics.js` and a `<site-analytics matomoid="N">` (add `downloads="event"`, or `matomo-downloads="event"` on `<site-page>`, when file URLs carry ids: downloads are then counted as `['download', '<extension>']` events without URLs); see the analytics page in [reference/snippets.md](reference/snippets.md). `<uvalib-analytics>` (`uvalib-analytics.js`) is the same element under its original name, for existing markup. It listens on `document` for `uvalib-analytics-*` and `site-analytics-*` events (`event`, `search`, `pageview`, `content`) and queues them for Matomo, so events fired before Matomo loads are kept, and a page never counts twice. A single-page app whose router uses `pushState` or hashes can set `spa="auto"` to have each route change counted (after the new title is set, never twice for one URL); bare `spa` means the app sends its own `uvalib-analytics-pageview` events.
230
232
 
231
- The library's components already report what visitors do with them; do not add tracking for any of it: header utility and site links, logo, skip link, Menu and colour scheme; main-nav menu opens and links; footer links; breadcrumb and contents levels, the contents disclosure, Copy citation; card clicks (the card's place in its grid, or single); pager next, previous, page numbers and Load more; tab changes (the tab's label); alerts (impressions, dismiss, links, errors); event clicks; See all hours, week changes; filter facets, scopes and See more/less; date-range changes; histogram selections (`<from>–<to>` when both ends are ISO dates, otherwise `other`); bento searches, result and See all clicks, retries; lightbox opens, next, previous and full size (the name is `image N`, never the URL or the caption) and version comparisons (`compare`, the mode and the version's place, never its label); load errors; and tag-list clicks and Show all (`list N`, or the label with `track-label`, and the tag's place; never the tag text); and combobox choices and clears (the field's label and the suggestion's place; never the typed text or the suggestion); and list-filter queries and clears (how many items match; never the typed text); and image-region outline clicks (the list's label and the region's number; never a region's label); and map marker choices and zoom-button presses (the map's label and the place's position or the zoom level; never the place's name, coordinates or URL). `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing. The README's "Analytics" section has the full table.
233
+ The library's components already report what visitors do with them; do not add tracking for any of it: header utility and site links, logo, skip link, Menu and colour scheme; main-nav menu opens and links; footer links; breadcrumb and contents levels, the contents disclosure, Copy citation; card clicks (the card's place in its grid, or single); pager next, previous, page numbers and Load more; tab changes (the tab's label); alerts (impressions, dismiss, links, errors); event clicks; See all hours, week changes; filter facets, scopes and See more/less; date-range changes; histogram selections (`<from>–<to>` when both ends are ISO dates, otherwise `other`); bento searches, result and See all clicks, retries; lightbox opens, next, previous and full size (the name is `image N`, never the URL or the caption) and version comparisons (`compare`, the mode and the version's place, never its label); load errors; and tag-list clicks and Show all (`list N`, or the label with `track-label`, and the tag's place; never the tag text); and combobox choices and clears (the field's label and the suggestion's place; never the typed text or the suggestion); and list-filter queries and clears (how many items match; never the typed text); and audio plays, completes, speed, resume and downloads (`chapter N`, never a title or URL); and image-region outline clicks (the list's label and the region's number; never a region's label); and map marker choices and zoom-button presses (the map's label and the place's position or the zoom level; never the place's name, coordinates or URL). `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing. The README's "Analytics" section has the full table.
232
234
 
233
235
  For the host page's own content, tag the clickable element (or a wrapper) with `data-uvalib-track="category,action[,name[,value]]"` instead of writing a listener, for example `<a href="/spaces" data-uvalib-track="home-page,banner-click,Study spaces">`: the category is your page or widget, the action a fixed kebab-case verb, the name a short fixed label, the value a number. It works inside shadow DOM too. Never put titles, URLs, search text, ids, email addresses, phone numbers or other personal data in events.
234
236
 
@@ -564,7 +566,7 @@ A static site (11ty, Jekyll, a generated collection) that searches with [Pagefin
564
566
 
565
567
  - Link `pagefind.css` (npm: `@uvalib/web-components/pagefind.css`) **instead of** Pagefind's `pagefind-ui.css`; never both (the stock rules out-rank the theme's). It styles Pagefind's default UI (`.pagefind-ui__*`): the field and Clear like `.uvalib-input`, the filters like `<uvalib-filter>`, link-coloured result titles, the library `<mark>`, Load more as a `.uvalib-button`, with dark mode and forced colors. Pagefind's `--pagefind-ui-*` properties still work for small changes.
566
568
  - Use `<uvalib-pagefind-search>` (from `uvalib-pagefind-search.js`) rather than `new PagefindUI(...)`: it loads `<bundle-path>pagefind-ui.js` from the site's bundle and adds what CSS cannot: a visible label (the stock field has only a title), a polite result-count status (the stock message is not announced), focus that stays in the field after Clear and Escape and moves to the first new result after Load more, `?q=` read and written (`query-param`), Pagefind filters read from and written to the URL (`filter-params`), and analytics (`trackSearch(…, 'Pagefind', count)` once results settle, and `filter-change` events). Do not add your own `?q=` or `triggerFilters` URL script or live region.
567
- - Attributes: `bundle-path` (default `/pagefind/`), `merge-index` (JSON array, for sharded indexes), `page-size` (10), `show-sub-results`, `show-images`, `excerpt-length`, `placeholder`, `label`, `label-hidden`, `translations` and `options` (JSON), `query-param` (default `q`) and `filter-params` (space-separated filter names, such as `collection author`: `?collection=Manuscripts` lands with that filter checked and its group open, applied with `?q=` as one search; repeated parameters check several values; values the index lacks are ignored; checkbox changes are written back), `searching` and `no-skeleton`. A search page opened with `?q=` must hold still while results load (CLS): add `searching` when the URL has a query, before any script runs, with one line after the element (`<script>if (new URLSearchParams(location.search).get('q')) document.querySelector('uvalib-pagefind-search').setAttribute('searching', '')</script>`, or server-side); `pagefind.css` then holds a window's height and draws placeholder results from first paint until the results load, and the element keeps the footer below the fold until the visitor uses the search. Do not add your own `min-height` hold. For a "Search this collection" link, use `filter-params` and link to `/search/?collection=…`; `el.ready.then((ui) => ui.triggerFilters(…))` is for filters set from your own script.
569
+ - Attributes: `bundle-path` (default `/pagefind/`), `merge-index` (JSON array, for sharded indexes), `page-size` (10), `show-sub-results`, `show-images`, `excerpt-length`, `placeholder`, `label`, `label-hidden`, `translations` and `options` (JSON), `query-param` (default `q`) and `filter-params` (space-separated filter names, such as `collection author`: `?collection=Manuscripts` lands with that filter checked and its group open, applied with `?q=` as one search; repeated parameters check several values; values the index lacks are ignored; checkbox changes are written back), `filter-flags` (one-value "has X" filters linked as `?audiobook=1`: the parameter with any value but `0`/`false`/`no`/`off` checks the filter's one value, whatever the index calls it, and checking writes `=1`; it need not be in `filter-params` too; do not rewrite such URLs with your own script), `searching` and `no-skeleton`. A search page opened with `?q=` must hold still while results load (CLS): add `searching` when the URL has a query, before any script runs, with one line after the element (`<script>if (new URLSearchParams(location.search).get('q')) document.querySelector('uvalib-pagefind-search').setAttribute('searching', '')</script>`, or server-side); `pagefind.css` then holds a window's height and draws placeholder results from first paint until the results load, and the element keeps the footer below the fold until the visitor uses the search. Do not add your own `min-height` hold. For a "Search this collection" link, use `filter-params` and link to `/search/?collection=…`; `el.ready.then((ui) => ui.triggerFilters(…))` is for filters set from your own script.
568
570
 
569
571
  ```html
570
572
  <!doctype html>
@@ -613,6 +615,35 @@ For a TEI text converted to class-annotated HTML (the class is the TEI element n
613
615
  - Classes: `div`/`div-*`, `head`, `p`, `ab`, `seg-*`, `lb`, `pb` (`pb-n`, `a.pb-image`), `lg`, `l` (`data-n`), `sp`, `speaker`, `stage`, `opener`, `closer`, `dateline`, `salute`, `signed`, `postscript`, `epigraph`, `argument`, `trailer`, `byline`, `bibl`, `cit`, `figure`, `figDesc`, `add`, `del`, `sic`, `orig`, `reg`, `unclear`, `gap`, `noteref`, `footnotes`, `note`, `note-inline`, `ornament`, `textbreak`, `titlepage`/`titlePage`, `list`, `rend-*` (italic, smallcaps, center, right, indent, indent2, indent3, hang, underline…).
614
616
  - Keep whitespace before each `<br class="lb">` (CSS cannot space a `<br>`), or write `<span class="lb"></span>`. Line breaks: a `<label class="uvalib-edition__lines"><input type="checkbox"> Show original line breaks</label>` before or inside the edition (or the class `uvalib-edition--lines`); readings in `title`: `.uvalib-edition__readings` (a title alone is hover-only).
615
617
  - Additions and deletions are announced by generated text; do not add your own. Page images: `<uvalib-lightbox selector=".uvalib-edition a.pb-image">`. README: "Reading texts (edition.css)".
618
+ - EPUB and PDF downloads of the same text: link `edition-epub.css` in each EPUB content document (copy it into the EPUB; no `.uvalib-edition` wrapper needed), and `edition-epub.css` then `edition-print.css` (page margins and numbers, print rules) in the HTML a PDF is printed from. Generated from edition.css, same classes and look, in CSS reading systems handle; don't keep a hand-made download stylesheet. No toggles there (prose reflows).
619
+
620
+ ### Audio by chapter
621
+
622
+ An audiobook's chapters or an oral history's sessions are one `<uvalib-audio>` (`uvalib-audio.js`) around a plain list of links to the files, never a native `<audio controls>` per chapter or your own player.
623
+
624
+ ```html
625
+ <uvalib-audio
626
+ label="Alice’s Adventures in Wonderland"
627
+ download-href="alice.m4b"
628
+ download-label="Download the whole book"
629
+ download-size="161234567"
630
+ >
631
+ <ol>
632
+ <li>
633
+ <a href="ch01.mp3" data-duration="12:31">1. Down the Rabbit-Hole</a>
634
+ <a href="../text.html#ch1">Read the text</a>
635
+ </li>
636
+ <li data-download data-size="9800000">
637
+ <a href="ch02.mp3" data-duration="10:02">2. The Pool of Tears</a>
638
+ </li>
639
+ </ol>
640
+ </uvalib-audio>
641
+ ```
642
+
643
+ - The first link in each item is the chapter (`data-duration` as `12:31`, `1:02:03` or seconds); other links stay links. `data-download` (+ `data-size`) on an item adds that chapter's download.
644
+ - It draws a Play button per chapter, `aria-current` and "Now playing", one player (Back 15 s, Play/Pause, Forward 30 s, a position slider, the time, a speed select 0.75–2×) and one polite status: do not add controls, live regions or keyboard shortcuts of your own. Nothing preloads or autoplays; `continuous` plays on to the next chapter.
645
+ - It remembers the chapter, position and speed per page in localStorage and offers "Resume … at 12:30" (`storage-key` when a page has two recordings; `no-resume` to turn it off).
646
+ - A cast or credits table goes after it as a `.uvalib-table`. With `base.css` the player's space is held. It reports its own analytics by chapter number. README: "Audio by chapter".
616
647
 
617
648
  ### Results toolbar, badges and tags
618
649
 
@@ -584,6 +584,57 @@ Compatibility element. Light mode (`no-shadow-dom`) installs the tokens and base
584
584
  | `site-analytics-event` | Listened for on `document` too: the same as `uvalib-analytics-event`. |
585
585
  | `site-analytics-content` | Listened for on `document` too: the same as `uvalib-analytics-content`. |
586
586
 
587
+ ## `<uvalib-audio>`
588
+
589
+ A long recording played by chapter: an audiobook, an oral history's sessions. One player for the whole list, so starting a chapter stops the one playing. Give the chapters as a list of links to their files, so the page works before (and without) the script: `<ol><li><a href="ch1.mp3" data-duration="12:31">Chapter 1. Down the Rabbit-Hole</a></li>…</ol>`. The first link in each item is the chapter (its text is the title; inline markup such as `<i>` or `lang` is kept); `data-duration` (`12:31`, `1:02:03` or seconds) is shown beside it and gives the slider its length before the file loads. Other links in the item (the chapter's text, a transcript) are kept as links after it. `data-download` on the `<li>` adds a Download link for that chapter (its own file, or the URL given), with `data-size` (bytes or text) after it. Upgraded, each chapter is a real button (“Play Chapter 1. Down the Rabbit-Hole”, its visible text), with its duration; the current chapter gets `aria-current="true"` and says “Now playing” or “Paused” in text, beside an orange bar. Above the list, a player for the current chapter: what is playing (as text, not a live region), Back 15 s, Play/Pause, Forward 30 s, a position slider (a native range, read as “12 minutes 30 seconds of 41 minutes”), the elapsed and total time, and a native Speed select (0.75× to 2×). One `<audio preload="none">` plays everything: nothing loads until the visitor presses Play, and nothing ever plays without a press. `continuous` plays the next chapter when one ends. The position is remembered per page in localStorage (the page's path, plus `storage-key` when a page has more than one recording): on the next visit a “Resume “Chapter 4” at 12:30” button offers to carry on, never playing by itself. Saved on pause, every few seconds while playing, and when the page is left; cleared when the last chapter ends. `no-resume` turns it off. Without storage it simply forgets. Chapter changes, pauses, speed changes and skips are announced politely in one status (a burst of skips once, where it ends); the time is never announced as it runs. A chapter that fails to load says so in text, with a direct link to its file. `download-href` adds a link to the whole recording (an M4B audiobook), with `download-label` and `download-size` (bytes, shown as “312 MB”, or text). Where the browser has the Media Session API, the system's media keys and lock screen show the chapter and can play, pause, seek and change chapter. Before it upgrades, `base.css` holds the player's height above the list and gives each item the height of its upgraded row, so the list does not move.
590
+
591
+ ### Attributes
592
+
593
+ | Attribute | Type | Default | Description |
594
+ |---|---|---|---|
595
+ | `label` | `string` | `''` | The player's accessible name, such as the book's title (default “Player”). |
596
+ | `continuous` | `boolean` | `false` | Play the next chapter when one ends. |
597
+ | `no-resume` | `boolean` | `false` | Don't remember the position (nothing is read from or written to localStorage). |
598
+ | `storage-key` | `string` | `''` | Added to the page's path to name what is remembered, for a page with several recordings. |
599
+ | `download-href` | `string` | `''` | The whole recording to download (an M4B audiobook with chapters, an MP3). |
600
+ | `download-label` | `string` | `'Download the whole recording'` | The download link's text. |
601
+ | `download-size` | `string` | `''` | The download's size: bytes (shown as “312 MB”) or text. |
602
+ | `no-shadow-dom` | `boolean` | `false` | |
603
+ | `no-style` | `boolean` | `false` | |
604
+
605
+ ### CSS parts
606
+
607
+ | Part | Description |
608
+ |---|---|
609
+ | `player` | The player box above the list. |
610
+ | `now` | The line saying what is playing (or the Resume button). |
611
+ | `controls` | The player's buttons, slider, time and speed. |
612
+ | `download` | The whole recording's download line. |
613
+ | `list` | The list of chapters. |
614
+ | `chapter` | Each chapter's row. |
615
+
616
+ ### Events
617
+
618
+ | Event | Description |
619
+ |---|---|
620
+ | `uvalib-analytics-event` | For `<site-analytics>`, on the visitor's actions only, never titles or URLs: `['uvalib-audio', 'play', 'chapter <N>', N]` the first time each chapter plays in a page view (N is its place in the list), `['uvalib-audio', 'complete', 'chapter <N>', N]` when it plays to its end, `['uvalib-audio', 'speed', '<speed>', speed]` once the visitor settles on a speed, `['uvalib-audio', 'resume', 'chapter <N>', N]`, and `['uvalib-audio', 'download', 'recording' \| 'chapter <N>']`. Bubbles and is composed. |
621
+
622
+ ### CSS custom properties
623
+
624
+ | Property | Default | Description |
625
+ |---|---|---|
626
+ | `--uva-color-text` | | Dark-mode role token: text (else `--uva-grey-darkest`). |
627
+ | `--uva-color-text-muted` | | Dark-mode role token: durations (else #4b5563). |
628
+ | `--uva-color-link` | | Dark-mode role token: links and the outline buttons (else `--uva-brand-blue`). |
629
+ | `--uva-color-button-bg` | | Dark-mode role token: Play/Pause and the slider (else `--uva-blue-alt`). |
630
+ | `--uva-color-button-text` | | Dark-mode role token: Play/Pause text (else #fff). |
631
+ | `--uva-color-surface-raised` | | Dark-mode role token: the player's and the controls' background (else #fff). |
632
+ | `--uva-color-table-border` | | Dark-mode role token: the player's border and the rules between chapters (else #dadada). |
633
+ | `--uva-color-accent-bg` | | Dark-mode role token: the “Now playing” marker (else `--uva-brand-blue`). |
634
+ | `--uva-color-on-accent` | | Dark-mode role token: the marker's text (else #fff). |
635
+ | `--uva-color-current` | | Dark-mode role token: the current chapter's bar (else `--uva-brand-orange`). |
636
+ | `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
637
+
587
638
  ## `<uvalib-back-to-top>`
588
639
 
589
640
  A “Back to top” button for long pages: minutes, finding aids, transcriptions, long result lists. It stays hidden (`visibility: hidden`, so it is neither a tab stop nor in the accessibility tree) until the top `offset` pixels of the page (default 400) have scrolled out of view, watched with an IntersectionObserver on a small sentinel at the top of the page, never a scroll listener. If it has focus as it hides, focus moves to the target. Activating it scrolls to the top (smoothly unless the visitor prefers reduced motion) and moves focus to the page's `<h1>` (the first in `<main>`, else the first anywhere, else `#top`), or to `target` (a selector), adding `tabindex="-1"` when it is not focusable, so keyboard and screen reader users land at the top too. The button is fixed in the bottom corner (end side), inside the safe-area insets. The element itself is an empty block 4.75rem tall: put it last in the page's main content and that is the space the button needs, so the last lines can always scroll clear of it. When that space comes into view the button sits in it instead of floating, so it never covers the footer either. It is hidden in print.
@@ -1509,7 +1560,7 @@ A record's details as a description list, as on the library's digital collection
1509
1560
 
1510
1561
  ## `<uvalib-pagefind-search>`
1511
1562
 
1512
- Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle) with the library's defaults and the accessibility fixes that need script. Use it with pagefind.css, in place of Pagefind's pagefind-ui.css. It renders in light DOM, so the page's styles reach Pagefind's markup. It loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI` already exists. What it adds to the stock UI: a visible `<label>` for the field (the stock field is named only by its title); a polite status region that announces the result count ("12 results for virginia") once results settle (the stock message is not a live region); focus kept in the field after Clear or Escape (the stock UI blurs it, dropping focus to the page) and moved to the first new result after "Load more results"; the loading placeholders' dots hidden from screen readers; `?q=` read at start (and on Back and Forward) and the settled query written back with `history.replaceState`, so a search can be shared; with `filter-params`, the named Pagefind filters read from and written to the URL the same way; and reports to `<site-analytics>`. While a search from the URL loads, it can hold the page still (issue #37): with `searching` set in the page's HTML when the URL has a query, the element holds a screen's height from first paint, and placeholder results (aria-hidden) stand in for Pagefind's until they, or "no results", are drawn; the element then still reaches the bottom of the window until the visitor uses the search, so a short list does not pull the footer up. It does the same on Back and Forward to a new query. The `ui` property is the `PagefindUI` instance (for `triggerFilters`), and `ready` resolves with it. Attributes are read once, when the element is first connected.
1563
+ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle) with the library's defaults and the accessibility fixes that need script. Use it with pagefind.css, in place of Pagefind's pagefind-ui.css. It renders in light DOM, so the page's styles reach Pagefind's markup. It loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI` already exists. What it adds to the stock UI: a visible `<label>` for the field (the stock field is named only by its title); a polite status region that announces the result count ("12 results for virginia") once results settle (the stock message is not a live region); focus kept in the field after Clear or Escape (the stock UI blurs it, dropping focus to the page) and moved to the first new result after "Load more results"; the loading placeholders' dots hidden from screen readers; `?q=` read at start (and on Back and Forward) and the settled query written back with `history.replaceState`, so a search can be shared; with `filter-params`, the named Pagefind filters read from and written to the URL the same way (and with `filter-flags`, one-value filters linked as `?audiobook=1`); and reports to `<site-analytics>`. While a search from the URL loads, it can hold the page still (issue #37): with `searching` set in the page's HTML when the URL has a query, the element holds a screen's height from first paint, and placeholder results (aria-hidden) stand in for Pagefind's until they, or "no results", are drawn; the element then still reaches the bottom of the window until the visitor uses the search, so a short list does not pull the footer up. It does the same on Back and Forward to a new query. The `ui` property is the `PagefindUI` instance (for `triggerFilters`), and `ready` resolves with it. Attributes are read once, when the element is first connected.
1513
1564
 
1514
1565
  ### Attributes
1515
1566
 
@@ -1530,6 +1581,7 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
1530
1581
  | `searching` | `boolean` | | Set it in the page's HTML when the URL has a query (server-side, or with a one-line inline script after the element): from first paint, before any script loads, it holds a screen's height for the results, and placeholder results show until they are drawn. The element removes it then (and at start without a query), and sets it itself on Back and Forward to a new query. |
1531
1582
  | `no-skeleton` | `boolean` | | Never hold space or show placeholder results (`searching` is ignored). |
1532
1583
  | `filter-params` | `string` | | Space-separated Pagefind filter names read from and written to URL parameters of the same name (`collection author`: `?collection=A&collection=B`). URL filters are applied with the query as one search, their filter groups open; values not in the index are ignored. Empty (the default) turns it off. |
1584
+ | `filter-flags` | `string` | | Space-separated names of one-value Pagefind filters ("has an audiobook": its one value is `Available`), read from and written to the URL as on/off flags (issue #40). The parameter with any value, or none (`?audiobook`, `?audiobook=1`, `?audiobook=yes`), checks the filter's one value, whatever its spelling in the index; `0`, `false`, `no` and `off` leave it unchecked. Checking it writes `?audiobook=1`; unchecking removes it. Otherwise as `filter-params` (one search with the query, Back and Forward); a name need not be repeated there, and a name in both is a flag. If the index has more or fewer than one value for it, a console warning says so once and the filter is read as `filter-params` (exact values). |
1533
1585
 
1534
1586
  ### Events
1535
1587