@uvalib/web-components 1.2.0 → 1.3.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 +87 -0
- package/README.md +808 -46
- package/dist/analytics.d.ts +10 -0
- package/dist/analytics.js +9 -0
- package/dist/analytics.js.map +1 -0
- package/dist/base/UvalibElement.js +8 -5
- package/dist/base/UvalibElement.js.map +1 -1
- package/dist/base/analytics-state.d.ts +7 -0
- package/dist/base/analytics-state.js.map +1 -1
- package/dist/base/light-dom-styles.d.ts +13 -0
- package/dist/base/light-dom-styles.js +26 -0
- package/dist/base/light-dom-styles.js.map +1 -1
- package/dist/base/search-tracker.d.ts +57 -0
- package/dist/base/search-tracker.js +51 -0
- package/dist/base/search-tracker.js.map +1 -0
- package/dist/base.css +286 -14
- package/dist/base.d.ts +2 -0
- package/dist/base.js +1 -0
- package/dist/base.js.map +1 -1
- package/dist/components/site-analytics/SiteAnalytics.d.ts +20 -1
- package/dist/components/site-analytics/SiteAnalytics.js +93 -12
- package/dist/components/site-analytics/SiteAnalytics.js.map +1 -1
- package/dist/components/site-page/SitePage.d.ts +23 -0
- package/dist/components/site-page/SitePage.js +77 -0
- package/dist/components/site-page/SitePage.js.map +1 -1
- package/dist/components/uvalib-back-to-top/UvalibBackToTop.d.ts +58 -0
- package/dist/components/uvalib-back-to-top/UvalibBackToTop.js +250 -0
- package/dist/components/uvalib-back-to-top/UvalibBackToTop.js.map +1 -0
- package/dist/components/uvalib-back-to-top/uvalib-back-to-top.d.ts +1 -0
- package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js +4 -0
- package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js.map +1 -0
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.d.ts +14 -0
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js +56 -4
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js.map +1 -1
- package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +25 -3
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js +80 -10
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +212 -0
- package/dist/components/uvalib-combobox/UvalibCombobox.js +1088 -0
- package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -0
- package/dist/components/uvalib-combobox/uvalib-combobox.d.ts +1 -0
- package/dist/components/uvalib-combobox/uvalib-combobox.js +4 -0
- package/dist/components/uvalib-combobox/uvalib-combobox.js.map +1 -0
- package/dist/components/uvalib-contents/UvalibContents.d.ts +53 -0
- package/dist/components/uvalib-contents/UvalibContents.js +202 -3
- package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +56 -17
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +285 -81
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -1
- package/dist/components/uvalib-date-range/UvalibDateRange.d.ts +6 -0
- package/dist/components/uvalib-date-range/UvalibDateRange.js +23 -0
- package/dist/components/uvalib-date-range/UvalibDateRange.js.map +1 -1
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +113 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +589 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -0
- package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.d.ts +1 -0
- package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js +4 -0
- package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js.map +1 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.d.ts +130 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js +658 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -0
- package/dist/components/uvalib-image-regions/regions.d.ts +57 -0
- package/dist/components/uvalib-image-regions/regions.js +117 -0
- package/dist/components/uvalib-image-regions/regions.js.map +1 -0
- package/dist/components/uvalib-image-regions/uvalib-image-regions.d.ts +1 -0
- package/dist/components/uvalib-image-regions/uvalib-image-regions.js +4 -0
- package/dist/components/uvalib-image-regions/uvalib-image-regions.js.map +1 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +40 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +144 -16
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-map/UvalibMap.d.ts +182 -0
- package/dist/components/uvalib-map/UvalibMap.js +1001 -0
- package/dist/components/uvalib-map/UvalibMap.js.map +1 -0
- package/dist/components/uvalib-map/uvalib-map.d.ts +1 -0
- package/dist/components/uvalib-map/uvalib-map.js +4 -0
- package/dist/components/uvalib-map/uvalib-map.js.map +1 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.d.ts +39 -2
- package/dist/components/uvalib-metadata/UvalibMetadata.js +214 -8
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
- package/dist/components/uvalib-pager/UvalibPager.d.ts +22 -3
- package/dist/components/uvalib-pager/UvalibPager.js +42 -4
- package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
- package/dist/custom-elements.json +9253 -3253
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/pagefind.css +4 -0
- package/dist/styles/base.js +119 -0
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +5 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +6 -0
- package/dist/styles/controls.js.map +1 -1
- package/dist/styles/hidden.d.ts +2 -0
- package/dist/styles/hidden.js +51 -0
- package/dist/styles/hidden.js.map +1 -0
- package/dist/styles/message.d.ts +1 -0
- package/dist/styles/message.js +82 -0
- package/dist/styles/message.js.map +1 -0
- package/dist/styles/pagefind.js +4 -0
- package/dist/styles/pagefind.js.map +1 -1
- package/dist/styles/result-list.d.ts +1 -0
- package/dist/styles/result-list.js +111 -0
- package/dist/styles/result-list.js.map +1 -0
- package/dist/styles/results.js +0 -15
- package/dist/styles/results.js.map +1 -1
- package/dist/testing/index.d.ts +110 -0
- package/dist/testing/index.js +100 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/lighthouse-rules.d.ts +10 -0
- package/dist/testing/lighthouse-rules.js +44 -0
- package/dist/testing/lighthouse-rules.js.map +1 -0
- package/dist/tokens.css +5 -0
- package/dist-cdn/analytics.js +32 -0
- package/dist-cdn/analytics.js.map +1 -0
- package/dist-cdn/base.css +286 -14
- package/dist-cdn/bento-box.js +3 -3
- package/dist-cdn/chunks/{SiteAnalytics-Cm-FyhYS.js → SiteAnalytics-B9gu5aGO.js} +59 -30
- package/dist-cdn/chunks/SiteAnalytics-B9gu5aGO.js.map +1 -0
- package/dist-cdn/chunks/{UvalibElement-BnI-eRRR.js → UvalibElement-pGONDAwB.js} +108 -101
- package/dist-cdn/chunks/UvalibElement-pGONDAwB.js.map +1 -0
- package/dist-cdn/chunks/{accessible-GqhVn5_H.js → accessible-DJv7YOtS.js} +2 -2
- package/dist-cdn/chunks/{accessible-GqhVn5_H.js.map → accessible-DJv7YOtS.js.map} +1 -1
- package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js.map +1 -1
- package/dist-cdn/chunks/{base-p5pk0vb2.js → base-BI8h0Gf3.js} +121 -2
- package/dist-cdn/chunks/base-BI8h0Gf3.js.map +1 -0
- package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js → library-weekly-hours-CrV3TlP5.js} +3 -3
- package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js.map → library-weekly-hours-CrV3TlP5.js.map} +1 -1
- package/dist-cdn/chunks/regions-B8ExwUGP.js +86 -0
- package/dist-cdn/chunks/regions-B8ExwUGP.js.map +1 -0
- package/dist-cdn/chunks/{repeat-CIFUYkyh.js → repeat-m5Zd_QeP.js} +2 -2
- package/dist-cdn/chunks/{repeat-CIFUYkyh.js.map → repeat-m5Zd_QeP.js.map} +1 -1
- package/dist-cdn/chunks/{site-header-BlOYvQg1.js → site-header-DYRMpdBj.js} +9 -4
- package/dist-cdn/chunks/{site-header-BlOYvQg1.js.map → site-header-DYRMpdBj.js.map} +1 -1
- package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js → site-main-nav-DURrQMal.js} +3 -3
- package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js.map → site-main-nav-DURrQMal.js.map} +1 -1
- package/dist-cdn/chunks/{static-html-1mTAG6nS.js → static-html-C1rhtCHu.js} +2 -2
- package/dist-cdn/chunks/{static-html-1mTAG6nS.js.map → static-html-C1rhtCHu.js.map} +1 -1
- package/dist-cdn/custom-elements.json +9253 -3253
- package/dist-cdn/events-section.js +3 -3
- package/dist-cdn/library-hours-setup.js +2 -2
- package/dist-cdn/library-weekly-hours.js +1 -1
- package/dist-cdn/manifest.json +10 -2
- package/dist-cdn/pagefind.css +4 -0
- package/dist-cdn/site-alerts.js +4 -4
- package/dist-cdn/site-analytics.js +2 -2
- package/dist-cdn/site-footer.js +2 -2
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-hours-section.js +4 -4
- package/dist-cdn/site-main-nav.js +1 -1
- package/dist-cdn/site-page.js +56 -11
- package/dist-cdn/site-page.js.map +1 -1
- package/dist-cdn/site-style.js +2 -2
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +98 -13
- package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +300 -13
- package/dist-cdn/skills/uvalib-web-components/reference/snippets.md +1 -1
- package/dist-cdn/tokens.css +5 -0
- package/dist-cdn/uvalib-analytics.js +2 -2
- package/dist-cdn/uvalib-back-to-top.js +156 -0
- package/dist-cdn/uvalib-back-to-top.js.map +1 -0
- package/dist-cdn/uvalib-breadcrumbs.js +31 -11
- package/dist-cdn/uvalib-breadcrumbs.js.map +1 -1
- package/dist-cdn/uvalib-card-grid.js +1 -1
- package/dist-cdn/uvalib-card.js +3 -3
- package/dist-cdn/uvalib-chip-group.js +53 -14
- package/dist-cdn/uvalib-chip-group.js.map +1 -1
- package/dist-cdn/uvalib-combobox.js +667 -0
- package/dist-cdn/uvalib-combobox.js.map +1 -0
- package/dist-cdn/uvalib-contents.js +100 -22
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-date-histogram.js +237 -127
- package/dist-cdn/uvalib-date-histogram.js.map +1 -1
- package/dist-cdn/uvalib-date-range.js +14 -2
- package/dist-cdn/uvalib-date-range.js.map +1 -1
- package/dist-cdn/uvalib-filter-drawer.js +355 -0
- package/dist-cdn/uvalib-filter-drawer.js.map +1 -0
- package/dist-cdn/uvalib-filter.js +3 -3
- package/dist-cdn/uvalib-image-regions.js +447 -0
- package/dist-cdn/uvalib-image-regions.js.map +1 -0
- package/dist-cdn/uvalib-lightbox.js +144 -55
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-map.js +471 -0
- package/dist-cdn/uvalib-map.js.map +1 -0
- package/dist-cdn/uvalib-metadata.js +150 -24
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pager.js +29 -17
- package/dist-cdn/uvalib-pager.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +2 -2
- package/dist-cdn/uvalib-results-count.js +2 -2
- package/dist-cdn/uvalib-tabs.js +2 -2
- package/dist-cdn/uvalib-tag-list.js +2 -2
- package/package.json +43 -1
- package/skills/uvalib-web-components/SKILL.md +98 -13
- package/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
- package/skills/uvalib-web-components/reference/components.md +300 -13
- package/skills/uvalib-web-components/reference/snippets.md +1 -1
- package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js.map +0 -1
- package/dist-cdn/chunks/UvalibElement-BnI-eRRR.js.map +0 -1
- package/dist-cdn/chunks/base-p5pk0vb2.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,9 +8,11 @@ Reusable web components for UVA Library sites, built with Lit and TypeScript:
|
|
|
8
8
|
- **Navigation:** `<uvalib-breadcrumbs>` (the breadcrumb trail) and `<uvalib-contents>` (sub-navigation or a table of contents).
|
|
9
9
|
- **Cards:** `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>`.
|
|
10
10
|
- **Tabs:** `<uvalib-tabs>`.
|
|
11
|
+
- **Long pages:** `<uvalib-back-to-top>` (a “Back to top” button that appears once the top has scrolled away).
|
|
11
12
|
- **Records:** `<uvalib-metadata>` (a record's details, credit, rights and how to cite).
|
|
12
|
-
- **Images:** `<uvalib-lightbox>` (an image viewer over plain links)
|
|
13
|
-
- **
|
|
13
|
+
- **Images:** `<uvalib-lightbox>` (an image viewer over plain links), `<uvalib-photo-grid>` (justified rows of thumbnails) and `<uvalib-image-regions>` (numbered region outlines on an image, with their list).
|
|
14
|
+
- **Maps:** `<uvalib-map>` (places on the page's own Leaflet map, sized by a count, with a linked list).
|
|
15
|
+
- **Search:** `<uvalib-filter>`, `<uvalib-date-range>`, `<uvalib-date-histogram>`, `<uvalib-combobox>` (a text field that suggests values as you type), `<uvalib-filter-drawer>` (the filters as a sidebar, or a modal panel on phones) and `<uvalib-pagefind-search>` (with `pagefind.css`, the library theme for Pagefind static-site search).
|
|
14
16
|
- **Library hours:** `<site-hours-section>`, `<library-weekly-hours>` and `<library-hours-setup>`.
|
|
15
17
|
- **Library events:** `<events-section>`.
|
|
16
18
|
- **Search results:** `<bento-box>` (library.virginia.edu/search), with its `<catalog-section>`, `<articles-section>`, `<libguides-section>` and `<website-section>`.
|
|
@@ -142,7 +144,7 @@ The page is built with the library itself. Its header's main navigation is the e
|
|
|
142
144
|
|
|
143
145
|
- `https://unpkg.internal.lib.virginia.edu/web-components/v1/<tag>.js` is the major alias. It follows releases within major 1 and is cached for about 5 minutes.
|
|
144
146
|
- `https://unpkg.internal.lib.virginia.edu/web-components/vX.Y.Z/<tag>.js` is an exact, immutable version. Use it to pin.
|
|
145
|
-
- `tokens.css` and `base.css` live at the same prefix (`.../v1/tokens.css`).
|
|
147
|
+
- `tokens.css` and `base.css` live at the same prefix (`.../v1/tokens.css`), and so does `analytics.js`, the analytics helpers for a page's own scripts (`trackEvent`, `trackSearch`, `createSearchTracker`; no element, no Lit; see [Analytics](#analytics)).
|
|
146
148
|
- Never use the legacy `/web-components/latest/` or `/web-components/cdn-v*` paths; they belong to the old components. See [migration](docs/migration.md).
|
|
147
149
|
- `site-page.js` also loads the header and footer. For Matomo, give `<site-page>` a `matomo-id` (it then loads the analytics code itself), or add `site-analytics.js` and a `<site-analytics>` element; see [Analytics](#analytics).
|
|
148
150
|
- Link `base.css` in `<head>` too. `<site-page>` installs the same page-level base styles itself, but only after the first paint, so without the link the page jumps once: the browser's default body margin goes away, and a heading's top margin stops collapsing through the not-yet-upgraded `<site-page>` (layout shifts Lighthouse counts on every page). With the link, `<site-page>` also stays invisible until its script has run, so its content never paints above where the header goes; if the script fails to load, the content appears anyway after two seconds. Sites with `no-global-styles` skip `base.css`, as that attribute turns those styles off.
|
|
@@ -157,7 +159,7 @@ npm i @uvalib/web-components
|
|
|
157
159
|
import '@uvalib/web-components/site-page.js'; // registers site-page, site-header, site-main-nav and site-footer
|
|
158
160
|
```
|
|
159
161
|
|
|
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.
|
|
162
|
+
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)). `@uvalib/web-components/analytics.js` has the analytics helpers on their own (`base.js` exports them too). Do not load the same component from both the CDN and npm on one page.
|
|
161
163
|
|
|
162
164
|
## Quick start
|
|
163
165
|
|
|
@@ -287,6 +289,19 @@ connect-src https://d2q6t6fdv76k7r.cloudfront.net wss://*.appsync-realtime-api.u
|
|
|
287
289
|
|
|
288
290
|
(Use the staging host, or your `alerts-src` host, instead where that applies.) Alert bodies can include images, so allow their hosts in `img-src` too. Alert bodies are inserted as HTML, so a page that enforces Trusted Types (`require-trusted-types-for 'script'`) is incompatible with the alerts; use `no-alerts` there.
|
|
289
291
|
|
|
292
|
+
### Printing
|
|
293
|
+
|
|
294
|
+
When a visitor prints a page (meeting minutes, a finding aid, an article), `<site-page>` prints only the content: the skip link, the header (with the main navigation and the header alert), the alert list band, the regional alerts, the breadcrumbs, the pre-footer band and the footer are left out, and `<main>` loses its side gutters. The content prints black on white, a dark scheme prints light, and the content's links are black and underlined, so they are told apart without colour. A short line above the content says where the page came from: “UVA Library — ” followed by the `site-name` (or else the page's `<title>`) and the page's URL, refreshed just before printing so a single-page app prints its current route. It is CSS generated content in a print-only rule, so screen readers never meet it on screen.
|
|
295
|
+
|
|
296
|
+
```html
|
|
297
|
+
<!-- Print the page as it is shown, header and footer included. -->
|
|
298
|
+
<site-page print-chrome> … </site-page>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
- **`print-chrome`** keeps the header, alerts, breadcrumbs and footer in print (the scheme still prints light).
|
|
302
|
+
- **Both modes:** the rules are in `<site-page>`'s own styles (shadow or `no-shadow-dom`); the link colours and the light scheme come from the page-level base styles, so with `no-global-styles` the links keep your own print colours. With `no-style` none of this applies: print styles are yours.
|
|
303
|
+
- **Your own print rules** still apply: hide a sidebar or a back-to-top button of your own with `@media print { … }`. Browsers print the title and URL in the page margins too unless the visitor turns that off.
|
|
304
|
+
|
|
290
305
|
## Breadcrumbs
|
|
291
306
|
|
|
292
307
|
`<uvalib-breadcrumbs>` is the breadcrumb trail, with library.virginia.edu's look (slash separators, underlined `--uva-blue-alt-dark` links) at body size (1rem), as the design system asks. Entry: `uvalib-breadcrumbs.js` on the CDN, `@uvalib/web-components/uvalib-breadcrumbs.js` on npm. Inside `<site-page>` give it `slot="breadcrumbs"` and load both scripts:
|
|
@@ -312,6 +327,7 @@ connect-src https://d2q6t6fdv76k7r.cloudfront.net wss://*.appsync-realtime-api.u
|
|
|
312
327
|
|
|
313
328
|
- **Markup.** A `<nav aria-label="Breadcrumb">` (`label` changes the name) holding an `<ol>`, one `<li>` per step. The slashes are `aria-hidden` elements, so screen readers do not read them. The last step is the current page: a `<span aria-current="page">`, or a link with `aria-current="page"` when it has an href.
|
|
314
329
|
- **The trail as children.** `<a href>` children, ending with the current page as a text-only element (`<span>Writing</span>`) or a link (`<a href="…" aria-current="page">`). The last child is always the current page; an earlier child without an href is shown as plain text (a level with no page of its own). Hrefs are used as written (relative, hash routes); an href with another scheme than http(s), `mailto:` or `tel:` (such as `javascript:` or `data:`) makes that step plain text, with one console warning. Children with no text, and bare text, are skipped with one console warning. The trail follows changes to the children (added, removed, href and text), so a single-page app can rewrite them on each route. An empty trail renders nothing and, in `<site-page>`, takes no space.
|
|
330
|
+
- **Back to the search.** On a record reached from search results, give the Search crumb `data-return-from` with the search page's path (or several, separated by spaces): `<a href="/" data-return-from="/">Search</a>`. When the visitor came from that page on the same site with a query string (`document.referrer`; a trailing slash or `index.html` does not matter), the crumb links back to that search (`/?q=budget&date_start=2023`) instead of a blank one; its text stays the same. Otherwise (a new tab, another page, another site, no query, or a `Referrer-Policy` that sends no path) it keeps its href. Nothing is stored or sent. Referrers never carry the hash, so a hash-routed search cannot be returned to this way. In `items` the same is `returnFrom`. No inline script rewriting the crumb is needed.
|
|
315
331
|
- **Single-page apps.** The trail is drawn from copies of the children, so a router's own click handlers on them don't run. A plain click on a trail link fires `uvalib-breadcrumbs-navigate` (`detail: { href, index }`, bubbling, cancelable): cancel it with `preventDefault()` and navigate in the app (the click's own navigation is then prevented). Hash links need nothing.
|
|
316
332
|
- **The trail as data.** Apps that build it in JavaScript (React, Vue) set the `items` property: `el.items = [{ label: 'Home', href: '/' }, { label: 'Search' }]`. While set it wins over any children; assign a new array to change it, `undefined` to go back to the children. Entries without a label are skipped with one warning.
|
|
317
333
|
- **Placement.** In `<site-page>` the trail sits where library.virginia.edu puts it: after the header and the alert list band, before `<main>` and outside it, so the skip link lands past it, lined up with `<main>`'s content (same max width and 40px side padding, 16px above). In light mode (`no-shadow-dom`) it is moved there as a real child of `<site-page>`, never into `<main>`. Without a `slot="breadcrumbs"` child the page is unchanged. Elsewhere it is an ordinary block: put it first in the page content, above the `<h1>`.
|
|
@@ -359,7 +375,7 @@ connect-src https://d2q6t6fdv76k7r.cloudfront.net wss://*.appsync-realtime-api.u
|
|
|
359
375
|
- **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”.
|
|
360
376
|
- **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”.
|
|
361
377
|
- **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”.
|
|
378
|
+
- **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`. Without a known total (ranked or semantic search), leave `total` unset (or 0): the count reads “Showing N” and the button stays. Add `has-more` while there is more and remove it (or set `hasMore = false`; `has-more="false"` also works, for templates that print false) after the last page. Once set, `has-more` alone decides whether the button shows, over `total`; `hasMore = undefined` returns to following `total`. It is one flag rather than a `has-more`/`no-more` pair, so the two can never contradict each other. If the button goes away while it has focus and `loaded()` was not called first, focus moves to the first new item of the `for` list, or else to the count, never to the page. `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”.
|
|
363
379
|
- **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'`.
|
|
364
380
|
- **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.
|
|
365
381
|
|
|
@@ -382,6 +398,15 @@ connect-src https://d2q6t6fdv76k7r.cloudfront.net wss://*.appsync-realtime-api.u
|
|
|
382
398
|
<button value="date">Date</button>
|
|
383
399
|
<button value="title">Title A–Z</button>
|
|
384
400
|
</uvalib-chip-group>
|
|
401
|
+
<uvalib-chip-group
|
|
402
|
+
label="Search by"
|
|
403
|
+
segmented
|
|
404
|
+
value="keyword"
|
|
405
|
+
description="Keyword matches your words. Meaning finds meetings about your topic, even when the minutes put it differently."
|
|
406
|
+
>
|
|
407
|
+
<button value="keyword">Keyword</button>
|
|
408
|
+
<button value="meaning">Meaning</button>
|
|
409
|
+
</uvalib-chip-group>
|
|
385
410
|
<uvalib-chip-group mode="multi" label="Category" value="traditions">
|
|
386
411
|
<button value="traditions" data-count="9">Traditions</button>
|
|
387
412
|
<button value="sports" data-count="21">Sports</button>
|
|
@@ -391,9 +416,21 @@ connect-src https://d2q6t6fdv76k7r.cloudfront.net wss://*.appsync-realtime-api.u
|
|
|
391
416
|
</uvalib-chip-group>
|
|
392
417
|
```
|
|
393
418
|
|
|
419
|
+
A colour key: `data-swatch` (or `swatch` in `items`) draws a small square of that colour before the label, so the filter chips double as a chart's or map's legend.
|
|
420
|
+
|
|
421
|
+
```html
|
|
422
|
+
<uvalib-chip-group mode="multi" label="Category" count-label="photos" value="athletics">
|
|
423
|
+
<button value="athletics" data-count="4203" data-swatch="#e57200">Athletics</button>
|
|
424
|
+
<button value="architecture" data-count="1180" data-swatch="#232d4b">Architecture</button>
|
|
425
|
+
<button value="traditions" data-count="912" data-swatch="#25cad3">Traditions</button>
|
|
426
|
+
</uvalib-chip-group>
|
|
427
|
+
```
|
|
428
|
+
|
|
394
429
|
- **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.
|
|
430
|
+
- **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?, swatch? }]`), which wins over the children while set. The chips follow changes to the children.
|
|
431
|
+
- **Description.** `description` is a hint shown under the chips in small muted text and tied to the group (the `radiogroup`, or the `group` in `multi` and `links`) with `aria-describedby`, so a screen reader reads it when focus enters the group. It is an attribute, not a slot, on purpose: the text lives in the element's own root next to the group, so the reference works in shadow DOM (an `aria-describedby` from the page cannot reach into a shadow root, nor out of one) and in light DOM (a unique id). It is plain text, so it cannot hold a link; put a longer explanation with links next to the element. Works in every mode, with `segmented`, `scroll` and `no-style`; before the script loads `base.css` holds a line for it.
|
|
396
432
|
- **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.
|
|
433
|
+
- **Swatches.** `data-swatch` / `swatch` is any CSS colour (checked with `CSS.supports`; an invalid one is ignored with one console warning) and is set as a style property, never as CSS text. The square is decorative (`aria-hidden="true"`, `part="swatch"`): the chip's name stays its label and count, so the colour is never the only cue; keep the chart's or map's own labels, and use the same label text in both. Its 1px border is the chip's text colour, so it shows against the chip unselected, selected, disabled and in dark mode (at least 3:1, WCAG 1.4.11), and the chip keeps its height. In forced colors the square keeps its real colour (`forced-color-adjust: none` on the square only, since it must match the chart or map, which forced colors leave alone in a canvas or image) with a system-colour border. It works in every mode, with `segmented` and `scroll`, and with `no-style`.
|
|
397
434
|
- **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
435
|
- **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
436
|
- **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.
|
|
@@ -483,6 +520,7 @@ Two components for Library sites with records and long texts, such as the Electr
|
|
|
483
520
|
|
|
484
521
|
- **Markup.** A `<nav>` landmark named by `label` (default "Contents"), with the label as a visible headline (`<h2>`; `heading-level` 2 to 6), then the nested list: dividers between the top-level entries, a bar beside each nested level, links in `--uva-color-utility-link` (else #005679) and the library focus ring. Every link is at least 24px tall.
|
|
485
522
|
- **The list as a child.** One `<ol>` or `<ul>` of `<li>`, 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; entries with no text are skipped with one console warning; hrefs other than relative, http(s), `mailto:` and `tel:` become plain text. `lang` and `dir` on the links and items are kept, and so is inline markup in the text (`em`, `cite`, `code`, `abbr`…, copied element by element with only `lang`, `dir` and an `abbr` title; never parsed as HTML). It follows changes to the children. Apps set the `items` property instead: `[{ label, href?, children? }]`, winning over the children while set.
|
|
523
|
+
- **From the page's headings.** For a long document (minutes, transcriptions, reports, finding aids), `headings-from="#article"` builds the list from the headings in that element: `levels` (`2-3` by default, or one level such as `2`) picks which, each lower level nested under the heading before it, and `min` (default 2) is the fewest top-level entries worth a list (fewer shows nothing). Headings with no text or hidden with `aria-hidden` (and text inside `aria-hidden`, such as a `#` permalink) are skipped. A heading without an id gets one from its text (lowercase ASCII, accents dropped, anything else as `-`: "Résumé of the budget" is `resume-of-the-budget`, a repeat `-2`, `-3`); existing ids are kept, so links to sections keep working, and opening the page at such a section goes to it. Headings added, removed or retitled are followed; call `refresh()` after other changes. A child list or `items` wins while given. Without JavaScript there is no list: where the list can be rendered at build time, give it as children instead.
|
|
486
524
|
- **Current entry.** `aria-current="page"` on the link to this page and `aria-current="location"` on the link to the section in the URL's hash, drawn bold with a bar. It is found from the page URL (path, ignoring a trailing slash or `index.html`, and hash; an entry whose href has a query string, such as `?part=2`, matches only that query, one without matches whatever the query), followed through `hashchange`, `popstate` and the Navigation API, or from `current` (a URL, for apps whose route is not the page URL; hash-only entries are then places on that URL). With `current` unset, a valid `aria-current` the author put on a source link (`page`, `location`, or `true` for a page) is used, at most one of each.
|
|
487
525
|
- **Narrow screens.** At and below `collapse-below` (a viewport width, default `64rem`; `0` never collapses) the headline becomes a full-width 44px button with `aria-expanded` and `aria-controls`, and the list starts closed until the reader opens it (as the Electronic Text Collections' Contents does on phones, so the text comes first; the `open` attribute starts it open), and opening it shows the current entry. It measures the viewport, not the element (no container query) on purpose: a contents sidebar is always much narrower than 64rem, so its own width cannot tell a phone from a desktop.
|
|
488
526
|
- **Sidebars.** `sticky` keeps it in view on wide screens (`--uvalib-contents-sticky-top`, default 1rem); the list then scrolls within the window's height (`--uvalib-contents-max-height`) and the current entry is scrolled into view inside it, never the page.
|
|
@@ -492,6 +530,7 @@ Two components for Library sites with records and long texts, such as the Electr
|
|
|
492
530
|
|
|
493
531
|
- **The rows as a `<dl>` child**, so the page reads the same before the script runs: `<dt>` labels and `<dd>` values, optionally a `<div>` per row; several `<dd>` are several values. Values are copied as written (links, lists such as subjects, `download` attributes, and `lang`/`dir` on the `<dt>` and `<dd>`); a link whose href is not relative, http(s), `mailto:` or `tel:` is shown as its text, with one console warning. A link with `data-size` is shown as a download, "EPUB · 184 KB", read as "EPUB, 184 KB" (not added again when the link's text already ends with the size). Apps set `items` instead: `[{ label, value }]`, a value being text, a link `{ label, href, size?, download? }` or an array of them (a list).
|
|
494
532
|
- **Credit and rights**, as Special Collections asks: `creator` and `organization` rows first; `rights` last, a rightsstatements.org or Creative Commons URL shown as its short name ("In Copyright", "No Copyright – United States", "CC BY 4.0", "CC0 1.0") linked with `rel="license"`, another URL as `rights-label` (else "Rights statement"), or plain text; `rights-info` adds a "More about rights and permissions" link (the library's is `https://www.library.virginia.edu/policies/use-of-materials`).
|
|
533
|
+
- **Long lists.** `list-limit="8"` on the element shortens every value that is a list (a `<ul>` or `<ol>` directly in the `<dd>`) of more than 8 items: the first 8 show, then a real button, “Show all 34 participants” (`aria-expanded`, `aria-controls`; the count in its name), reveals the rest in place and moves focus to the first one revealed (its link, or the item itself with `tabindex="-1"`); it then reads “Show fewer”, which hides them again and keeps focus on the button. `data-limit` on a `<dd>` or its list sets that row's own limit and wins (`data-limit="0"`: never shortened). The noun is the row's label with a lowercase first letter (“Participants” → “participants”; a label that starts with an acronym, “ORCID iDs”, is kept as written); set `data-limit-label="people"` when that does not read well (a singular label, say). Apps set `limit` and `limitLabel` on an `items` row. The hidden values carry `hidden`, so they are not read until shown, and every value stays in the markup: without JavaScript the whole list shows. Before the script loads the element is hidden at its full height, so content below moves up once when it upgrades. The button is an underlined text button like `<uvalib-tag-list>`'s Show all: at least 2rem (34px) square (24px with `no-style`), `ButtonText` in forced colors, no animation (nothing to reduce). Analytics: `show-all` / `show-fewer` with `row N`, the row's place, never its label or values.
|
|
495
534
|
- **How to cite.** `citation` (as written), or `citation-title` for the Special Collections formula "<title or collection>, Albert and Shirley Small Special Collections Library, University of Virginia". A Copy citation button copies it and says "Copied" in a polite status; where the clipboard is unavailable it selects the citation and says so.
|
|
496
535
|
- **Layout.** Label and value side by side when the element is 36rem wide or more, stacked below that (a container query: the element's own width). Labels in `--uva-color-text-muted`, rows divided by `--uva-color-border`.
|
|
497
536
|
|
|
@@ -531,6 +570,143 @@ Both follow dark mode through the role tokens and reflow at 320px; `no-style` ke
|
|
|
531
570
|
- **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.
|
|
532
571
|
- **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.
|
|
533
572
|
|
|
573
|
+
### Image regions
|
|
574
|
+
|
|
575
|
+
`<uvalib-image-regions>` outlines regions of an image (people, objects, inscriptions, page areas), numbered, with a list of the same regions beside it (under it on a narrow screen). Entry: `uvalib-image-regions.js` on the CDN, `@uvalib/web-components/uvalib-image-regions.js` on npm. See the [Image regions](https://uvalib.github.io/reusable-web-library/#image-regions) example.
|
|
576
|
+
|
|
577
|
+
```html
|
|
578
|
+
<script
|
|
579
|
+
type="module"
|
|
580
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-image-regions.js"
|
|
581
|
+
></script>
|
|
582
|
+
|
|
583
|
+
<!-- The page's own image and list: it works before the script loads and without it. -->
|
|
584
|
+
<uvalib-image-regions label="People">
|
|
585
|
+
<img src="group.jpg" alt="Five students on the Rotunda steps" width="1200" height="800" />
|
|
586
|
+
<ol>
|
|
587
|
+
<li data-xywh="percent:12,30,10,22">
|
|
588
|
+
<a href="/people/42">Person 1</a>
|
|
589
|
+
<button type="button" class="uvalib-button uvalib-button--small">Not this person</button>
|
|
590
|
+
</li>
|
|
591
|
+
<li data-xywh="xywh=560,240,120,176">
|
|
592
|
+
Person 2
|
|
593
|
+
<button type="button" class="uvalib-button uvalib-button--small">Name this person</button>
|
|
594
|
+
</li>
|
|
595
|
+
</ol>
|
|
596
|
+
</uvalib-image-regions>
|
|
597
|
+
|
|
598
|
+
<!-- Or the items property, and the element draws the list. -->
|
|
599
|
+
<uvalib-image-regions
|
|
600
|
+
id="page"
|
|
601
|
+
label="Regions"
|
|
602
|
+
src="page.jpg"
|
|
603
|
+
alt="A manuscript page"
|
|
604
|
+
width="900"
|
|
605
|
+
height="1200"
|
|
606
|
+
></uvalib-image-regions>
|
|
607
|
+
<script type="module">
|
|
608
|
+
document.querySelector('#page').items = [
|
|
609
|
+
{ label: 'Inscription', x: 10, y: 8, w: 80, h: 12, unit: 'percent', href: '#inscription' },
|
|
610
|
+
{ label: 'Seal', x: 640, y: 980, w: 160, h: 160, description: 'Wax, red' },
|
|
611
|
+
];
|
|
612
|
+
</script>
|
|
613
|
+
|
|
614
|
+
<!-- In the image viewer: data-regions on a link (or the lightbox's regions callback). -->
|
|
615
|
+
<uvalib-lightbox regions-label="People">
|
|
616
|
+
<a
|
|
617
|
+
href="group-large.jpg"
|
|
618
|
+
data-caption="Students on the Rotunda steps"
|
|
619
|
+
data-regions="percent:12,30,10,22 Person 1; percent:46,30,10,22 Person 2"
|
|
620
|
+
>
|
|
621
|
+
<img src="group-small.jpg" alt="Students on the Rotunda steps" width="300" height="200" />
|
|
622
|
+
</a>
|
|
623
|
+
</uvalib-lightbox>
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
- **The list is the way in.** Every region is an entry in the list, with the same name and the page's own links and buttons. The outlines are a visual aid: the overlay is `aria-hidden` and the outlines are not focusable, so no region is a second tab stop. Clicking an outline moves focus to its entry (and fires `select`); from there Tab reaches its links and buttons. Labels shown on a highlighted outline are the list's text, so nothing is only on hover.
|
|
627
|
+
- **Regions.** An `<ol>` child whose `<li>` items carry `data-xywh`, IIIF and Media Fragments style: `percent:x,y,w,h`, or pixels (`x,y,w,h`, `pixel:x,y,w,h` or `xywh=…`) of the image's natural size, or of `image-width` × `image-height` when the image is a smaller derivative of the original (a IIIF `,880` size, say). A label is `data-label`, else the entry's first link, else its text without its buttons. `data-id` (or `id`) is sent back in events. Or set `items` (`{ id?, label, x, y, w, h, unit?: 'px' | 'percent', href?, description? }[]`): it replaces the child list. A pixel region is drawn once the image's size is known.
|
|
628
|
+
- **Host content.** The child list and everything in it stay the page's: the element only numbers, positions and highlights them (it adds `data-uvalib-region` and, while highlighted, `data-uvalib-active` to each `<li>`, and `tabindex="-1"` when an outline moves focus to one). Your buttons' events are yours.
|
|
629
|
+
- **Numbers and highlight.** Outline numbers are the list's numbers (from 1, or the `<ol>`'s `start`); `numbering="none"` hides them on the outlines. Hovering or focusing an entry, or anything in it, highlights its region: a thicker double outline with its label, the others dimmed, and the entry gets a bar at its start and a tint. Hovering an outline highlights its entry. Not colour alone.
|
|
630
|
+
- **Contrast on any image.** Each outline is white inside black (2px each, 4px highlighted), with black number badges, on light and dark photos alike and in dark mode; in forced colors they are Canvas and CanvasText, the highlight is Highlight (the overlay alone has `forced-color-adjust: none`).
|
|
631
|
+
- **Layout.** The image keeps its own width (at most the element's) and the list sits beside it when 14rem is left, else under it, so it reflows at 320px. Outlines are in percent and scale with the image; give the image `width` and `height` so its space is reserved. `base.css` gives the children the same layout before the element upgrades, so the image does not move. `hide-outlines` hides the outlines and keeps the list. `label` (default “Regions”) is the list's heading; `heading-level` sets its level (default: one below the heading before it).
|
|
632
|
+
- **Events.** `highlight` (`detail: { item, index }`, `item` null when none) as hover or focus changes the highlight; `select` (`detail: { item, index }`) when an outline is clicked. Both bubble and are composed.
|
|
633
|
+
- **Lightbox.** On `<uvalib-lightbox>`, `data-regions` on a link is a JSON array of region objects, or `xywh` values each followed by its label, separated by `;` (`percent:10,20,30,40 Person 1; 160,120,320,240 Sign`; use JSON when a label contains `;`). Or set the lightbox's `regions` property to a function from `{ element, id, href, index }` to regions. An image with regions shows the outlines over it and their list beside it, and a “Show regions” toggle (`aria-pressed`) hides the outlines; `regions-label` names the list. `<uvalib-image-regions>` is loaded the first time it is needed. Because the viewer asks for a resized IIIF image, give pixel regions `data-image-width` and `data-image-height` (the original's size), or use percent. Images without regions are unchanged.
|
|
634
|
+
- **Analytics.** `select` when an outline is clicked, with the list's `label` and the region's number. Never a region's label: it may be a person's name. Nothing on hover or focus.
|
|
635
|
+
- **Motion and styles.** The dimming fades only without `prefers-reduced-motion: reduce`. Shadow and light DOM; `no-style` keeps the layout and the outlines.
|
|
636
|
+
|
|
637
|
+
## Maps
|
|
638
|
+
|
|
639
|
+
`<uvalib-map>` shows places (buildings, rooms, outdoor spaces) as markers sized by a count, each a link to the place's page, with a list of the same places under the map. It wraps [Leaflet](https://leafletjs.com) 1.9, which **your page provides**: the library never bundles Leaflet, and its CDN entry imports nothing from it. `leaflet` is an optional peer dependency of the npm package. Entry: `uvalib-map.js` on the CDN, `@uvalib/web-components/uvalib-map.js` on npm. See the [Map](https://uvalib.github.io/reusable-web-library/#places-map) example.
|
|
640
|
+
|
|
641
|
+
```html
|
|
642
|
+
<!-- CDN: Leaflet first (defer keeps it before the module scripts), then the element. -->
|
|
643
|
+
<script
|
|
644
|
+
defer
|
|
645
|
+
src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
|
|
646
|
+
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
|
|
647
|
+
crossorigin=""
|
|
648
|
+
></script>
|
|
649
|
+
<script
|
|
650
|
+
type="module"
|
|
651
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-map.js"
|
|
652
|
+
></script>
|
|
653
|
+
|
|
654
|
+
<!-- The child list is the list of places, before the script runs and after. -->
|
|
655
|
+
<uvalib-map label="Places on Grounds" count-label="photos">
|
|
656
|
+
<ul>
|
|
657
|
+
<li>
|
|
658
|
+
<a href="/places/rotunda" data-lat="38.0356" data-lng="-78.5034" data-count="2702"
|
|
659
|
+
>The Rotunda</a
|
|
660
|
+
>
|
|
661
|
+
</li>
|
|
662
|
+
<li>
|
|
663
|
+
<a
|
|
664
|
+
href="/places/alderman"
|
|
665
|
+
data-lat="38.0367"
|
|
666
|
+
data-lng="-78.5055"
|
|
667
|
+
data-count="640"
|
|
668
|
+
data-description="The main library."
|
|
669
|
+
>Alderman Library</a
|
|
670
|
+
>
|
|
671
|
+
</li>
|
|
672
|
+
</ul>
|
|
673
|
+
</uvalib-map>
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
```js
|
|
677
|
+
// npm: give the element the Leaflet module (npm i leaflet).
|
|
678
|
+
import * as L from 'leaflet';
|
|
679
|
+
import '@uvalib/web-components/uvalib-map.js';
|
|
680
|
+
|
|
681
|
+
const map = document.querySelector('uvalib-map');
|
|
682
|
+
map.leaflet = L;
|
|
683
|
+
map.items = [
|
|
684
|
+
{
|
|
685
|
+
id: 'rotunda',
|
|
686
|
+
name: 'The Rotunda',
|
|
687
|
+
lat: 38.0356,
|
|
688
|
+
lng: -78.5034,
|
|
689
|
+
count: 2702,
|
|
690
|
+
href: '/places/rotunda',
|
|
691
|
+
},
|
|
692
|
+
{ id: 'stadium', name: 'Scott Stadium', lat: 38.0311, lng: -78.5137, count: 1150 }, // no href: a button
|
|
693
|
+
];
|
|
694
|
+
map.addEventListener('select', (e) => console.log(e.detail.item.id));
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
- **Leaflet.** The `leaflet` property (the module namespace, or its `default`) wins; otherwise `window.L` (leaflet.js from a script tag, also loaded `async` or after the element: it looks again once the page has loaded). Without either, only the list is shown, with one console warning a second after the page loads. Leaflet's `leaflet.css` is **optional**: the element carries the layout rules the map needs (panes, tiles, controls, tooltip), in shadow DOM and light DOM alike, so there is nothing to adopt into the shadow root. A page that also loads `leaflet.css` (for its own maps) keeps the element's sizes and colours.
|
|
698
|
+
- **Places.** `items` (`[{ id?, name, lat, lng, count?, href?, description? }]`) wins over the children while non-empty. Children: one `<ul>` or `<ol>` of `<li>`, each with an `<a href>` carrying `data-lat`, `data-lng` and optionally `data-count`, `data-id` and `data-description` (or those on the `<li>` itself, for a place without a page). A place without valid coordinates is listed but has no marker. Hrefs other than relative, http(s), `mailto:` and `tel:` become plain text. The list follows changes to the children.
|
|
699
|
+
- **Markers.** Each is a real link (a button when there is no `href`) named “The Rotunda, 2,702 photos”: `count-label` is the noun (default “items”; a count of one drops a trailing s). The dot is 24 to 56px, by the square root of the count, in a target of at least 44px; smaller dots sit above larger ones. Tab, or the arrow keys, Home and End, move between markers; Enter (or Space) follows the link, or chooses the place. A hover or focus shows a tooltip with the name and count (it is also in the marker's name and the list, never the only source) that stays until another place is hovered or focused, the pointer leaves the map, or Escape.
|
|
700
|
+
- **The list and the map are linked.** Hovering or focusing a list entry highlights its marker (a ring and a larger dot, not colour alone) and brings it into view; hovering or focusing a marker outlines its list entry.
|
|
701
|
+
- **The region.** The map is `role="region"` named “<label>, map” (`label` is required: one console warning without it), after a “Skip map, go to the list” link (shown on focus; it moves focus to the list, which is named “<label>, list”) and a visible line of key instructions. With the map itself focused, Leaflet's own keys pan (arrows) and zoom (+ and −). The wheel does not zoom (no scroll trap); the zoom buttons are 44px with the library focus ring. The attribution stays, readable (13px, underlined links).
|
|
702
|
+
- **Opening view.** The bounds of the places, as close as the largest marker allows (half zoom steps), moved clear of the zoom buttons and attribution when a marker would sit under them; or `center="lat,lng"` and `zoom`. It refits on resize until the visitor moves the map.
|
|
703
|
+
- **Tiles.** `tile-url` (default `https://tile.openstreetmap.org/{z}/{x}/{y}.png`) and `attribution` (HTML; default “© OpenStreetMap contributors”). OpenStreetMap's tiles are for light use only: their [tile usage policy](https://operations.osmfoundation.org/policies/tiles/) asks for the attribution (kept here) and no heavy traffic. For a busy page use a library-hosted tile server or a commercial provider, and set both attributes.
|
|
704
|
+
- **Dark mode.** In the page's dark mode, `dark-tile-url` gives dark tiles; without it the light tiles are inverted with a CSS filter on the tile pane only (`--uvalib-map-dark-filter`, default `invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9)`), so markers, controls, the tooltip and the attribution are never filtered. Everything else follows the role tokens.
|
|
705
|
+
- **Motion, colours and layout.** `prefers-reduced-motion` turns off Leaflet's zoom, fade and marker animations, inertia and the highlight's transition, and panning to a place jumps. In forced colors the markers, controls, tooltip and list entries keep borders, and the highlight is a Highlight outline. The map is `--uvalib-map-height` tall (default `min(24rem, 75vw)`, at least 12rem); the list sits under it in as many columns as fit, one on a phone, with no sideways scroll at 320px.
|
|
706
|
+
- **Before the script loads.** `base.css` shows the key instructions and holds the map's height above the child list, so the list does not move when the map is drawn.
|
|
707
|
+
- **Modes.** Shadow DOM (default) or `no-shadow-dom`; `no-style` keeps Leaflet's layout, the map height, the 44px targets and the hidden marker names, and drops the colours.
|
|
708
|
+
- **Events and analytics.** `select` (`detail: { item }`, bubbling, composed and cancelable) when a marker is chosen; cancel it to stay on the page for a place with an `href`. Analytics: `select` with the map's label and the place's position from 1, and `zoom` with the label and the zoom level, 1 s after the last zoom-button press. Never a place's name, coordinates or URL.
|
|
709
|
+
|
|
534
710
|
## Rendering modes
|
|
535
711
|
|
|
536
712
|
| Attributes | Rendering |
|
|
@@ -571,12 +747,70 @@ The mode is read once, at first connect; do not toggle it afterwards.
|
|
|
571
747
|
- **`.uvalib-input`** is a 44px text field; **`.uvalib-search-form`** puts the label, field and button in one row that wraps on phones. Keep a visible `<label>` (or at least an `aria-label`).
|
|
572
748
|
- **Dark mode and forced colors:** they follow the `--uva-color-button-*` role tokens. `base.css` carries every role token it reads itself (the same values as `tokens.css`), so a page that links only `base.css` stays readable under `data-uva-color-scheme`; link `tokens.css` too for your own content's other `--uva-color-*` tokens. Turn dark mode on with `color-scheme-switch` (see [Dark mode](#dark-mode)). In Windows high-contrast mode they keep visible outlines, show hover and press as a Highlight outline (dashed while pressed), a highlighted pressed toggle, and GrayText when disabled.
|
|
573
749
|
- **Cascade:** like the rest of `base.css` the rules are unlayered, so a host reset such as `button { background: none }` does not undo them; restyle with a more specific selector. They are only in `base.css`: `<site-page>` does not install them. The components' own buttons (bento-box, events-section, library-weekly-hours) keep their look, in light DOM too.
|
|
750
|
+
- **`hidden` hides them.** Every `base.css` class that sets `display` (buttons, fields, the search form, badges, media, the toolbar, the empty state, skeletons, messages, the results list) is hidden by the `hidden` attribute, so `button.hidden = true` takes it out of sight, the tab order and the accessibility tree. The rule is scoped to those classes (`:where(.uvalib-button, …)[hidden] { display: none !important }`), not a global `[hidden]` reset, so a page's own `[hidden]` content behaves as it did before.
|
|
751
|
+
|
|
752
|
+
## Messages
|
|
753
|
+
|
|
754
|
+
An inline message for the page's own content: a search error, a notice that results are partial, a saved confirmation. It has the severity look of `<site-alerts>` (the alert background, a thick start border in the severity colour) at the size of the content around it. The class is in `base.css`.
|
|
755
|
+
|
|
756
|
+
```html
|
|
757
|
+
<!-- An error that appears after an action: role="alert" announces it at once. -->
|
|
758
|
+
<div class="uvalib-message uvalib-message--error" role="alert">
|
|
759
|
+
<strong class="uvalib-message__label">Error:</strong> the search could not be run.
|
|
760
|
+
<a href="/search">Try again</a>
|
|
761
|
+
</div>
|
|
762
|
+
|
|
763
|
+
<!-- A notice: role="status" announces it politely. -->
|
|
764
|
+
<div class="uvalib-message uvalib-message--notice" role="status">
|
|
765
|
+
<strong class="uvalib-message__label">Note:</strong> search by meaning isn't available right now,
|
|
766
|
+
so these are keyword results.
|
|
767
|
+
</div>
|
|
768
|
+
|
|
769
|
+
<div class="uvalib-message uvalib-message--warning">
|
|
770
|
+
<strong class="uvalib-message__label">Warning:</strong> some records are still being added.
|
|
771
|
+
</div>
|
|
772
|
+
<div class="uvalib-message uvalib-message--success" role="status">
|
|
773
|
+
<svg class="uvalib-message__icon" aria-hidden="true" viewBox="0 0 16 16">
|
|
774
|
+
<path d="M2 8l4 4 8-8" fill="none" stroke="currentColor" stroke-width="2" />
|
|
775
|
+
</svg>
|
|
776
|
+
<strong class="uvalib-message__label">Saved:</strong> your list was updated.
|
|
777
|
+
</div>
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
- **Kinds:** `--error`, `--warning`, `--info` (or its alias `--notice`) and `--success`; a plain `.uvalib-message` looks like `--info`. Text and links are 7:1 or more (WCAG AAA) on every kind in light and dark (the `--uva-color-alert-*` and `--uva-color-status-success-*` role tokens, which `base.css` carries itself). Links are underlined, with a focus ring in the text colour.
|
|
781
|
+
- **Never colour alone:** start the text with the severity in words (“Error:”, “Warning:”, “Note:”, “Saved:”), in `.uvalib-message__label` (bold); an icon (`.uvalib-message__icon`) is decorative, `aria-hidden="true"`, and never replaces the word. There is no CSS-generated prefix: screen readers read generated content inconsistently, it is not translated with the page, and it would double the word you wrote.
|
|
782
|
+
- **Live regions:** use `role="alert"` only for an error that appears in response to what the visitor did (it interrupts); use `role="status"` for a notice or confirmation (polite). For a status to be announced reliably, put the empty `role="status"` container in the page first and fill it later, rather than inserting the whole element. A message that is there when the page loads needs no role. Do not put an alert role on a message that is always shown.
|
|
783
|
+
- **Forced colors:** every message keeps a system-colour border, thicker at the start. In the flow of the page it is a block with the content's own width, its first and last child without outer margins.
|
|
784
|
+
|
|
785
|
+
## Back to top
|
|
786
|
+
|
|
787
|
+
`<uvalib-back-to-top>` is a “Back to top” button for long pages: minutes, finding aids, transcriptions, long result lists. Entry: `uvalib-back-to-top.js` on the CDN, `@uvalib/web-components/uvalib-back-to-top.js` on npm. See the [Back to top](https://uvalib.github.io/reusable-web-library/#back-to-top) example.
|
|
788
|
+
|
|
789
|
+
```html
|
|
790
|
+
<script
|
|
791
|
+
type="module"
|
|
792
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-back-to-top.js"
|
|
793
|
+
></script>
|
|
794
|
+
|
|
795
|
+
<site-page>
|
|
796
|
+
<h1>Minutes of the Board of Visitors</h1>
|
|
797
|
+
…
|
|
798
|
+
<uvalib-back-to-top></uvalib-back-to-top>
|
|
799
|
+
</site-page>
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
- **When it shows.** Hidden until the top `offset` pixels (default 400) have scrolled out of view, watched with an IntersectionObserver on a 1px-wide sentinel it adds to `<body>`, positioned at the top of the page (no scroll listener). Hidden means `visibility: hidden`: not a tab stop and not in the accessibility tree. If it has focus as it hides, focus moves to the target.
|
|
803
|
+
- **What it does.** A real `<button>` with visible text (`label`, default “Back to top”) and an arrow. It scrolls to the top, smoothly unless the visitor prefers reduced motion, and moves focus to the page's `<h1>` (the first in `<main>`, else the first on the page, else `#top`), or to the element `target` selects, adding `tabindex="-1"` when that element is not focusable, so keyboard and screen reader users land at the top too.
|
|
804
|
+
- **Where it sits.** Fixed in the bottom corner on the end side, 1rem in (or the safe-area inset), 44px tall, with the outline (`.uvalib-button--secondary`) look on a solid background. **Put it last in the page's content** (inside `<site-page>`, after everything else): the element is an empty block `--uvalib-back-to-top-space` (default 4.75rem) tall, the space the button needs, so the last lines can scroll clear of it; once that space is in view the button sits in it instead of floating, so it never covers the footer either. While scrolling it floats over content like any fixed button; it never widens the page at 320px. It is hidden in print. `<site-page>` has no attribute for it: load `uvalib-back-to-top.js` and add the element.
|
|
805
|
+
- **Colours.** Dark mode follows the role tokens; in forced colors it is a ButtonFace button with a ButtonText border.
|
|
806
|
+
- **Analytics.** `['uvalib-back-to-top', 'click']`.
|
|
574
807
|
|
|
575
808
|
## Tokens and theming
|
|
576
809
|
|
|
577
810
|
- **Tokens:** inherited `--uva-*` custom properties (for example `--uva-brand-blue`, `--uva-font-family`), set on `:root` or an ancestor of the component. The full set is in `tokens.css`. Components read tokens with fallbacks and never set them.
|
|
578
811
|
- **Parts (shadow mode):** on a page, `site-page::part(header)`, `site-page::part(footer)` and `site-page::part(main)`. For a standalone element, `site-header::part(header)` or `site-footer::part(footer)`.
|
|
579
812
|
- **Light mode** has no shadow parts; use ordinary selectors, which win over the layered component styles.
|
|
813
|
+
- **Highlight:** `--uva-color-highlight` and `--uva-color-on-highlight` colour highlighted search terms (`<mark>` in `.uvalib-result__snippet`): library.virginia.edu's orange-200 (`--uva-brand-orange-200`, `#ffc999`) with dark text (9.5:1) in light, `#854200` with white text (7.6:1) in dark. Read them for your own highlights, with the light values as fallbacks: `background: var(--uva-color-highlight, #ffc999); color: var(--uva-color-on-highlight, #2b2b2b)`, and keep the highlight bold (or otherwise marked) so it is not colour alone.
|
|
580
814
|
|
|
581
815
|
## Dark mode
|
|
582
816
|
|
|
@@ -615,26 +849,28 @@ Dark mode is **off by default**. Without it nothing changes: no control, no dark
|
|
|
615
849
|
|
|
616
850
|
**Role tokens.** Defined only while dark mode is on; components fall back to the palette token or value they always used, so light mode is unchanged. Do not flip the palette tokens instead: `--uva-brand-blue` is both text on white and a background under white text. With dark mode on, the role tokens resolve on `:root`, so `--uva-brand-*` overrides set on `:root` still apply in Light, but overrides scoped below `:root` (for example `site-header { --uva-brand-blue: … }`) are ignored for the colours the role tokens cover; set them on `:root`, or override the `--uva-color-*` token there instead.
|
|
617
851
|
|
|
618
|
-
| Token | Used for | Light
|
|
619
|
-
| ----------------------------- | ----------------------------------------------------------- |
|
|
620
|
-
| `--uva-color-surface` | page background | `#ffffff`
|
|
621
|
-
| `--uva-color-surface-raised` | header, nav bar, panels, popover, inputs, buttons, chips | `#ffffff`
|
|
622
|
-
| `--uva-color-surface-hover` | hover and open-group background | `--uva-grey-100` (`#dadada`)
|
|
623
|
-
| `--uva-color-text` | text | `--uva-grey-darkest` (`#2b2b2b`)
|
|
624
|
-
| `--uva-color-text-muted` | secondary labels | `#4b5563`
|
|
625
|
-
| `--uva-color-link` | links, headings, accent text | `--uva-brand-blue` (`#232d4b`)
|
|
626
|
-
| `--uva-color-utility-link` | header utility and site links | `--uva-blue-alt-dark` (`#005679`)
|
|
627
|
-
| `--uva-color-focus` | focus rings | `--uva-brand-orange` (`#e57200`)
|
|
628
|
-
| `--uva-color-current` | current-page underline | `--uva-brand-orange` (`#e57200`)
|
|
629
|
-
| `--uva-color-accent-bg` | pressed chip, slider range and thumbs, skip link, selection | `--uva-brand-blue` (`#232d4b`)
|
|
630
|
-
| `--uva-color-on-accent` | text on `--uva-color-accent-bg` | `#ffffff`
|
|
631
|
-
| `--uva-color-control-border` | borders of controls (chips, inputs, the theme control) | `--uva-grey` (`#808080`)
|
|
632
|
-
| `--uva-color-input-text` | date input text | `#1f2937`
|
|
633
|
-
| `--uva-color-border` | decorative borders and rules (dark only) | each component's own (`#ccc`, …)
|
|
634
|
-
| `--uva-color-track` | slider track | `#e5e7eb`
|
|
635
|
-
| `--uva-color-shadow` | panel shadow | `rgba(0, 0, 0, 0.2)`
|
|
636
|
-
| `--uva-color-pre-footer-bg` | pre-footer band background | `--uva-blue-alt-300` (`#bfe7f7`)
|
|
637
|
-
| `--uva-color-pre-footer-text` | pre-footer band text | `--uva-grey-darkest` (`#2b2b2b`)
|
|
852
|
+
| Token | Used for | Light | Dark |
|
|
853
|
+
| ----------------------------- | ----------------------------------------------------------- | ------------------------------------ | -------------------- |
|
|
854
|
+
| `--uva-color-surface` | page background | `#ffffff` | `#10172b` |
|
|
855
|
+
| `--uva-color-surface-raised` | header, nav bar, panels, popover, inputs, buttons, chips | `#ffffff` | `#232d4b` |
|
|
856
|
+
| `--uva-color-surface-hover` | hover and open-group background | `--uva-grey-100` (`#dadada`) | `#2c3858` |
|
|
857
|
+
| `--uva-color-text` | text | `--uva-grey-darkest` (`#2b2b2b`) | `#e8e8e8` |
|
|
858
|
+
| `--uva-color-text-muted` | secondary labels | `#4b5563` | `#adadad` |
|
|
859
|
+
| `--uva-color-link` | links, headings, accent text | `--uva-brand-blue` (`#232d4b`) | `#87b9d9` |
|
|
860
|
+
| `--uva-color-utility-link` | header utility and site links | `--uva-blue-alt-dark` (`#005679`) | `#91d8f2` |
|
|
861
|
+
| `--uva-color-focus` | focus rings | `--uva-brand-orange` (`#e57200`) | `#ffb370` |
|
|
862
|
+
| `--uva-color-current` | current-page underline | `--uva-brand-orange` (`#e57200`) | `#e57200` |
|
|
863
|
+
| `--uva-color-accent-bg` | pressed chip, slider range and thumbs, skip link, selection | `--uva-brand-blue` (`#232d4b`) | `#87b9d9` |
|
|
864
|
+
| `--uva-color-on-accent` | text on `--uva-color-accent-bg` | `#ffffff` | `#10172b` |
|
|
865
|
+
| `--uva-color-control-border` | borders of controls (chips, inputs, the theme control) | `--uva-grey` (`#808080`) | `#7a84a0` |
|
|
866
|
+
| `--uva-color-input-text` | date input text | `#1f2937` | `#e8e8e8` |
|
|
867
|
+
| `--uva-color-border` | decorative borders and rules (dark only) | each component's own (`#ccc`, …) | `#7a84a0` |
|
|
868
|
+
| `--uva-color-track` | slider track | `#e5e7eb` | `#2c3858` |
|
|
869
|
+
| `--uva-color-shadow` | panel shadow | `rgba(0, 0, 0, 0.2)` | `rgba(0, 0, 0, 0.6)` |
|
|
870
|
+
| `--uva-color-pre-footer-bg` | pre-footer band background | `--uva-blue-alt-300` (`#bfe7f7`) | `#005679` |
|
|
871
|
+
| `--uva-color-pre-footer-text` | pre-footer band text | `--uva-grey-darkest` (`#2b2b2b`) | `#ffffff` |
|
|
872
|
+
| `--uva-color-highlight` | highlighted search terms (`<mark>` in results) | `--uva-brand-orange-200` (`#ffc999`) | `#854200` |
|
|
873
|
+
| `--uva-color-on-highlight` | text on `--uva-color-highlight` | `--uva-grey-darkest` (`#2b2b2b`) | `#ffffff` |
|
|
638
874
|
|
|
639
875
|
`--uva-color-scheme` is the scheme the components follow (`light dark`, `light` or `dark`). See the [Dark mode](https://uvalib.github.io/reusable-web-library/#dark-mode) example in the playground.
|
|
640
876
|
|
|
@@ -669,9 +905,9 @@ Dark mode is **off by default**. Without it nothing changes: no control, no dark
|
|
|
669
905
|
</script>
|
|
670
906
|
```
|
|
671
907
|
|
|
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.
|
|
908
|
+
The filter and the date range are controlled: set `value` (and `scopeValue`) from your own state after each event. The date range also fires `uvalib-date-range-value` (`detail: { value: [start, end] }`) for every change to the range it shows, including a `value`, `min` or `max` set in script, so other components (such as a linked `<uvalib-date-histogram>`) can follow it; it is not a visitor action and is never sent to analytics. `date-range-change` stays the visitor's own change. `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
909
|
|
|
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
|
|
910
|
+
`<uvalib-date-histogram>` draws one button per month (grouped by year), per year, or per decade (`granularity="decade"`, five to a row labelled 1800, 1850, …, named "1810s: 22 meetings"; choosing one selects `1810/1819`, and a linked date range gets `1810-01-01` to `1819-12-31`). `granularity="auto"` picks months when every count is a month within 3 years, years up to 30 years, and decades beyond. For a long span such as 1817–2026 use decades rather than a sideways-scrolling year row: 210 year bars at the 24px minimum would be over 5,000px wide. 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 any change to the range's value, from its controls or set in script (a Clear button, Back/Forward, a restored URL), highlights the overlapping bars; the range fires `uvalib-date-range-value` for every change, which other code can listen for too. On (re)connect the range's value wins when it holds a selection, and the histogram never writes a rounded value back. Setting `selected` in script updates the date range and does not fire `select`. 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, per decade with `granularity="decade"`. 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
911
|
|
|
676
912
|
```html
|
|
677
913
|
<script
|
|
@@ -706,6 +942,121 @@ The filter and the date range are controlled: set `value` (and `scopeValue`) fro
|
|
|
706
942
|
</script>
|
|
707
943
|
```
|
|
708
944
|
|
|
945
|
+
## Combobox
|
|
946
|
+
|
|
947
|
+
`<uvalib-combobox>` is a text field that suggests values as you type, from a local list or a URL: a person, place or subject picker. It follows the WAI-ARIA APG [editable combobox with list autocomplete](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-list/) and looks like `.uvalib-input`. Entry: `uvalib-combobox.js` on the CDN, `@uvalib/web-components/uvalib-combobox.js` on npm.
|
|
948
|
+
|
|
949
|
+
```html
|
|
950
|
+
<script
|
|
951
|
+
type="module"
|
|
952
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-combobox.js"
|
|
953
|
+
></script>
|
|
954
|
+
|
|
955
|
+
<!-- Local items, set in script (objects or strings). -->
|
|
956
|
+
<form action="/search">
|
|
957
|
+
<uvalib-combobox
|
|
958
|
+
id="person"
|
|
959
|
+
name="person"
|
|
960
|
+
label="Person"
|
|
961
|
+
description="Type part of a name."
|
|
962
|
+
></uvalib-combobox>
|
|
963
|
+
<button class="uvalib-button" type="submit">Search</button>
|
|
964
|
+
</form>
|
|
965
|
+
<script type="module">
|
|
966
|
+
document.querySelector('#person').items = [
|
|
967
|
+
{ value: 'p-101', label: 'Avery Ashby', description: 'Photographer' },
|
|
968
|
+
{ value: 'p-102', label: 'Bea Brandt' },
|
|
969
|
+
];
|
|
970
|
+
</script>
|
|
971
|
+
|
|
972
|
+
<!-- <option> children, directly or in a <datalist>. A fallback <input list> works before
|
|
973
|
+
the script loads (give it aria-label); its text and name carry over. -->
|
|
974
|
+
<uvalib-combobox label="Subject" name="subject">
|
|
975
|
+
<input name="subject" list="subjects" aria-label="Subject" />
|
|
976
|
+
<datalist id="subjects">
|
|
977
|
+
<option value="architecture">Architecture</option>
|
|
978
|
+
<option value="athletics" data-description="Sports, games and teams">Athletics</option>
|
|
979
|
+
</datalist>
|
|
980
|
+
</uvalib-combobox>
|
|
981
|
+
|
|
982
|
+
<!-- A URL: {q} is the typed text, URL-encoded. -->
|
|
983
|
+
<uvalib-combobox
|
|
984
|
+
id="place"
|
|
985
|
+
label="Place"
|
|
986
|
+
name="place"
|
|
987
|
+
src="/api/places?q={q}"
|
|
988
|
+
min-length="2"
|
|
989
|
+
></uvalib-combobox>
|
|
990
|
+
<script type="module">
|
|
991
|
+
// Only if the response is not already an array of { value, label?, description? }.
|
|
992
|
+
document.querySelector('#place').transform = (data) =>
|
|
993
|
+
data.results.map((r) => ({ value: r.id, label: r.name }));
|
|
994
|
+
</script>
|
|
995
|
+
```
|
|
996
|
+
|
|
997
|
+
- **Suggestions.** `items` (`[{ value, label?, description?, disabled? }]` or strings) wins over the children while set; `<option>` children use `label` or their text, `value`, `data-description` and `disabled`. Local matching ignores case and accents and finds the text anywhere in the label: labels that start with it come first, then those with a word that starts with it. At most `max-results` are shown (default 50; `0` for all), so 16,000 records stay fast; the popup then says “Showing 50 of 1,234. Type more to narrow them.” The matched text is bold and underlined in a `<mark>`.
|
|
998
|
+
- **`src`.** Fetched 250 ms after the last keystroke once the text has `min-length` characters (default 1); a newer keystroke aborts the older request, and answers are cached per text. The response is a JSON array of the same shape, or `transform(data, query)` maps it. A failed load shows and announces “Couldn't load suggestions” and never throws.
|
|
999
|
+
- **Keys** (as the APG example). Down opens the list on the first suggestion and moves, wrapping; Up opens on the last; Alt+Down opens without moving and Alt+Up closes. Enter chooses the active suggestion and does not submit the form; with none active, Enter submits as in any field. Escape closes the list, and a second Escape clears the field. Home, End, Left and Right move the caret. Tab leaves without choosing. Typing never picks a suggestion for you.
|
|
1000
|
+
- **Free text or a choice.** `value` is the text in the field and `selected` the chosen suggestion (or null). Typing after a choice keeps the text and drops the choice; leaving the field with text that is exactly one suggestion's label (ignoring case and accents) chooses it. `must-choose` makes any other text invalid. Set `selected` (an item) or `value` in script to show a value; neither fires `change`.
|
|
1001
|
+
- **Forms.** The element is form-associated: with `name` it submits the chosen suggestion's `value`, or else the text, in a plain `<form>`. A reset restores the `value` attribute; `required`, `disabled` and a disabled `<fieldset>` work as on an `<input>`.
|
|
1002
|
+
- **Events.** `select` (`detail: { item }`, the object you gave) when a suggestion is chosen; `change` (`detail: { value, item }`) when the value is committed: a choice, a clear, or leaving the field with changed text. Both bubble and are composed. The field's own `input` events reach the page; its native `change` and `select` do not.
|
|
1003
|
+
- **Accessibility.** A visible `label` is required (one console warning without it); `description` is a hint read with the field (`aria-describedby`). The field is a real `<input role="combobox">` with `aria-expanded`, `aria-controls` and `aria-activedescendant`; the popup is a `role="listbox"`. A polite status says “5 suggestions”, “No suggestions” or “Loading suggestions” half a second after the list settles, never on the first render. The clear button is a real button named “Clear <label>”, 44px, shown only with text, and returns focus to the field. Suggestions are at least 44px tall; the active one has a fill, a bar at its start and an outline (Highlight in forced colors), not colour alone.
|
|
1004
|
+
- **Layout.** The popup is positioned under the field inside the element (no top layer), as wide as the field, so it never overflows a 320px screen and scrolls with the page or a scrolling container; a long list scrolls inside it with the active suggestion kept in view. An ancestor with `overflow: hidden` clips it. Dark mode follows the role tokens. `no-style` keeps the layout, the 44px targets and the hidden status.
|
|
1005
|
+
- **Before the script loads.** `base.css` shows the label (from the attribute) and holds the field's height, plus one line for a `description`, so nothing below moves on upgrade. A fallback `<input>` child is a working field meanwhile (with `list`, the browser's own suggestions); once upgraded it is disabled so it does not submit twice. Other children stay hidden.
|
|
1006
|
+
- **Analytics.** `select` with the label and the suggestion's position (from 1), and `clear` with the label. Never the typed text or a suggestion's text or value: they can be people's names.
|
|
1007
|
+
|
|
1008
|
+
## Filter drawer
|
|
1009
|
+
|
|
1010
|
+
`<uvalib-filter-drawer>` holds a search page's form and filters: a plain sidebar on wide screens, and at and below `breakpoint` (default `48rem`) a “Search and filters” button that opens them in a modal panel from the side, as Virgo does on phones. Entry: `uvalib-filter-drawer.js` on the CDN, `@uvalib/web-components/uvalib-filter-drawer.js` on npm. See the [Filter drawer](https://uvalib.github.io/reusable-web-library/#filter-drawer) example.
|
|
1011
|
+
|
|
1012
|
+
```html
|
|
1013
|
+
<script
|
|
1014
|
+
type="module"
|
|
1015
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-filter-drawer.js"
|
|
1016
|
+
></script>
|
|
1017
|
+
|
|
1018
|
+
<div class="search-layout">
|
|
1019
|
+
<uvalib-filter-drawer label="Search and filters" live="results-count status">
|
|
1020
|
+
<form class="uvalib-search-form" role="search">…</form>
|
|
1021
|
+
<uvalib-filter id="decade"></uvalib-filter>
|
|
1022
|
+
</uvalib-filter-drawer>
|
|
1023
|
+
<section>
|
|
1024
|
+
<uvalib-results-count id="results-count" total="1204"></uvalib-results-count>
|
|
1025
|
+
<p id="status" role="status"></p>
|
|
1026
|
+
…
|
|
1027
|
+
</section>
|
|
1028
|
+
</div>
|
|
1029
|
+
<script type="module">
|
|
1030
|
+
const drawer = document.querySelector('uvalib-filter-drawer');
|
|
1031
|
+
document.querySelector('#decade').addEventListener('filter-change', (e) => {
|
|
1032
|
+
drawer.count = e.detail.value.length; // the number of filters set, on the button
|
|
1033
|
+
});
|
|
1034
|
+
</script>
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
- **Wide screens.** The children are shown as written: no button, no dialog role. Lay out the sidebar column yourself (a grid with the drawer in the first column above `48rem`).
|
|
1038
|
+
- **Narrow screens.** Only the button is shown (44px, `aria-haspopup="dialog"`, `aria-expanded`). It opens a native `<dialog>` with `showModal()`, named by its visible heading (the `label`), with a 44px Close button that takes focus. Close, Escape and a click on the backdrop close it, and focus returns to the button. Widening the window past the breakpoint closes it and leaves focus where it was. `show()` and `close()` open and close it from script (call `close()` after a search, say); `open` says whether it is open; `open` and `close` events follow.
|
|
1039
|
+
- **The page behind is inert.** A modal dialog makes everything outside it inert, `<site-page>`'s shadow header, skip link and alerts included, so focus cannot reach them and no script has to send it back. The only way out is Escape, Close, the backdrop or the browser's own controls: no keyboard trap.
|
|
1040
|
+
- **Announcements from behind.** Inert content is not announced, so a results count or status notice outside the panel would go silent while the visitor filters. List their ids in `live`: while the panel is open the drawer watches them (also inside a component's open shadow root, such as `<uvalib-results-count>`'s live region) and repeats each new announcement in its own polite live region inside the panel, cleared after 5 seconds. Regions inside the drawer need no entry.
|
|
1041
|
+
- **Same nodes.** The children are moved between the sidebar and the panel (with `moveBefore()` where the browser has it), never re-created: typed text, checked boxes, listeners and each `<uvalib-filter>`'s state stay, through open, close and resizes. In shadow DOM they never move at all (the slot does). Children added later are included.
|
|
1042
|
+
- **Count.** `count` (a number the page sets) is shown on the button when above 0 and read as “Search and filters, 3 active”. The drawer does not count inputs itself: only the page knows which of them are filters.
|
|
1043
|
+
- **Look.** The panel slides in from the start side (no slide with reduced motion), `--uvalib-filter-drawer-width` wide (default `min(24rem, 100% - 3rem)`, leaving a strip of backdrop at 320px), scrolling on its own. Dark mode follows the role tokens; in forced colors the panel keeps a visible edge.
|
|
1044
|
+
- **Before the script loads.** On wide screens the children show as the sidebar, as they will once it upgrades. At and below the default `48rem`, `base.css` hides them and holds the button's 44px, so a phone never shows the filters in full and nothing moves when the element upgrades (no layout shift). With your own `breakpoint`, `base.css` leaves the drawer alone: add the same rule for your width to the page's CSS (`(max-width: …)`, as the element's own media query):
|
|
1045
|
+
|
|
1046
|
+
```css
|
|
1047
|
+
@media (max-width: 60rem) {
|
|
1048
|
+
:where(uvalib-filter-drawer[breakpoint='60rem']):not(:defined) {
|
|
1049
|
+
display: block;
|
|
1050
|
+
min-block-size: 44px;
|
|
1051
|
+
}
|
|
1052
|
+
:where(uvalib-filter-drawer[breakpoint='60rem']):not(:defined) > * {
|
|
1053
|
+
display: none;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
- **Analytics.** `open` and `close` with the drawer's `label`, only when the visitor does it (not a resize or a script).
|
|
1059
|
+
|
|
709
1060
|
## Results, badges and tags
|
|
710
1061
|
|
|
711
1062
|
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.
|
|
@@ -796,6 +1147,54 @@ filter.addEventListener('input', () => {
|
|
|
796
1147
|
});
|
|
797
1148
|
```
|
|
798
1149
|
|
|
1150
|
+
### Results list
|
|
1151
|
+
|
|
1152
|
+
For long result sets (hundreds or thousands of rows that re-render as the visitor types), plain list rows from `base.css` are much lighter than a `<uvalib-card>` per result: no element per row, no script. See the [Results list](https://uvalib.github.io/reusable-web-library/#results-list) example.
|
|
1153
|
+
|
|
1154
|
+
```html
|
|
1155
|
+
<h2>1999</h2>
|
|
1156
|
+
<ul class="uvalib-result-list">
|
|
1157
|
+
<li class="uvalib-result">
|
|
1158
|
+
<p class="uvalib-result__meta">
|
|
1159
|
+
<span class="uvalib-badge uvalib-badge--category">March 12, 1999</span>
|
|
1160
|
+
<span>14 pages</span>
|
|
1161
|
+
</p>
|
|
1162
|
+
<h3 class="uvalib-result__title"><a href="/minutes/1999-03-12">Meeting of the Board</a></h3>
|
|
1163
|
+
<p class="uvalib-result__snippet">
|
|
1164
|
+
The board approved the <mark>library</mark> renovation budget …
|
|
1165
|
+
</p>
|
|
1166
|
+
<div class="uvalib-result__actions">
|
|
1167
|
+
<a
|
|
1168
|
+
class="uvalib-button uvalib-button--secondary uvalib-button--small"
|
|
1169
|
+
href="/minutes/1999-03-12.pdf"
|
|
1170
|
+
>
|
|
1171
|
+
PDF<span class="visually-hidden"> of Meeting of the Board, March 12, 1999</span>
|
|
1172
|
+
</a>
|
|
1173
|
+
</div>
|
|
1174
|
+
</li>
|
|
1175
|
+
</ul>
|
|
1176
|
+
|
|
1177
|
+
<!-- Loading: a skeleton row the size of a row, hidden from assistive technology. -->
|
|
1178
|
+
<ul class="uvalib-result-list" aria-hidden="true">
|
|
1179
|
+
<li class="uvalib-result">
|
|
1180
|
+
<span class="uvalib-result__meta"
|
|
1181
|
+
><span class="uvalib-skeleton-text" style="inline-size: 8rem"></span
|
|
1182
|
+
></span>
|
|
1183
|
+
<span class="uvalib-result__title"><span class="uvalib-skeleton-text"></span></span>
|
|
1184
|
+
<span class="uvalib-result__snippet"
|
|
1185
|
+
><span class="uvalib-skeleton-text"></span><span class="uvalib-skeleton-text"></span
|
|
1186
|
+
></span>
|
|
1187
|
+
</li>
|
|
1188
|
+
</ul>
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
- **`.uvalib-result-list`** is a `<ul>` without bullets; **`.uvalib-result`** a row, separated by a rule. In a row: **`__meta`** (badges, a date, a format, in small muted text), **`__title`** (the row's one link: on a heading holding the `<a>`, or on the `<a>` itself; only as wide as its text), **`__snippet`** and **`__actions`** (secondary actions, at the end of the row on wide screens and below the text, wrapping, at 40em and narrower). Put meta, title and snippet first, actions last. Keep one link per row and give each action a unique name (a visually hidden “of <title>, <date>”).
|
|
1192
|
+
- **Highlights:** a `<mark>` in `__snippet` is bold on `--uva-color-highlight` with `--uva-color-on-highlight` text (9.5:1 light, 7.6:1 dark), and the system Highlight colours in forced colors: never colour alone. A `<mark>` elsewhere is left to the page.
|
|
1193
|
+
- **Groups:** for date-sorted results, a heading and one list per group (by year, say); none for relevance order.
|
|
1194
|
+
- **Speed:** each row has `content-visibility: auto` with `contain-intrinsic-block-size: auto 7rem`, so rows off screen are not laid out or painted until they scroll near. They stay in the DOM and the accessibility tree; find-in-page, fragment links and focus still reach them (the browser renders a row as it is found). The rows keep 0.5rem of inline padding because that property also clips painting to the row, and the focus rings need the room. Render the rows as one HTML string or a `DocumentFragment` rather than one element at a time.
|
|
1195
|
+
- **Phones:** actions wrap below the text, and nothing scrolls sideways at 320px. Room for a button fixed in a corner (back to top, say) is the page's to leave, for example with padding below the list.
|
|
1196
|
+
- **`hidden`** on a row hides it, for filtering in place.
|
|
1197
|
+
|
|
799
1198
|
### Tag lists
|
|
800
1199
|
|
|
801
1200
|
```html
|
|
@@ -877,6 +1276,34 @@ Three elements show opening hours from the library's own data, for library.virgi
|
|
|
877
1276
|
- **States.** On the first load a polite `role="status"` says "Loading hours…". Later loads keep the current rows on screen (the weekly table gets `aria-busy="true"`) until the new data lands. If the data cannot be loaded the status says "Hours are unavailable right now."; `<library-weekly-hours>` keeps its week header and adds a Retry button, and both elements retry quietly on their timers. Only user actions (the week buttons, Retry) are announced; midnight rollovers and background refreshes are silent. Read the read-only `state` (`loading`, `ready` or `error`) from script. On the first load `<library-weekly-hours>` draws its rows straight away (Building hours and each space, as soon as the library list is in) with invisible placeholder hours, so the table has its final height in the page's own font and nothing below it moves when the hours arrive. `--library-weekly-hours-min-height` can reserve space even before the library list is in (it applies while the element has a `loading` attribute), and `library-weekly-hours:not(:defined) { display: block; min-height: … }` before it upgrades. `<site-hours-section>` has `--site-hours-list-min-height` for the same purpose.
|
|
878
1277
|
- **Harrison special case.** `<library-hours-setup>` adds `hide-building-hours` to `library-slug="harrison"`: Harrison's building calendar (LibCal 4114) is also the calendar of its own "Harrison/Small Building & Exhibitions" space, so the building row would repeat it.
|
|
879
1278
|
- **Light DOM output** keeps the class names Drupal's CSS targets (`home-hours-block`, `hours-locations`, `weekly-hours-header-section`, `weekly-hours-body-section`, `date--mobile`, `lib-space-link`, …). `<library-weekly-hours>` keeps a few layout rules even with `no-style` (the host is `display: block`, the week header is a flex row, `[hidden]` hides), scoped to the tag in `@layer uvalib`. `headinglevelstart` is still read as an alias of `heading-level`. With neither set, the week heading's `aria-level` is one below the nearest heading before the element in the page (3 under each library's `<h2>` on /hours), or 2 when there is none, while its class stays `heading-h2`, the one the library website's CSS styles; set `heading-level` to override both. `<site-hours-section>` does not infer its level: on the home page it sits in a side column after another section's cards, where the heading before it in the page is not its parent, so it keeps its explicit default.
|
|
1279
|
+
- **Testing a site's analytics and accessibility.** `@uvalib/web-components/testing` (npm only, for Playwright; not on the CDN) has the helpers library sites share: `stubMatomo(page, { siteId? })` (call it before `page.goto`: `…/matomo.js` gets an empty script and `…/matomo.php` a 204, so nothing reaches Matomo, and `siteId` becomes the `matomo-id` of each `<site-page>` without one), `matomoQueue(page)` (a copy of `window._paq`: the page views, site searches and events, in order), `waitForUpgrade(page, { selector?, timeout? })` (every `<site-page>`, or `selector`, defined and rendered), `strictAxe(page, { include?, exclude?, AxeBuilder? })` (axe after `waitForUpgrade`, with `LIGHTHOUSE_RULES` forced on and the WCAG 2.x A/AA and best-practice tags `STRICT_AXE_TAGS`; it needs the optional peer dependency `@axe-core/playwright`, loaded only when it runs) and `formatViolations(violations)` (one line each). See [accessibility testing](skills/uvalib-web-components/reference/accessibility-testing.md).
|
|
1280
|
+
|
|
1281
|
+
```js
|
|
1282
|
+
import { test, expect } from '@playwright/test';
|
|
1283
|
+
import { stubMatomo, matomoQueue, waitForUpgrade } from '@uvalib/web-components/testing';
|
|
1284
|
+
|
|
1285
|
+
test('a search is one site search', async ({ page }) => {
|
|
1286
|
+
await stubMatomo(page, { siteId: 42 });
|
|
1287
|
+
await page.goto('./search/');
|
|
1288
|
+
await waitForUpgrade(page);
|
|
1289
|
+
await page.getByLabel('Search').fill('rotunda');
|
|
1290
|
+
await page.getByRole('button', { name: 'Search' }).click();
|
|
1291
|
+
await expect
|
|
1292
|
+
.poll(async () => (await matomoQueue(page)).filter((c) => c[0] === 'trackSiteSearch'))
|
|
1293
|
+
.toEqual([['trackSiteSearch', 'rotunda', 'Keyword', 4]]);
|
|
1294
|
+
});
|
|
1295
|
+
|
|
1296
|
+
test('Do Not Track sends nothing', async ({ page }) => {
|
|
1297
|
+
await page.addInitScript(() =>
|
|
1298
|
+
Object.defineProperty(Navigator.prototype, 'doNotTrack', { get: () => '1' }),
|
|
1299
|
+
);
|
|
1300
|
+
await stubMatomo(page, { siteId: 42 });
|
|
1301
|
+
await page.goto('./');
|
|
1302
|
+
await waitForUpgrade(page);
|
|
1303
|
+
expect(await matomoQueue(page)).toEqual([]);
|
|
1304
|
+
});
|
|
1305
|
+
```
|
|
1306
|
+
|
|
880
1307
|
- **Drupal switch.** Replace the old `…/web-components/cdn-vX.Y.Z/@uvalib/site-hours/<file>.js` script URLs with `https://unpkg.internal.lib.virginia.edu/web-components/v1/<tag>.js` (`site-hours-section.js` on the home page, `library-hours-setup.js` on /hours). The markup stays the same. `library-daily-hours` is not migrated.
|
|
881
1308
|
|
|
882
1309
|
## Library events
|
|
@@ -964,17 +1391,56 @@ Static sites that search with [Pagefind](https://pagefind.app) (such as Electron
|
|
|
964
1391
|
<uvalib-analytics matomoid="10"></uvalib-analytics>
|
|
965
1392
|
```
|
|
966
1393
|
|
|
967
|
-
- **Attributes.** `matomoid`: the Matomo site id; without it, the site whose URL the page is under (the library's site registry), and with none, the element does nothing. `matomourl` (default `https://analytics.lib.virginia.edu/`, ending in `/`): the Matomo server. `spa`: no page view on load; a single-page app records each view with a pageview event. `spa="auto"`: the element records them itself, one on load and one per same-document route change (see below). `variables`: custom dimensions as a JSON object, `variables='{"1":"staff"}'`, set before the page view.
|
|
1394
|
+
- **Attributes.** `matomoid`: the Matomo site id; without it, the site whose URL the page is under (the library's site registry), and with none, the element does nothing. `matomourl` (default `https://analytics.lib.virginia.edu/`, ending in `/`): the Matomo server. `spa`: no page view on load; a single-page app records each view with a pageview event. `spa="auto"`: the element records them itself, one on load and one per same-document route change (see below). `variables`: custom dimensions as a JSON object, `variables='{"1":"staff"}'`, set before the page view. `downloads="event"`: count downloads without their URLs (see below).
|
|
968
1395
|
- **Events.** Both tags listen on `document` for both families, `uvalib-analytics-*` (the original names) and `site-analytics-*`. Fire them bubbling and composed from anywhere, or with `trackEvent(el, parts)` and `trackSearch(el, query, category?, count?)` from `@uvalib/web-components/base.js` (which follow the opt-outs below; `analyticsAllowed(el)` tells you whether `el` may report), or the mixins (`UvalibAnalyticsMixin`: `_analyticsEvent`, `_analyticsSearch`, firing `uvalib-analytics-*`; `SiteAnalyticsMixin`: `analyticsEvent`, `analyticsSearch`, firing `site-analytics-*`).
|
|
969
1396
|
- `…-event`: `detail: { event: [category, action, name?, value?] }` (`track` is accepted as the old name), a Matomo `trackEvent`.
|
|
970
1397
|
- `…-search`: `detail: { searchQuery, searchCategory?, resultCount? }`, a Matomo site search; an unknown count (null or missing) is sent as Matomo's "unknown".
|
|
971
1398
|
- `…-pageview`: `detail: { customTitle?, referrer? }`, a page view; the title defaults to the document's, a referrer without `http` is a path on this origin, and with none the document's referrer is used.
|
|
972
1399
|
- `…-content`: `detail: { name, piece, target?, interaction? }`, a Matomo content impression (`trackContentImpression`), or with `interaction` a `trackContentInteraction`; `trackContent(el, { name, piece, target?, interaction? })` from `@uvalib/web-components/base.js` fires it.
|
|
1400
|
+
- **Site search in your own search UI: `createSearchTracker`.** `<bento-box>` and `<uvalib-pagefind-search>` report their searches; a page with its own search box uses `createSearchTracker({ element?, debounce? })` from `analytics.js` (CDN `https://unpkg.internal.lib.virginia.edu/web-components/v1/analytics.js`, npm `@uvalib/web-components/analytics.js` or `base.js`) rather than calling `trackSearch` itself. It sends one Matomo site search per search the visitor settles on, with the result count (0 included) and a category, through `trackSearch`, so the opt-outs below apply; the query goes only into Matomo's site-search keyword, never into an event. Each method takes `{ query, count?, category?, key? }`:
|
|
1401
|
+
- `typed(search)`: search-as-you-type; sent once the results have stayed the same for `debounce` ms (default 1000), and a later call replaces it.
|
|
1402
|
+
- `settled(search)`: a submitted or server-backed search, when its results arrive; sent at once.
|
|
1403
|
+
- `restored(search)`: the page opened from a link with a query, or Back/Forward; nothing is sent, and the same search again (Enter) is not counted.
|
|
1404
|
+
- `cancel()`: the field was cleared or the search failed; a typed search still waiting is dropped. Send nothing for errors.
|
|
1405
|
+
- `reset()`: forget the last search sent, so the same one counts again.
|
|
1406
|
+
|
|
1407
|
+
A search is never sent twice in a row for the same `key` (default: the query and the category); pass the query and the active filters as `key` when filters make a new search. `element` (default `document`) is where it reports from, so a `no-analytics` ancestor silences it.
|
|
1408
|
+
|
|
1409
|
+
```html
|
|
1410
|
+
<script type="module">
|
|
1411
|
+
import { createSearchTracker } from 'https://unpkg.internal.lib.virginia.edu/web-components/v1/analytics.js';
|
|
1412
|
+
const form = document.querySelector('#search');
|
|
1413
|
+
const tracker = createSearchTracker({ element: form });
|
|
1414
|
+
const fromUrl = new URLSearchParams(location.search).get('q');
|
|
1415
|
+
if (fromUrl) tracker.restored({ query: fromUrl, category: 'Keyword', count: show(fromUrl) });
|
|
1416
|
+
form.q.addEventListener('input', () => {
|
|
1417
|
+
const query = form.q.value;
|
|
1418
|
+
if (!query.trim()) return tracker.cancel();
|
|
1419
|
+
tracker.typed({ query, category: 'Keyword', count: show(query) });
|
|
1420
|
+
});
|
|
1421
|
+
form.addEventListener('submit', async (e) => {
|
|
1422
|
+
e.preventDefault();
|
|
1423
|
+
try {
|
|
1424
|
+
const results = await search(form.q.value); // your own search
|
|
1425
|
+
tracker.settled({ query: form.q.value, category: 'Keyword', count: results.length });
|
|
1426
|
+
} catch {
|
|
1427
|
+
tracker.cancel(); // never on an error
|
|
1428
|
+
}
|
|
1429
|
+
});
|
|
1430
|
+
</script>
|
|
1431
|
+
```
|
|
1432
|
+
|
|
973
1433
|
- **Nothing is lost or counted twice.** Every call goes through Matomo's `_paq` queue, which matomo.js replays when it loads, so events fired before it arrives are kept (and nothing waits for it if it is blocked). However many analytics elements a page has, from any copy of this library (an npm build next to a CDN script, two CDN versions), matomo.js is loaded and the page view recorded once and only one element forwards each event; if it is removed, the next one takes over. A Matomo snippet already on the page (a `matomo.js` script, or a `_paq` that sets a site id) is used as it is: nothing is loaded or recorded again, and the element only forwards the events.
|
|
974
|
-
- **Matomo's own link tracking** (`enableLinkTracking`, on unless `spa`, as in the old element) still records clicks on links to other sites and downloads with their URLs, result links included. Besides Matomo's own download types (pdf, doc*, xls*, ppt*, …), links to the library's file types count as downloads: epub, mobi, csv, tsv, json, xml, zip, tar, gz, mp3, mp4, m4a, tif, tiff, jp2, mrc, ris, bib and txt (`addDownloadExtensions`). The components' own events never carry titles or URLs.
|
|
1434
|
+
- **Matomo's own link tracking** (`enableLinkTracking`, on unless `spa` or `downloads="event"`, as in the old element) still records clicks on links to other sites and downloads with their URLs, result links included. Besides Matomo's own download types (pdf, doc*, xls*, ppt*, …), links to the library's file types count as downloads: epub, mobi, csv, tsv, json, xml, zip, tar, gz, mp3, mp4, m4a, tif, tiff, jp2, mrc, ris, bib and txt (`addDownloadExtensions`). The components' own events never carry titles or URLs.
|
|
1435
|
+
- **`downloads="event"`: downloads without their URLs.** Opt in when file URLs carry ids you do not want in analytics (`<site-analytics downloads="event">`, `<uvalib-analytics downloads="event">`, or `<site-page matomo-id="N" matomo-downloads="event">`). Matomo's link tracking is then left off (no `enableLinkTracking`, no `addDownloadExtensions`), and the element sends instead:
|
|
1436
|
+
- for a left or middle click on a download, the event `['download', '<extension>']`: no URL and no file name. A download is a link with the `download` attribute (the extension of its file name, else of its URL, else `file`) or a link to a file of the types above (Matomo's and the library's), in light or shadow DOM;
|
|
1437
|
+
- for a click on a light DOM link to another site, Matomo's outlink (`trackLink`, with the URL), as its link tracking would have; with `spa` there are none, as before.
|
|
1438
|
+
|
|
1439
|
+
Links with Matomo's `matomo_ignore` class, and links under `no-analytics`, send nothing. A `data-uvalib-track` on the link still sends its own event too, so a fixed label can go with it (`data-uvalib-track="bov,pdf-download,result"`). Default: unchanged. It has no effect when a Matomo snippet is already on the page.
|
|
1440
|
+
|
|
975
1441
|
- **`spa="auto"`** records a page view on load and on every same-document route change (`history.replaceState`, such as a search page syncing its filters to the URL, and reloads are never page views): a hash change, Back and Forward (`popstate`), the Navigation API's `currententrychange` where the browser has it, and `history.pushState` (wrapped once per page, shared by every copy of this library, and left in place). The view is recorded on the next frame, so the title the app sets right after navigating is the one counted, with the URL as the custom URL and the previous view's URL as the referrer. A change to the URL already counted (`replaceState`, a second `pushState` to the same URL, the several events one Back fires) is not counted again. Opening `<uvalib-lightbox url-param>` pushes one history entry, so this counts that open as a page view; stepping through the images replaces the entry and is not another view. Bare `spa` keeps its meaning: no automatic views.
|
|
976
1442
|
- **`data-uvalib-track` for host content.** A click on an element with `data-uvalib-track="category,action[,name[,value]]"`, or on anything inside it, sends that Matomo event (the nearest tagged element wins; `value` must be a number). It works in light and shadow DOM (one capture-phase listener on `document`, reading the click's composed path) and needs an analytics element on the page. Use your site's name or the widget as the category and a fixed verb as the action, and never put titles, URLs or personal data in it: `<a href="/spaces" data-uvalib-track="home-page,banner-click,Study spaces">`.
|
|
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.
|
|
1443
|
+
- **`<site-page matomo-id="N">`** (and optional `matomo-url` and `matomo-downloads`) 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.
|
|
978
1444
|
- **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.
|
|
979
1445
|
|
|
980
1446
|
| Component | Action | Name | Value |
|
|
@@ -993,8 +1459,10 @@ Static sites that search with [Pagefind](https://pagefind.app) (such as Electron
|
|
|
993
1459
|
| `uvalib-tabs` | `change` | the tab's label (capped at 100 characters; not a URL) | |
|
|
994
1460
|
| `uvalib-contents` | `link-click` | `level N` (never the label or URL) | N, from 1 (the top level) |
|
|
995
1461
|
| `uvalib-contents` | `toggle` (the narrow-screen disclosure) | `open` or `close` | |
|
|
996
|
-
| `uvalib-metadata` | `copy-citation` (downloads are left to Matomo's
|
|
1462
|
+
| `uvalib-metadata` | `copy-citation` (downloads are left to Matomo's, or to `downloads="event"`) | | |
|
|
1463
|
+
| `uvalib-metadata` | `show-all`, `show-fewer` (a long list's toggle) | `row N` (the row's place in the list; never its label or values) | |
|
|
997
1464
|
| `uvalib-lightbox` | `open`, `next`, `previous`, `full-size` | `image N` (never the URL or the caption) | N, from 1 |
|
|
1465
|
+
| `uvalib-image-regions` | `select` (an outline clicked; nothing on hover or focus) | the list's `label` (never a region's label) | the region's number, from 1 |
|
|
998
1466
|
| `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
1467
|
| `uvalib-tag-list` | `show-all`, `show-fewer` | `list N`, or with `track-label` the `label` | |
|
|
1000
1468
|
| `site-alerts` | a content impression, once per alert per page view: `trackContentImpression('Library alert', '<severity>: <title>')` | | |
|
|
@@ -1007,6 +1475,13 @@ Static sites that search with [Pagefind](https://pagefind.app) (such as Electron
|
|
|
1007
1475
|
| `library-weekly-hours` | `week-change` | `next` or `previous` | |
|
|
1008
1476
|
| `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
1477
|
| `uvalib-chip-group` | `select` (links mode) | the group's label (never the chip or its URL) | |
|
|
1478
|
+
| `uvalib-combobox` | `select` (a suggestion chosen) | the field's label (never the typed text or the suggestion) | the suggestion's position, from 1 |
|
|
1479
|
+
| `uvalib-combobox` | `clear` (the clear button, or Escape on a closed list) | the field's label | |
|
|
1480
|
+
| `uvalib-combobox` | `error` (`src` failed to load) | `load` | |
|
|
1481
|
+
| `uvalib-filter-drawer` | `open`, `close` (by the visitor: the button, Close, Escape or the backdrop; not a resize or a script) | the drawer's `label` | |
|
|
1482
|
+
| `uvalib-back-to-top` | `click` | | |
|
|
1483
|
+
| `uvalib-map` | `select` (a marker chosen: click, Enter or Space) | the map's label (never the place's name, coordinates or URL) | the place's position, from 1 |
|
|
1484
|
+
| `uvalib-map` | `zoom` (1 s after the last zoom-button press) | the map's label | the zoom level |
|
|
1010
1485
|
| `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
1486
|
| `uvalib-filter` | `scope-change` | the scope's label | 1 pressed, 0 not |
|
|
1012
1487
|
| `uvalib-filter` | `see-more`, `see-less` | the filter's title | |
|
|
@@ -1285,7 +1760,7 @@ Live UVA Library alerts, drawn as library.virginia.edu draws them. The alerts pr
|
|
|
1285
1760
|
|
|
1286
1761
|
### `<site-analytics>`
|
|
1287
1762
|
|
|
1288
|
-
Matomo analytics, with no visual output. Loads matomo.js for the site and records the page view, then forwards the events below, fired anywhere in the page, to Matomo. Every call goes through Matomo's `_paq` queue, so events fired before matomo.js loads are kept. One tracker per page: however many `<site-analytics>` and `<uvalib-analytics>` elements there are (from any copy of this library), matomo.js is loaded and the page view recorded once, and only one element forwards each event; if it is removed, the next takes over. A Matomo snippet already on the page is used as it is (nothing is loaded or recorded again). When the browser sends Do Not Track or Global Privacy Control, or the page has `<html data-uvalib-analytics="off">`, it loads nothing and records nothing. A click on an element with `data-uvalib-track="category,action[,name[,value]]"` (or inside one, in light or shadow DOM) sends that event, unless `<html data-uvalib-analytics="off">` or a `no-analytics` ancestor opts it out. The same element is registered as `<uvalib-analytics>` by `uvalib-analytics.js`.
|
|
1763
|
+
Matomo analytics, with no visual output. Loads matomo.js for the site and records the page view, then forwards the events below, fired anywhere in the page, to Matomo. Every call goes through Matomo's `_paq` queue, so events fired before matomo.js loads are kept. One tracker per page: however many `<site-analytics>` and `<uvalib-analytics>` elements there are (from any copy of this library), matomo.js is loaded and the page view recorded once, and only one element forwards each event; if it is removed, the next takes over. A Matomo snippet already on the page is used as it is (nothing is loaded or recorded again). When the browser sends Do Not Track or Global Privacy Control, or the page has `<html data-uvalib-analytics="off">`, it loads nothing and records nothing. A click on an element with `data-uvalib-track="category,action[,name[,value]]"` (or inside one, in light or shadow DOM) sends that event, unless `<html data-uvalib-analytics="off">` or a `no-analytics` ancestor opts it out. With `downloads="event"` downloads are counted as `['download', '<extension>']` events, without their URLs, instead of by Matomo's link tracking. The same element is registered as `<uvalib-analytics>` by `uvalib-analytics.js`.
|
|
1289
1764
|
|
|
1290
1765
|
#### Attributes
|
|
1291
1766
|
|
|
@@ -1295,6 +1770,7 @@ Matomo analytics, with no visual output. Loads matomo.js for the site and record
|
|
|
1295
1770
|
| `matomoid` | `number \| undefined` | | The Matomo site id (attribute `matomoid`). Default: the site whose URL the page is under. |
|
|
1296
1771
|
| `spa` | `boolean \| 'auto'` | `false` | A single-page app. `spa` (no value): it records its own page views (`uvalib-analytics-pageview`), none on load. `spa="auto"`: a page view on load and one per same-document route change (hash change, Back and Forward, `history.pushState`), once the title has settled, never twice in a row for the same URL, with the previous URL as the referrer. Either way Matomo's link tracking is off. |
|
|
1297
1772
|
| `variables` | `Record<string, unknown> \| null` | `null` | Custom dimensions, a JSON object of `{ id: value }`, set before the page view. |
|
|
1773
|
+
| `downloads` | `string \| undefined` | | `event`: count downloads without their URLs. Matomo's link tracking is left off; a left or middle click on a link to a file (the `download` attribute, or a download file type) sends the event `['download', '<extension>']` (no URL, no file name), and a click on a link to another site is still sent as an outlink (`trackLink`), as Matomo's link tracking would. Off by default. Read when Matomo is set up; no effect with a Matomo snippet already on the page. |
|
|
1298
1774
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1299
1775
|
| `no-style` | `boolean` | `false` | |
|
|
1300
1776
|
|
|
@@ -1494,7 +1970,7 @@ The UVA Library main navigation (About, Using the Library, Research & teaching s
|
|
|
1494
1970
|
|
|
1495
1971
|
### `<site-page>`
|
|
1496
1972
|
|
|
1497
|
-
Page wrapper: skip link (inside the header landmark in shadow mode), header, a single `<main>`, footer (unless `no-footer`), and global page styles. Side-effect free: `site-page.ts` registers `<site-header>` (and its `<site-main-nav>`) and `<site-footer>`. The header shows the UVA Library main navigation by default (`no-main-nav` turns it off; `header-variant="vendor"` never shows it). Shows live UVA Library alerts by default with `<site-alerts>` (its code loads only then), placed as Virgo places them: a full-bleed `<site-alerts show="header">` banner at the top of the header landmark (after the skip link), a full-bleed band between the header and `<main>` holding `<site-alerts show="list">` (a `<section aria-label="Library alerts">` region, hidden while the list has nothing to show), and `<site-alerts show="regional">` as the first child of `<main>`, inside its padding. Their data comes from one headless `<uvalib-alerts>`, loaded once per document, with a module script, from the alerts CDN (`alerts-env`, or `alerts-src`); if it fails to load, one console warning is logged and the page works as before. `no-alerts` renders no alert elements and loads nothing. A `slot="breadcrumbs"` child (a `<uvalib-breadcrumbs>`) is placed where library.virginia.edu puts the trail: after the header and the alert list band, before `<main>` and outside it (so the skip link lands past it), with the same gutters as `<main>`.
|
|
1973
|
+
Page wrapper: skip link (inside the header landmark in shadow mode), header, a single `<main>`, footer (unless `no-footer`), and global page styles. Side-effect free: `site-page.ts` registers `<site-header>` (and its `<site-main-nav>`) and `<site-footer>`. The header shows the UVA Library main navigation by default (`no-main-nav` turns it off; `header-variant="vendor"` never shows it). Shows live UVA Library alerts by default with `<site-alerts>` (its code loads only then), placed as Virgo places them: a full-bleed `<site-alerts show="header">` banner at the top of the header landmark (after the skip link), a full-bleed band between the header and `<main>` holding `<site-alerts show="list">` (a `<section aria-label="Library alerts">` region, hidden while the list has nothing to show), and `<site-alerts show="regional">` as the first child of `<main>`, inside its padding. Their data comes from one headless `<uvalib-alerts>`, loaded once per document, with a module script, from the alerts CDN (`alerts-env`, or `alerts-src`); if it fails to load, one console warning is logged and the page works as before. `no-alerts` renders no alert elements and loads nothing. A `slot="breadcrumbs"` child (a `<uvalib-breadcrumbs>`) is placed where library.virginia.edu puts the trail: after the header and the alert list band, before `<main>` and outside it (so the skip link lands past it), with the same gutters as `<main>`. Printing leaves out the chrome: the skip link, header (with the main navigation and the header alert), alert list band, regional alerts, breadcrumbs, pre-footer and footer are not printed, `<main>` loses its gutters, and the content prints black on white (a dark scheme prints light), its links underlined. A short line above the content says where the page came from ("UVA Library — <site name or page title>" and the page's URL). `print-chrome` prints the page as it is shown instead. With `no-style` none of this applies.
|
|
1498
1974
|
|
|
1499
1975
|
#### Attributes
|
|
1500
1976
|
|
|
@@ -1504,6 +1980,7 @@ Page wrapper: skip link (inside the header landmark in shadow mode), header, a s
|
|
|
1504
1980
|
| `header-variant` | `'full' \| 'vendor'` | `'full'` | |
|
|
1505
1981
|
| `no-global-styles` | `boolean` | `false` | |
|
|
1506
1982
|
| `no-footer` | `boolean` | `false` | Hide the footer (and any pre-footer band), for tools and app-like pages where the site footer does not belong. The footer is kept hidden rather than removed, so toggling the attribute keeps pre-footer content. |
|
|
1983
|
+
| `print-chrome` | `boolean` | `false` | Print the header, alerts, breadcrumbs and footer too. By default printing leaves them out and prints only `<main>`, black on white. |
|
|
1507
1984
|
| `site-links-label` | `string \| undefined` | | Accessible name of the header navigation when site links are given (default "Site"). |
|
|
1508
1985
|
| `site-name` | `string \| undefined` | | The sub-site's name, forwarded to `<site-header site-name>`: shown after the logo as a link to the site's home. |
|
|
1509
1986
|
| `site-name-href` | `string \| undefined` | | Where the site name links, forwarded to `<site-header site-name-href>` (default `/`). |
|
|
@@ -1517,6 +1994,7 @@ Page wrapper: skip link (inside the header landmark in shadow mode), header, a s
|
|
|
1517
1994
|
| `color-scheme-switch` | `boolean` | `false` | Opt in to dark mode, forwarded to `<site-header color-scheme-switch>`: the page follows the OS preference, and a Light / Dark / System control in the header lets the visitor override it (remembered per site). Off by default: the page is always light. The page's own content must support it (see the README's "Dark mode"). |
|
|
1518
1995
|
| `matomo-id` | `number \| undefined` | | Opt in to Matomo analytics: the site's Matomo id. The page then adds one `<site-analytics>` for it (loading its code only then), which records the page view and what the library's components report (see the README's "Analytics"). Off by default. With an analytics element or a Matomo snippet already on the page nothing is counted twice. |
|
|
1519
1996
|
| `matomo-url` | `string \| undefined` | | The Matomo server for `matomo-id`, ending in `/` (default: the library's). |
|
|
1997
|
+
| `matomo-downloads` | `string \| undefined` | | `event`: the `<site-analytics downloads="event">` option for `matomo-id`, counting downloads as `['download', '<extension>']` events without their URLs. |
|
|
1520
1998
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1521
1999
|
| `no-style` | `boolean` | `false` | |
|
|
1522
2000
|
|
|
@@ -1594,6 +2072,7 @@ Compatibility element. Light mode (`no-shadow-dom`) installs the tokens and base
|
|
|
1594
2072
|
| `matomoid` | `number \| undefined` | | The Matomo site id (attribute `matomoid`). Default: the site whose URL the page is under. |
|
|
1595
2073
|
| `spa` | `boolean \| 'auto'` | `false` | A single-page app. `spa` (no value): it records its own page views (`uvalib-analytics-pageview`), none on load. `spa="auto"`: a page view on load and one per same-document route change (hash change, Back and Forward, `history.pushState`), once the title has settled, never twice in a row for the same URL, with the previous URL as the referrer. Either way Matomo's link tracking is off. |
|
|
1596
2074
|
| `variables` | `Record<string, unknown> \| null` | `null` | Custom dimensions, a JSON object of `{ id: value }`, set before the page view. |
|
|
2075
|
+
| `downloads` | `string \| undefined` | | `event`: count downloads without their URLs. Matomo's link tracking is left off; a left or middle click on a link to a file (the `download` attribute, or a download file type) sends the event `['download', '<extension>']` (no URL, no file name), and a click on a link to another site is still sent as an outlink (`trackLink`), as Matomo's link tracking would. Off by default. Read when Matomo is set up; no effect with a Matomo snippet already on the page. |
|
|
1597
2076
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1598
2077
|
| `no-style` | `boolean` | `false` | |
|
|
1599
2078
|
|
|
@@ -1610,9 +2089,46 @@ Compatibility element. Light mode (`no-shadow-dom`) installs the tokens and base
|
|
|
1610
2089
|
| `site-analytics-event` | Listened for on `document` too: the same as `uvalib-analytics-event`. |
|
|
1611
2090
|
| `site-analytics-content` | Listened for on `document` too: the same as `uvalib-analytics-content`. |
|
|
1612
2091
|
|
|
2092
|
+
### `<uvalib-back-to-top>`
|
|
2093
|
+
|
|
2094
|
+
A “Back to top” button for long pages: minutes, finding aids, transcriptions, long result lists. It stays hidden (`visibility: hidden`, so it is neither a tab stop nor in the accessibility tree) until the top `offset` pixels of the page (default 400) have scrolled out of view, watched with an IntersectionObserver on a small sentinel at the top of the page, never a scroll listener. If it has focus as it hides, focus moves to the target. Activating it scrolls to the top (smoothly unless the visitor prefers reduced motion) and moves focus to the page's `<h1>` (the first in `<main>`, else the first anywhere, else `#top`), or to `target` (a selector), adding `tabindex="-1"` when it is not focusable, so keyboard and screen reader users land at the top too. The button is fixed in the bottom corner (end side), inside the safe-area insets. The element itself is an empty block 4.75rem tall: put it last in the page's main content and that is the space the button needs, so the last lines can always scroll clear of it. When that space comes into view the button sits in it instead of floating, so it never covers the footer either. It is hidden in print.
|
|
2095
|
+
|
|
2096
|
+
#### Attributes
|
|
2097
|
+
|
|
2098
|
+
| Attribute | Type | Default | Description |
|
|
2099
|
+
|---|---|---|---|
|
|
2100
|
+
| `label` | | `DEFAULT_LABEL` | The button's text. |
|
|
2101
|
+
| `offset` | | `DEFAULT_OFFSET` | How many pixels at the top of the page must scroll out of view before the button shows. |
|
|
2102
|
+
| `target` | `string` | `''` | A selector for where focus goes (default: the page's `<h1>`, else `#top`). |
|
|
2103
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2104
|
+
| `no-style` | `boolean` | `false` | |
|
|
2105
|
+
|
|
2106
|
+
#### CSS parts
|
|
2107
|
+
|
|
2108
|
+
| Part | Description |
|
|
2109
|
+
|---|---|
|
|
2110
|
+
| `button` | The button. |
|
|
2111
|
+
|
|
2112
|
+
#### Events
|
|
2113
|
+
|
|
2114
|
+
| Event | Description |
|
|
2115
|
+
|---|---|
|
|
2116
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-back-to-top', 'click']` when activated. Bubbles and is composed. |
|
|
2117
|
+
|
|
2118
|
+
#### CSS custom properties
|
|
2119
|
+
|
|
2120
|
+
| Property | Default | Description |
|
|
2121
|
+
|---|---|---|
|
|
2122
|
+
| `--uvalib-back-to-top-space` | `4.75rem` | The height the element keeps for the button at the end of the content. |
|
|
2123
|
+
| `--uva-color-surface-raised` | | Dark-mode role token: button background (else #fff). |
|
|
2124
|
+
| `--uva-color-button-bg` | | Dark-mode role token: button border and text (else `--uva-blue-alt`, #007bac). |
|
|
2125
|
+
| `--uva-color-button-hover-bg` | | Dark-mode role token: hovered button (else `--uva-blue-alt-A`, #005679). |
|
|
2126
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
2127
|
+
| `--uva-color-shadow` | | Dark-mode role token: the floating button's shadow. |
|
|
2128
|
+
|
|
1613
2129
|
### `<uvalib-breadcrumbs>`
|
|
1614
2130
|
|
|
1615
|
-
A breadcrumb trail, as on library.virginia.edu: links separated by slashes, ending with the current page, at body size. A `<nav aria-label="Breadcrumb">` holding an `<ol>`; the separators are hidden from assistive technology and the last item has `aria-current="page"` (a `<span>`, or a link when it has an href). Give the trail as children: `<a href>` elements, ending with the current page as a text-only element (`<span>Hours</span>`) or a link (`<a href aria-current="page">`). The last child is always the current page. An earlier child without an href is shown as plain text. Children with no text are skipped with one console warning. Hrefs are used as written, and the trail follows changes to the children (attributes and text too). Apps that build the trail in JavaScript set the `items` property instead (it then wins over any children); assigning a new array re-renders. Inside `<site-page>`, give it `slot="breadcrumbs"`: it is placed between the header (and alerts band) and `<main>`, with the page's gutters. It works anywhere else too. Single-page apps: the trail is drawn from copies of the children, so a router's own click handlers on them do not run. Listen for `uvalib-breadcrumbs-navigate` and cancel it to route in place; hash links need nothing.
|
|
2131
|
+
A breadcrumb trail, as on library.virginia.edu: links separated by slashes, ending with the current page, at body size. A `<nav aria-label="Breadcrumb">` holding an `<ol>`; the separators are hidden from assistive technology and the last item has `aria-current="page"` (a `<span>`, or a link when it has an href). Give the trail as children: `<a href>` elements, ending with the current page as a text-only element (`<span>Hours</span>`) or a link (`<a href aria-current="page">`). The last child is always the current page. An earlier child without an href is shown as plain text. Children with no text are skipped with one console warning. Hrefs are used as written, and the trail follows changes to the children (attributes and text too). Apps that build the trail in JavaScript set the `items` property instead (it then wins over any children); assigning a new array re-renders. A step back to a search: give its link `data-return-from` with the search page's path (or several, separated by spaces), as in `<a href="/" data-return-from="/">Search</a>`. When the visitor came from that page on this site with a query string (`document.referrer`; a trailing slash or `index.html` does not matter), the step links back to that search (path and query) instead; its text stays the same. Otherwise, as when the result was opened in a new tab or the site sends no referrer, it keeps its href. Nothing is stored or sent. In `items`, the same is `returnFrom`. Inside `<site-page>`, give it `slot="breadcrumbs"`: it is placed between the header (and alerts band) and `<main>`, with the page's gutters. It works anywhere else too. Single-page apps: the trail is drawn from copies of the children, so a router's own click handlers on them do not run. Listen for `uvalib-breadcrumbs-navigate` and cancel it to route in place; hash links need nothing.
|
|
1616
2132
|
|
|
1617
2133
|
#### Attributes
|
|
1618
2134
|
|
|
@@ -1718,7 +2234,7 @@ A grid of `<uvalib-card>` elements. It is a list, so a screen reader announces h
|
|
|
1718
2234
|
|
|
1719
2235
|
### `<uvalib-chip-group>`
|
|
1720
2236
|
|
|
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`.
|
|
2237
|
+
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?, swatch? }`), 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. `data-swatch` (or `swatch` in `items`) is a CSS colour drawn as a small bordered square before the label, so the chips double as a chart's or map's colour key. It is decorative (`aria-hidden`) and never the only cue: the name stays the label. An invalid colour is ignored with one warning. In forced colors the square keeps its colour. 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. `description` is a hint shown under the chips and tied to the group with `aria-describedby`, so it is read when focus enters the group (“Keyword matches your words…”). It is plain text in the element's own root, so it works in a closed shadow root. `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
2238
|
|
|
1723
2239
|
#### Attributes
|
|
1724
2240
|
|
|
@@ -1726,6 +2242,7 @@ A row of chips: a segmented control or single-select filter (`mode="single"`), f
|
|
|
1726
2242
|
|---|---|---|---|
|
|
1727
2243
|
| `mode` | `ChipGroupMode` | `'single'` | `single` (radios: one value), `multi` (toggles: an array of values) or `links`. |
|
|
1728
2244
|
| `label` | `string` | `''` | The group's accessible name (required), also the first part of the analytics name. |
|
|
2245
|
+
| `description` | `string` | `''` | A hint shown under the chips and read with the group when focus enters it (`aria-describedby` on the group). Plain text. |
|
|
1729
2246
|
| `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
2247
|
| `count-label` | `string` | `'items'` | The word after a count in each chip's accessible name: “2005, 213 items”. |
|
|
1731
2248
|
| `scroll` | `boolean` | `false` | One row that scrolls sideways instead of wrapping. |
|
|
@@ -1734,6 +2251,12 @@ A row of chips: a segmented control or single-select filter (`mode="single"`), f
|
|
|
1734
2251
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1735
2252
|
| `no-style` | `boolean` | `false` | |
|
|
1736
2253
|
|
|
2254
|
+
#### CSS parts
|
|
2255
|
+
|
|
2256
|
+
| Part | Description |
|
|
2257
|
+
|---|---|
|
|
2258
|
+
| `swatch` | The colour square before a chip's label (`data-swatch`, `swatch`). |
|
|
2259
|
+
|
|
1737
2260
|
#### Events
|
|
1738
2261
|
|
|
1739
2262
|
| Event | Description |
|
|
@@ -1749,15 +2272,72 @@ A row of chips: a segmented control or single-select filter (`mode="single"`), f
|
|
|
1749
2272
|
| `--uva-color-surface-raised` | | Dark-mode role token: chip background (else #fff). |
|
|
1750
2273
|
| `--uva-color-control-border` | | Dark-mode role token: chip border (else `--uva-grey`, #808080). |
|
|
1751
2274
|
| `--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). |
|
|
2275
|
+
| `--uva-color-text-muted` | | Dark-mode role token: the count and the description (else #4f4f4f). |
|
|
1753
2276
|
| `--uva-color-accent-bg` | | Dark-mode role token: selected chip background and border (else `--uva-brand-blue`). |
|
|
1754
2277
|
| `--uva-color-on-accent` | | Dark-mode role token: selected chip text (else #fff). |
|
|
1755
2278
|
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1756
2279
|
| `--uva-color-surface` | | Dark-mode role token: the page background the scrolling row fades into at an edge with more chips (else #fff). |
|
|
1757
2280
|
|
|
2281
|
+
### `<uvalib-combobox>`
|
|
2282
|
+
|
|
2283
|
+
An editable text field that suggests values as you type, from a local list or a URL: a person, place or subject picker. It follows the WAI-ARIA APG “Editable Combobox With List Autocomplete”: a real `<input role="combobox">` and a `role="listbox"` popup under it. Suggestions come from the `items` property (`{ value, label?, description?, disabled? }` objects, or strings), from `<option>` children (directly or inside a `<datalist>`; the `label` attribute or text is the label, `data-description` the second line), or from `src`, a URL template with `{q}` (fetched 250 ms after the last keystroke once the text has `min-length` characters, default 1; a newer keystroke aborts the older request; the response is a JSON array of the same shape, or anything `transform(data, query)` turns into one). `items` wins over the children while set. Local suggestions match anywhere in the label, ignoring case and accents, those starting with the text first, then those with a word starting with it; at most `max-results` (default 50, 0 for all) are shown, which keeps a list of 16,000 people fast. The matched text is bold and underlined in a `<mark>`. Keys: Down opens the list on the first suggestion and moves (wrapping), Up opens on the last, Alt+Down opens without moving, Alt+Up closes, Enter chooses the active suggestion (and then does not submit the form; with none active, Enter submits as in any field), Escape closes the list and a second Escape clears the field, Home, End, Left and Right move the caret, and Tab leaves without choosing. A real clear button (“Clear <label>”, 44px, shown only with text) empties the field and returns focus to it. Free text is allowed: `value` is whatever is in the field, and `selected` the chosen suggestion (or null); typing after choosing clears it, and leaving the field with text that is exactly one suggestion's label chooses it. `must-choose` makes any other text invalid (“Choose one of the suggestions.”). The element is form-associated: with `name` it submits the chosen suggestion's value, or else the text, and a form reset restores the `value` attribute. `required` and `disabled` (also from a disabled fieldset) work as on an input. A polite status says “5 suggestions”, “50 of 1,234 suggestions”, “No suggestions”, “Loading suggestions” or “Couldn't load suggestions” half a second after the list settles (never on the first render); the popup shows the same notes visibly. A failed load never throws. Before it upgrades, `base.css` shows the label (from the attribute) and holds the field's height. A fallback `<input list>` child works as a plain field meanwhile; on upgrade its text, `name` and `placeholder` carry over, and it is disabled so it does not submit twice.
|
|
2284
|
+
|
|
2285
|
+
#### Attributes
|
|
2286
|
+
|
|
2287
|
+
| Attribute | Type | Default | Description |
|
|
2288
|
+
|---|---|---|---|
|
|
2289
|
+
| `label` | `string` | `''` | The field's visible label (required); also the analytics name. |
|
|
2290
|
+
| `description` | `string` | `''` | A hint under the field, read with it (aria-describedby). |
|
|
2291
|
+
| `placeholder` | `string` | `''` | |
|
|
2292
|
+
| `name` | `string` | `''` | The form field name. |
|
|
2293
|
+
| `value` | `string` | `''` | The text in the field. The attribute is the starting text, and what a form reset restores. Setting it does not fire `change`. |
|
|
2294
|
+
| `src` | `string` | `''` | A URL template with `{q}` (the trimmed text, URL-encoded) that returns suggestions as JSON. |
|
|
2295
|
+
| `min-length` | `number` | `1` | Characters typed before suggestions appear (and `src` is fetched). |
|
|
2296
|
+
| `max-results` | `number` | `50` | The most suggestions shown at once; 0 for all. |
|
|
2297
|
+
| `must-choose` | `boolean` | `false` | Text that is not one of the suggestions is invalid. |
|
|
2298
|
+
| `required` | `boolean` | `false` | |
|
|
2299
|
+
| `disabled` | `boolean` | `false` | |
|
|
2300
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2301
|
+
| `no-style` | `boolean` | `false` | |
|
|
2302
|
+
|
|
2303
|
+
#### CSS parts
|
|
2304
|
+
|
|
2305
|
+
| Part | Description |
|
|
2306
|
+
|---|---|
|
|
2307
|
+
| `label` | The visible label. |
|
|
2308
|
+
| `input` | The text field. |
|
|
2309
|
+
| `clear` | The clear button. |
|
|
2310
|
+
| `popup` | The popup under the field. |
|
|
2311
|
+
| `option` | Each suggestion. |
|
|
2312
|
+
| `description` | The hint under the field. |
|
|
2313
|
+
|
|
2314
|
+
#### Events
|
|
2315
|
+
|
|
2316
|
+
| Event | Description |
|
|
2317
|
+
|---|---|
|
|
2318
|
+
| `type` | |
|
|
2319
|
+
| `input` | The text changed by typing (the native event of the field, composed). Not fired when an option is chosen. |
|
|
2320
|
+
| `select` | A suggestion was chosen (click or Enter). `detail` is `{ item }`, the object given. Bubbles and is composed. |
|
|
2321
|
+
| `change` | The value was committed: a suggestion chosen, the field cleared, or the field left with changed text. `detail` is `{ value, item }` (`item` is the chosen suggestion or null). Not fired when the app sets `value` or `selected`. Bubbles and is composed. |
|
|
2322
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-combobox', 'select', '<label>', <position from 1>]` when a suggestion is chosen, `['uvalib-combobox', 'clear', '<label>']` when the clear button or Escape empties the field, and `['uvalib-combobox', 'error', 'load']` once when `src` fails. Never the typed text or a suggestion's text or value. Bubbles and is composed. |
|
|
2323
|
+
|
|
2324
|
+
#### CSS custom properties
|
|
2325
|
+
|
|
2326
|
+
| Property | Default | Description |
|
|
2327
|
+
|---|---|---|
|
|
2328
|
+
| `--uva-color-surface-raised` | | Dark-mode role token: field and popup background (else #fff). |
|
|
2329
|
+
| `--uva-color-control-border` | | Dark-mode role token: field and popup border (else `--uva-grey`, #808080). |
|
|
2330
|
+
| `--uva-color-input-text` | | Dark-mode role token: field and suggestion text (else #2b2b2b). |
|
|
2331
|
+
| `--uva-color-text-muted` | | Dark-mode role token: descriptions, notes and the clear icon (else #4f4f4f). |
|
|
2332
|
+
| `--uva-color-surface-hover` | | Dark-mode role token: active suggestion background (else #dadada). |
|
|
2333
|
+
| `--uva-color-track` | | Dark-mode role token: hovered suggestion background (else #f1f1f1). |
|
|
2334
|
+
| `--uva-color-accent-bg` | | Dark-mode role token: the active suggestion's bar and outline (else `--uva-brand-blue`). |
|
|
2335
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
2336
|
+
| `--uva-color-shadow` | | Dark-mode role token: popup shadow. |
|
|
2337
|
+
|
|
1758
2338
|
### `<uvalib-contents>`
|
|
1759
2339
|
|
|
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.
|
|
2340
|
+
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). A table of contents for a long document: `headings-from="#article"` builds the list from the headings in that element (`levels`, `2-3` by default; nothing shown below `min` top-level entries, 2 by default). Headings without text or hidden with `aria-hidden` are skipped; one without an id gets one from its text (`budget-report`, then `budget-report-2`), and existing ids are kept, so links to sections keep working. It follows headings added, removed or retitled; `refresh()` reads them again after other changes. The children and `items` win while they give a list. Without JavaScript there is no list: a list rendered at build time, as children, works everywhere. 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.
|
|
1761
2341
|
|
|
1762
2342
|
#### Attributes
|
|
1763
2343
|
|
|
@@ -1769,6 +2349,9 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
1769
2349
|
| `collapse-below` | | `DEFAULT_COLLAPSE` | The viewport width at and below which the list collapses into a disclosure: a CSS length (`64rem`, `800px`). `0` or `none` never collapses. |
|
|
1770
2350
|
| `open` | `boolean` | `false` | Whether the collapsed disclosure is open (no effect on wide screens). Toggled by its button. |
|
|
1771
2351
|
| `sticky` | `boolean` | `false` | Keep it in view while the page scrolls (a sidebar), on wide screens. |
|
|
2352
|
+
| `headings-from` | `string \| undefined` | | Build the list from the headings in the element this selector names (`#article`): each heading at `levels` gets an entry linking to it (an id is added when it has none), the lower levels nested under the heading before them. The children and `items` win while they give a list. |
|
|
2353
|
+
| `levels` | | `DEFAULT_LEVELS` | With `headings-from`: the heading levels to list, `2-3` (the default) or one level, `2`. |
|
|
2354
|
+
| `min` | | `DEFAULT_MIN` | With `headings-from`: the fewest top-level entries worth a list (default 2). With fewer, nothing is shown. |
|
|
1772
2355
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1773
2356
|
| `no-style` | `boolean` | `false` | |
|
|
1774
2357
|
|
|
@@ -1800,14 +2383,14 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
1800
2383
|
|
|
1801
2384
|
### `<uvalib-date-histogram>`
|
|
1802
2385
|
|
|
1803
|
-
Monthly or
|
|
2386
|
+
Monthly, yearly or per-decade 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. `granularity="decade"` is for a long span (two centuries of minutes): one bar per decade ("1810s: 22 meetings"), an empty decade a gap, five decades to a row labelled with its first year (1800, 1850, …), the decades lined up in columns. Choosing a decade selects its first to last year (`selected="1810/1819"`, `select` `{ from: '1810-01-01', to: '1819-12-31' }`); up and down arrows move 50 years. `granularity="auto"` draws months when every count is a month within 3 years (at most 36 bars), years up to 30 years, and decades beyond. A year row that scrolls sideways is not offered: 200 years at the 24px minimum bar is over 5,000px, so a sidebar would show ten years at a time and lose the shape that decades show whole. 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`. Whenever the range's value changes, from its controls or set in script (a Clear button, Back/Forward, a restored URL), this element highlights the buckets that overlap it (it listens for `uvalib-date-range-value`). A value that is exactly the range's own `min` and `max` is no selection. On connect or reconnect, or when the range is added later, the range's value wins when it holds a selection or changed while this element was away; otherwise `selected` is written to it. A range value is never rounded to whole buckets and written back. Setting `selected` here updates the date range. `variant="strip"` is the small per-year row for a card: not interactive, `role="img"`, one bar per year, or per decade with `decade` (or `auto` over more than 30 years). The chart reserves its height before the counts arrive: one bar track, or one track per year (per half-century for decades) when those years are already known from the data, a linked date range or the table (`--uvalib-date-histogram-bar-size`, 8rem, plus the 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; a decade row fits 320px.
|
|
1804
2387
|
|
|
1805
2388
|
#### Attributes
|
|
1806
2389
|
|
|
1807
2390
|
| Attribute | Type | Default | Description |
|
|
1808
2391
|
|---|---|---|---|
|
|
1809
2392
|
| `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 `
|
|
2393
|
+
| `granularity` | `'year' \| 'month' \| 'decade' \| 'auto'` | `'month'` | `month` (twelve bars per year), `year`, `decade` (one bar per decade, five to a row), or `auto`: months when every count is a month within 3 years, years up to 30 years, else decades. Anything else is month, with one console warning. |
|
|
1811
2394
|
| `scale` | `'linear' \| 'log'` | `'linear'` | `log` scales bar height by log(count + 1). Anything else is linear. |
|
|
1812
2395
|
| `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
2396
|
| `range-for` | `string` | `''` | Id of a `<uvalib-date-range>` to keep in step with, both ways. |
|
|
@@ -1876,6 +2459,7 @@ A date-range picker: a two-thumb year slider plus "From" and "To" date inputs. `
|
|
|
1876
2459
|
|
|
1877
2460
|
| Event | Description |
|
|
1878
2461
|
|---|---|
|
|
2462
|
+
| `uvalib-date-range-value` | The selected range changed for any reason: a slider, a date input, or `value`, `min` or `max` set in script (a Clear button, Back/Forward, a restored URL). `detail` is `{ value: [start, end] }`, the range as shown (ISO dates inside `min`..`max`). For keeping other components in step; it is not a visitor action, so it is never sent to analytics. Not fired for the first render or when the shown range is unchanged. Bubbles and is composed. |
|
|
1879
2463
|
| `date-range-change` | The range changed from a slider or a date input. `detail` is `{ value: [start, end] }` (ISO dates). Bubbles and is composed. |
|
|
1880
2464
|
| `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-date-range', 'range-change', '<from year>–<to year>']`, 1 s after the visitor's last change (not when the range ends where it started). Bubbles and is composed. |
|
|
1881
2465
|
|
|
@@ -1941,6 +2525,117 @@ A faceted-search filter: a fieldset of checkboxes (value plus result count), opt
|
|
|
1941
2525
|
| `--uva-color-on-accent` | | Dark-mode role token: pressed chip text (else #fff). |
|
|
1942
2526
|
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1943
2527
|
|
|
2528
|
+
### `<uvalib-filter-drawer>`
|
|
2529
|
+
|
|
2530
|
+
A search page's form and filters: a plain sidebar on wide screens, and on narrow ones a “Search and filters” button that opens them in a modal panel from the side. Put the page's search form, `<uvalib-filter>`s and other facets inside. Above `breakpoint` (default `48rem`) they are shown as written: no button, no dialog role. At and below it only the button is shown; it opens a native `<dialog>` (`showModal()`) with a visible heading (the `label`) and a 44px Close button, which takes focus. Escape, Close and a click on the backdrop close it, and focus returns to the button; widening the window past the breakpoint closes it and keeps focus where it was. While it is open the rest of the page, including `<site-page>`'s header, skip link and alerts, is inert (the browser's modal dialog), so focus cannot leave it except to the browser itself, and nothing else is announced. The children are the same nodes in both layouts (moved, never re-created): typed text, checked boxes, listeners and each filter's state are kept. Inert content is not announced, so results counts and status notices outside the panel would go silent while the visitor filters: name them in `live` (space-separated ids) and the drawer repeats what they announce in its own polite live region while it is open. `count` (the page's number of active filters) is shown on the button when above 0. The drawer never counts by itself: only the page knows which inputs are filters.
|
|
2531
|
+
|
|
2532
|
+
#### Attributes
|
|
2533
|
+
|
|
2534
|
+
| Attribute | Type | Default | Description |
|
|
2535
|
+
|---|---|---|---|
|
|
2536
|
+
| `label` | | `DEFAULT_LABEL` | The button's text, the panel's heading and the dialog's name. |
|
|
2537
|
+
| `breakpoint` | | `DEFAULT_BREAKPOINT` | The widest viewport that gets the button and panel (`48rem`, `768px`); wider gets the sidebar. |
|
|
2538
|
+
| `count` | `number` | `0` | Active filters, set by the page; shown on the button when above 0. |
|
|
2539
|
+
| `live` | `string` | `''` | Space-separated ids of live regions outside the drawer (a results count, a status notice) to keep announcing while the panel is open. |
|
|
2540
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2541
|
+
| `no-style` | `boolean` | `false` | |
|
|
2542
|
+
|
|
2543
|
+
#### Slots
|
|
2544
|
+
|
|
2545
|
+
| Slot | Description |
|
|
2546
|
+
|---|---|
|
|
2547
|
+
| (default) | The search form and filters. Shown as the sidebar on wide screens and inside the panel on narrow ones. |
|
|
2548
|
+
|
|
2549
|
+
#### CSS parts
|
|
2550
|
+
|
|
2551
|
+
| Part | Description |
|
|
2552
|
+
|---|---|
|
|
2553
|
+
| `toggle` | The “Search and filters” button (narrow screens only). |
|
|
2554
|
+
| `count` | The number of active filters on the button. |
|
|
2555
|
+
| `sidebar` | The wrapper of the children on wide screens. |
|
|
2556
|
+
| `dialog` | The `<dialog>` panel. |
|
|
2557
|
+
| `header` | The panel's heading row. |
|
|
2558
|
+
| `heading` | The panel's heading. |
|
|
2559
|
+
| `close` | The Close button. |
|
|
2560
|
+
| `body` | The wrapper of the children, in the sidebar or the panel. |
|
|
2561
|
+
|
|
2562
|
+
#### Events
|
|
2563
|
+
|
|
2564
|
+
| Event | Description |
|
|
2565
|
+
|---|---|
|
|
2566
|
+
| `close` | The panel closed (Close, Escape, the backdrop, `close()`, or the window widening past the breakpoint). Does not bubble. |
|
|
2567
|
+
| `open` | The panel opened. Does not bubble. |
|
|
2568
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-filter-drawer', 'open', '<label>']` when the visitor opens the panel, and `['uvalib-filter-drawer', 'close', '<label>']` when they close it (Close, Escape or the backdrop; not when the window widens or a script closes it). Bubbles and is composed. |
|
|
2569
|
+
|
|
2570
|
+
#### CSS custom properties
|
|
2571
|
+
|
|
2572
|
+
| Property | Default | Description |
|
|
2573
|
+
|---|---|---|
|
|
2574
|
+
| `--uvalib-filter-drawer-width` | `min(24rem, 100% - 3rem)` | The panel's width. |
|
|
2575
|
+
| `--uva-color-surface` | | Dark-mode role token: panel background (else #fff). |
|
|
2576
|
+
| `--uva-color-text` | | Dark-mode role token: panel text (else #2b2b2b). |
|
|
2577
|
+
| `--uva-color-border` | | Dark-mode role token: panel edge and heading rule (else #dadada). |
|
|
2578
|
+
| `--uva-color-button-bg` | | Dark-mode role token: button border and text, the count's background (else `--uva-blue-alt`, #007bac). |
|
|
2579
|
+
| `--uva-color-button-hover-bg` | | Dark-mode role token: hovered button (else `--uva-blue-alt-A`, #005679). |
|
|
2580
|
+
| `--uva-color-button-text` | | Dark-mode role token: the count's text (else #fff). |
|
|
2581
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
2582
|
+
|
|
2583
|
+
### `<uvalib-image-regions>`
|
|
2584
|
+
|
|
2585
|
+
An image with numbered region outlines (people, objects, inscriptions) and a list of the same regions beside it (under it on a narrow screen). The list is the way in: the outlines are a visual aid, hidden from assistive technology and not in the tab order, so no region is a second tab stop. Hovering or focusing a list entry (or anything in it) highlights its region with a thicker double outline and its label, and dims the others; hovering a region highlights its entry. Clicking a region moves focus to its entry. The image: an `<img>` (or `<picture>`) child, which keeps its `alt`, or `src` and `alt`. Give it `width` and `height` so its space is reserved before it loads. The regions: an `<ol>` child whose `<li>` items carry `data-xywh` (IIIF / Media Fragments: `percent:10,20,30,40`, or pixels `160,120,320,240` of the image's natural size). The list is shown as written, so it works before the component loads or without JavaScript, and any links and buttons in it stay the page's own (their events are the page's). Or set the `items` property, and the component draws the list. Region numbers are the list's numbers, from 1 (or the `<ol>`'s `start`).
|
|
2586
|
+
|
|
2587
|
+
#### Attributes
|
|
2588
|
+
|
|
2589
|
+
| Attribute | Type | Default | Description |
|
|
2590
|
+
|---|---|---|---|
|
|
2591
|
+
| `src` | `string` | `''` | Image URL, when there is no `<img>` child. |
|
|
2592
|
+
| `alt` | `string` | `''` | The image's alternative text (with `src`). |
|
|
2593
|
+
| `width` | `number \| undefined` | | The image's width (with `src`), reserving its space. |
|
|
2594
|
+
| `height` | `number \| undefined` | | The image's height (with `src`). |
|
|
2595
|
+
| `image-width` | `number \| undefined` | | The size pixel regions are measured in, when it is not the image's natural size (for example a IIIF derivative of a larger original: the original's width and height). |
|
|
2596
|
+
| `image-height` | `number \| undefined` | | The height pixel regions are measured in (with `image-width`). |
|
|
2597
|
+
| `label` | `string` | `'Regions'` | The list's heading, and the analytics name. |
|
|
2598
|
+
| `heading-level` | `number \| undefined` | | The heading's level (2 to 6). Default: one below the heading before the element. |
|
|
2599
|
+
| `numbering` | `'numbers' \| 'none'` | `'numbers'` | `numbers` (default) shows each region's number on its outline; `none` hides them. |
|
|
2600
|
+
| `hide-outlines` | `boolean` | `false` | Hide the outlines (the list stays). |
|
|
2601
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2602
|
+
| `no-style` | `boolean` | `false` | |
|
|
2603
|
+
|
|
2604
|
+
#### Slots
|
|
2605
|
+
|
|
2606
|
+
| Slot | Description |
|
|
2607
|
+
|---|---|
|
|
2608
|
+
| (default) | The region list (`<ol>` with `<li data-xywh>`), shown as written. Not used with `items`. |
|
|
2609
|
+
| `image` | The image. A first `<img>` or `<picture>` child is put here by itself. |
|
|
2610
|
+
|
|
2611
|
+
#### CSS parts
|
|
2612
|
+
|
|
2613
|
+
| Part | Description |
|
|
2614
|
+
|---|---|
|
|
2615
|
+
| `layout` | The grid holding the image and the list. |
|
|
2616
|
+
| `media` | The image and its overlay. |
|
|
2617
|
+
| `overlay` | The outlines over the image (`aria-hidden`). |
|
|
2618
|
+
| `region` | One outline. |
|
|
2619
|
+
| `list` | The heading and the list. |
|
|
2620
|
+
|
|
2621
|
+
#### Events
|
|
2622
|
+
|
|
2623
|
+
| Event | Description |
|
|
2624
|
+
|---|---|
|
|
2625
|
+
| `highlight` | The highlighted region changed by hover or focus: `detail` is `{ item, index }` (`item` null and `index` -1 when none is). Bubbles and is composed. |
|
|
2626
|
+
| `select` | A region's outline was clicked (focus moved to its list entry): `detail` is `{ item, index }`. Bubbles and is composed. |
|
|
2627
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-image-regions', 'select', '<label>', <number>]` when an outline is clicked (the list's `label`, and the region's number from 1). Never a region's label (it may be a person's name). Nothing on hover or focus. Bubbles and is composed. |
|
|
2628
|
+
|
|
2629
|
+
#### CSS custom properties
|
|
2630
|
+
|
|
2631
|
+
| Property | Default | Description |
|
|
2632
|
+
|---|---|---|
|
|
2633
|
+
| `--uva-color-text` | | Dark-mode role token: text (else `--uva-grey-darkest`). |
|
|
2634
|
+
| `--uva-color-surface-hover` | | Dark-mode role token: the highlighted entry's tint (else #f1f1f1). |
|
|
2635
|
+
| `--uva-color-link` | | Dark-mode role token: entry links (else `--uva-brand-blue`). |
|
|
2636
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
2637
|
+
| `--uva-color-text-muted` | | Dark-mode role token: descriptions (else #4b5563). |
|
|
2638
|
+
|
|
1944
2639
|
### `<uvalib-lightbox>`
|
|
1945
2640
|
|
|
1946
2641
|
An accessible image viewer over a set of plain links. With JavaScript a primary click opens a modal dialog; without it (or with a modified click) the link opens the image as before. Wrap the links, or point at them with `selector` (for example `a.pb-image` on a reading page). There is no autoplay and no carousel. The dialog is labelled by the caption (`data-caption`, else the image alt, else the link text). Focus moves to Close on open and back to the trigger on close. Escape and a click on the backdrop close it. With more than one image, Previous and Next and the arrow keys move through the set (wrapping), and a polite “3 of 13” counter is shown. Full size opens the original image in a new tab. A IIIF Image API URL keeps its region; only the size becomes `!W,H` for the viewport. TIFF and JPEG2000 URLs are left as written. `url-param` (for example `photo`) keeps `?photo=<id>` in sync, including on a hash route (`#/text?photo=<id>`): opening pushes a history entry, stepping replaces it, and Back closes. Optional details: children with `slot="details"` (and `data-for` equal to the item's id or its position from 1; without `data-for` they show for every image), or `data-details-id` on a link pointing at an element elsewhere on the page. Either is shown inside the dialog and put back when the viewer moves on or closes.
|
|
@@ -1951,6 +2646,7 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
|
|
|
1951
2646
|
|---|---|---|---|
|
|
1952
2647
|
| `selector` | `string` | `''` | CSS selector for image links elsewhere in this root (the page, or the shadow root the component sits in). Combined with any links inside the component. Example: `a.pb-image`. |
|
|
1953
2648
|
| `url-param` | `string` | `''` | Query parameter kept in sync with the open image, for example `photo` → `?photo=<id>`. The id is the link's `data-id`, else its `id`, else the IIIF identifier, else its position from 1. On a hash route the parameter is written inside the hash. Empty: no deep link. |
|
|
2649
|
+
| `regions-label` | `string` | `'Regions'` | The heading of the regions list (for example `People`). |
|
|
1954
2650
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1955
2651
|
| `no-style` | `boolean` | `false` | |
|
|
1956
2652
|
|
|
@@ -1971,6 +2667,7 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
|
|
|
1971
2667
|
| `image` | The image. |
|
|
1972
2668
|
| `controls` | Previous, Next, the counter and Full size. |
|
|
1973
2669
|
| `details` | The details panel. |
|
|
2670
|
+
| `regions` | The `<uvalib-image-regions>` around an image with regions. |
|
|
1974
2671
|
|
|
1975
2672
|
#### Events
|
|
1976
2673
|
|
|
@@ -1996,9 +2693,72 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
|
|
|
1996
2693
|
| `--uva-grey-darkest` | `#2b2b2b` | Text when `--uva-color-text` is unset. |
|
|
1997
2694
|
| `--uva-grey-100` | `#dadada` | Border when `--uva-color-border` is unset. |
|
|
1998
2695
|
|
|
2696
|
+
### `<uvalib-map>`
|
|
2697
|
+
|
|
2698
|
+
A map of places with a linked list of the same places: buildings, rooms or outdoor spaces, each a marker sized by a count, with a link to the place's page. It wraps [Leaflet](https://leafletjs.com) 1.9, which the page provides (the library never bundles it): set the `leaflet` property to the Leaflet module (`import * as L from 'leaflet'`), or load leaflet.js so that `window.L` exists. Without Leaflet only the list is shown, with one console warning. Leaflet's leaflet.css is optional: the element carries the layout rules it needs, in shadow DOM and light DOM alike. Places come from `items` (`{ id?, name, lat, lng, count?, href?, description? }`) or from a child `<ul>`/`<ol>` of `<li><a href data-lat data-lng data-count>Name</a></li>`, which is the list before the script runs (and without it). The list always stays, under the map: it is the text equivalent. Each marker is a real link (a button when the place has no `href`) named like "The Rotunda, 2,702 photos" (`count-label` is the noun), sized by the square root of its count (a 24 to 56px dot in a hit area of at least 44px). Tab or the arrow keys move between markers, Enter follows the link (or chooses the place), and Escape hides the tooltip. Hovering or focusing a marker shows a tooltip with its name and count and highlights its list entry; hovering or focusing a list entry highlights its marker (a ring and a larger dot, not colour alone) and brings it into view. The map is a region named by `label`, after a "Skip map, go to the list" link and a line of key instructions. It opens on the bounds of the places, or on `center` and `zoom`. The zoom buttons are 44px with a visible focus ring; the attribution stays. Tiles come from `tile-url` (OpenStreetMap by default: low-traffic use only) with `attribution`. In the page's dark mode the tiles are inverted with a CSS filter (`--uvalib-map-dark-filter`) unless `dark-tile-url` gives dark tiles; markers and controls are never filtered. With `prefers-reduced-motion` nothing animates.
|
|
2699
|
+
|
|
2700
|
+
#### Attributes
|
|
2701
|
+
|
|
2702
|
+
| Attribute | Type | Default | Description |
|
|
2703
|
+
|---|---|---|---|
|
|
2704
|
+
| `items` | `MapItem[]` | `[]` | The places. When non-empty, wins over the child list. Set a new array to update. |
|
|
2705
|
+
| `label` | `string` | `''` | The map's name (required): the region's label, the list's label and the analytics name. |
|
|
2706
|
+
| `count-label` | `string` | `'items'` | The noun after each count, plural ("photos"); a count of one drops a trailing s. |
|
|
2707
|
+
| `tile-url` | | `OSM_TILE_URL` | The tile URL template (`{z}/{x}/{y}`, optionally `{s}` and `{r}`). |
|
|
2708
|
+
| `dark-tile-url` | `string` | `''` | Tiles for the page's dark mode. Without it, dark mode filters the light tiles instead. |
|
|
2709
|
+
| `attribution` | | `OSM_ATTRIBUTION` | The tiles' attribution, as HTML. Required by most tile sources; always shown. |
|
|
2710
|
+
| `center` | `string` | `''` | Where the map opens, `"lat,lng"`. Without it the map fits every place. |
|
|
2711
|
+
| `zoom` | `number \| undefined` | | The opening zoom level (with `center`, or centred on the places). |
|
|
2712
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2713
|
+
| `no-style` | `boolean` | `false` | |
|
|
2714
|
+
|
|
2715
|
+
#### Slots
|
|
2716
|
+
|
|
2717
|
+
| Slot | Description |
|
|
2718
|
+
|---|---|
|
|
2719
|
+
| (default) | A `<ul>` or `<ol>` of places: each `<li>` holds an `<a href>` (or the `<li>` itself) with `data-lat`, `data-lng` and optionally `data-count`, `data-id` and `data-description`. Used when `items` is empty; without JavaScript it is the list. |
|
|
2720
|
+
|
|
2721
|
+
#### CSS parts
|
|
2722
|
+
|
|
2723
|
+
| Part | Description |
|
|
2724
|
+
|---|---|
|
|
2725
|
+
| `map` | The map region (the Leaflet container). |
|
|
2726
|
+
| `instructions` | The line of key instructions above the map. |
|
|
2727
|
+
| `list` | The list of places. |
|
|
2728
|
+
| `place` | Each list entry. |
|
|
2729
|
+
|
|
2730
|
+
#### Events
|
|
2731
|
+
|
|
2732
|
+
| Event | Description |
|
|
2733
|
+
|---|---|
|
|
2734
|
+
| `select` | A marker was chosen (click, Enter or Space). `detail` is `{ item }`. Cancelable: for a place with `href`, `preventDefault()` keeps the page from following the link. Bubbles and is composed. |
|
|
2735
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-map', 'select', '<label>', <position from 1>]` when a marker is chosen, and `['uvalib-map', 'zoom', '<label>', <zoom level>]` 1 s after the last zoom-button press. Never a place's name, coordinates or URL. Bubbles and is composed. |
|
|
2736
|
+
|
|
2737
|
+
#### CSS custom properties
|
|
2738
|
+
|
|
2739
|
+
| Property | Default | Description |
|
|
2740
|
+
|---|---|---|
|
|
2741
|
+
| `--uvalib-map-height` | `min(24rem, 75vw)` | Height of the map. |
|
|
2742
|
+
| `--uvalib-map-dark-filter` | `invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9)` | The filter on the tiles in dark mode, when there is no `dark-tile-url`. |
|
|
2743
|
+
| `--uva-brand-blue` | `#232d4b` | Marker fill. |
|
|
2744
|
+
| `--uva-brand-orange` | `#e57200` | Focus ring when `--uva-color-focus` is unset. |
|
|
2745
|
+
| `--uva-font-family` | `inherit` | Font family. |
|
|
2746
|
+
| `--uva-color-accent-bg` | | Dark-mode role token: marker fill (else `--uva-brand-blue`). |
|
|
2747
|
+
| `--uva-color-on-accent` | | Dark-mode role token: marker border (else #fff). |
|
|
2748
|
+
| `--uva-color-text` | | Dark-mode role token: text and the highlight ring (else #2b2b2b). |
|
|
2749
|
+
| `--uva-color-text-muted` | | Dark-mode role token: instructions and descriptions (else #4b5563). |
|
|
2750
|
+
| `--uva-color-link` | | Dark-mode role token: links (else `--uva-brand-blue`). |
|
|
2751
|
+
| `--uva-color-surface` | | Dark-mode role token: attribution background and the highlight ring's gap (else #fff). |
|
|
2752
|
+
| `--uva-color-surface-raised` | | Dark-mode role token: zoom buttons, tooltip and list entries (else #fff). |
|
|
2753
|
+
| `--uva-color-surface-hover` | | Dark-mode role token: hovered zoom button (else #dadada). |
|
|
2754
|
+
| `--uva-color-track` | | Dark-mode role token: the map before tiles load, and count badges (else #e5e7eb). |
|
|
2755
|
+
| `--uva-color-control-border` | | Dark-mode role token: borders (else #808080). |
|
|
2756
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
2757
|
+
| `--uva-color-shadow` | | Dark-mode role token: control and tooltip shadow. |
|
|
2758
|
+
|
|
1999
2759
|
### `<uvalib-metadata>`
|
|
2000
2760
|
|
|
2001
|
-
A record's details as a description list, as on the library's digital collections: label and value side by side on wide screens (the element's own width, 36rem and up), stacked on narrow ones. Values may be text, links or lists (subjects). Give the rows as a `<dl>` child (so the page reads the same before the script loads): `<dt>` labels and `<dd>` values, optionally wrapped in a `<div>` per row; several `<dd>` after one `<dt>` are several values. The values are copied as written (links, lists, `download` attributes kept); a link with `data-size="184 KB"` is shown as a download, "EPUB · 184 KB". The list follows changes to the children. Apps set the `items` property instead (`{ label, value }`, winning over the children while set). Built-in rows for credit and rights (as Special Collections asks): `creator` and `organization` come first; `rights` (a rightsstatements.org or Creative Commons URL, shown as its short name linked to it, or plain text) and `citation` ("How to cite", with a Copy citation button that announces "Copied" politely) come last. `citation-title` builds the Special Collections citation, "<title>, Albert and Shirley Small Special Collections Library, University of Virginia".
|
|
2761
|
+
A record's details as a description list, as on the library's digital collections: label and value side by side on wide screens (the element's own width, 36rem and up), stacked on narrow ones. Values may be text, links or lists (subjects). Give the rows as a `<dl>` child (so the page reads the same before the script loads): `<dt>` labels and `<dd>` values, optionally wrapped in a `<div>` per row; several `<dd>` after one `<dt>` are several values. The values are copied as written (links, lists, `download` attributes kept); a link with `data-size="184 KB"` is shown as a download, "EPUB · 184 KB". The list follows changes to the children. Apps set the `items` property instead (`{ label, value }`, winning over the children while set). Built-in rows for credit and rights (as Special Collections asks): `creator` and `organization` come first; `rights` (a rightsstatements.org or Creative Commons URL, shown as its short name linked to it, or plain text) and `citation` ("How to cite", with a Copy citation button that announces "Copied" politely) come last. `citation-title` builds the Special Collections citation, "<title>, Albert and Shirley Small Special Collections Library, University of Virginia". Long lists: `list-limit="8"` shortens every value that is a list (a `<ul>`/`<ol>` in the `<dd>`) of more than 8 items to its first 8 and a “Show all 34 participants” button (`aria-expanded`, `aria-controls`) that reveals the rest in place and moves focus to the first one; it then reads “Show fewer”. `data-limit` on a `<dd>` or its list sets that row's own limit (`0`: none); the noun is the label with a lowercase first letter, or `data-limit-label`. Every value stays in the markup (the hidden ones `hidden`).
|
|
2002
2762
|
|
|
2003
2763
|
#### Attributes
|
|
2004
2764
|
|
|
@@ -2011,6 +2771,7 @@ A record's details as a description list, as on the library's digital collection
|
|
|
2011
2771
|
| `rights-info` | `string \| undefined` | | A "More about rights and permissions" link under the statement, such as `https://www.library.virginia.edu/policies/use-of-materials`. |
|
|
2012
2772
|
| `citation` | `string \| undefined` | | "How to cite": the citation, as written. Wins over `citation-title`. |
|
|
2013
2773
|
| `citation-title` | `string \| undefined` | | A title or collection name for the Special Collections citation: "<title>, Albert and Shirley Small Special Collections Library, University of Virginia". |
|
|
2774
|
+
| `list-limit` | `number \| undefined` | | Shorten every list value of more than this many items to its first ones and a “Show all N” button. Zero or empty shows every item. A row's `data-limit` wins. |
|
|
2014
2775
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2015
2776
|
| `no-style` | `boolean` | `false` | |
|
|
2016
2777
|
|
|
@@ -2018,7 +2779,7 @@ A record's details as a description list, as on the library's digital collection
|
|
|
2018
2779
|
|
|
2019
2780
|
| Event | Description |
|
|
2020
2781
|
|---|---|
|
|
2021
|
-
| `uvalib-analytics-event` | For `<site-analytics>`: the Copy citation button, `['uvalib-metadata', 'copy-citation']
|
|
2782
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: the Copy citation button, `['uvalib-metadata', 'copy-citation']`, and a list's toggle, `['uvalib-metadata', 'show-all'\|'show-fewer', 'row N']` (N from 1, the row's place in the list; never its label or values). Downloads are left to Matomo's own download tracking. Bubbles and is composed. |
|
|
2022
2783
|
|
|
2023
2784
|
#### CSS custom properties
|
|
2024
2785
|
|
|
@@ -2030,7 +2791,7 @@ A record's details as a description list, as on the library's digital collection
|
|
|
2030
2791
|
| `--uva-color-text` | | Dark-mode role token: value colour (else `--uva-grey-darkest`). |
|
|
2031
2792
|
| `--uva-color-text-muted` | | Dark-mode role token: label and status colour (else #4b5563). |
|
|
2032
2793
|
| `--uva-color-border` | | Dark-mode role token: row dividers (else #dadada). |
|
|
2033
|
-
| `--uva-color-link` | | Dark-mode role token: the
|
|
2794
|
+
| `--uva-color-link` | | Dark-mode role token: the buttons' text and the Copy citation button's border (else `--uva-brand-blue`). |
|
|
2034
2795
|
| `--uva-color-surface-raised` | | Dark-mode role token: the button's background (else #fff). |
|
|
2035
2796
|
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
2036
2797
|
|
|
@@ -2065,7 +2826,7 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
|
|
|
2065
2826
|
|
|
2066
2827
|
### `<uvalib-pager>`
|
|
2067
2828
|
|
|
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.
|
|
2829
|
+
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`), or “Showing N” when `total` is unset or 0 (ranked search often cannot know it). 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. Once `has-more` has been set (the attribute, or the `hasMore` property), it alone decides whether the button shows: present (or `hasMore = true`) shows it; removed, `has-more="false"` or `hasMore = false` hides it. Left unset, the button hides once `shown` has reached a positive `total`, and stays with no 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.
|
|
2069
2830
|
|
|
2070
2831
|
#### Attributes
|
|
2071
2832
|
|
|
@@ -2077,7 +2838,8 @@ Previous/next section links, as on a reading page, or a numbered page list. Prev
|
|
|
2077
2838
|
| `next-label` | `string \| undefined` | | Title of the next section, under the “Next” kicker. |
|
|
2078
2839
|
| `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
2840
|
| `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”. |
|
|
2841
|
+
| `total` | `number \| undefined` | | How many results there are. Used by `mode="load-more"` as M in “Showing N of M”. Unset or 0 (an unknown total), the count reads “Showing N”. |
|
|
2842
|
+
| `has-more` | `boolean \| undefined` | | Whether `mode="load-more"` has more to load, for when `total` is not known. Unset (the default), the button follows `total`. Set, it decides: the attribute present means true; removing it, `has-more="false"` or `hasMore = false` means false. `hasMore = undefined` returns to following `total`. |
|
|
2081
2843
|
| `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
2844
|
| `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. |
|
|
2083
2845
|
| `pages` | `number \| undefined` | | How many pages. A positive number selects numbered pages and ignores previous/next. Zero, negative or non-numeric does not. |
|
|
@@ -2315,7 +3077,7 @@ Three automated checks guard accessibility, best practice and performance. The f
|
|
|
2315
3077
|
| `tokens.css` | 592 | 670 |
|
|
2316
3078
|
| `base.css` | 226 | 260 |
|
|
2317
3079
|
|
|
2318
|
-
- **Lighthouse CI** (`pnpm lhci`, `@lhci/cli`, settings and assertions in `lighthouserc.json`). The playground's previews run in a cross-origin sandbox, so `scripts/lhci.mjs` writes each example in `site/src/presets.ts` as a plain page into a temporary folder, next to a copy of the site build's `cdn/` (the local `dist-cdn`) and `data/`, serves it from localhost and audits it with Playwright's Chromium (Lighthouse's default mobile emulation, three runs per page, about 10 minutes). Assertions use each metric's median over the three runs, since a single run's CLS depends on when the page's first paint lands. Each page must score 1.0 for accessibility, at least 0.95 for best practices and
|
|
3080
|
+
- **Lighthouse CI** (`pnpm lhci`, `@lhci/cli`, settings and assertions in `lighthouserc.json`). The playground's previews run in a cross-origin sandbox, so `scripts/lhci.mjs` writes each example in `site/src/presets.ts` as a plain page into a temporary folder, next to a copy of the site build's `cdn/` (the local `dist-cdn`) and `data/`, serves it from localhost, compressed as the CDN serves it, and audits it with Playwright's Chromium (Lighthouse's default mobile emulation, three runs per page, about 10 minutes). Assertions use each metric's median over the three runs, since a single run's CLS depends on when the page's first paint lands. Each page must score 1.0 for accessibility, at least 0.95 for best practices and for performance, with CLS at most 0.05 and TBT at most 200 ms. Nothing reaches the network: Typekit and the alerts CDN are blocked (site-page treats both as optional, so the pages fall back to the system font stack and show no alerts, and their font swap is not measured); the header logo and LibCal are answered locally (a same-size stand-in logo through `root-link-domain`, and every library open 8am–10pm), with the library website and LibCal also blocked as a backstop. LibCal's events are stubbed the same way on the events example (18 upcoming events, one a day from tomorrow, one over two days), so the cards render as they do live. `pnpm lhci` builds first; reports are left in `.lighthouseci/`.
|
|
2319
3081
|
- `pnpm sync:main-nav` regenerates the bundled main navigation (`src/components/site-main-nav/main-nav-data.ts`) from the desktop "Main navigation" menu of the live library.virginia.edu home page. `node scripts/sync-main-nav.mjs saved.html` reads a saved page instead. It exits non-zero, writing nothing, if the menu's structure is not found or has fewer than 2 groups or 6 links. Commit the result.
|
|
2320
3082
|
- `pnpm start` runs the Vite dev server for the playground site (`site/`) and the demos (`demo/`), rooted at the repo: open `/site/` for the examples page, or `/demo/` for the demo pages. In dev, `cdn/<tag>.js` is served straight from `src/components/`, so edits show up on reload; `cdn/tokens.css` and `base.css` come from `dist-cdn/` (run `pnpm build` first).
|
|
2321
3083
|
- Previews run on the playground-elements sandbox at unpkg.com (never self-hosted: share links run untrusted code), which needs internet access. Locally, that public origin has to load the components from `http://localhost`; Vite's localhost-only CORS policy and Chrome's local network protections block this, so the components may not render in previews under `pnpm start` or `vite preview`. The editors, plain HTML previews and share links still work. Components render in previews on GitHub Pages, which serves `cdn/` with `Access-Control-Allow-Origin: *`.
|