@uvalib/web-components 1.1.0 → 1.2.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.
- package/CHANGELOG.md +64 -0
- package/README.md +563 -47
- package/dist/base/url-param.d.ts +23 -0
- package/dist/base/url-param.js +49 -0
- package/dist/base/url-param.js.map +1 -0
- package/dist/base.css +289 -1
- package/dist/components/uvalib-card/UvalibCard.d.ts +19 -5
- package/dist/components/uvalib-card/UvalibCard.js +112 -9
- package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
- package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +156 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js +747 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.d.ts +1 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.js +4 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.js.map +1 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +148 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +1248 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.d.ts +1 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js +4 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js.map +1 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +8 -1
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-lightbox/media.d.ts +1 -18
- package/dist/components/uvalib-lightbox/media.js +1 -42
- package/dist/components/uvalib-lightbox/media.js.map +1 -1
- package/dist/components/uvalib-pager/UvalibPager.d.ts +58 -4
- package/dist/components/uvalib-pager/UvalibPager.js +232 -8
- package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +27 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +192 -26
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
- package/dist/components/uvalib-results-count/UvalibResultsCount.d.ts +62 -0
- package/dist/components/uvalib-results-count/UvalibResultsCount.js +208 -0
- package/dist/components/uvalib-results-count/UvalibResultsCount.js.map +1 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.d.ts +1 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.js +4 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.js.map +1 -0
- package/dist/components/uvalib-tabs/UvalibTabs.d.ts +127 -0
- package/dist/components/uvalib-tabs/UvalibTabs.js +821 -0
- package/dist/components/uvalib-tabs/UvalibTabs.js.map +1 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.d.ts +1 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.js +4 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.js.map +1 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +89 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.js +411 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.d.ts +1 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.js +4 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.js.map +1 -0
- package/dist/custom-elements.json +7140 -2630
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/base.js +35 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +4 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +2 -0
- package/dist/styles/controls.js.map +1 -1
- package/dist/styles/results.d.ts +1 -0
- package/dist/styles/results.js +257 -0
- package/dist/styles/results.js.map +1 -0
- package/dist/tokens.css +4 -0
- package/dist-cdn/base.css +289 -1
- package/dist-cdn/chunks/{base-CAFQWnZG.js → base-p5pk0vb2.js} +36 -2
- package/dist-cdn/chunks/{base-CAFQWnZG.js.map → base-p5pk0vb2.js.map} +1 -1
- package/dist-cdn/chunks/inline-copy-BANQSMIR.js +69 -0
- package/dist-cdn/chunks/inline-copy-BANQSMIR.js.map +1 -0
- package/dist-cdn/chunks/{site-header-C9V7Wuw2.js → site-header-BlOYvQg1.js} +5 -1
- package/dist-cdn/chunks/site-header-BlOYvQg1.js.map +1 -0
- package/dist-cdn/chunks/source-children-BHsDwCvL.js +53 -0
- package/dist-cdn/chunks/source-children-BHsDwCvL.js.map +1 -0
- package/dist-cdn/chunks/url-param-C1sk_F1d.js +28 -0
- package/dist-cdn/chunks/url-param-C1sk_F1d.js.map +1 -0
- package/dist-cdn/custom-elements.json +7140 -2630
- package/dist-cdn/manifest.json +7 -2
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-page.js +2 -2
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +206 -19
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +220 -6
- package/dist-cdn/tokens.css +4 -0
- package/dist-cdn/uvalib-card.js +94 -20
- package/dist-cdn/uvalib-card.js.map +1 -1
- package/dist-cdn/uvalib-chip-group.js +496 -0
- package/dist-cdn/uvalib-chip-group.js.map +1 -0
- package/dist-cdn/uvalib-contents.js +2 -1
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-date-histogram.js +850 -0
- package/dist-cdn/uvalib-date-histogram.js.map +1 -0
- package/dist-cdn/uvalib-lightbox.js +26 -48
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-metadata.js +2 -1
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pager.js +141 -7
- package/dist-cdn/uvalib-pager.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +121 -19
- package/dist-cdn/uvalib-photo-grid.js.map +1 -1
- package/dist-cdn/uvalib-results-count.js +101 -0
- package/dist-cdn/uvalib-results-count.js.map +1 -0
- package/dist-cdn/uvalib-tabs.js +436 -0
- package/dist-cdn/uvalib-tabs.js.map +1 -0
- package/dist-cdn/uvalib-tag-list.js +267 -0
- package/dist-cdn/uvalib-tag-list.js.map +1 -0
- package/package.json +24 -3
- package/skills/uvalib-web-components/SKILL.md +206 -19
- package/skills/uvalib-web-components/reference/components.md +220 -6
- package/dist-cdn/chunks/site-header-C9V7Wuw2.js.map +0 -1
- package/dist-cdn/chunks/source-children-RuAec527.js +0 -119
- package/dist-cdn/chunks/source-children-RuAec527.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# @uvalib/web-components
|
|
2
2
|
|
|
3
|
+
[](https://uvalib.github.io/reusable-web-library/report/) [](https://uvalib.github.io/reusable-web-library/report/) [](https://uvalib.github.io/reusable-web-library/report/#lighthouse)
|
|
4
|
+
|
|
3
5
|
Reusable web components for UVA Library sites, built with Lit and TypeScript:
|
|
4
6
|
|
|
5
7
|
- **Page chrome:** `<site-page>` (skip link, header with the library main navigation and live library alerts, one `<main>`, footer), `<site-alerts>` (the alerts, also usable alone), `<site-header>`, `<site-main-nav>`, `<site-footer>`, `<site-analytics>` and `<uvalib-analytics>` (Matomo, one element under two names) and `<site-style>` (legacy compatibility).
|
|
6
8
|
- **Navigation:** `<uvalib-breadcrumbs>` (the breadcrumb trail) and `<uvalib-contents>` (sub-navigation or a table of contents).
|
|
7
9
|
- **Cards:** `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>`.
|
|
10
|
+
- **Tabs:** `<uvalib-tabs>`.
|
|
8
11
|
- **Records:** `<uvalib-metadata>` (a record's details, credit, rights and how to cite).
|
|
9
12
|
- **Images:** `<uvalib-lightbox>` (an image viewer over plain links) and `<uvalib-photo-grid>` (justified rows of thumbnails).
|
|
10
|
-
- **Search:** `<uvalib-filter>` and `<uvalib-
|
|
13
|
+
- **Search:** `<uvalib-filter>`, `<uvalib-date-range>`, `<uvalib-date-histogram>` and `<uvalib-pagefind-search>` (with `pagefind.css`, the library theme for Pagefind static-site search).
|
|
11
14
|
- **Library hours:** `<site-hours-section>`, `<library-weekly-hours>` and `<library-hours-setup>`.
|
|
12
15
|
- **Library events:** `<events-section>`.
|
|
13
16
|
- **Search results:** `<bento-box>` (library.virginia.edu/search), with its `<catalog-section>`, `<articles-section>`, `<libguides-section>` and `<website-section>`.
|
|
@@ -26,6 +29,50 @@ Then ask, for example:
|
|
|
26
29
|
|
|
27
30
|
> Wrap this site's pages in the UVA Library `<site-page>` from the v1 CDN, with our own nav links in the header.
|
|
28
31
|
|
|
32
|
+
### Example prompts
|
|
33
|
+
|
|
34
|
+
Name the skill so the agent loads it, say what to keep, and ask it to audit before editing and to check accessibility before finishing. These are starting points; add your site's specifics.
|
|
35
|
+
|
|
36
|
+
**Brand a new or existing site**
|
|
37
|
+
|
|
38
|
+
> Use the uvalib-web-components skill to apply UVA Library branding to this site with the v1 CDN. First audit, with no changes: list how the current header, footer, navigation, buttons, forms and colours map to the library components and classes, and show me the list. Then wrap every page in `<site-page site-name="Our site name">` with our own links as site links, link `base.css` in `<head>`, replace hand-built buttons and search forms with the library classes, and move our colours onto the `--uva-*` tokens. Keep every page and URL working. Verify with the skill's accessibility testing guide and commit on a new branch; don't push until I approve.
|
|
39
|
+
|
|
40
|
+
**Migrate from the old components**
|
|
41
|
+
|
|
42
|
+
> Use the uvalib-web-components skill to move this project off the old `/web-components/latest/` and `cdn-v…` URLs and `@uvalib/<package>` npm names to `@uvalib/web-components` v1. List every old reference first, then change them following the skill's migration guide, keeping the markup working. Run the site's tests and check each page in a browser.
|
|
43
|
+
|
|
44
|
+
**Switch one library.virginia.edu page**
|
|
45
|
+
|
|
46
|
+
> Use the uvalib-web-components skill's "Switching library.virginia.edu" table to update the script URLs on the /hours page to v1. Change only the URLs, keep the markup, and tell me what to check after it's live.
|
|
47
|
+
|
|
48
|
+
**Add one pattern**
|
|
49
|
+
|
|
50
|
+
> Use the uvalib-web-components skill to add breadcrumbs to every page under /collections/ (Home › Collections › the collection) with `<uvalib-breadcrumbs>`, placed where `<site-page>` puts them.
|
|
51
|
+
|
|
52
|
+
> Use the uvalib-web-components skill to turn our collections list into a grid of clickable `<uvalib-card>`s (title and item count), and add `<uvalib-pager>` previous/next links to the reading pages.
|
|
53
|
+
|
|
54
|
+
> Use the uvalib-web-components skill to show each record's details with `<uvalib-metadata>` (creator, date, subjects, downloads with file sizes, rights and how to cite), and open our IIIF page images in `<uvalib-lightbox>` instead of a new tab.
|
|
55
|
+
|
|
56
|
+
> Use the uvalib-web-components skill to theme our Pagefind search with `<uvalib-pagefind-search>` and `pagefind.css`, keeping our index shards and filters.
|
|
57
|
+
|
|
58
|
+
**Dark mode, analytics and search pages**
|
|
59
|
+
|
|
60
|
+
> Use the uvalib-web-components skill to turn on the library's opt-in dark mode (Light / Dark / System in the header) and make our own CSS follow the `--uva-color-*` role tokens. Check contrast in both schemes.
|
|
61
|
+
|
|
62
|
+
> Use the uvalib-web-components skill to add Matomo analytics with `<site-page matomo-id="42">`. This is a single-page app, so record a page view per route; tag our own Download and Share buttons with `data-uvalib-track`.
|
|
63
|
+
|
|
64
|
+
**Check and fix accessibility**
|
|
65
|
+
|
|
66
|
+
> Use the uvalib-web-components skill's accessibility testing guide to add a Playwright + axe test matched to Lighthouse and a Lighthouse CI config to this project, run them on the home, a list, a detail and the search page in light and dark at phone and desktop widths, and fix what they find. Report anything you couldn't test.
|
|
67
|
+
|
|
68
|
+
**Ask for something the library doesn't have**
|
|
69
|
+
|
|
70
|
+
> Our pages need an accordion and the library has none. Use the uvalib-web-components skill to check the repo's issues for an existing request, then draft a new-component issue for uvalib/reusable-web-library (what it's for, our public page URLs, the library.virginia.edu pattern to match, accessibility needs). Show me the draft before filing it, and build a small accessible stopgap that links the issue.
|
|
71
|
+
|
|
72
|
+
**Keep it current**
|
|
73
|
+
|
|
74
|
+
> Update the uvalib-web-components skill in this project to the latest release, then check whether anything we use changed and needs updating.
|
|
75
|
+
|
|
29
76
|
- `npx` fetches the package on the fly, so this works in any repository, including sites that only use script tags (it needs Node, not an npm dependency).
|
|
30
77
|
- Other agents or folders: `npx @uvalib/web-components install-skill --dir .agents/skills`. Add `--force` to update an existing copy.
|
|
31
78
|
- Or copy `node_modules/@uvalib/web-components/skills/uvalib-web-components` into your skills folder. The skill is also on the CDN at `https://unpkg.internal.lib.virginia.edu/web-components/v1/skills/uvalib-web-components/SKILL.md`. More in [docs/usage.md](docs/usage.md#agent-skill).
|
|
@@ -61,6 +108,20 @@ Projects that commit `.claude/skills/` get each update as an ordinary reviewed c
|
|
|
61
108
|
|
|
62
109
|
To do it by hand, read on.
|
|
63
110
|
|
|
111
|
+
## Requests and bug reports
|
|
112
|
+
|
|
113
|
+
Ask for a new component, a feature or change in an existing one, or report a bug through [the repository's issues](https://github.com/uvalib/reusable-web-library/issues/new/choose). Each has a form: **New component**, **Feature or change request** and **Bug report**. The repository is public, so leave out passwords, tokens, internal-only hostnames and personal data. The agent skill knows the forms too: ask your agent to search the existing issues, draft one, and file it once you approve it (it uses the GitHub CLI, `gh`, or gives you the form's link).
|
|
114
|
+
|
|
115
|
+
## Test results
|
|
116
|
+
|
|
117
|
+
Every push to `main` is tested before the examples site is published, and the results go up with it: **[test report](https://uvalib.github.io/reusable-web-library/report/)**. Lighthouse takes about half an hour, so it runs alongside: the site goes up as soon as the tests pass, showing the previous Lighthouse results (marked as from an earlier commit), and is published again with this commit's when the audit finishes. It lists:
|
|
118
|
+
|
|
119
|
+
- **Tests:** every build and package test (Node) and every component test (Chromium), file by file, with each test's outcome.
|
|
120
|
+
- **Accessibility:** the axe-core checks, in shadow and light DOM, light and dark, held to WCAG 2.2 AA plus the extra rules Lighthouse enables. Lighthouse must also score 100 for accessibility on every example.
|
|
121
|
+
- **Lighthouse:** each example page's median performance, accessibility, best-practices, layout-shift and blocking-time results, against the budgets in [Quality checks](#quality-checks).
|
|
122
|
+
|
|
123
|
+
The badges above read the same report ([`report/results.json`](https://uvalib.github.io/reusable-web-library/report/results.json) has the numbers for scripts). Locally, `pnpm test`, `pnpm lhci` and `pnpm report` write it to `dist-site/report/`.
|
|
124
|
+
|
|
64
125
|
## Playground
|
|
65
126
|
|
|
66
127
|
Try every component and mode, edit the code, and share a link: <https://uvalib.github.io/reusable-web-library/>
|
|
@@ -96,7 +157,7 @@ npm i @uvalib/web-components
|
|
|
96
157
|
import '@uvalib/web-components/site-page.js'; // registers site-page, site-header, site-main-nav and site-footer
|
|
97
158
|
```
|
|
98
159
|
|
|
99
|
-
The define entries are `site-page.js`, `site-header.js`, `site-main-nav.js`, `site-footer.js`, `site-analytics.js`, `uvalib-analytics.js`, `site-style.js`, `uvalib-filter.js`, `uvalib-date-range.js`, `site-hours-section.js`, `library-weekly-hours.js`, `library-hours-setup.js`, `events-section.js`, `bento-box.js` and `uvalib-pagefind-search.js`. The package root (`import '@uvalib/web-components'`) exports the classes only and registers nothing. To use a class such as `SitePage` directly, also import the define entries. CSS is available as `@uvalib/web-components/tokens.css`, `base.css` and `pagefind.css` (the Pagefind theme, see [Static-site search](#static-site-search-pagefind)). Do not load the same component from both the CDN and npm on one page.
|
|
160
|
+
The define entries are `site-page.js`, `site-header.js`, `site-main-nav.js`, `site-footer.js`, `site-analytics.js`, `uvalib-analytics.js`, `site-style.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` and `uvalib-pagefind-search.js`. The package root (`import '@uvalib/web-components'`) exports the classes only and registers nothing. To use a class such as `SitePage` directly, also import the define entries. CSS is available as `@uvalib/web-components/tokens.css`, `base.css` and `pagefind.css` (the Pagefind theme, see [Static-site search](#static-site-search-pagefind)). Do not load the same component from both the CDN and npm on one page.
|
|
100
161
|
|
|
101
162
|
## Quick start
|
|
102
163
|
|
|
@@ -291,15 +352,81 @@ connect-src https://d2q6t6fdv76k7r.cloudfront.net wss://*.appsync-realtime-api.u
|
|
|
291
352
|
```
|
|
292
353
|
|
|
293
354
|
- **A clickable card.** `href` makes the heading the link, and a CSS pseudo-element stretches that link over the card, so the whole card is one destination. The arrow is only a visual aid. Never wrap the card in an `<a>`. A clickable card must not contain another link, button or other control: the stretched link would cover it, and a link inside a link is invalid. The heading needs an accessible name (text, or an image alt or label); otherwise the link is hidden. A static card (no `href`, or an empty or unsafe one such as `javascript:`) has no stretch, so its excerpt may contain links. An unsafe href is shown as plain text, with one console warning.
|
|
294
|
-
- **Slots.** `media` (an `<img>` with a real alt, or `alt=""` when the heading already names it), `badge` (for example “13 photos”, over the image), `heading`, `meta` (a date in `<time>`, or a byline), `chip` (one element per category) and the default slot for the excerpt.
|
|
355
|
+
- **Slots.** `media` (an `<img>` with a real alt, or `alt=""` when the heading already names it), `badge` (for example “13 photos”, over the image), `heading`, `meta` (a date in `<time>`, or a byline), `chip` (one element per category), `actions` (links or buttons on a static card, such as “Read the story” and “Photos (132)”) and the default slot for the excerpt. A clickable card must not contain an actions row: the stretched link would cover those controls, and the card warns once.
|
|
356
|
+
- **Circle media.** `media-shape="circle"` draws the media as a centered circle for a person or avatar. The image keeps its alt, and the count badge still sits on it. Any other value is ignored, with one warning.
|
|
295
357
|
- **Heading level.** Unset, it is one below the nearest heading before the card, or 3 when there is none (the same rule as `<events-section>`). `heading-level` (1–6) wins.
|
|
296
358
|
- **The grid.** A list, so a screen reader announces how many cards there are. Columns follow the grid’s own width: four above 992px, two through 767px, then one. Cards in a row match the tallest. `min-card-width` (a length such as `16rem`) switches that to `auto-fill` / `minmax`; anything else is ignored, with one warning. Only `<uvalib-card>` children are listed.
|
|
297
359
|
- **Previous/next.** `prev-href` and `next-href` (either may be omitted; with neither, nothing is rendered). Each link shows a “Previous” or “Next” kicker and, when set, `prev-label` or `next-label`. A long title truncates; the full text stays in the accessible name. The links use `rel="prev"` and `rel="next"`. The landmark’s name is `label`, or “Sections”.
|
|
298
360
|
- **Numbered pages.** Set `pages` (a positive count; it wins over previous/next, with one warning if those are set too). `page` is the current page, clamped to that range, and is text with `aria-current="page"`, not a link. Other pages use `href-template`, which must contain `{page}` (the default is `?page={page}`). A long range keeps the first page, a window around the current page, the last page, and an ellipsis where numbers are skipped. The landmark’s name is `label`, or “Pagination”.
|
|
299
361
|
- **One landmark name.** Two pagers with the same accessible name fail the accessibility check. Give the second a different `label`.
|
|
362
|
+
- **Load more.** `mode="load-more"` replaces the landmark with a group: a “Load more” button (`.uvalib-button`) and a polite “Showing N of M” (`shown` and `total`). It wins over numbered pages and previous/next, with one warning when those are also set. The button hides once `shown` has reached a positive `total`. `page` is the last loaded page (default 1). A click fires `load-more` with `{ page }` set to the next page. Call `loaded(firstNewElement)`, or set `for` to the list’s id and call `loaded()`, and focus moves to that new item (an element that cannot take focus gets `tabindex="-1"`). The group’s name is `label`, or “More results”.
|
|
300
363
|
- **Single-page apps.** A plain click fires `uvalib-card-navigate` (`detail: { href, position }`) or `uvalib-pager-navigate` (`detail: { href, kind, page? }`). Cancel it with `preventDefault()` and route in the app. `position` is `'single'` or `'1'`, `'2'`, …. `kind` is `'next'`, `'previous'` or `'number'`, and `page` is set only for `'number'`.
|
|
301
364
|
- **Styles.** A raised surface, a 1px border, and on hover or focus the shadow `0 0 20px 0 #DADADA`. Focusing the heading link draws the focus ring on the card. The chip is `--uva-blue-alt-300` on `--uva-blue-alt-dark` (6.13:1: WCAG AA for normal text, short of AAA’s 7:1). Dark mode follows the role tokens. `no-style` keeps the stretch, the grid and the truncation, and drops the colours.
|
|
302
365
|
|
|
366
|
+
## Chips
|
|
367
|
+
|
|
368
|
+
`<uvalib-chip-group>` is a row of chips: a segmented control or single-select filter (a year rail, a sort toggle), filter chips that toggle, or suggestion chips that go somewhere. Entry: `uvalib-chip-group.js` on the CDN, `@uvalib/web-components/uvalib-chip-group.js` on npm.
|
|
369
|
+
|
|
370
|
+
```html
|
|
371
|
+
<script
|
|
372
|
+
type="module"
|
|
373
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-chip-group.js"
|
|
374
|
+
></script>
|
|
375
|
+
<uvalib-chip-group label="Year" count-label="shoots" value="" scroll url-param="year">
|
|
376
|
+
<button value="" data-count="3694">All Years</button>
|
|
377
|
+
<button value="2004" data-count="213">2004</button>
|
|
378
|
+
<button value="2005" data-count="461">2005</button>
|
|
379
|
+
</uvalib-chip-group>
|
|
380
|
+
<uvalib-chip-group label="Sort by" segmented value="photos">
|
|
381
|
+
<button value="photos">Most photos</button>
|
|
382
|
+
<button value="date">Date</button>
|
|
383
|
+
<button value="title">Title A–Z</button>
|
|
384
|
+
</uvalib-chip-group>
|
|
385
|
+
<uvalib-chip-group mode="multi" label="Category" value="traditions">
|
|
386
|
+
<button value="traditions" data-count="9">Traditions</button>
|
|
387
|
+
<button value="sports" data-count="21">Sports</button>
|
|
388
|
+
</uvalib-chip-group>
|
|
389
|
+
<uvalib-chip-group mode="links" label="Suggested searches">
|
|
390
|
+
<a href="/search?q=snow+on+the+Lawn">snow on the Lawn</a>
|
|
391
|
+
</uvalib-chip-group>
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
- **Modes.** `single` (the default): native radios drawn as chips in a `role="radiogroup"`. Tab enters at the selected chip and the arrow keys move and select, as in any radio group; `value` is a string. `multi`: toggle buttons with `aria-pressed`; `value` is an array (comma-separated as an attribute). `links`: links (or, without `href`, buttons) that fire `select` and have no selected state.
|
|
395
|
+
- **Chips.** Children: `<button value data-count>` (the value falls back to `data-value`, then the text; `disabled` disables), or `<a href>` in `links` mode (an unsafe href such as `javascript:` makes the chip plain text, with one warning; an empty one makes it a button). Or set `items` (`[{ value, label, count?, href?, disabled? }]`), which wins over the children while set. The chips follow changes to the children.
|
|
396
|
+
- **Names.** `label` names the group and is required (one console warning without it). A count is shown smaller and muted, and read as part of the chip's name: “2005, 461 shoots” with `count-label="shoots"` (default “items”). Numbers are formatted for the page's language.
|
|
397
|
+
- **Events.** `change` (`detail: { value }`) on the visitor's change only, never when the app sets `value`; `select` (`detail: { value, href? }`) in `links` mode, cancelable for a plain click on a link: cancel it to route in a single-page app. Both bubble and are composed.
|
|
398
|
+
- **Before the script loads.** `base.css` hides each `<uvalib-chip-group>` and holds one row's height (44px, or the scrolling row's), so nothing below moves when it upgrades; the raw children show after two seconds if the script never arrives.
|
|
399
|
+
- **Look.** The `<uvalib-filter>` scope chip (a pill with a grey border and blue text, filled blue when selected), with a tick on the selected chip so the state never rests on colour alone. `segmented` joins the chips into one bar like the header's Light / Dark / System control; it stays on one row. Each chip is a target at least 44px square; the visible pill is 36px. Chips wrap on narrow screens. `scroll` keeps them on one row that scrolls sideways: the scrollbar stays visible, the edge with more chips fades out, focus scrolls a chip into view, and Tab moves on past the group (no trap). Dark mode follows the role tokens; in forced colors the selected chip is Highlight. `no-style` keeps the layout, the targets and the hidden radios.
|
|
400
|
+
- **Address.** `url-param="year"` keeps the value in the query (`?year=2005`; inside the hash on a hash route such as `#/series?year=2005` or `#chapter?year=2005`; a `multi` value comma-separated). It is read on connect. The markup's `value` stands for the address without the parameter; any other value is written, an empty one as `?year=`. Each change is one `pushState`: in `multi` at once, in `single` once the visitor settles (a second after the last change, so arrowing through a year rail adds one entry, and none when they end where they started). Back and Forward are followed and fire `change` with `restored: true`; a change still settling is dropped. With `<site-analytics spa="auto">` each push is one page view.
|
|
401
|
+
- **Analytics.** `change` with `<label>: <chip label>` and the count as the value (single: once the visitor settles, a second after the last change, and not when they end where they started); `select` with the group's label only, never the chip or its URL.
|
|
402
|
+
|
|
403
|
+
## Tabs
|
|
404
|
+
|
|
405
|
+
`<uvalib-tabs>` is a tab set. Each direct child with `data-tab` is a panel (the attribute is the tab’s label; give the panel an `id`), or pair `<button slot="tab">` labels with the panels in order. Entry: `uvalib-tabs.js` on the CDN, `@uvalib/web-components/uvalib-tabs.js` on npm.
|
|
406
|
+
|
|
407
|
+
```html
|
|
408
|
+
<script
|
|
409
|
+
type="module"
|
|
410
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-tabs.js"
|
|
411
|
+
></script>
|
|
412
|
+
<uvalib-tabs url-param="tab">
|
|
413
|
+
<section data-tab="Events" id="events">
|
|
414
|
+
<h2>Events</h2>
|
|
415
|
+
<p>Upcoming.</p>
|
|
416
|
+
</section>
|
|
417
|
+
<section data-tab="Stories" id="stories">
|
|
418
|
+
<h2>Stories</h2>
|
|
419
|
+
<p>From the archive.</p>
|
|
420
|
+
</section>
|
|
421
|
+
</uvalib-tabs>
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
- **Roles and keys.** The component renders `tablist`, `tab` and `tabpanel`, with `aria-selected`, `aria-controls` and `aria-labelledby`. Arrow keys move (they wrap, and they flip in right-to-left), Home and End jump. Selection follows the arrow unless `activation="manual"`, which waits for Enter or Space. Only the selected tab is in the tab order.
|
|
425
|
+
- **Selection.** `selected` is the panel id (a label or a 0-based index is accepted and rewritten to the id). A `change` event carries `{ id, label, index }`. The first panel is visible before the element upgrades, and a hidden panel is not in the accessibility tree.
|
|
426
|
+
- **Linkable tabs.** `url-param` keeps the selected id in the query string, or inside the hash on a hash route. `url-param="hash"` uses a bare `#panel-id`. Opening from a URL that already names a tab does not rewrite it. Back and Forward restore the tab. Nothing is written on the first render.
|
|
427
|
+
- **Phone.** The tabs wrap onto more than one line. Each tab stays at least 44px.
|
|
428
|
+
- **Analytics.** A visitor’s click or key reports `['uvalib-tabs', 'change', '<tab label>']`. The label is capped at 100 characters. Nothing is reported on render, on `requestUpdate`, or when Back restores a tab.
|
|
429
|
+
|
|
303
430
|
## Contents and record metadata
|
|
304
431
|
|
|
305
432
|
Two components for Library sites with records and long texts, such as the Electronic Text Collections. Entries: `uvalib-contents.js` and `uvalib-metadata.js` on the CDN, `@uvalib/web-components/uvalib-contents.js` and `@uvalib/web-components/uvalib-metadata.js` on npm.
|
|
@@ -401,7 +528,7 @@ Both follow dark mode through the role tokens and reflow at 320px; `no-style` ke
|
|
|
401
528
|
- **IIIF.** An Image API URL keeps its region (a crop or `square` stays). Only the size becomes `!W,H` for the viewport (CSS pixels times the screen density, at most 2, and at most 2000 pixels on a side). TIFF and JPEG2000 URLs are left as written. Full size still opens the original href, and only for an http(s) URL or a PNG, JPEG, GIF or WebP `data:` image. A resize while the viewer is open asks for the new size and is not an analytics event. Other image URLs are used as written. A `javascript:` URL, and an SVG `data:` URL, are refused.
|
|
402
529
|
- **Deep link.** `url-param="photo"` keeps `?photo=<id>` in sync: opening pushes a history entry, stepping replaces it, and Back closes. On a hash route (`#/text`, or a hash that already contains `?`) the parameter is written inside the hash (`#/text?photo=<id>`). Opening from a URL that already has the parameter is not a new action, and neither is Back or Forward. With `<site-analytics spa="auto">` (or `<uvalib-analytics spa="auto">`), that opening push is a same-document route change, so Matomo may count one page view; stepping replaces the entry and does not.
|
|
403
530
|
- **Details.** A child with `slot="details"` (optional `data-for` equal to the item's id or its position from 1; without `data-for` it shows for every image), or `data-details-id` on a link naming an element elsewhere on the page. It is shown in the dialog and put back when the viewer moves on or closes.
|
|
404
|
-
- **Photo grid.** Each direct child that is an `<a href>` or a `<button>` is one photo. The row is about 220px tall, and 140px when the viewport is 767px or narrower, unless `row-height` is set (a bare number is pixels; `rem`, `em` and the other CSS lengths are kept). Each image keeps its shape from its `width` and `height` attributes, or from the loaded image, so the row does not jump. Every item stays a real link or button. An image with no visible text gets a visible caption from its alt, and an alt that repeats that caption is cleared so it is not announced twice. The original alt is kept for a lightbox. A different alt is kept (the accessible name still contains the visible text). An `aria-label` is left as the name. Generated "Photo N" captions renumber when the photos change order. An item with no name is captioned "Photo N" and warned about once. A child that is not a link or a button is skipped, with one warning. The grid reports no analytics. Put it inside `<uvalib-lightbox>` and a plain click opens the viewer.
|
|
531
|
+
- **Photo grid.** Each direct child that is an `<a href>` or a `<button>` is one photo. The row is about 220px tall, and 140px when the viewport is 767px or narrower, unless `row-height` is set (a bare number is pixels; `rem`, `em` and the other CSS lengths are kept). Each image keeps its shape from its `width` and `height` attributes, or from the loaded image, so the row does not jump. Every item stays a real link or button. An image with no visible text gets a visible caption from its alt, and an alt that repeats that caption is cleared so it is not announced twice. The original alt is kept for a lightbox. A different alt is kept (the accessible name still contains the visible text). An `aria-label` is left as the name. Generated "Photo N" captions renumber when the photos change order. An item with no name is captioned "Photo N" and warned about once. A child that is not a link or a button is skipped, with one warning. A badge sits on the thumbnail: `<span slot="badge">` inside the item, or `data-badge` on the item (“seq”, “3 photos”). It is part of the item’s accessible name; when the item already has an `aria-label`, the badge is appended and the author’s words stay in `data-uvalib-label`. The grid reports no analytics. Put it inside `<uvalib-lightbox>` and a plain click opens the viewer.
|
|
405
532
|
- **Motion and colour.** `prefers-reduced-motion` turns the dialog's short fade off. The backdrop, surface and focus ring use the dark-mode role tokens. Controls are at least 44px. `no-style` keeps the dialog's structure and, for the grid, the row layout: the thumbnails stay in light DOM, and those rules are what reserve each image's space.
|
|
406
533
|
|
|
407
534
|
## Rendering modes
|
|
@@ -513,7 +640,7 @@ Dark mode is **off by default**. Without it nothing changes: no control, no dark
|
|
|
513
640
|
|
|
514
641
|
## Search and filter components
|
|
515
642
|
|
|
516
|
-
`<uvalib-filter>` (a checkbox facet with optional scope chips and See more / See less)
|
|
643
|
+
`<uvalib-filter>` (a checkbox facet with optional scope chips and See more / See less), `<uvalib-date-range>` (a year slider plus date inputs) and `<uvalib-date-histogram>` (counts as bars) are for search results pages. They are not page chrome, so use them inside `<site-page>`. Each has its own entry: `uvalib-filter.js`, `uvalib-date-range.js` and `uvalib-date-histogram.js` on the CDN, `@uvalib/web-components/uvalib-filter.js` and the same path for the others on npm.
|
|
517
644
|
|
|
518
645
|
```html
|
|
519
646
|
<script
|
|
@@ -542,7 +669,175 @@ Dark mode is **off by default**. Without it nothing changes: no control, no dark
|
|
|
542
669
|
</script>
|
|
543
670
|
```
|
|
544
671
|
|
|
545
|
-
|
|
672
|
+
The filter and the date range are controlled: set `value` (and `scopeValue`) from your own state after each event. `min` and `max` are required for the date range; without valid ones it renders nothing and warns once in the console. All three support `no-shadow-dom` and `no-style`. See the [Search facets](https://uvalib.github.io/reusable-web-library/#search-facets) example in the playground and the generated reference below.
|
|
673
|
+
|
|
674
|
+
`<uvalib-date-histogram>` draws one button per month (grouped by year) or per year. Give it `items` (`{ date: 'YYYY' | 'YYYY-MM', count }`) or a child `<table>` (two columns, or a year-by-month grid). The table stays in the page for assistive technology and for visitors without JavaScript, and "Show as table" shows it again. `unit="photos"` names a bar "October 2015: 5,311 photos". Arrow keys move between bars. `selected` is one bucket or a range (`2015-10` or `2015-10/2016-03`); the pressed bars also get a ring and a stripe. A choice fires `select` with `{ from, to }` as ISO dates. `range-for="dates"` keeps a `<uvalib-date-range id="dates">` in step: a bar sets its `value`, and `date-range-change` highlights the overlapping bars. Setting `selected` in script updates the date range and does not fire `select`. Setting the date range's `value` in script does not update the histogram unless the histogram connects afterwards or the range fires `date-range-change`. A value equal to that range's own `min` and `max` selects nothing. `scale="log"` sizes bars by log(count + 1). On a narrow screen each year row scrolls inside the component ("Scroll sideways to see more."); year bars wrap. `variant="strip"` is a non-interactive per-year row (`role="img"`) for a card. A date that is not a bucket at the current granularity (a bare year on a month chart, a day, "undated") is a chip.
|
|
675
|
+
|
|
676
|
+
```html
|
|
677
|
+
<script
|
|
678
|
+
type="module"
|
|
679
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-date-histogram.js"
|
|
680
|
+
></script>
|
|
681
|
+
<script
|
|
682
|
+
type="module"
|
|
683
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-date-range.js"
|
|
684
|
+
></script>
|
|
685
|
+
|
|
686
|
+
<uvalib-date-range
|
|
687
|
+
id="dates"
|
|
688
|
+
min="2005-01-01"
|
|
689
|
+
max="2017-12-31"
|
|
690
|
+
label="Photo dates"
|
|
691
|
+
></uvalib-date-range>
|
|
692
|
+
<uvalib-date-histogram
|
|
693
|
+
id="hist"
|
|
694
|
+
range-for="dates"
|
|
695
|
+
granularity="month"
|
|
696
|
+
unit="photos"
|
|
697
|
+
label="Photos by date"
|
|
698
|
+
></uvalib-date-histogram>
|
|
699
|
+
<script type="module">
|
|
700
|
+
const hist = document.querySelector('#hist');
|
|
701
|
+
hist.items = [
|
|
702
|
+
{ date: '2015-10', count: 5311 },
|
|
703
|
+
{ date: '2015-11', count: 842 },
|
|
704
|
+
];
|
|
705
|
+
hist.addEventListener('select', (e) => console.log(e.detail)); // { from, to }
|
|
706
|
+
</script>
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
## Results, badges and tags
|
|
710
|
+
|
|
711
|
+
For search pages, Virgo-like result lists and digital collections: badges and labels, a toolbar above the results, a results count that screen readers hear, keyword lists, an empty state and loading placeholders. The classes are in `base.css` (no script); `<uvalib-tag-list>` and `<uvalib-results-count>` are elements with their own entries (`uvalib-tag-list.js`, `uvalib-results-count.js`; npm `@uvalib/web-components/uvalib-tag-list.js`, `…/uvalib-results-count.js`). See the [Results toolbar & badges](https://uvalib.github.io/reusable-web-library/#results-toolbar) example.
|
|
712
|
+
|
|
713
|
+
### Badges
|
|
714
|
+
|
|
715
|
+
```html
|
|
716
|
+
<span class="uvalib-badge">Plain</span>
|
|
717
|
+
<span class="uvalib-badge uvalib-badge--category">Faculty & Staff Portraits</span>
|
|
718
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--success">Done</span>
|
|
719
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--warning">Processing</span>
|
|
720
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--danger">Failed</span>
|
|
721
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--info">Largest</span>
|
|
722
|
+
<span class="uvalib-badge uvalib-badge--new">New</span>
|
|
723
|
+
<span class="uvalib-badge uvalib-badge--body">At body size</span>
|
|
724
|
+
|
|
725
|
+
<!-- A count over an image: the wrapper positions it at the top-left corner. -->
|
|
726
|
+
<div class="uvalib-media">
|
|
727
|
+
<img src="rotunda.jpg" alt="The Rotunda in snow" width="600" height="400" />
|
|
728
|
+
<span class="uvalib-badge uvalib-badge--count">13 photos</span>
|
|
729
|
+
</div>
|
|
730
|
+
<!-- Several: wrap them. -->
|
|
731
|
+
<div class="uvalib-media">
|
|
732
|
+
<img src="lawn.jpg" alt="The Lawn" width="600" height="400" />
|
|
733
|
+
<div class="uvalib-media__badges">
|
|
734
|
+
<span class="uvalib-badge uvalib-badge--count">51 events · 10,700 photos</span>
|
|
735
|
+
<span class="uvalib-badge uvalib-badge--new">New</span>
|
|
736
|
+
</div>
|
|
737
|
+
</div>
|
|
738
|
+
|
|
739
|
+
<!-- A decorative icon before the word (the word carries the meaning). -->
|
|
740
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--success">
|
|
741
|
+
<svg aria-hidden="true" viewBox="0 0 16 16">
|
|
742
|
+
<path d="M2 8l4 4 8-8" fill="none" stroke="currentColor" stroke-width="2" />
|
|
743
|
+
</svg>
|
|
744
|
+
Done
|
|
745
|
+
</span>
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
- **Sizes:** small text (0.875rem) by default, the card chip's size; `--body` is body size.
|
|
749
|
+
- **`--category`** is the `<uvalib-card>` chip exactly (`--uva-blue-alt-300` with `--uva-blue-alt-dark` text, 6.13:1, in both schemes). **`--count`** is for media: near-black at 82% with white text, at least 11:1 over any picture (AAA). **`--status`** with `--success`, `--warning`, `--danger` or `--info` reads the alert role tokens (and `--uva-color-status-success-*`): text 7:1 or more in light and dark. **`--new`** is the accent (brand blue, AAA). The plain badge is neutral grey (AAA).
|
|
750
|
+
- **Never colour alone:** a status badge always says its state in words; an icon is decorative (`aria-hidden="true"`). In forced colors every badge keeps an outline.
|
|
751
|
+
- **On cards and links:** a badge inside a link is part of its name, so keep it short and meaningful (“13 photos”), or put it outside the link. Inside `<uvalib-card>`, use `slot="badge"` and `slot="chip"` instead.
|
|
752
|
+
|
|
753
|
+
### Results toolbar
|
|
754
|
+
|
|
755
|
+
```html
|
|
756
|
+
<div class="uvalib-toolbar">
|
|
757
|
+
<div class="uvalib-toolbar__field uvalib-toolbar__field--grow">
|
|
758
|
+
<label for="filter">Filter shoots</label>
|
|
759
|
+
<input class="uvalib-input" id="filter" type="search" />
|
|
760
|
+
</div>
|
|
761
|
+
<div class="uvalib-toolbar__field">
|
|
762
|
+
<label for="category">Category</label>
|
|
763
|
+
<select class="uvalib-input" id="category">
|
|
764
|
+
<option value="">All categories</option>
|
|
765
|
+
<option>Faculty & Staff Portraits</option>
|
|
766
|
+
</select>
|
|
767
|
+
</div>
|
|
768
|
+
<div class="uvalib-toolbar__group" role="group" aria-label="Decade">
|
|
769
|
+
<button class="uvalib-button uvalib-button--small" type="button" aria-pressed="false">
|
|
770
|
+
2000s
|
|
771
|
+
</button>
|
|
772
|
+
<button class="uvalib-button uvalib-button--small" type="button" aria-pressed="true">
|
|
773
|
+
2010s
|
|
774
|
+
</button>
|
|
775
|
+
</div>
|
|
776
|
+
<uvalib-results-count
|
|
777
|
+
class="uvalib-toolbar__summary"
|
|
778
|
+
shown="48"
|
|
779
|
+
total="3694"
|
|
780
|
+
noun="shoots"
|
|
781
|
+
singular="shoot"
|
|
782
|
+
></uvalib-results-count>
|
|
783
|
+
</div>
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
- **`.uvalib-toolbar`** is a wrapping row with consistent gaps (0.75rem by 1rem), controls aligned on their bottom edge. **`__field`** stacks a label over its control (keep the visible `<label>`); **`__field--grow`** (or a `.uvalib-search-form` in the toolbar) takes the spare width. **`__group`** holds a chip group (`.uvalib-button` toggles with `aria-pressed`; give the group a name with `role="group"` and `aria-label`). **`__summary`** sits at the end in muted text (AAA). At 30em and narrower every item takes the full width, in source order.
|
|
787
|
+
- **`<uvalib-results-count>`** writes “Showing 48 of 3,694 shoots” (“Showing all 12 shoots”, “Showing 1 shoot”, “No shoots” for a total or a shown of 0) from `shown`, `total`, `noun` and `singular`, and keeps it in sync at once; a missing or blank `shown` / `total` is unset, not 0. A hidden polite live region announces it once the text has not changed for a second (`announce-delay`), then clears itself after five seconds. The first render is never announced, but when it had no count yet (results still loading), the first count that arrives is. A count that comes back after a different one (a new search with as many results) is announced again. Update `shown` / `total` from your script after each filter change, and leave them unset while loading rather than setting 0. `<bento-box>` and `<uvalib-pagefind-search>` announce their own counts, so do not add one beside them.
|
|
788
|
+
|
|
789
|
+
```js
|
|
790
|
+
const count = document.querySelector('uvalib-results-count');
|
|
791
|
+
filter.addEventListener('input', () => {
|
|
792
|
+
const hits = shoots.filter((s) => s.title.toLowerCase().includes(filter.value.toLowerCase()));
|
|
793
|
+
render(hits.slice(0, 48));
|
|
794
|
+
count.shown = Math.min(hits.length, 48);
|
|
795
|
+
count.total = hits.length;
|
|
796
|
+
});
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
### Tag lists
|
|
800
|
+
|
|
801
|
+
```html
|
|
802
|
+
<uvalib-tag-list label="Subjects" track-label limit="8" href-template="/search?q={tag}">
|
|
803
|
+
<span>Rotunda</span>
|
|
804
|
+
<span>Lawn</span>
|
|
805
|
+
<a href="/collections/snow">Snow</a>
|
|
806
|
+
</uvalib-tag-list>
|
|
807
|
+
<!-- Plain text tags: no href-template and no links. -->
|
|
808
|
+
<uvalib-tag-list label="AI tags" hide-label>
|
|
809
|
+
<span>building</span>
|
|
810
|
+
<span>columns</span>
|
|
811
|
+
</uvalib-tag-list>
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
A labelled list (`label`, shown above it or visually hidden with `hide-label`) that wraps. Each tag is a link (an `<a href>` child, or any tag when `href-template` has `{tag}`, URL-encoded) or plain text; links are outlined pills in the link colour, plain tags the filled chip; every tag and the toggle are at least 2rem (34px) tall and wide and 0.5rem apart (WCAG 2.5.8 with room to spare; not AAA's 44px, which would make the pills button-sized), and at least 24px with `no-style`. A child's `lang` and `dir` are kept, and so is inline markup inside it (`em`, `cite`, `abbr`, `bdi`, a `span lang`…), copied element by element, never parsed as HTML; a blank `href` counts as none. `limit` shows that many and a “Show all N” button (`aria-expanded`, `aria-controls`); the rest appear in place and focus stays on the button, which then reads “Show fewer”. Apps can set `items` (`[{ label, href?, lang?, dir? }]`) instead of children, and route with the cancelable `uvalib-tag-list-navigate` event. Analytics never sends a tag's text, as tags can come from a record, a person or a machine, and by default not the label either, which a template may fill from a record: the name is `list N`, the list's place among the page's tag lists, with the tag's position as the value. Add `track-label` when the label is fixed text you wrote (“Subjects”) to send it instead (see [Analytics](#analytics)).
|
|
815
|
+
|
|
816
|
+
### Empty and loading states
|
|
817
|
+
|
|
818
|
+
```html
|
|
819
|
+
<div class="uvalib-empty-state">
|
|
820
|
+
<svg class="uvalib-empty-state__icon" aria-hidden="true" viewBox="0 0 24 24">
|
|
821
|
+
<circle cx="11" cy="11" r="7" fill="none" stroke="currentColor" stroke-width="2" />
|
|
822
|
+
<path d="M16 16l5 5" stroke="currentColor" stroke-width="2" />
|
|
823
|
+
</svg>
|
|
824
|
+
<h2>No photos match “snow”</h2>
|
|
825
|
+
<p>Try another word, or clear the filters.</p>
|
|
826
|
+
<button class="uvalib-button uvalib-button--secondary" type="button">Clear filters</button>
|
|
827
|
+
</div>
|
|
828
|
+
|
|
829
|
+
<div class="results" aria-busy="true">
|
|
830
|
+
<div aria-hidden="true">
|
|
831
|
+
<div class="uvalib-skeleton uvalib-skeleton--media"></div>
|
|
832
|
+
<p><span class="uvalib-skeleton-text"></span><span class="uvalib-skeleton-text"></span></p>
|
|
833
|
+
</div>
|
|
834
|
+
<p class="visually-hidden" role="status">Loading results</p>
|
|
835
|
+
</div>
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
- **`.uvalib-empty-state`**: an optional decorative icon (`__icon`, `aria-hidden`), a heading at the page's next level, a sentence and one action, centred in a dashed box. When it replaces results, the results count already announces “No shoots”; it needs no live region of its own.
|
|
839
|
+
- **`.uvalib-skeleton`** is a box: give it a height, or `--media` for a 3:2 image. **`.uvalib-skeleton-text`** reserves exactly one line of text (the last of several is shorter). Make the placeholders the same size as what replaces them, so nothing shifts. They shimmer, except under `prefers-reduced-motion`, and are outlined in forced colors.
|
|
840
|
+
- **Hide them from assistive technology** (`aria-hidden="true"` on their container), mark the region `aria-busy="true"` while it loads, and say “Loading results” once in a polite status (or rely on the results count when the results arrive). Remove `aria-busy` and the placeholders together.
|
|
546
841
|
|
|
547
842
|
## Library hours
|
|
548
843
|
|
|
@@ -682,39 +977,46 @@ Static sites that search with [Pagefind](https://pagefind.app) (such as Electron
|
|
|
682
977
|
- **`<site-page matomo-id="N">`** (and optional `matomo-url`) adds one `<site-analytics>` for that site and loads its code only then. Off by default. While that code loads, what the components report is kept and handed over, so an early bento search is not lost. If the page already has a `<site-analytics>` or `<uvalib-analytics>` (including the old v0.0.12 one), site-page adds none and that element does the recording.
|
|
683
978
|
- **What the library's components send.** They only fire `uvalib-analytics-*` events, so nothing happens without an analytics element (the old v0.0.12 element records them too). Every event is `[category, action, name?, value?]`: the category is the component's tag, the action a fixed verb, the name a short label from the library's own chrome or data (never a URL, never typed text), the value a number. Each one follows a visitor's action or a real failure: nothing is sent on render, re-render, the initial state or a restored one (a filter value set by the app, a remembered colour scheme). Errors are sent once per element and kind of failure.
|
|
684
979
|
|
|
685
|
-
| Component | Action | Name | Value
|
|
686
|
-
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
687
|
-
| `site-header` | `link-click` (a utility or site link) | the link's label |
|
|
688
|
-
| `site-header` | `menu-open` (the phone Menu popover) | |
|
|
689
|
-
| `site-header` | `skip-link`, `logo-click` | |
|
|
690
|
-
| `site-header` | `color-scheme` | `light`, `dark` or `system` |
|
|
691
|
-
| `site-main-nav` | `menu-open` (a group opens, not closes) | the group's label |
|
|
692
|
-
| `site-main-nav` | `link-click` | `Group > Link` (a top-level link: its label) |
|
|
693
|
-
| `site-footer` | `link-click` (not the pre-footer's) | `Column: Link`, e.g. `About: Staff directory`; `Contact us: Phone`, `Contact us: Email`; `Social: Facebook`, `Social: Instagram` |
|
|
694
|
-
| `uvalib-breadcrumbs` | `link-click` | `level N` (never the label) | N, from 1
|
|
695
|
-
| `uvalib-card` | `card-click` | `single`, or the card's place in its grid (`1`, `2`, …); never the title or URL | that place, from 1, in a grid
|
|
696
|
-
| `uvalib-pager` | `page-change` | `next`, `previous` or `number` (never the label or URL) | the page, for `number` only
|
|
697
|
-
| `uvalib-
|
|
698
|
-
| `uvalib-
|
|
699
|
-
| `uvalib-
|
|
700
|
-
| `uvalib-
|
|
701
|
-
| `
|
|
702
|
-
| `
|
|
703
|
-
| `
|
|
704
|
-
| `
|
|
705
|
-
| `
|
|
706
|
-
| `site-
|
|
707
|
-
| `site-
|
|
708
|
-
| `
|
|
709
|
-
| `
|
|
710
|
-
| `
|
|
711
|
-
| `
|
|
712
|
-
| `
|
|
713
|
-
| `
|
|
714
|
-
| `
|
|
715
|
-
| `
|
|
716
|
-
|
|
717
|
-
|
|
980
|
+
| Component | Action | Name | Value |
|
|
981
|
+
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
982
|
+
| `site-header` | `link-click` (a utility or site link) | the link's label | |
|
|
983
|
+
| `site-header` | `menu-open` (the phone Menu popover) | | |
|
|
984
|
+
| `site-header` | `skip-link`, `logo-click` | | |
|
|
985
|
+
| `site-header` | `color-scheme` | `light`, `dark` or `system` | |
|
|
986
|
+
| `site-main-nav` | `menu-open` (a group opens, not closes) | the group's label | |
|
|
987
|
+
| `site-main-nav` | `link-click` | `Group > Link` (a top-level link: its label) | |
|
|
988
|
+
| `site-footer` | `link-click` (not the pre-footer's) | `Column: Link`, e.g. `About: Staff directory`; `Contact us: Phone`, `Contact us: Email`; `Social: Facebook`, `Social: Instagram` | |
|
|
989
|
+
| `uvalib-breadcrumbs` | `link-click` | `level N` (never the label) | N, from 1 |
|
|
990
|
+
| `uvalib-card` | `card-click` | `single`, or the card's place in its grid (`1`, `2`, …); never the title or URL | that place, from 1, in a grid |
|
|
991
|
+
| `uvalib-pager` | `page-change` | `next`, `previous` or `number` (never the label or URL) | the page, for `number` only |
|
|
992
|
+
| `uvalib-pager` | `load-more` | (empty) | the next page |
|
|
993
|
+
| `uvalib-tabs` | `change` | the tab's label (capped at 100 characters; not a URL) | |
|
|
994
|
+
| `uvalib-contents` | `link-click` | `level N` (never the label or URL) | N, from 1 (the top level) |
|
|
995
|
+
| `uvalib-contents` | `toggle` (the narrow-screen disclosure) | `open` or `close` | |
|
|
996
|
+
| `uvalib-metadata` | `copy-citation` (downloads are left to Matomo's own download tracking) | | |
|
|
997
|
+
| `uvalib-lightbox` | `open`, `next`, `previous`, `full-size` | `image N` (never the URL or the caption) | N, from 1 |
|
|
998
|
+
| `uvalib-tag-list` | `tag-click` | `list N` (the list's place on the page), or with `track-label` the list's own fixed `label`; never the tag's text or URL | the tag's place, from 1 |
|
|
999
|
+
| `uvalib-tag-list` | `show-all`, `show-fewer` | `list N`, or with `track-label` the `label` | |
|
|
1000
|
+
| `site-alerts` | a content impression, once per alert per page view: `trackContentImpression('Library alert', '<severity>: <title>')` | | |
|
|
1001
|
+
| `site-alerts` | `dismiss`, `link-click` (a link in an alert's text) | `<severity>: <title>` | |
|
|
1002
|
+
| `site-alerts` | `error` (the alerts script failed to load) | `alerts-script` | |
|
|
1003
|
+
| `events-section` | `event-click` | the `category` id, or `all` | the event's position, from 1 |
|
|
1004
|
+
| `events-section` | `error` | `events-load` | |
|
|
1005
|
+
| `site-hours-section` | `link-click` | `See all hours` | |
|
|
1006
|
+
| `site-hours-section`, `library-weekly-hours` | `error` | `hours-load` | |
|
|
1007
|
+
| `library-weekly-hours` | `week-change` | `next` or `previous` | |
|
|
1008
|
+
| `uvalib-chip-group` | `change` (single: 1 s after the last change, and only if it differs from where it started; multi: each toggle) | `<group label>: <chip label>` | the chip's count, when it has one |
|
|
1009
|
+
| `uvalib-chip-group` | `select` (links mode) | the group's label (never the chip or its URL) | |
|
|
1010
|
+
| `uvalib-filter` | `facet-change` | `<filter title>: <value>` (the facet value as the search service returns it, such as a format, library or subject; cut at 100 characters) | 1 checked, 0 unchecked |
|
|
1011
|
+
| `uvalib-filter` | `scope-change` | the scope's label | 1 pressed, 0 not |
|
|
1012
|
+
| `uvalib-filter` | `see-more`, `see-less` | the filter's title | |
|
|
1013
|
+
| `uvalib-date-range` | `range-change` (1 s after the last change, and only if the years differ) | `<from year>–<to year>` | |
|
|
1014
|
+
| `uvalib-date-histogram` | `select` (not when the selection is cleared, set in script, or restored from a date range) | `<from>–<to>` when both ends are ISO dates, otherwise `other` | |
|
|
1015
|
+
| `bento-box` | `result-click` | the section (`Virgo catalog`, `Virgo articles`, `Subject guides`, `Library website`) | the result's position, from 1 |
|
|
1016
|
+
| `bento-box` | `see-all-click`, `retry` | the section | |
|
|
1017
|
+
| `bento-box` | `error` | `section-load: <section>` | |
|
|
1018
|
+
|
|
1019
|
+
`<bento-box>` also sends a Matomo site search per section once its results are in (not on an error, not again on a re-render): the query, the section as category, and the section's total (0 when nothing was found). A new query, also by Back or Forward, is a new search. The `<library-weekly-hours>` elements `<library-hours-setup>` creates report as `library-weekly-hours`. Alert severities are `Critical`, `Warning`, `Information`, `Header` or `Regional warning` / `Regional information`. Names are capped at 100 characters. `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing.
|
|
718
1020
|
|
|
719
1021
|
- **Privacy.** The components never send URLs, paths, record titles, ids, email addresses or phone numbers, or anything a visitor typed: only the fixed names above, positions and counts, labels of the library's own links, and the titles of library alerts (written by the library for everyone). The one exception is search: bento-box's queries are what visitors typed, and are sent as Matomo site searches.
|
|
720
1022
|
- **Opting out.** Nothing is sent from a component, a `data-uvalib-track` element or an event fired by hand when:
|
|
@@ -1341,13 +1643,14 @@ A breadcrumb trail, as on library.virginia.edu: links separated by slashes, endi
|
|
|
1341
1643
|
|
|
1342
1644
|
### `<uvalib-card>`
|
|
1343
1645
|
|
|
1344
|
-
One card: a collection (title and “N texts”), a photo (image, count, date, category, title, excerpt) or any other raised summary. With `href`, the heading is the link and a pseudo-element stretches that link over the card, so the whole card is one click. The arrow is only a visual aid. The card is never wrapped in an `<a>`. A clickable card must not contain another link, button or other control: the stretched link covers it. A static card (no `href`, or an empty or unsafe one) has no stretch, so its excerpt may contain links. With `href`, the heading needs an accessible name (text, or an image `alt` or `aria-label`); otherwise the link is hidden. Regions are light-DOM children. Give `slot="media"`, `slot="badge"`, `slot="heading"`, `slot="meta"` or `slot="
|
|
1646
|
+
One card: a collection (title and “N texts”), a photo (image, count, date, category, title, excerpt) or any other raised summary. With `href`, the heading is the link and a pseudo-element stretches that link over the card, so the whole card is one click. The arrow is only a visual aid. The card is never wrapped in an `<a>`. A clickable card must not contain another link, button or other control: the stretched link covers it. A static card (no `href`, or an empty or unsafe one) has no stretch, so its excerpt and `actions` slot may contain links. With `href`, the heading needs an accessible name (text, or an image `alt` or `aria-label`); otherwise the link is hidden. `media-shape="circle"` draws the media as a centered circle, for a person or avatar. The image keeps its alt, and the count badge still sits on it. Any other shape is ignored. Regions are light-DOM children. Give `slot="media"`, `slot="badge"`, `slot="heading"`, `slot="meta"`, `slot="chip"` or `slot="actions"`; anything else (including text) is the excerpt. An image needs a real alt, or `alt=""` when the heading already names it. A date belongs in `<time>` in the meta slot. One element per chip. `actions` is a row of links or buttons on a static card (“Read the story”, “Photos (132)”). The heading level defaults like `<events-section>`: one below the nearest heading before the card, or 3 when there is none. `heading-level` (1–6) wins. An invalid value is ignored.
|
|
1345
1647
|
|
|
1346
1648
|
#### Attributes
|
|
1347
1649
|
|
|
1348
1650
|
| Attribute | Type | Default | Description |
|
|
1349
1651
|
|---|---|---|---|
|
|
1350
1652
|
| `href` | `string \| undefined` | | Makes the card one link: the heading stretches over the card. Empty is not a link. |
|
|
1653
|
+
| `media-shape` | `string` | `''` | `circle` crops the media to a centered circle and keeps the image alt. Anything else is ignored, with one console warning. |
|
|
1351
1654
|
| `heading-level` | `number \| undefined` | | Heading level of the title, 1–6. Unset, it is one below the nearest heading before this card, or 3 when there is none. Any other value is ignored. |
|
|
1352
1655
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1353
1656
|
| `no-style` | `boolean` | `false` | |
|
|
@@ -1361,6 +1664,7 @@ One card: a collection (title and “N texts”), a photo (image, count, date, c
|
|
|
1361
1664
|
| `heading` | The card title. With `href`, this heading’s link is the card, so it needs an accessible name. |
|
|
1362
1665
|
| `meta` | Date (`<time>`) or byline, under the title. |
|
|
1363
1666
|
| `chip` | Category. One element per chip. |
|
|
1667
|
+
| `actions` | Links or buttons on a static card. A clickable card must not contain them; the card link covers them. |
|
|
1364
1668
|
| (default) | Excerpt. A static card may put links here; a clickable card must not contain other controls. |
|
|
1365
1669
|
|
|
1366
1670
|
#### Events
|
|
@@ -1412,6 +1716,45 @@ A grid of `<uvalib-card>` elements. It is a list, so a screen reader announces h
|
|
|
1412
1716
|
|---|---|---|
|
|
1413
1717
|
| `--uvalib-card-min` | | Set from `min-card-width` when that value is a length. The grid uses it as the `auto-fill` minimum. |
|
|
1414
1718
|
|
|
1719
|
+
### `<uvalib-chip-group>`
|
|
1720
|
+
|
|
1721
|
+
A row of chips: a segmented control or single-select filter (`mode="single"`), filter chips that toggle (`mode="multi"`), or suggestion chips that go somewhere (`mode="links"`), as in a year rail with counts (“2005 213”), a sort toggle (“Most photos \| Date \| Title A–Z”) or “Try: snow on the Lawn”. Give the chips as children, `<button value="2005" data-count="213">2005</button>` (the value is the `value` attribute, else `data-value`, else the text; `disabled` disables), or `<a href>` in `links` mode, or set the `items` property (`{ value, label, count?, href?, disabled? }`), which wins over the children while set. The chips follow later changes to the children. `single`: native radios drawn as chips, in a `role="radiogroup"` named by `label`. Tab enters the group at the selected chip, the arrow keys move and select (as any radio group), and `value` is the selected chip's value. `multi`: toggle buttons with `aria-pressed`, and `value` is an array (as an attribute, comma-separated). `links`: links, or buttons that fire `select`, with no selected state; a chip whose href is unsafe (`javascript:`) is plain text, and an empty href is a button. A count is shown in a smaller muted span after the label and read as part of the name: “2005, 213 items”, with `count-label` in place of “items”. A selected chip is filled, keeps its border and shows a tick. Chips wrap on a narrow screen; `scroll` keeps them on one row that scrolls sideways, with its scrollbar shown and a fade at an edge with more chips. Each chip is a target at least 44px square. `segmented` joins the chips into one bar that does not wrap (a long label wraps inside its segment), like the header's Light / Dark / System control. `url-param` (for example `year`) keeps the value in the address (`?year=2005`, a multi value comma-separated, inside the hash on a hash route). It is read on connect; the markup's `value` stands for the address without the parameter, and any other value is written, an empty one as `?year=`. Each change is one `pushState`: in `multi` at once, in `single` once the visitor settles (a second after the last change, so arrowing through a year rail adds one entry, none if it ends where it started). Back and Forward are followed and fire `change` with `restored: true`.
|
|
1722
|
+
|
|
1723
|
+
#### Attributes
|
|
1724
|
+
|
|
1725
|
+
| Attribute | Type | Default | Description |
|
|
1726
|
+
|---|---|---|---|
|
|
1727
|
+
| `mode` | `ChipGroupMode` | `'single'` | `single` (radios: one value), `multi` (toggles: an array of values) or `links`. |
|
|
1728
|
+
| `label` | `string` | `''` | The group's accessible name (required), also the first part of the analytics name. |
|
|
1729
|
+
| `value` | `string \| string[]` | `''` | The selection: a chip's value in `single`, an array of values in `multi` (as an attribute, comma-separated). Setting it does not fire `change`. Unused in `links`. |
|
|
1730
|
+
| `count-label` | `string` | `'items'` | The word after a count in each chip's accessible name: “2005, 213 items”. |
|
|
1731
|
+
| `scroll` | `boolean` | `false` | One row that scrolls sideways instead of wrapping. |
|
|
1732
|
+
| `segmented` | `boolean` | `false` | Join the chips into one segmented bar. |
|
|
1733
|
+
| `url-param` | `string` | `''` | Query parameter that keeps the value in the address, for example `year` → `?year=2005`. |
|
|
1734
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1735
|
+
| `no-style` | `boolean` | `false` | |
|
|
1736
|
+
|
|
1737
|
+
#### Events
|
|
1738
|
+
|
|
1739
|
+
| Event | Description |
|
|
1740
|
+
|---|---|
|
|
1741
|
+
| `change` | The visitor changed the selection (`single`, `multi`), or Back or Forward changed it through `url-param`: `detail` is `{ value, restored? }` (a string in `single`, an array in `multi`; `restored` is true for Back and Forward). Not fired when the app sets `value`. Bubbles and is composed. |
|
|
1742
|
+
| `select` | `links` mode: a chip was chosen. `detail` is `{ value, href? }`. For a link, a plain primary click fires it cancelable: cancel it (`preventDefault()`) to route in the app, and the click's default is prevented too. Bubbles and is composed. |
|
|
1743
|
+
| `uvalib-analytics-event` | For `<site-analytics>`, on the visitor's actions only: `['uvalib-chip-group', 'change', '<label>: <chip label>', <count>?]` (in `single`, one second after the last change, for the chip then selected; in `multi`, for the chip toggled), and `['uvalib-chip-group', 'select', '<label>']` in `links` mode (never the chip or its URL). The count is sent when it is a number. Bubbles and is composed. |
|
|
1744
|
+
|
|
1745
|
+
#### CSS custom properties
|
|
1746
|
+
|
|
1747
|
+
| Property | Default | Description |
|
|
1748
|
+
|---|---|---|
|
|
1749
|
+
| `--uva-color-surface-raised` | | Dark-mode role token: chip background (else #fff). |
|
|
1750
|
+
| `--uva-color-control-border` | | Dark-mode role token: chip border (else `--uva-grey`, #808080). |
|
|
1751
|
+
| `--uva-color-link` | | Dark-mode role token: chip text and hover border (else `--uva-brand-blue`). |
|
|
1752
|
+
| `--uva-color-text-muted` | | Dark-mode role token: the count (else #4f4f4f). |
|
|
1753
|
+
| `--uva-color-accent-bg` | | Dark-mode role token: selected chip background and border (else `--uva-brand-blue`). |
|
|
1754
|
+
| `--uva-color-on-accent` | | Dark-mode role token: selected chip text (else #fff). |
|
|
1755
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1756
|
+
| `--uva-color-surface` | | Dark-mode role token: the page background the scrolling row fades into at an edge with more chips (else #fff). |
|
|
1757
|
+
|
|
1415
1758
|
### `<uvalib-contents>`
|
|
1416
1759
|
|
|
1417
1760
|
Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a `<nav>` landmark (named by `label`, "Contents" by default) with the label as a visible headline, and a nested list of links with dividers between the top-level entries and a bar beside each nested level. Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>` (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any depth. Other children (a heading) are ignored. The list follows changes to the children. Apps set the `items` property instead (`{ label, href?, children? }`, winning over the children while set). The current entry gets `aria-current`: `page` for the link to this page, `location` for the link to the section of it in the URL's hash. It is found from the page URL (path, and hash for in-page sections), followed through same-document navigations (`hashchange`, `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like the links). An entry whose href has a query string matches only that query (`?part=2`); one without matches the page whatever its query. Hash-only hrefs are places on that page. With `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is used instead, the first of each kind. `lang` and `dir` on the source links and items, and inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element, never as HTML), are kept. On narrow screens the list collapses into a disclosure: the headline becomes a button with `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents does on phones, so the text comes first) until the reader opens it, or while the `open` attribute is set; opening it shows the current entry. Narrow means the viewport (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is always far narrower than 64rem, so a container query could not tell a phone from a desktop. `sticky` keeps it in view in a sidebar on wide screens; a list longer than the window then scrolls, and the current entry is scrolled into view inside it (never the page). Single-page apps: the list is drawn from copies of the children, so a router's own click handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in place; hash links need nothing.
|
|
@@ -1455,6 +1798,65 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
1455
1798
|
| `--uva-color-surface-raised` | | Dark-mode role token: the button's background (else #fff). |
|
|
1456
1799
|
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1457
1800
|
|
|
1801
|
+
### `<uvalib-date-histogram>`
|
|
1802
|
+
|
|
1803
|
+
Monthly or yearly counts as bars: a date distribution for a search page, an archive timeline or a card. Give `items` (`{ date, count }`, `date` a `YYYY` or `YYYY-MM`) or a child `<table>` (the no-JS fallback). `granularity="month"` draws twelve bars for every year from the first date to the last, including months with a count of zero. A year-only count in a month chart, a day, or any other date is a chip beside the chart. Each bar is a button named like "October 2015: 5,311 photos". Arrow keys move between bars; Enter or Space selects. `selected` is one bucket (`2015-10`, `2015`) or a range (`2015-03/2016-01`, also `..` or an en dash). The selection is `aria-pressed`, an inset ring and a stripe, not colour alone. Choosing a bar fires `select` with `{ from, to }` as ISO dates (a month runs from its first day to its last). Choosing the selected bar again clears it (`from` and `to` are empty strings). `range-for` is the id of a `<uvalib-date-range>`. A bar click sets that element's `value`. Its `date-range-change` (and its `value` when this element connects, reconnects, or the range is added later) highlights the buckets that overlap the range. A value that is exactly the range's own `min` and `max` is no selection. Setting `selected` here updates the date range; setting the date range's `value` in script does not, unless this element connects afterwards or the range fires `date-range-change`. `variant="strip"` is the small per-year row for a card: not interactive, `role="img"`, one bar per year whatever `granularity` is. The chart reserves its height before the counts arrive: one bar track, or one track per year when those years are already known from the data, a linked date range or the table (`--uvalib-date-histogram-bar-size`, 8rem, plus the year-row gap). Filling the bars in does not move the page. On a narrow screen a month row scrolls inside the component; "Scroll sideways to see more." shows while it overflows. Years wrap.
|
|
1804
|
+
|
|
1805
|
+
#### Attributes
|
|
1806
|
+
|
|
1807
|
+
| Attribute | Type | Default | Description |
|
|
1808
|
+
|---|---|---|---|
|
|
1809
|
+
| `items` | `HistogramItem[]` | `[]` | Counts to draw. When non-empty, wins over the child table. Set a new array to update. |
|
|
1810
|
+
| `granularity` | `'year' \| 'month'` | `'month'` | `month` (twelve bars per year) or `year`. Anything else is month, with one console warning. |
|
|
1811
|
+
| `scale` | `'linear' \| 'log'` | `'linear'` | `log` scales bar height by log(count + 1). Anything else is linear. |
|
|
1812
|
+
| `selected` | `string` | `''` | One bucket (`2015-10` or `2015`) or a range (`2015-03/2016-01`). A linked date range writes a range here. Empty when nothing is selected. |
|
|
1813
|
+
| `range-for` | `string` | `''` | Id of a `<uvalib-date-range>` to keep in step with, both ways. |
|
|
1814
|
+
| `variant` | `string` | `''` | `strip`: a non-interactive per-year row (`role="img"`). Anything else is the bar chart. |
|
|
1815
|
+
| `unit` | `string` | `'items'` | Word after the count in each bar's name. Plural; a count of one drops a trailing s. |
|
|
1816
|
+
| `label` | `string` | `'Dates'` | Accessible name of the bar group, and the start of the strip's summary. |
|
|
1817
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1818
|
+
| `no-style` | `boolean` | `false` | |
|
|
1819
|
+
|
|
1820
|
+
#### Slots
|
|
1821
|
+
|
|
1822
|
+
| Slot | Description |
|
|
1823
|
+
|---|---|
|
|
1824
|
+
| (default) | A `<table>` of dates and counts: two columns (date, count) or a year-by-month grid. Without JavaScript it is the fallback. With JavaScript it supplies the counts when `items` is empty. Show as table lists those counts, including odd dates; once `items` is set it lists `items` instead. |
|
|
1825
|
+
|
|
1826
|
+
#### CSS parts
|
|
1827
|
+
|
|
1828
|
+
| Part | Description |
|
|
1829
|
+
|---|---|
|
|
1830
|
+
| `chart` | The bar chart (shadow mode). |
|
|
1831
|
+
| `bar` | A bar button, or a strip segment (shadow mode). |
|
|
1832
|
+
| `table` | The generated table in Show as table (shadow mode). |
|
|
1833
|
+
|
|
1834
|
+
#### Events
|
|
1835
|
+
|
|
1836
|
+
| Event | Description |
|
|
1837
|
+
|---|---|
|
|
1838
|
+
| `select` | A bar or an odd-date chip was chosen, or the current one chosen again to clear it. `detail` is `{ from, to }` (ISO dates, or the odd token). Empty strings clear the selection. Not fired when `selected` is set in script or when a linked date range changes. Bubbles and is composed. |
|
|
1839
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-date-histogram', 'select', '<from>–<to>']` when both ends are ISO dates, or `'other'` for any other choice. Not fired when the selection is cleared, set in script, or restored from a date range. Bubbles and is composed. |
|
|
1840
|
+
|
|
1841
|
+
#### CSS custom properties
|
|
1842
|
+
|
|
1843
|
+
| Property | Default | Description |
|
|
1844
|
+
|---|---|---|
|
|
1845
|
+
| `--uvalib-date-histogram-bar-size` | `8rem` | Height of each bar track. The chart reserves one track, or one per known year, before the counts arrive. |
|
|
1846
|
+
| `--uvalib-date-histogram-strip-size` | `1.5rem` | Height of `variant="strip"`. |
|
|
1847
|
+
| `--uva-brand-blue` | `#232d4b` | Bar fill. |
|
|
1848
|
+
| `--uva-brand-orange` | `#e57200` | Focus ring when `--uva-color-focus` is unset. |
|
|
1849
|
+
| `--uva-font-family` | `inherit` | Font family. |
|
|
1850
|
+
| `--uva-color-accent-bg` | | Dark-mode role token: bar fill (else `--uva-brand-blue`). |
|
|
1851
|
+
| `--uva-color-on-accent` | | Dark-mode role token: the selection stripe (else #fff). |
|
|
1852
|
+
| `--uva-color-text` | | Dark-mode role token: labels and the selection ring (else #2b2b2b). |
|
|
1853
|
+
| `--uva-color-text-muted` | | Dark-mode role token: the scroll hint (else #4b5563). |
|
|
1854
|
+
| `--uva-color-track` | | Dark-mode role token: the empty part of a bar (else #e5e7eb). |
|
|
1855
|
+
| `--uva-color-surface` | | Dark-mode role token: the sticky year label (else #fff). |
|
|
1856
|
+
| `--uva-color-surface-raised` | | Dark-mode role token: odd-date chips (else #fff). |
|
|
1857
|
+
| `--uva-color-control-border` | | Dark-mode role token: bar, chip and table borders (else #808080). |
|
|
1858
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1859
|
+
|
|
1458
1860
|
### `<uvalib-date-range>`
|
|
1459
1861
|
|
|
1460
1862
|
A date-range picker: a two-thumb year slider plus "From" and "To" date inputs. `min` and `max` (ISO dates, `YYYY-MM-DD`) are required; without valid ones the element renders nothing and logs a console warning once. The start can never pass the end, and both stay within `min`..`max`.
|
|
@@ -1663,7 +2065,7 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
|
|
|
1663
2065
|
|
|
1664
2066
|
### `<uvalib-pager>`
|
|
1665
2067
|
|
|
1666
|
-
Previous/next section links, as on a reading page, or a numbered page list. Previous/next: set `prev-href` and `next-href` (either may be omitted). Each link shows a “Previous” or “Next” kicker and, when `prev-label` or `next-label` is set, that title. A visually hidden “: ” sits between them, so the accessible name is punctuated even when CSS is off. A long title truncates visually; the full text stays in the accessible name. The links use `rel="prev"` and `rel="next"`. With neither href, nothing is rendered. Numbered pages: set `pages` (a positive count). `page` is the current page, clamped to `1…pages`. Each link’s href comes from `href-template`, which must contain `{page}` (the default is `?page={page}`). The current page is text with `aria-current="page"`, not a link. Long ranges collapse to the first page, a window around the current page, the last page, and an ellipsis where numbers are skipped. `pages` wins when previous/next attributes are also set, with one console warning. The landmark’s accessible name is `label`, or “Sections” for previous/next and “Pagination” for numbered pages. An empty `label` uses that default. Two pagers on one page need different labels: a repeated landmark name fails the accessibility check.
|
|
2068
|
+
Previous/next section links, as on a reading page, or a numbered page list. Previous/next: set `prev-href` and `next-href` (either may be omitted). Each link shows a “Previous” or “Next” kicker and, when `prev-label` or `next-label` is set, that title. A visually hidden “: ” sits between them, so the accessible name is punctuated even when CSS is off. A long title truncates visually; the full text stays in the accessible name. The links use `rel="prev"` and `rel="next"`. With neither href, nothing is rendered. Numbered pages: set `pages` (a positive count). `page` is the current page, clamped to `1…pages`. Each link’s href comes from `href-template`, which must contain `{page}` (the default is `?page={page}`). The current page is text with `aria-current="page"`, not a link. Long ranges collapse to the first page, a window around the current page, the last page, and an ellipsis where numbers are skipped. `pages` wins when previous/next attributes are also set, with one console warning. Load more: `mode="load-more"` shows a “Load more” button and “Showing N of M” (`shown` of `total`). It wins over numbered pages and previous/next, with one warning when those are also set. The button is not a link and the control is a group, not a navigation landmark. The button hides once `shown` has reached a positive `total`. `page` is the last loaded page (default 1). A click fires `load-more` with `{ page }` set to the next page and reports `['uvalib-pager', 'load-more', '', page]`. Nothing is reported on render. Call `loaded(firstNewElement)`, or set `for` to a list id and call `loaded()`, and focus moves to that new item. The landmark’s accessible name is `label`, or “Sections” for previous/next and “Pagination” for numbered pages. Load more uses `label` or “More results”. An empty `label` uses that default. Two pagers on one page need different labels: a repeated landmark name fails the accessibility check.
|
|
1667
2069
|
|
|
1668
2070
|
#### Attributes
|
|
1669
2071
|
|
|
@@ -1673,7 +2075,11 @@ Previous/next section links, as on a reading page, or a numbered page list. Prev
|
|
|
1673
2075
|
| `prev-label` | `string \| undefined` | | Title of the previous section, under the “Previous” kicker. |
|
|
1674
2076
|
| `next-href` | `string \| undefined` | | Href of the next section. Omitted, that side is not shown. |
|
|
1675
2077
|
| `next-label` | `string \| undefined` | | Title of the next section, under the “Next” kicker. |
|
|
1676
|
-
| `
|
|
2078
|
+
| `mode` | `string \| undefined` | | `load-more` shows a Load more button instead of previous/next or numbered pages. Any other value, including empty, leaves the pager in its other modes. |
|
|
2079
|
+
| `shown` | `number \| undefined` | | How many results are already shown. Used by `mode="load-more"` as N in “Showing N of M”. |
|
|
2080
|
+
| `total` | `number \| undefined` | | How many results there are. Used by `mode="load-more"` as M in “Showing N of M”. |
|
|
2081
|
+
| `for` | `string \| undefined` | | Id of the list Load more appends to. `loaded()` focuses the first child added after the click. Ignored when `loaded` is passed an element. |
|
|
2082
|
+
| `page` | `number \| undefined` | | Current page, from 1. Clamped to `pages`. Used when `pages` is set. In load-more, the last loaded page (default 1); a click asks for the next one. |
|
|
1677
2083
|
| `pages` | `number \| undefined` | | How many pages. A positive number selects numbered pages and ignores previous/next. Zero, negative or non-numeric does not. |
|
|
1678
2084
|
| `href-template` | `string \| undefined` | | Href of each numbered page, with `{page}` where the number goes. Default `?page={page}` when omitted. Without `{page}`, numbered links are not made. |
|
|
1679
2085
|
| `label` | `string \| undefined` | | Accessible name of the navigation landmark. Default “Pagination” for numbered pages and “Sections” for previous/next. Empty uses that default. A second pager on the page needs its own name. |
|
|
@@ -1684,7 +2090,8 @@ Previous/next section links, as on a reading page, or a numbered page list. Prev
|
|
|
1684
2090
|
|
|
1685
2091
|
| Event | Description |
|
|
1686
2092
|
|---|---|
|
|
1687
|
-
| `
|
|
2093
|
+
| `load-more` | A primary click on Load more: `detail` is `{ page }` (the next page). Bubbles and is composed. |
|
|
2094
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: a primary-button click that was not already canceled, including a modified click, on a page link `['uvalib-pager', 'page-change', 'number', <n>]`, on a section link `['uvalib-pager', 'page-change', 'next'\|'previous']`, or on Load more `['uvalib-pager', 'load-more', '', <next page>]`. Never the label or URL. Nothing on render. Bubbles and is composed. |
|
|
1688
2095
|
| `uvalib-pager-navigate` | A plain click on a pager link: `detail` is `{ href, kind, page? }` (`kind` is `'next'`, `'previous'` or `'number'`; `page` is set for `'number'`). Cancel it (`preventDefault()`) to route in the app; the click’s default is then prevented. Bubbles and is composed. |
|
|
1689
2096
|
|
|
1690
2097
|
#### CSS custom properties
|
|
@@ -1697,10 +2104,13 @@ Previous/next section links, as on a reading page, or a numbered page list. Prev
|
|
|
1697
2104
|
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1698
2105
|
| `--uva-color-accent-bg` | | Dark-mode role token: current page background (else `--uva-brand-blue`). |
|
|
1699
2106
|
| `--uva-color-on-accent` | | Text on the current page background (else #fff). |
|
|
2107
|
+
| `--uva-color-button-bg` | | Load more background (else `--uva-blue-alt`). |
|
|
2108
|
+
| `--uva-color-button-text` | | Load more text (else #fff). Dark mode’s own text is dark on the light button. |
|
|
2109
|
+
| `--uva-color-button-hover-bg` | | Load more hover background (else `--uva-blue-alt-A`). |
|
|
1700
2110
|
|
|
1701
2111
|
### `<uvalib-photo-grid>`
|
|
1702
2112
|
|
|
1703
|
-
Justified rows of thumbnails. Each direct child that is a link or a button is one photo; its image keeps its shape from the `width` and `height` attributes, or from the loaded image, so the row does not jump when the picture arrives. The row is about 220px tall and shorter on a phone; `row-height` sets that height. Every item stays a real link or button. An image with no visible text gets a visible caption from its alt (the caption is then the accessible name, and a repeated alt is cleared). The original alt is kept in `data-uvalib-alt` so a lightbox still describes the picture. An item with no name at all is captioned “Photo N” and warned about once; that caption is renumbered when the photos change order. An `aria-label` is left as the name: the grid does not add a caption that would disagree with it. Put the grid inside `<uvalib-lightbox>` and a plain click opens the viewer.
|
|
2113
|
+
Justified rows of thumbnails. Each direct child that is a link or a button is one photo; its image keeps its shape from the `width` and `height` attributes, or from the loaded image, so the row does not jump when the picture arrives. The row is about 220px tall and shorter on a phone; `row-height` sets that height. Every item stays a real link or button. An image with no visible text gets a visible caption from its alt (the caption is then the accessible name, and a repeated alt is cleared). The original alt is kept in `data-uvalib-alt` so a lightbox still describes the picture. An item with no name at all is captioned “Photo N” and warned about once; that caption is renumbered when the photos change order. An `aria-label` is left as the name: the grid does not add a caption that would disagree with it. Put the grid inside `<uvalib-lightbox>` and a plain click opens the viewer. A badge sits on the thumbnail: `<span slot="badge">` inside the link or button, or `data-badge` on that item (for example “seq” or “3 photos”). It is read after the caption (“The Lawn, 3 photos”). When the item already has an `aria-label`, the badge is appended to that label (the author’s words stay in `data-uvalib-label`) and an alt that repeats those words is cleared. A badge does not replace the alt caption.
|
|
1704
2114
|
|
|
1705
2115
|
#### Attributes
|
|
1706
2116
|
|
|
@@ -1714,7 +2124,7 @@ Justified rows of thumbnails. Each direct child that is a link or a button is on
|
|
|
1714
2124
|
|
|
1715
2125
|
| Slot | Description |
|
|
1716
2126
|
|---|---|
|
|
1717
|
-
| (default) | The thumbnails: one `<a href>` or `<button>` per photo, each with an `<img>`. |
|
|
2127
|
+
| (default) | The thumbnails: one `<a href>` or `<button>` per photo, each with an `<img>`. A `<span slot="badge">` inside an item is drawn over that thumbnail. |
|
|
1718
2128
|
|
|
1719
2129
|
#### CSS custom properties
|
|
1720
2130
|
|
|
@@ -1726,6 +2136,112 @@ Justified rows of thumbnails. Each direct child that is a link or a button is on
|
|
|
1726
2136
|
| `--uva-grey-darkest` | `#2b2b2b` | Caption colour when `--uva-color-text` is unset. |
|
|
1727
2137
|
| `--uva-brand-orange` | `#e57200` | Focus ring when `--uva-color-focus` is unset. |
|
|
1728
2138
|
|
|
2139
|
+
### `<uvalib-results-count>`
|
|
2140
|
+
|
|
2141
|
+
The results summary of a search or listing page, such as “Showing 48 of 3,694 shoots”, and a polite live region that tells screen reader users when it changes. Set `total` (how many match), `shown` (how many are on the page) and `noun` (plural, default “results”; `singular` for a total of one). The visible text follows at once: “Showing 48 of 3,694 shoots”, “Showing all 12 shoots” (shown is the total, or unset), “Showing 1 shoot” or “No shoots” (a total of 0, or 0 shown); with only `shown`, “Showing 48 shoots”. Numbers use thousands separators. A missing or blank `shown` or `total` is unset, not 0. The announcement waits until the text has not changed for `announce-delay` milliseconds (default 1000, as `<bento-box>` and `<uvalib-pagefind-search>` settle), so typing in a filter box is announced once. The first render is never announced; when it has no count yet (the data still loading), the first count that arrives is. A count is announced again when it comes back after a different one (a new search with the same number of results), but not when nothing was shown in between. The announcement is cleared from the hidden region five seconds later, so reading the page finds the count once. `<bento-box>` and `<uvalib-pagefind-search>` announce their own counts: use this element for your own listings, not beside them.
|
|
2142
|
+
|
|
2143
|
+
#### Attributes
|
|
2144
|
+
|
|
2145
|
+
| Attribute | Type | Default | Description |
|
|
2146
|
+
|---|---|---|---|
|
|
2147
|
+
| `shown` | `number \| undefined` | | How many results are shown on the page. |
|
|
2148
|
+
| `total` | `number \| undefined` | | How many results match in all. |
|
|
2149
|
+
| `noun` | `string` | `'results'` | What is counted, plural: “results” by default. |
|
|
2150
|
+
| `singular` | `string` | `''` | What is counted, singular, for a total of one. Default: “result” when `noun` is unset, else `noun`. |
|
|
2151
|
+
| `announce-delay` | `number` | `1000` | Milliseconds the text must stay the same before it is announced. |
|
|
2152
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2153
|
+
| `no-style` | `boolean` | `false` | |
|
|
2154
|
+
|
|
2155
|
+
#### CSS parts
|
|
2156
|
+
|
|
2157
|
+
| Part | Description |
|
|
2158
|
+
|---|---|
|
|
2159
|
+
| `text` | The visible summary. |
|
|
2160
|
+
|
|
2161
|
+
#### CSS custom properties
|
|
2162
|
+
|
|
2163
|
+
| Property | Default | Description |
|
|
2164
|
+
|---|---|---|
|
|
2165
|
+
| `--uva-color-text-muted` | | Dark-mode role token: text colour (else `--uva-grey-A`, #4f4f4f). |
|
|
2166
|
+
|
|
2167
|
+
### `<uvalib-tabs>`
|
|
2168
|
+
|
|
2169
|
+
Tabs, as on library.virginia.edu: a row of buttons over one visible panel. Each panel is a child with `data-tab="Events"` (and an `id` when the tab should be linkable). Or put `<button slot="tab">` elements first and one panel element after each; the button text is the label and those buttons are hidden, because the component draws the real tabs. The selected panel stays visible across the upgrade. With `base.css`, later `data-tab` panels stay hidden before the element upgrades, and space is reserved for the tab row so the first panel does not jump. The tab row wraps on a narrow screen. Arrow keys, Home and End move between tabs. Selection follows the arrow unless `activation="manual"`, in which case Enter or Space selects the focused tab. `selected` is the panel id (a label or a 0-based index also selects). It reflects the panel id. `url-param` writes that id into the query string, or into the hash when the page is a hash route (`#/stories?tab=events`). `url-param="hash"` uses the hash itself (`#events`) and leaves a hash route (`#/…`) alone.
|
|
2170
|
+
|
|
2171
|
+
#### Attributes
|
|
2172
|
+
|
|
2173
|
+
| Attribute | Type | Default | Description |
|
|
2174
|
+
|---|---|---|---|
|
|
2175
|
+
| `selected` | `string` | `''` | The selected tab. A panel id, the tab label, or a 0-based index. Reflects the panel id once the tabs have been read. Empty selects the first tab. |
|
|
2176
|
+
| `activation` | `string` | `''` | `manual`: arrow keys move focus and Enter or Space selects. Anything else, including empty, selects as the arrow moves. |
|
|
2177
|
+
| `url-param` | `string` | `''` | Name of the query parameter that stores the selected panel id, so the tab is linkable and Back restores it. `hash` stores it in the hash (`#panel-id`) instead. Empty does not touch the URL. |
|
|
2178
|
+
| `label` | `string` | `''` | Accessible name of the tab list. Empty uses “Tabs”. |
|
|
2179
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2180
|
+
| `no-style` | `boolean` | `false` | |
|
|
2181
|
+
|
|
2182
|
+
#### Slots
|
|
2183
|
+
|
|
2184
|
+
| Slot | Description |
|
|
2185
|
+
|---|---|
|
|
2186
|
+
| (default) | The panels. Each element with `data-tab` is a panel, or each element that is not a `slot="tab"` button. |
|
|
2187
|
+
| `tab` | A `<button>` whose text labels the panel that follows. Hidden once the tabs are drawn. |
|
|
2188
|
+
|
|
2189
|
+
#### Events
|
|
2190
|
+
|
|
2191
|
+
| Event | Description |
|
|
2192
|
+
|---|---|
|
|
2193
|
+
| `change` | The selected tab changed after the first render, including a script setting `selected` and the Back button. `detail` is `{ id, label, index }` (`id` is the panel id, `index` from 0). Not fired on the first render. Bubbles and is composed. |
|
|
2194
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: a click or arrow-key selection, `['uvalib-tabs', 'change', '<tab label>']`. The label is cut to 100 characters. Not fired on the first render, when `selected` is set from script, or when Back or the hash restores a tab. |
|
|
2195
|
+
|
|
2196
|
+
#### CSS custom properties
|
|
2197
|
+
|
|
2198
|
+
| Property | Default | Description |
|
|
2199
|
+
|---|---|---|
|
|
2200
|
+
| `--uva-color-button-bg` | | Dark-mode role token: unselected tab background (else `--uva-blue-alt-base`). |
|
|
2201
|
+
| `--uva-color-button-text` | | Text on an unselected tab (else #fff). |
|
|
2202
|
+
| `--uva-color-button-hover-bg` | | Dark-mode role token: unselected tab hover (else `--uva-blue-alt-dark`). |
|
|
2203
|
+
| `--uva-color-accent-bg` | | Dark-mode role token: selected tab background (else `--uva-brand-blue`). |
|
|
2204
|
+
| `--uva-color-on-accent` | | Selected tab text and the selected underline (else #fff). |
|
|
2205
|
+
| `--uva-color-focus` | | Dark-mode role token: focus outline (else `--uva-brand-orange`). |
|
|
2206
|
+
| `--uva-blue-alt-base` | `#007BAC` | Unselected tab when `--uva-color-button-bg` is unset. |
|
|
2207
|
+
| `--uva-blue-alt-dark` | `#005679` | Unselected hover when `--uva-color-button-hover-bg` is unset. |
|
|
2208
|
+
| `--uva-brand-blue` | `#232D4B` | Selected tab when `--uva-color-accent-bg` is unset. |
|
|
2209
|
+
| `--uva-brand-orange` | `#E57200` | Focus outline when `--uva-color-focus` is unset. |
|
|
2210
|
+
|
|
2211
|
+
### `<uvalib-tag-list>`
|
|
2212
|
+
|
|
2213
|
+
A labelled list of keywords or subjects that wraps: each tag a link (for example a search for that term) or plain text. Link tags are outlined pills in the link colour; plain tags are filled chips (the card chip's colours), so a link never looks like a label. Every tag and the toggle are at least 2rem (34px) tall and wide, 0.5rem apart. Give the tags as children: `<a href>` for a link, any other element (`<span>`) for plain text. A child's `lang` and `dir` are kept, and so is inline markup inside it (`em`, `cite`, `abbr`, `bdi`, a `span lang`…), copied element by element (never parsed as HTML). Or set `href-template` (with `{tag}`, replaced by the URL-encoded text) to make every tag without its own href a link; a blank href counts as none. Apps can set the `items` property (`{ label, href?, lang?, dir? }`) instead; it wins over the children. Children with no text are skipped with one warning. `label` names the list (shown above it, or visually hidden with `hide-label`); without one a console warning is logged. `limit` shows that many tags and a “Show all N” button (`aria-expanded`, `aria-controls`), which reveals the rest in place and keeps focus. Analytics never sends a tag's text (record tags can be user-submitted or machine-made), and by default not the label either, which a template may fill from a record: the name is the list's place among the tag lists on the page, `list N`. Add `track-label` when the label is fixed text the page author wrote (“Subjects”), to send it instead.
|
|
2214
|
+
|
|
2215
|
+
#### Attributes
|
|
2216
|
+
|
|
2217
|
+
| Attribute | Type | Default | Description |
|
|
2218
|
+
|---|---|---|---|
|
|
2219
|
+
| `label` | `string` | `''` | The list's name: shown above the tags (and, with `track-label`, the analytics name). |
|
|
2220
|
+
| `hide-label` | `boolean` | `false` | Hide the label visually; it still names the list. |
|
|
2221
|
+
| `track-label` | `boolean` | `false` | Send the label as the analytics name. Only for fixed text the page author wrote, never a label filled from a record. Without it the name is `list N`. |
|
|
2222
|
+
| `limit` | `number \| undefined` | | Show this many tags and a “Show all N” button. Zero or empty shows every tag. |
|
|
2223
|
+
| `href-template` | `string` | `''` | Href for tags without their own, with `{tag}` where the URL-encoded text goes, for example `/search?q={tag}`. Empty: such tags are plain text. |
|
|
2224
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2225
|
+
| `no-style` | `boolean` | `false` | |
|
|
2226
|
+
|
|
2227
|
+
#### Events
|
|
2228
|
+
|
|
2229
|
+
| Event | Description |
|
|
2230
|
+
|---|---|
|
|
2231
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: a primary-button click on a tag link, `['uvalib-tag-list', 'tag-click', '<name>', <n>]` (n from 1, the tag's place in the list), and the toggle, `['uvalib-tag-list', 'show-all'\|'show-fewer', '<name>']`. The name is `list N` (N from 1, the list's place among the tag lists in its document or shadow root), or with `track-label` the list's `label`; never the tag text or URL. Bubbles and is composed. |
|
|
2232
|
+
| `uvalib-tag-list-navigate` | A plain click on a tag link: `detail` is `{ href, tag, index }` (index from 0). Cancel it (`preventDefault()`) to route in the app; the click's default is then prevented. Bubbles and is composed. |
|
|
2233
|
+
|
|
2234
|
+
#### CSS custom properties
|
|
2235
|
+
|
|
2236
|
+
| Property | Default | Description |
|
|
2237
|
+
|---|---|---|
|
|
2238
|
+
| `--uva-blue-alt-300` | `#BFE7F7` | Plain tag background (the card chip's). |
|
|
2239
|
+
| `--uva-blue-alt-dark` | `#005679` | Plain tag text. |
|
|
2240
|
+
| `--uva-color-link` | | Dark-mode role token: link tag text (else `--uva-brand-blue`). |
|
|
2241
|
+
| `--uva-color-control-border` | | Dark-mode role token: link tag outline (else `--uva-grey`). |
|
|
2242
|
+
| `--uva-color-text` | | Dark-mode role token: the label (else `--uva-grey-darkest`). |
|
|
2243
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
2244
|
+
|
|
1729
2245
|
### `<website-section>`
|
|
1730
2246
|
|
|
1731
2247
|
The library website's first pages (pages, people, libraries, news) matching `query`, from Drupal's search index, with its excerpt (the matched words marked). The index sends no CORS headers, so this section works on library.virginia.edu (or wherever `BentoBox.endpoints.website` points to a same-origin copy) only.
|
|
@@ -1774,7 +2290,7 @@ The library website's first pages (pages, people, libraries, news) matching `que
|
|
|
1774
2290
|
|
|
1775
2291
|
### Quality checks
|
|
1776
2292
|
|
|
1777
|
-
Three automated checks guard accessibility, best practice and performance. The first two run in `pnpm test`; Lighthouse is slower and runs on its own (`pnpm lhci`,
|
|
2293
|
+
Three automated checks guard accessibility, best practice and performance. The first two run in `pnpm test`; Lighthouse is slower and runs on its own (`pnpm lhci`, the `lighthouse` job in the `CI` workflow on pull requests, and the `Pages` workflow on `main`). The results of the last build of `main` are in the [test report](#test-results).
|
|
1778
2294
|
|
|
1779
2295
|
- **axe, at every impact level, at least as strict as Lighthouse.** `expectNoAxeViolations` (`test/helpers/axe.ts`) fails on minor, moderate, serious and critical violations, so best-practice rules such as `heading-order`, `region` and the landmark rules count. It runs every axe rule and also turns on the ones Lighthouse's accessibility audit enables that a default axe run leaves off (`target-size`, `identical-links-same-purpose`, `table-fake-caption`, `td-has-header`), so a component that passes here cannot lose Lighthouse accessibility points to axe. Sites built with the components get the same setup for Playwright in the skill's [accessibility testing guide](skills/uvalib-web-components/reference/accessibility-testing.md). Every visual component is audited in shadow and light DOM, and in the states people use: menus and groups open (the header Menu popover at 390px, `site-main-nav` at 1280px and 390px), `uvalib-filter` expanded with a scope pressed and a box checked, `uvalib-date-range` with the sliders on one year and dates typed, the hours elements loading, loaded and failing, and `events-section` loading, loaded, empty and failing, on its own and in home-page markup in light and dark. Full-page tests use `expectNoPageAxeViolations`, which audits the whole document so the rules that only match `<html>` (`landmark-one-main`, `page-has-heading-one`) run too; it gives the test runner's bare page a `<title>` and `lang` first, and disables no rule. Tests never reach the network: `test/helpers/*-intercept.mjs` route the alerts, hours, events and main-nav hosts to fixtures.
|
|
1780
2296
|
- **Bundle-size budgets.** `test/size-budget.test.mjs` gzips (level 9) every entry in `dist-cdn/manifest.json` together with every chunk it imports, statically or with `import()` (site-page's lazy site-footer), each counted once, and fails if one exceeds its budget in `test/size-budgets.json` (about 12% over the sizes below). `node scripts/bundle-sizes.mjs` prints today's sizes against the budgets. When a change has to grow a bundle, raise its budget in the same PR and say why.
|
|
@@ -1817,7 +2333,7 @@ pnpm release <patch|minor|major> # lint, test, build, bump, tag vX.Y
|
|
|
1817
2333
|
|
|
1818
2334
|
The first release must be `pnpm release major` (0.0.0 → 1.0.0).
|
|
1819
2335
|
|
|
1820
|
-
Pull requests to `main` run `.github/workflows/ci.yml` in GitHub Actions (install, lint, test, Lighthouse) with a read-only token and no secrets. Pushes to `main` are
|
|
2336
|
+
Pull requests to `main` run `.github/workflows/ci.yml` in GitHub Actions (install, lint, test, Lighthouse) with a read-only token and no secrets. Pushes to `main` are tested and audited with Lighthouse by `.github/workflows/pages.yml`, which publishes the examples site with the [test report](#test-results) twice: as soon as the tests pass, then again with the Lighthouse results. A Lighthouse failure fails the run but still publishes, so the report shows what is over budget; a newer push cancels an older run. The CI workflow's Lighthouse job can also be started by hand (Actions → CI → Run workflow).
|
|
1821
2337
|
|
|
1822
2338
|
One `v*` tag starts two independent releases. Each can be re-run on its own, and no npm token is stored anywhere:
|
|
1823
2339
|
|