@uvalib/web-components 1.1.1 → 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 +140 -0
- package/README.md +1310 -80
- 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/url-param.d.ts +23 -0
- package/dist/base/url-param.js +49 -0
- package/dist/base/url-param.js.map +1 -0
- package/dist/base.css +562 -2
- 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-card/UvalibCard.d.ts +19 -5
- package/dist/components/uvalib-card/UvalibCard.js +112 -9
- package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
- package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +178 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js +817 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.d.ts +1 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.js +4 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.js.map +1 -0
- package/dist/components/uvalib-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 +187 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +1452 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.d.ts +1 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js +4 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js.map +1 -0
- package/dist/components/uvalib-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 +152 -17
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-lightbox/media.d.ts +1 -18
- package/dist/components/uvalib-lightbox/media.js +1 -42
- package/dist/components/uvalib-lightbox/media.js.map +1 -1
- package/dist/components/uvalib-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 +77 -4
- package/dist/components/uvalib-pager/UvalibPager.js +270 -8
- package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +27 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +192 -26
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
- package/dist/components/uvalib-results-count/UvalibResultsCount.d.ts +62 -0
- package/dist/components/uvalib-results-count/UvalibResultsCount.js +208 -0
- package/dist/components/uvalib-results-count/UvalibResultsCount.js.map +1 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.d.ts +1 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.js +4 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.js.map +1 -0
- package/dist/components/uvalib-tabs/UvalibTabs.d.ts +127 -0
- package/dist/components/uvalib-tabs/UvalibTabs.js +821 -0
- package/dist/components/uvalib-tabs/UvalibTabs.js.map +1 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.d.ts +1 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.js +4 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.js.map +1 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +89 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.js +411 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.d.ts +1 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.js +4 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.js.map +1 -0
- package/dist/custom-elements.json +14007 -3497
- package/dist/index.d.ts +16 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/pagefind.css +4 -0
- package/dist/styles/base.js +154 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +9 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +8 -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.d.ts +1 -0
- package/dist/styles/results.js +242 -0
- package/dist/styles/results.js.map +1 -0
- 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 +9 -0
- package/dist-cdn/analytics.js +32 -0
- package/dist-cdn/analytics.js.map +1 -0
- package/dist-cdn/base.css +562 -2
- 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-BI8h0Gf3.js +281 -0
- package/dist-cdn/chunks/base-BI8h0Gf3.js.map +1 -0
- package/dist-cdn/chunks/inline-copy-BANQSMIR.js +69 -0
- package/dist-cdn/chunks/inline-copy-BANQSMIR.js.map +1 -0
- package/dist-cdn/chunks/{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-C9V7Wuw2.js → site-header-DYRMpdBj.js} +13 -4
- package/dist-cdn/chunks/site-header-DYRMpdBj.js.map +1 -0
- 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/source-children-BHsDwCvL.js +53 -0
- package/dist-cdn/chunks/source-children-BHsDwCvL.js.map +1 -0
- 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/chunks/url-param-C1sk_F1d.js +28 -0
- package/dist-cdn/chunks/url-param-C1sk_F1d.js.map +1 -0
- package/dist-cdn/custom-elements.json +14007 -3497
- 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 +15 -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 +269 -24
- package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +514 -13
- package/dist-cdn/skills/uvalib-web-components/reference/snippets.md +1 -1
- package/dist-cdn/tokens.css +9 -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 +97 -23
- package/dist-cdn/uvalib-card.js.map +1 -1
- package/dist-cdn/uvalib-chip-group.js +535 -0
- package/dist-cdn/uvalib-chip-group.js.map +1 -0
- package/dist-cdn/uvalib-combobox.js +667 -0
- package/dist-cdn/uvalib-combobox.js.map +1 -0
- package/dist-cdn/uvalib-contents.js +102 -23
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-date-histogram.js +960 -0
- package/dist-cdn/uvalib-date-histogram.js.map +1 -0
- 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 +145 -78
- 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 +152 -25
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pager.js +164 -18
- package/dist-cdn/uvalib-pager.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +123 -21
- package/dist-cdn/uvalib-photo-grid.js.map +1 -1
- package/dist-cdn/uvalib-results-count.js +101 -0
- package/dist-cdn/uvalib-results-count.js.map +1 -0
- package/dist-cdn/uvalib-tabs.js +436 -0
- package/dist-cdn/uvalib-tabs.js.map +1 -0
- package/dist-cdn/uvalib-tag-list.js +267 -0
- package/dist-cdn/uvalib-tag-list.js.map +1 -0
- package/package.json +66 -3
- package/skills/uvalib-web-components/SKILL.md +269 -24
- package/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
- package/skills/uvalib-web-components/reference/components.md +514 -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-CAFQWnZG.js +0 -128
- package/dist-cdn/chunks/base-CAFQWnZG.js.map +0 -1
- package/dist-cdn/chunks/site-header-C9V7Wuw2.js.map +0 -1
- package/dist-cdn/chunks/source-children-RuAec527.js +0 -119
- package/dist-cdn/chunks/source-children-RuAec527.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
# @uvalib/web-components
|
|
2
2
|
|
|
3
|
+
[](https://uvalib.github.io/reusable-web-library/report/) [](https://uvalib.github.io/reusable-web-library/report/) [](https://uvalib.github.io/reusable-web-library/report/#lighthouse)
|
|
4
|
+
|
|
3
5
|
Reusable web components for UVA Library sites, built with Lit and TypeScript:
|
|
4
6
|
|
|
5
7
|
- **Page chrome:** `<site-page>` (skip link, header with the library main navigation and live library alerts, one `<main>`, footer), `<site-alerts>` (the alerts, also usable alone), `<site-header>`, `<site-main-nav>`, `<site-footer>`, `<site-analytics>` and `<uvalib-analytics>` (Matomo, one element under two names) and `<site-style>` (legacy compatibility).
|
|
6
8
|
- **Navigation:** `<uvalib-breadcrumbs>` (the breadcrumb trail) and `<uvalib-contents>` (sub-navigation or a table of contents).
|
|
7
9
|
- **Cards:** `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>`.
|
|
10
|
+
- **Tabs:** `<uvalib-tabs>`.
|
|
11
|
+
- **Long pages:** `<uvalib-back-to-top>` (a “Back to top” button that appears once the top has scrolled away).
|
|
8
12
|
- **Records:** `<uvalib-metadata>` (a record's details, credit, rights and how to cite).
|
|
9
|
-
- **Images:** `<uvalib-lightbox>` (an image viewer over plain links)
|
|
10
|
-
- **
|
|
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).
|
|
11
16
|
- **Library hours:** `<site-hours-section>`, `<library-weekly-hours>` and `<library-hours-setup>`.
|
|
12
17
|
- **Library events:** `<events-section>`.
|
|
13
18
|
- **Search results:** `<bento-box>` (library.virginia.edu/search), with its `<catalog-section>`, `<articles-section>`, `<libguides-section>` and `<website-section>`.
|
|
@@ -109,6 +114,16 @@ To do it by hand, read on.
|
|
|
109
114
|
|
|
110
115
|
Ask for a new component, a feature or change in an existing one, or report a bug through [the repository's issues](https://github.com/uvalib/reusable-web-library/issues/new/choose). Each has a form: **New component**, **Feature or change request** and **Bug report**. The repository is public, so leave out passwords, tokens, internal-only hostnames and personal data. The agent skill knows the forms too: ask your agent to search the existing issues, draft one, and file it once you approve it (it uses the GitHub CLI, `gh`, or gives you the form's link).
|
|
111
116
|
|
|
117
|
+
## Test results
|
|
118
|
+
|
|
119
|
+
Every push to `main` is tested before the examples site is published, and the results go up with it: **[test report](https://uvalib.github.io/reusable-web-library/report/)**. Lighthouse takes about half an hour, so it runs alongside: the site goes up as soon as the tests pass, showing the previous Lighthouse results (marked as from an earlier commit), and is published again with this commit's when the audit finishes. It lists:
|
|
120
|
+
|
|
121
|
+
- **Tests:** every build and package test (Node) and every component test (Chromium), file by file, with each test's outcome.
|
|
122
|
+
- **Accessibility:** the axe-core checks, in shadow and light DOM, light and dark, held to WCAG 2.2 AA plus the extra rules Lighthouse enables. Lighthouse must also score 100 for accessibility on every example.
|
|
123
|
+
- **Lighthouse:** each example page's median performance, accessibility, best-practices, layout-shift and blocking-time results, against the budgets in [Quality checks](#quality-checks).
|
|
124
|
+
|
|
125
|
+
The badges above read the same report ([`report/results.json`](https://uvalib.github.io/reusable-web-library/report/results.json) has the numbers for scripts). Locally, `pnpm test`, `pnpm lhci` and `pnpm report` write it to `dist-site/report/`.
|
|
126
|
+
|
|
112
127
|
## Playground
|
|
113
128
|
|
|
114
129
|
Try every component and mode, edit the code, and share a link: <https://uvalib.github.io/reusable-web-library/>
|
|
@@ -129,7 +144,7 @@ The page is built with the library itself. Its header's main navigation is the e
|
|
|
129
144
|
|
|
130
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.
|
|
131
146
|
- `https://unpkg.internal.lib.virginia.edu/web-components/vX.Y.Z/<tag>.js` is an exact, immutable version. Use it to pin.
|
|
132
|
-
- `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)).
|
|
133
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).
|
|
134
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).
|
|
135
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.
|
|
@@ -144,7 +159,7 @@ npm i @uvalib/web-components
|
|
|
144
159
|
import '@uvalib/web-components/site-page.js'; // registers site-page, site-header, site-main-nav and site-footer
|
|
145
160
|
```
|
|
146
161
|
|
|
147
|
-
The define entries are `site-page.js`, `site-header.js`, `site-main-nav.js`, `site-footer.js`, `site-analytics.js`, `uvalib-analytics.js`, `site-style.js`, `uvalib-filter.js`, `uvalib-date-range.js`, `site-hours-section.js`, `library-weekly-hours.js`, `library-hours-setup.js`, `events-section.js`, `bento-box.js` and `uvalib-pagefind-search.js`. The package root (`import '@uvalib/web-components'`) exports the classes only and registers nothing. To use a class such as `SitePage` directly, also import the define entries. CSS is available as `@uvalib/web-components/tokens.css`, `base.css` and `pagefind.css` (the Pagefind theme, see [Static-site search](#static-site-search-pagefind)). Do not load the same component from both the CDN and npm on one page.
|
|
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.
|
|
148
163
|
|
|
149
164
|
## Quick start
|
|
150
165
|
|
|
@@ -274,6 +289,19 @@ connect-src https://d2q6t6fdv76k7r.cloudfront.net wss://*.appsync-realtime-api.u
|
|
|
274
289
|
|
|
275
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.
|
|
276
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
|
+
|
|
277
305
|
## Breadcrumbs
|
|
278
306
|
|
|
279
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:
|
|
@@ -299,6 +327,7 @@ connect-src https://d2q6t6fdv76k7r.cloudfront.net wss://*.appsync-realtime-api.u
|
|
|
299
327
|
|
|
300
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.
|
|
301
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.
|
|
302
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.
|
|
303
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.
|
|
304
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>`.
|
|
@@ -339,15 +368,102 @@ connect-src https://d2q6t6fdv76k7r.cloudfront.net wss://*.appsync-realtime-api.u
|
|
|
339
368
|
```
|
|
340
369
|
|
|
341
370
|
- **A clickable card.** `href` makes the heading the link, and a CSS pseudo-element stretches that link over the card, so the whole card is one destination. The arrow is only a visual aid. Never wrap the card in an `<a>`. A clickable card must not contain another link, button or other control: the stretched link would cover it, and a link inside a link is invalid. The heading needs an accessible name (text, or an image alt or label); otherwise the link is hidden. A static card (no `href`, or an empty or unsafe one such as `javascript:`) has no stretch, so its excerpt may contain links. An unsafe href is shown as plain text, with one console warning.
|
|
342
|
-
- **Slots.** `media` (an `<img>` with a real alt, or `alt=""` when the heading already names it), `badge` (for example “13 photos”, over the image), `heading`, `meta` (a date in `<time>`, or a byline), `chip` (one element per category) and the default slot for the excerpt.
|
|
371
|
+
- **Slots.** `media` (an `<img>` with a real alt, or `alt=""` when the heading already names it), `badge` (for example “13 photos”, over the image), `heading`, `meta` (a date in `<time>`, or a byline), `chip` (one element per category), `actions` (links or buttons on a static card, such as “Read the story” and “Photos (132)”) and the default slot for the excerpt. A clickable card must not contain an actions row: the stretched link would cover those controls, and the card warns once.
|
|
372
|
+
- **Circle media.** `media-shape="circle"` draws the media as a centered circle for a person or avatar. The image keeps its alt, and the count badge still sits on it. Any other value is ignored, with one warning.
|
|
343
373
|
- **Heading level.** Unset, it is one below the nearest heading before the card, or 3 when there is none (the same rule as `<events-section>`). `heading-level` (1–6) wins.
|
|
344
374
|
- **The grid.** A list, so a screen reader announces how many cards there are. Columns follow the grid’s own width: four above 992px, two through 767px, then one. Cards in a row match the tallest. `min-card-width` (a length such as `16rem`) switches that to `auto-fill` / `minmax`; anything else is ignored, with one warning. Only `<uvalib-card>` children are listed.
|
|
345
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”.
|
|
346
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”.
|
|
347
377
|
- **One landmark name.** Two pagers with the same accessible name fail the accessibility check. Give the second a different `label`.
|
|
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”.
|
|
348
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'`.
|
|
349
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.
|
|
350
381
|
|
|
382
|
+
## Chips
|
|
383
|
+
|
|
384
|
+
`<uvalib-chip-group>` is a row of chips: a segmented control or single-select filter (a year rail, a sort toggle), filter chips that toggle, or suggestion chips that go somewhere. Entry: `uvalib-chip-group.js` on the CDN, `@uvalib/web-components/uvalib-chip-group.js` on npm.
|
|
385
|
+
|
|
386
|
+
```html
|
|
387
|
+
<script
|
|
388
|
+
type="module"
|
|
389
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-chip-group.js"
|
|
390
|
+
></script>
|
|
391
|
+
<uvalib-chip-group label="Year" count-label="shoots" value="" scroll url-param="year">
|
|
392
|
+
<button value="" data-count="3694">All Years</button>
|
|
393
|
+
<button value="2004" data-count="213">2004</button>
|
|
394
|
+
<button value="2005" data-count="461">2005</button>
|
|
395
|
+
</uvalib-chip-group>
|
|
396
|
+
<uvalib-chip-group label="Sort by" segmented value="photos">
|
|
397
|
+
<button value="photos">Most photos</button>
|
|
398
|
+
<button value="date">Date</button>
|
|
399
|
+
<button value="title">Title A–Z</button>
|
|
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>
|
|
410
|
+
<uvalib-chip-group mode="multi" label="Category" value="traditions">
|
|
411
|
+
<button value="traditions" data-count="9">Traditions</button>
|
|
412
|
+
<button value="sports" data-count="21">Sports</button>
|
|
413
|
+
</uvalib-chip-group>
|
|
414
|
+
<uvalib-chip-group mode="links" label="Suggested searches">
|
|
415
|
+
<a href="/search?q=snow+on+the+Lawn">snow on the Lawn</a>
|
|
416
|
+
</uvalib-chip-group>
|
|
417
|
+
```
|
|
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
|
+
|
|
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.
|
|
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.
|
|
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`.
|
|
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.
|
|
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.
|
|
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.
|
|
437
|
+
- **Address.** `url-param="year"` keeps the value in the query (`?year=2005`; inside the hash on a hash route such as `#/series?year=2005` or `#chapter?year=2005`; a `multi` value comma-separated). It is read on connect. The markup's `value` stands for the address without the parameter; any other value is written, an empty one as `?year=`. Each change is one `pushState`: in `multi` at once, in `single` once the visitor settles (a second after the last change, so arrowing through a year rail adds one entry, and none when they end where they started). Back and Forward are followed and fire `change` with `restored: true`; a change still settling is dropped. With `<site-analytics spa="auto">` each push is one page view.
|
|
438
|
+
- **Analytics.** `change` with `<label>: <chip label>` and the count as the value (single: once the visitor settles, a second after the last change, and not when they end where they started); `select` with the group's label only, never the chip or its URL.
|
|
439
|
+
|
|
440
|
+
## Tabs
|
|
441
|
+
|
|
442
|
+
`<uvalib-tabs>` is a tab set. Each direct child with `data-tab` is a panel (the attribute is the tab’s label; give the panel an `id`), or pair `<button slot="tab">` labels with the panels in order. Entry: `uvalib-tabs.js` on the CDN, `@uvalib/web-components/uvalib-tabs.js` on npm.
|
|
443
|
+
|
|
444
|
+
```html
|
|
445
|
+
<script
|
|
446
|
+
type="module"
|
|
447
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-tabs.js"
|
|
448
|
+
></script>
|
|
449
|
+
<uvalib-tabs url-param="tab">
|
|
450
|
+
<section data-tab="Events" id="events">
|
|
451
|
+
<h2>Events</h2>
|
|
452
|
+
<p>Upcoming.</p>
|
|
453
|
+
</section>
|
|
454
|
+
<section data-tab="Stories" id="stories">
|
|
455
|
+
<h2>Stories</h2>
|
|
456
|
+
<p>From the archive.</p>
|
|
457
|
+
</section>
|
|
458
|
+
</uvalib-tabs>
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
- **Roles and keys.** The component renders `tablist`, `tab` and `tabpanel`, with `aria-selected`, `aria-controls` and `aria-labelledby`. Arrow keys move (they wrap, and they flip in right-to-left), Home and End jump. Selection follows the arrow unless `activation="manual"`, which waits for Enter or Space. Only the selected tab is in the tab order.
|
|
462
|
+
- **Selection.** `selected` is the panel id (a label or a 0-based index is accepted and rewritten to the id). A `change` event carries `{ id, label, index }`. The first panel is visible before the element upgrades, and a hidden panel is not in the accessibility tree.
|
|
463
|
+
- **Linkable tabs.** `url-param` keeps the selected id in the query string, or inside the hash on a hash route. `url-param="hash"` uses a bare `#panel-id`. Opening from a URL that already names a tab does not rewrite it. Back and Forward restore the tab. Nothing is written on the first render.
|
|
464
|
+
- **Phone.** The tabs wrap onto more than one line. Each tab stays at least 44px.
|
|
465
|
+
- **Analytics.** A visitor’s click or key reports `['uvalib-tabs', 'change', '<tab label>']`. The label is capped at 100 characters. Nothing is reported on render, on `requestUpdate`, or when Back restores a tab.
|
|
466
|
+
|
|
351
467
|
## Contents and record metadata
|
|
352
468
|
|
|
353
469
|
Two components for Library sites with records and long texts, such as the Electronic Text Collections. Entries: `uvalib-contents.js` and `uvalib-metadata.js` on the CDN, `@uvalib/web-components/uvalib-contents.js` and `@uvalib/web-components/uvalib-metadata.js` on npm.
|
|
@@ -404,6 +520,7 @@ Two components for Library sites with records and long texts, such as the Electr
|
|
|
404
520
|
|
|
405
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.
|
|
406
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.
|
|
407
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.
|
|
408
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.
|
|
409
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.
|
|
@@ -413,6 +530,7 @@ Two components for Library sites with records and long texts, such as the Electr
|
|
|
413
530
|
|
|
414
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).
|
|
415
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.
|
|
416
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.
|
|
417
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`.
|
|
418
536
|
|
|
@@ -449,9 +567,146 @@ Both follow dark mode through the role tokens and reflow at 320px; `no-style` ke
|
|
|
449
567
|
- **IIIF.** An Image API URL keeps its region (a crop or `square` stays). Only the size becomes `!W,H` for the viewport (CSS pixels times the screen density, at most 2, and at most 2000 pixels on a side). TIFF and JPEG2000 URLs are left as written. Full size still opens the original href, and only for an http(s) URL or a PNG, JPEG, GIF or WebP `data:` image. A resize while the viewer is open asks for the new size and is not an analytics event. Other image URLs are used as written. A `javascript:` URL, and an SVG `data:` URL, are refused.
|
|
450
568
|
- **Deep link.** `url-param="photo"` keeps `?photo=<id>` in sync: opening pushes a history entry, stepping replaces it, and Back closes. On a hash route (`#/text`, or a hash that already contains `?`) the parameter is written inside the hash (`#/text?photo=<id>`). Opening from a URL that already has the parameter is not a new action, and neither is Back or Forward. With `<site-analytics spa="auto">` (or `<uvalib-analytics spa="auto">`), that opening push is a same-document route change, so Matomo may count one page view; stepping replaces the entry and does not.
|
|
451
569
|
- **Details.** A child with `slot="details"` (optional `data-for` equal to the item's id or its position from 1; without `data-for` it shows for every image), or `data-details-id` on a link naming an element elsewhere on the page. It is shown in the dialog and put back when the viewer moves on or closes.
|
|
452
|
-
- **Photo grid.** Each direct child that is an `<a href>` or a `<button>` is one photo. The row is about 220px tall, and 140px when the viewport is 767px or narrower, unless `row-height` is set (a bare number is pixels; `rem`, `em` and the other CSS lengths are kept). Each image keeps its shape from its `width` and `height` attributes, or from the loaded image, so the row does not jump. Every item stays a real link or button. An image with no visible text gets a visible caption from its alt, and an alt that repeats that caption is cleared so it is not announced twice. The original alt is kept for a lightbox. A different alt is kept (the accessible name still contains the visible text). An `aria-label` is left as the name. Generated "Photo N" captions renumber when the photos change order. An item with no name is captioned "Photo N" and warned about once. A child that is not a link or a button is skipped, with one warning. The grid reports no analytics. Put it inside `<uvalib-lightbox>` and a plain click opens the viewer.
|
|
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.
|
|
453
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.
|
|
454
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
|
+
|
|
455
710
|
## Rendering modes
|
|
456
711
|
|
|
457
712
|
| Attributes | Rendering |
|
|
@@ -492,12 +747,70 @@ The mode is read once, at first connect; do not toggle it afterwards.
|
|
|
492
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`).
|
|
493
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.
|
|
494
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']`.
|
|
495
807
|
|
|
496
808
|
## Tokens and theming
|
|
497
809
|
|
|
498
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.
|
|
499
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)`.
|
|
500
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.
|
|
501
814
|
|
|
502
815
|
## Dark mode
|
|
503
816
|
|
|
@@ -536,32 +849,34 @@ Dark mode is **off by default**. Without it nothing changes: no control, no dark
|
|
|
536
849
|
|
|
537
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.
|
|
538
851
|
|
|
539
|
-
| Token | Used for | Light
|
|
540
|
-
| ----------------------------- | ----------------------------------------------------------- |
|
|
541
|
-
| `--uva-color-surface` | page background | `#ffffff`
|
|
542
|
-
| `--uva-color-surface-raised` | header, nav bar, panels, popover, inputs, buttons, chips | `#ffffff`
|
|
543
|
-
| `--uva-color-surface-hover` | hover and open-group background | `--uva-grey-100` (`#dadada`)
|
|
544
|
-
| `--uva-color-text` | text | `--uva-grey-darkest` (`#2b2b2b`)
|
|
545
|
-
| `--uva-color-text-muted` | secondary labels | `#4b5563`
|
|
546
|
-
| `--uva-color-link` | links, headings, accent text | `--uva-brand-blue` (`#232d4b`)
|
|
547
|
-
| `--uva-color-utility-link` | header utility and site links | `--uva-blue-alt-dark` (`#005679`)
|
|
548
|
-
| `--uva-color-focus` | focus rings | `--uva-brand-orange` (`#e57200`)
|
|
549
|
-
| `--uva-color-current` | current-page underline | `--uva-brand-orange` (`#e57200`)
|
|
550
|
-
| `--uva-color-accent-bg` | pressed chip, slider range and thumbs, skip link, selection | `--uva-brand-blue` (`#232d4b`)
|
|
551
|
-
| `--uva-color-on-accent` | text on `--uva-color-accent-bg` | `#ffffff`
|
|
552
|
-
| `--uva-color-control-border` | borders of controls (chips, inputs, the theme control) | `--uva-grey` (`#808080`)
|
|
553
|
-
| `--uva-color-input-text` | date input text | `#1f2937`
|
|
554
|
-
| `--uva-color-border` | decorative borders and rules (dark only) | each component's own (`#ccc`, …)
|
|
555
|
-
| `--uva-color-track` | slider track | `#e5e7eb`
|
|
556
|
-
| `--uva-color-shadow` | panel shadow | `rgba(0, 0, 0, 0.2)`
|
|
557
|
-
| `--uva-color-pre-footer-bg` | pre-footer band background | `--uva-blue-alt-300` (`#bfe7f7`)
|
|
558
|
-
| `--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` |
|
|
559
874
|
|
|
560
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.
|
|
561
876
|
|
|
562
877
|
## Search and filter components
|
|
563
878
|
|
|
564
|
-
`<uvalib-filter>` (a checkbox facet with optional scope chips and See more / See less)
|
|
879
|
+
`<uvalib-filter>` (a checkbox facet with optional scope chips and See more / See less), `<uvalib-date-range>` (a year slider plus date inputs) and `<uvalib-date-histogram>` (counts as bars) are for search results pages. They are not page chrome, so use them inside `<site-page>`. Each has its own entry: `uvalib-filter.js`, `uvalib-date-range.js` and `uvalib-date-histogram.js` on the CDN, `@uvalib/web-components/uvalib-filter.js` and the same path for the others on npm.
|
|
565
880
|
|
|
566
881
|
```html
|
|
567
882
|
<script
|
|
@@ -590,7 +905,338 @@ Dark mode is **off by default**. Without it nothing changes: no control, no dark
|
|
|
590
905
|
</script>
|
|
591
906
|
```
|
|
592
907
|
|
|
593
|
-
|
|
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.
|
|
909
|
+
|
|
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.
|
|
911
|
+
|
|
912
|
+
```html
|
|
913
|
+
<script
|
|
914
|
+
type="module"
|
|
915
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-date-histogram.js"
|
|
916
|
+
></script>
|
|
917
|
+
<script
|
|
918
|
+
type="module"
|
|
919
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-date-range.js"
|
|
920
|
+
></script>
|
|
921
|
+
|
|
922
|
+
<uvalib-date-range
|
|
923
|
+
id="dates"
|
|
924
|
+
min="2005-01-01"
|
|
925
|
+
max="2017-12-31"
|
|
926
|
+
label="Photo dates"
|
|
927
|
+
></uvalib-date-range>
|
|
928
|
+
<uvalib-date-histogram
|
|
929
|
+
id="hist"
|
|
930
|
+
range-for="dates"
|
|
931
|
+
granularity="month"
|
|
932
|
+
unit="photos"
|
|
933
|
+
label="Photos by date"
|
|
934
|
+
></uvalib-date-histogram>
|
|
935
|
+
<script type="module">
|
|
936
|
+
const hist = document.querySelector('#hist');
|
|
937
|
+
hist.items = [
|
|
938
|
+
{ date: '2015-10', count: 5311 },
|
|
939
|
+
{ date: '2015-11', count: 842 },
|
|
940
|
+
];
|
|
941
|
+
hist.addEventListener('select', (e) => console.log(e.detail)); // { from, to }
|
|
942
|
+
</script>
|
|
943
|
+
```
|
|
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
|
+
|
|
1060
|
+
## Results, badges and tags
|
|
1061
|
+
|
|
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.
|
|
1063
|
+
|
|
1064
|
+
### Badges
|
|
1065
|
+
|
|
1066
|
+
```html
|
|
1067
|
+
<span class="uvalib-badge">Plain</span>
|
|
1068
|
+
<span class="uvalib-badge uvalib-badge--category">Faculty & Staff Portraits</span>
|
|
1069
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--success">Done</span>
|
|
1070
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--warning">Processing</span>
|
|
1071
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--danger">Failed</span>
|
|
1072
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--info">Largest</span>
|
|
1073
|
+
<span class="uvalib-badge uvalib-badge--new">New</span>
|
|
1074
|
+
<span class="uvalib-badge uvalib-badge--body">At body size</span>
|
|
1075
|
+
|
|
1076
|
+
<!-- A count over an image: the wrapper positions it at the top-left corner. -->
|
|
1077
|
+
<div class="uvalib-media">
|
|
1078
|
+
<img src="rotunda.jpg" alt="The Rotunda in snow" width="600" height="400" />
|
|
1079
|
+
<span class="uvalib-badge uvalib-badge--count">13 photos</span>
|
|
1080
|
+
</div>
|
|
1081
|
+
<!-- Several: wrap them. -->
|
|
1082
|
+
<div class="uvalib-media">
|
|
1083
|
+
<img src="lawn.jpg" alt="The Lawn" width="600" height="400" />
|
|
1084
|
+
<div class="uvalib-media__badges">
|
|
1085
|
+
<span class="uvalib-badge uvalib-badge--count">51 events · 10,700 photos</span>
|
|
1086
|
+
<span class="uvalib-badge uvalib-badge--new">New</span>
|
|
1087
|
+
</div>
|
|
1088
|
+
</div>
|
|
1089
|
+
|
|
1090
|
+
<!-- A decorative icon before the word (the word carries the meaning). -->
|
|
1091
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--success">
|
|
1092
|
+
<svg aria-hidden="true" viewBox="0 0 16 16">
|
|
1093
|
+
<path d="M2 8l4 4 8-8" fill="none" stroke="currentColor" stroke-width="2" />
|
|
1094
|
+
</svg>
|
|
1095
|
+
Done
|
|
1096
|
+
</span>
|
|
1097
|
+
```
|
|
1098
|
+
|
|
1099
|
+
- **Sizes:** small text (0.875rem) by default, the card chip's size; `--body` is body size.
|
|
1100
|
+
- **`--category`** is the `<uvalib-card>` chip exactly (`--uva-blue-alt-300` with `--uva-blue-alt-dark` text, 6.13:1, in both schemes). **`--count`** is for media: near-black at 82% with white text, at least 11:1 over any picture (AAA). **`--status`** with `--success`, `--warning`, `--danger` or `--info` reads the alert role tokens (and `--uva-color-status-success-*`): text 7:1 or more in light and dark. **`--new`** is the accent (brand blue, AAA). The plain badge is neutral grey (AAA).
|
|
1101
|
+
- **Never colour alone:** a status badge always says its state in words; an icon is decorative (`aria-hidden="true"`). In forced colors every badge keeps an outline.
|
|
1102
|
+
- **On cards and links:** a badge inside a link is part of its name, so keep it short and meaningful (“13 photos”), or put it outside the link. Inside `<uvalib-card>`, use `slot="badge"` and `slot="chip"` instead.
|
|
1103
|
+
|
|
1104
|
+
### Results toolbar
|
|
1105
|
+
|
|
1106
|
+
```html
|
|
1107
|
+
<div class="uvalib-toolbar">
|
|
1108
|
+
<div class="uvalib-toolbar__field uvalib-toolbar__field--grow">
|
|
1109
|
+
<label for="filter">Filter shoots</label>
|
|
1110
|
+
<input class="uvalib-input" id="filter" type="search" />
|
|
1111
|
+
</div>
|
|
1112
|
+
<div class="uvalib-toolbar__field">
|
|
1113
|
+
<label for="category">Category</label>
|
|
1114
|
+
<select class="uvalib-input" id="category">
|
|
1115
|
+
<option value="">All categories</option>
|
|
1116
|
+
<option>Faculty & Staff Portraits</option>
|
|
1117
|
+
</select>
|
|
1118
|
+
</div>
|
|
1119
|
+
<div class="uvalib-toolbar__group" role="group" aria-label="Decade">
|
|
1120
|
+
<button class="uvalib-button uvalib-button--small" type="button" aria-pressed="false">
|
|
1121
|
+
2000s
|
|
1122
|
+
</button>
|
|
1123
|
+
<button class="uvalib-button uvalib-button--small" type="button" aria-pressed="true">
|
|
1124
|
+
2010s
|
|
1125
|
+
</button>
|
|
1126
|
+
</div>
|
|
1127
|
+
<uvalib-results-count
|
|
1128
|
+
class="uvalib-toolbar__summary"
|
|
1129
|
+
shown="48"
|
|
1130
|
+
total="3694"
|
|
1131
|
+
noun="shoots"
|
|
1132
|
+
singular="shoot"
|
|
1133
|
+
></uvalib-results-count>
|
|
1134
|
+
</div>
|
|
1135
|
+
```
|
|
1136
|
+
|
|
1137
|
+
- **`.uvalib-toolbar`** is a wrapping row with consistent gaps (0.75rem by 1rem), controls aligned on their bottom edge. **`__field`** stacks a label over its control (keep the visible `<label>`); **`__field--grow`** (or a `.uvalib-search-form` in the toolbar) takes the spare width. **`__group`** holds a chip group (`.uvalib-button` toggles with `aria-pressed`; give the group a name with `role="group"` and `aria-label`). **`__summary`** sits at the end in muted text (AAA). At 30em and narrower every item takes the full width, in source order.
|
|
1138
|
+
- **`<uvalib-results-count>`** writes “Showing 48 of 3,694 shoots” (“Showing all 12 shoots”, “Showing 1 shoot”, “No shoots” for a total or a shown of 0) from `shown`, `total`, `noun` and `singular`, and keeps it in sync at once; a missing or blank `shown` / `total` is unset, not 0. A hidden polite live region announces it once the text has not changed for a second (`announce-delay`), then clears itself after five seconds. The first render is never announced, but when it had no count yet (results still loading), the first count that arrives is. A count that comes back after a different one (a new search with as many results) is announced again. Update `shown` / `total` from your script after each filter change, and leave them unset while loading rather than setting 0. `<bento-box>` and `<uvalib-pagefind-search>` announce their own counts, so do not add one beside them.
|
|
1139
|
+
|
|
1140
|
+
```js
|
|
1141
|
+
const count = document.querySelector('uvalib-results-count');
|
|
1142
|
+
filter.addEventListener('input', () => {
|
|
1143
|
+
const hits = shoots.filter((s) => s.title.toLowerCase().includes(filter.value.toLowerCase()));
|
|
1144
|
+
render(hits.slice(0, 48));
|
|
1145
|
+
count.shown = Math.min(hits.length, 48);
|
|
1146
|
+
count.total = hits.length;
|
|
1147
|
+
});
|
|
1148
|
+
```
|
|
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
|
+
|
|
1198
|
+
### Tag lists
|
|
1199
|
+
|
|
1200
|
+
```html
|
|
1201
|
+
<uvalib-tag-list label="Subjects" track-label limit="8" href-template="/search?q={tag}">
|
|
1202
|
+
<span>Rotunda</span>
|
|
1203
|
+
<span>Lawn</span>
|
|
1204
|
+
<a href="/collections/snow">Snow</a>
|
|
1205
|
+
</uvalib-tag-list>
|
|
1206
|
+
<!-- Plain text tags: no href-template and no links. -->
|
|
1207
|
+
<uvalib-tag-list label="AI tags" hide-label>
|
|
1208
|
+
<span>building</span>
|
|
1209
|
+
<span>columns</span>
|
|
1210
|
+
</uvalib-tag-list>
|
|
1211
|
+
```
|
|
1212
|
+
|
|
1213
|
+
A labelled list (`label`, shown above it or visually hidden with `hide-label`) that wraps. Each tag is a link (an `<a href>` child, or any tag when `href-template` has `{tag}`, URL-encoded) or plain text; links are outlined pills in the link colour, plain tags the filled chip; every tag and the toggle are at least 2rem (34px) tall and wide and 0.5rem apart (WCAG 2.5.8 with room to spare; not AAA's 44px, which would make the pills button-sized), and at least 24px with `no-style`. A child's `lang` and `dir` are kept, and so is inline markup inside it (`em`, `cite`, `abbr`, `bdi`, a `span lang`…), copied element by element, never parsed as HTML; a blank `href` counts as none. `limit` shows that many and a “Show all N” button (`aria-expanded`, `aria-controls`); the rest appear in place and focus stays on the button, which then reads “Show fewer”. Apps can set `items` (`[{ label, href?, lang?, dir? }]`) instead of children, and route with the cancelable `uvalib-tag-list-navigate` event. Analytics never sends a tag's text, as tags can come from a record, a person or a machine, and by default not the label either, which a template may fill from a record: the name is `list N`, the list's place among the page's tag lists, with the tag's position as the value. Add `track-label` when the label is fixed text you wrote (“Subjects”) to send it instead (see [Analytics](#analytics)).
|
|
1214
|
+
|
|
1215
|
+
### Empty and loading states
|
|
1216
|
+
|
|
1217
|
+
```html
|
|
1218
|
+
<div class="uvalib-empty-state">
|
|
1219
|
+
<svg class="uvalib-empty-state__icon" aria-hidden="true" viewBox="0 0 24 24">
|
|
1220
|
+
<circle cx="11" cy="11" r="7" fill="none" stroke="currentColor" stroke-width="2" />
|
|
1221
|
+
<path d="M16 16l5 5" stroke="currentColor" stroke-width="2" />
|
|
1222
|
+
</svg>
|
|
1223
|
+
<h2>No photos match “snow”</h2>
|
|
1224
|
+
<p>Try another word, or clear the filters.</p>
|
|
1225
|
+
<button class="uvalib-button uvalib-button--secondary" type="button">Clear filters</button>
|
|
1226
|
+
</div>
|
|
1227
|
+
|
|
1228
|
+
<div class="results" aria-busy="true">
|
|
1229
|
+
<div aria-hidden="true">
|
|
1230
|
+
<div class="uvalib-skeleton uvalib-skeleton--media"></div>
|
|
1231
|
+
<p><span class="uvalib-skeleton-text"></span><span class="uvalib-skeleton-text"></span></p>
|
|
1232
|
+
</div>
|
|
1233
|
+
<p class="visually-hidden" role="status">Loading results</p>
|
|
1234
|
+
</div>
|
|
1235
|
+
```
|
|
1236
|
+
|
|
1237
|
+
- **`.uvalib-empty-state`**: an optional decorative icon (`__icon`, `aria-hidden`), a heading at the page's next level, a sentence and one action, centred in a dashed box. When it replaces results, the results count already announces “No shoots”; it needs no live region of its own.
|
|
1238
|
+
- **`.uvalib-skeleton`** is a box: give it a height, or `--media` for a 3:2 image. **`.uvalib-skeleton-text`** reserves exactly one line of text (the last of several is shorter). Make the placeholders the same size as what replaces them, so nothing shifts. They shimmer, except under `prefers-reduced-motion`, and are outlined in forced colors.
|
|
1239
|
+
- **Hide them from assistive technology** (`aria-hidden="true"` on their container), mark the region `aria-busy="true"` while it loads, and say “Loading results” once in a polite status (or rely on the results count when the results arrive). Remove `aria-busy` and the placeholders together.
|
|
594
1240
|
|
|
595
1241
|
## Library hours
|
|
596
1242
|
|
|
@@ -630,6 +1276,34 @@ Three elements show opening hours from the library's own data, for library.virgi
|
|
|
630
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.
|
|
631
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.
|
|
632
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
|
+
|
|
633
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.
|
|
634
1308
|
|
|
635
1309
|
## Library events
|
|
@@ -717,52 +1391,107 @@ Static sites that search with [Pagefind](https://pagefind.app) (such as Electron
|
|
|
717
1391
|
<uvalib-analytics matomoid="10"></uvalib-analytics>
|
|
718
1392
|
```
|
|
719
1393
|
|
|
720
|
-
- **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).
|
|
721
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-*`).
|
|
722
1396
|
- `…-event`: `detail: { event: [category, action, name?, value?] }` (`track` is accepted as the old name), a Matomo `trackEvent`.
|
|
723
1397
|
- `…-search`: `detail: { searchQuery, searchCategory?, resultCount? }`, a Matomo site search; an unknown count (null or missing) is sent as Matomo's "unknown".
|
|
724
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.
|
|
725
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
|
+
|
|
726
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.
|
|
727
|
-
- **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
|
+
|
|
728
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.
|
|
729
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">`.
|
|
730
|
-
- **`<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.
|
|
731
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.
|
|
732
1445
|
|
|
733
|
-
| Component | Action | Name | Value
|
|
734
|
-
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
735
|
-
| `site-header` | `link-click` (a utility or site link) | the link's label |
|
|
736
|
-
| `site-header` | `menu-open` (the phone Menu popover) | |
|
|
737
|
-
| `site-header` | `skip-link`, `logo-click` | |
|
|
738
|
-
| `site-header` | `color-scheme` | `light`, `dark` or `system` |
|
|
739
|
-
| `site-main-nav` | `menu-open` (a group opens, not closes) | the group's label |
|
|
740
|
-
| `site-main-nav` | `link-click` | `Group > Link` (a top-level link: its label) |
|
|
741
|
-
| `site-footer` | `link-click` (not the pre-footer's) | `Column: Link`, e.g. `About: Staff directory`; `Contact us: Phone`, `Contact us: Email`; `Social: Facebook`, `Social: Instagram` |
|
|
742
|
-
| `uvalib-breadcrumbs` | `link-click` | `level N` (never the label) | N, from 1
|
|
743
|
-
| `uvalib-card` | `card-click` | `single`, or the card's place in its grid (`1`, `2`, …); never the title or URL | that place, from 1, in a grid
|
|
744
|
-
| `uvalib-pager` | `page-change` | `next`, `previous` or `number` (never the label or URL) | the page, for `number` only
|
|
745
|
-
| `uvalib-
|
|
746
|
-
| `uvalib-
|
|
747
|
-
| `uvalib-
|
|
748
|
-
| `uvalib-
|
|
749
|
-
| `
|
|
750
|
-
| `
|
|
751
|
-
| `
|
|
752
|
-
| `
|
|
753
|
-
| `
|
|
754
|
-
| `
|
|
755
|
-
| `site-
|
|
756
|
-
| `
|
|
757
|
-
| `
|
|
758
|
-
| `
|
|
759
|
-
| `
|
|
760
|
-
| `
|
|
761
|
-
| `
|
|
762
|
-
| `
|
|
763
|
-
| `
|
|
764
|
-
|
|
765
|
-
|
|
1446
|
+
| Component | Action | Name | Value |
|
|
1447
|
+
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
1448
|
+
| `site-header` | `link-click` (a utility or site link) | the link's label | |
|
|
1449
|
+
| `site-header` | `menu-open` (the phone Menu popover) | | |
|
|
1450
|
+
| `site-header` | `skip-link`, `logo-click` | | |
|
|
1451
|
+
| `site-header` | `color-scheme` | `light`, `dark` or `system` | |
|
|
1452
|
+
| `site-main-nav` | `menu-open` (a group opens, not closes) | the group's label | |
|
|
1453
|
+
| `site-main-nav` | `link-click` | `Group > Link` (a top-level link: its label) | |
|
|
1454
|
+
| `site-footer` | `link-click` (not the pre-footer's) | `Column: Link`, e.g. `About: Staff directory`; `Contact us: Phone`, `Contact us: Email`; `Social: Facebook`, `Social: Instagram` | |
|
|
1455
|
+
| `uvalib-breadcrumbs` | `link-click` | `level N` (never the label) | N, from 1 |
|
|
1456
|
+
| `uvalib-card` | `card-click` | `single`, or the card's place in its grid (`1`, `2`, …); never the title or URL | that place, from 1, in a grid |
|
|
1457
|
+
| `uvalib-pager` | `page-change` | `next`, `previous` or `number` (never the label or URL) | the page, for `number` only |
|
|
1458
|
+
| `uvalib-pager` | `load-more` | (empty) | the next page |
|
|
1459
|
+
| `uvalib-tabs` | `change` | the tab's label (capped at 100 characters; not a URL) | |
|
|
1460
|
+
| `uvalib-contents` | `link-click` | `level N` (never the label or URL) | N, from 1 (the top level) |
|
|
1461
|
+
| `uvalib-contents` | `toggle` (the narrow-screen disclosure) | `open` or `close` | |
|
|
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) | |
|
|
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 |
|
|
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 |
|
|
1467
|
+
| `uvalib-tag-list` | `show-all`, `show-fewer` | `list N`, or with `track-label` the `label` | |
|
|
1468
|
+
| `site-alerts` | a content impression, once per alert per page view: `trackContentImpression('Library alert', '<severity>: <title>')` | | |
|
|
1469
|
+
| `site-alerts` | `dismiss`, `link-click` (a link in an alert's text) | `<severity>: <title>` | |
|
|
1470
|
+
| `site-alerts` | `error` (the alerts script failed to load) | `alerts-script` | |
|
|
1471
|
+
| `events-section` | `event-click` | the `category` id, or `all` | the event's position, from 1 |
|
|
1472
|
+
| `events-section` | `error` | `events-load` | |
|
|
1473
|
+
| `site-hours-section` | `link-click` | `See all hours` | |
|
|
1474
|
+
| `site-hours-section`, `library-weekly-hours` | `error` | `hours-load` | |
|
|
1475
|
+
| `library-weekly-hours` | `week-change` | `next` or `previous` | |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
1486
|
+
| `uvalib-filter` | `scope-change` | the scope's label | 1 pressed, 0 not |
|
|
1487
|
+
| `uvalib-filter` | `see-more`, `see-less` | the filter's title | |
|
|
1488
|
+
| `uvalib-date-range` | `range-change` (1 s after the last change, and only if the years differ) | `<from year>–<to year>` | |
|
|
1489
|
+
| `uvalib-date-histogram` | `select` (not when the selection is cleared, set in script, or restored from a date range) | `<from>–<to>` when both ends are ISO dates, otherwise `other` | |
|
|
1490
|
+
| `bento-box` | `result-click` | the section (`Virgo catalog`, `Virgo articles`, `Subject guides`, `Library website`) | the result's position, from 1 |
|
|
1491
|
+
| `bento-box` | `see-all-click`, `retry` | the section | |
|
|
1492
|
+
| `bento-box` | `error` | `section-load: <section>` | |
|
|
1493
|
+
|
|
1494
|
+
`<bento-box>` also sends a Matomo site search per section once its results are in (not on an error, not again on a re-render): the query, the section as category, and the section's total (0 when nothing was found). A new query, also by Back or Forward, is a new search. The `<library-weekly-hours>` elements `<library-hours-setup>` creates report as `library-weekly-hours`. Alert severities are `Critical`, `Warning`, `Information`, `Header` or `Regional warning` / `Regional information`. Names are capped at 100 characters. `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing.
|
|
766
1495
|
|
|
767
1496
|
- **Privacy.** The components never send URLs, paths, record titles, ids, email addresses or phone numbers, or anything a visitor typed: only the fixed names above, positions and counts, labels of the library's own links, and the titles of library alerts (written by the library for everyone). The one exception is search: bento-box's queries are what visitors typed, and are sent as Matomo site searches.
|
|
768
1497
|
- **Opting out.** Nothing is sent from a component, a `data-uvalib-track` element or an event fired by hand when:
|
|
@@ -1031,7 +1760,7 @@ Live UVA Library alerts, drawn as library.virginia.edu draws them. The alerts pr
|
|
|
1031
1760
|
|
|
1032
1761
|
### `<site-analytics>`
|
|
1033
1762
|
|
|
1034
|
-
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`.
|
|
1035
1764
|
|
|
1036
1765
|
#### Attributes
|
|
1037
1766
|
|
|
@@ -1041,6 +1770,7 @@ Matomo analytics, with no visual output. Loads matomo.js for the site and record
|
|
|
1041
1770
|
| `matomoid` | `number \| undefined` | | The Matomo site id (attribute `matomoid`). Default: the site whose URL the page is under. |
|
|
1042
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. |
|
|
1043
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. |
|
|
1044
1774
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1045
1775
|
| `no-style` | `boolean` | `false` | |
|
|
1046
1776
|
|
|
@@ -1240,7 +1970,7 @@ The UVA Library main navigation (About, Using the Library, Research & teaching s
|
|
|
1240
1970
|
|
|
1241
1971
|
### `<site-page>`
|
|
1242
1972
|
|
|
1243
|
-
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.
|
|
1244
1974
|
|
|
1245
1975
|
#### Attributes
|
|
1246
1976
|
|
|
@@ -1250,6 +1980,7 @@ Page wrapper: skip link (inside the header landmark in shadow mode), header, a s
|
|
|
1250
1980
|
| `header-variant` | `'full' \| 'vendor'` | `'full'` | |
|
|
1251
1981
|
| `no-global-styles` | `boolean` | `false` | |
|
|
1252
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. |
|
|
1253
1984
|
| `site-links-label` | `string \| undefined` | | Accessible name of the header navigation when site links are given (default "Site"). |
|
|
1254
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. |
|
|
1255
1986
|
| `site-name-href` | `string \| undefined` | | Where the site name links, forwarded to `<site-header site-name-href>` (default `/`). |
|
|
@@ -1263,6 +1994,7 @@ Page wrapper: skip link (inside the header landmark in shadow mode), header, a s
|
|
|
1263
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"). |
|
|
1264
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. |
|
|
1265
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. |
|
|
1266
1998
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1267
1999
|
| `no-style` | `boolean` | `false` | |
|
|
1268
2000
|
|
|
@@ -1340,6 +2072,7 @@ Compatibility element. Light mode (`no-shadow-dom`) installs the tokens and base
|
|
|
1340
2072
|
| `matomoid` | `number \| undefined` | | The Matomo site id (attribute `matomoid`). Default: the site whose URL the page is under. |
|
|
1341
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. |
|
|
1342
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. |
|
|
1343
2076
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1344
2077
|
| `no-style` | `boolean` | `false` | |
|
|
1345
2078
|
|
|
@@ -1356,9 +2089,46 @@ Compatibility element. Light mode (`no-shadow-dom`) installs the tokens and base
|
|
|
1356
2089
|
| `site-analytics-event` | Listened for on `document` too: the same as `uvalib-analytics-event`. |
|
|
1357
2090
|
| `site-analytics-content` | Listened for on `document` too: the same as `uvalib-analytics-content`. |
|
|
1358
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
|
+
|
|
1359
2129
|
### `<uvalib-breadcrumbs>`
|
|
1360
2130
|
|
|
1361
|
-
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.
|
|
1362
2132
|
|
|
1363
2133
|
#### Attributes
|
|
1364
2134
|
|
|
@@ -1389,13 +2159,14 @@ A breadcrumb trail, as on library.virginia.edu: links separated by slashes, endi
|
|
|
1389
2159
|
|
|
1390
2160
|
### `<uvalib-card>`
|
|
1391
2161
|
|
|
1392
|
-
One card: a collection (title and “N texts”), a photo (image, count, date, category, title, excerpt) or any other raised summary. With `href`, the heading is the link and a pseudo-element stretches that link over the card, so the whole card is one click. The arrow is only a visual aid. The card is never wrapped in an `<a>`. A clickable card must not contain another link, button or other control: the stretched link covers it. A static card (no `href`, or an empty or unsafe one) has no stretch, so its excerpt may contain links. With `href`, the heading needs an accessible name (text, or an image `alt` or `aria-label`); otherwise the link is hidden. Regions are light-DOM children. Give `slot="media"`, `slot="badge"`, `slot="heading"`, `slot="meta"` or `slot="
|
|
2162
|
+
One card: a collection (title and “N texts”), a photo (image, count, date, category, title, excerpt) or any other raised summary. With `href`, the heading is the link and a pseudo-element stretches that link over the card, so the whole card is one click. The arrow is only a visual aid. The card is never wrapped in an `<a>`. A clickable card must not contain another link, button or other control: the stretched link covers it. A static card (no `href`, or an empty or unsafe one) has no stretch, so its excerpt and `actions` slot may contain links. With `href`, the heading needs an accessible name (text, or an image `alt` or `aria-label`); otherwise the link is hidden. `media-shape="circle"` draws the media as a centered circle, for a person or avatar. The image keeps its alt, and the count badge still sits on it. Any other shape is ignored. Regions are light-DOM children. Give `slot="media"`, `slot="badge"`, `slot="heading"`, `slot="meta"`, `slot="chip"` or `slot="actions"`; anything else (including text) is the excerpt. An image needs a real alt, or `alt=""` when the heading already names it. A date belongs in `<time>` in the meta slot. One element per chip. `actions` is a row of links or buttons on a static card (“Read the story”, “Photos (132)”). The heading level defaults like `<events-section>`: one below the nearest heading before the card, or 3 when there is none. `heading-level` (1–6) wins. An invalid value is ignored.
|
|
1393
2163
|
|
|
1394
2164
|
#### Attributes
|
|
1395
2165
|
|
|
1396
2166
|
| Attribute | Type | Default | Description |
|
|
1397
2167
|
|---|---|---|---|
|
|
1398
2168
|
| `href` | `string \| undefined` | | Makes the card one link: the heading stretches over the card. Empty is not a link. |
|
|
2169
|
+
| `media-shape` | `string` | `''` | `circle` crops the media to a centered circle and keeps the image alt. Anything else is ignored, with one console warning. |
|
|
1399
2170
|
| `heading-level` | `number \| undefined` | | Heading level of the title, 1–6. Unset, it is one below the nearest heading before this card, or 3 when there is none. Any other value is ignored. |
|
|
1400
2171
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1401
2172
|
| `no-style` | `boolean` | `false` | |
|
|
@@ -1409,6 +2180,7 @@ One card: a collection (title and “N texts”), a photo (image, count, date, c
|
|
|
1409
2180
|
| `heading` | The card title. With `href`, this heading’s link is the card, so it needs an accessible name. |
|
|
1410
2181
|
| `meta` | Date (`<time>`) or byline, under the title. |
|
|
1411
2182
|
| `chip` | Category. One element per chip. |
|
|
2183
|
+
| `actions` | Links or buttons on a static card. A clickable card must not contain them; the card link covers them. |
|
|
1412
2184
|
| (default) | Excerpt. A static card may put links here; a clickable card must not contain other controls. |
|
|
1413
2185
|
|
|
1414
2186
|
#### Events
|
|
@@ -1460,9 +2232,112 @@ A grid of `<uvalib-card>` elements. It is a list, so a screen reader announces h
|
|
|
1460
2232
|
|---|---|---|
|
|
1461
2233
|
| `--uvalib-card-min` | | Set from `min-card-width` when that value is a length. The grid uses it as the `auto-fill` minimum. |
|
|
1462
2234
|
|
|
2235
|
+
### `<uvalib-chip-group>`
|
|
2236
|
+
|
|
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`.
|
|
2238
|
+
|
|
2239
|
+
#### Attributes
|
|
2240
|
+
|
|
2241
|
+
| Attribute | Type | Default | Description |
|
|
2242
|
+
|---|---|---|---|
|
|
2243
|
+
| `mode` | `ChipGroupMode` | `'single'` | `single` (radios: one value), `multi` (toggles: an array of values) or `links`. |
|
|
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. |
|
|
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`. |
|
|
2247
|
+
| `count-label` | `string` | `'items'` | The word after a count in each chip's accessible name: “2005, 213 items”. |
|
|
2248
|
+
| `scroll` | `boolean` | `false` | One row that scrolls sideways instead of wrapping. |
|
|
2249
|
+
| `segmented` | `boolean` | `false` | Join the chips into one segmented bar. |
|
|
2250
|
+
| `url-param` | `string` | `''` | Query parameter that keeps the value in the address, for example `year` → `?year=2005`. |
|
|
2251
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2252
|
+
| `no-style` | `boolean` | `false` | |
|
|
2253
|
+
|
|
2254
|
+
#### CSS parts
|
|
2255
|
+
|
|
2256
|
+
| Part | Description |
|
|
2257
|
+
|---|---|
|
|
2258
|
+
| `swatch` | The colour square before a chip's label (`data-swatch`, `swatch`). |
|
|
2259
|
+
|
|
2260
|
+
#### Events
|
|
2261
|
+
|
|
2262
|
+
| Event | Description |
|
|
2263
|
+
|---|---|
|
|
2264
|
+
| `change` | The visitor changed the selection (`single`, `multi`), or Back or Forward changed it through `url-param`: `detail` is `{ value, restored? }` (a string in `single`, an array in `multi`; `restored` is true for Back and Forward). Not fired when the app sets `value`. Bubbles and is composed. |
|
|
2265
|
+
| `select` | `links` mode: a chip was chosen. `detail` is `{ value, href? }`. For a link, a plain primary click fires it cancelable: cancel it (`preventDefault()`) to route in the app, and the click's default is prevented too. Bubbles and is composed. |
|
|
2266
|
+
| `uvalib-analytics-event` | For `<site-analytics>`, on the visitor's actions only: `['uvalib-chip-group', 'change', '<label>: <chip label>', <count>?]` (in `single`, one second after the last change, for the chip then selected; in `multi`, for the chip toggled), and `['uvalib-chip-group', 'select', '<label>']` in `links` mode (never the chip or its URL). The count is sent when it is a number. Bubbles and is composed. |
|
|
2267
|
+
|
|
2268
|
+
#### CSS custom properties
|
|
2269
|
+
|
|
2270
|
+
| Property | Default | Description |
|
|
2271
|
+
|---|---|---|
|
|
2272
|
+
| `--uva-color-surface-raised` | | Dark-mode role token: chip background (else #fff). |
|
|
2273
|
+
| `--uva-color-control-border` | | Dark-mode role token: chip border (else `--uva-grey`, #808080). |
|
|
2274
|
+
| `--uva-color-link` | | Dark-mode role token: chip text and hover border (else `--uva-brand-blue`). |
|
|
2275
|
+
| `--uva-color-text-muted` | | Dark-mode role token: the count and the description (else #4f4f4f). |
|
|
2276
|
+
| `--uva-color-accent-bg` | | Dark-mode role token: selected chip background and border (else `--uva-brand-blue`). |
|
|
2277
|
+
| `--uva-color-on-accent` | | Dark-mode role token: selected chip text (else #fff). |
|
|
2278
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
2279
|
+
| `--uva-color-surface` | | Dark-mode role token: the page background the scrolling row fades into at an edge with more chips (else #fff). |
|
|
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
|
+
|
|
1463
2338
|
### `<uvalib-contents>`
|
|
1464
2339
|
|
|
1465
|
-
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.
|
|
1466
2341
|
|
|
1467
2342
|
#### Attributes
|
|
1468
2343
|
|
|
@@ -1474,6 +2349,9 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
1474
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. |
|
|
1475
2350
|
| `open` | `boolean` | `false` | Whether the collapsed disclosure is open (no effect on wide screens). Toggled by its button. |
|
|
1476
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. |
|
|
1477
2355
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1478
2356
|
| `no-style` | `boolean` | `false` | |
|
|
1479
2357
|
|
|
@@ -1503,6 +2381,65 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
1503
2381
|
| `--uva-color-surface-raised` | | Dark-mode role token: the button's background (else #fff). |
|
|
1504
2382
|
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1505
2383
|
|
|
2384
|
+
### `<uvalib-date-histogram>`
|
|
2385
|
+
|
|
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.
|
|
2387
|
+
|
|
2388
|
+
#### Attributes
|
|
2389
|
+
|
|
2390
|
+
| Attribute | Type | Default | Description |
|
|
2391
|
+
|---|---|---|---|
|
|
2392
|
+
| `items` | `HistogramItem[]` | `[]` | Counts to draw. When non-empty, wins over the child table. Set a new array to update. |
|
|
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. |
|
|
2394
|
+
| `scale` | `'linear' \| 'log'` | `'linear'` | `log` scales bar height by log(count + 1). Anything else is linear. |
|
|
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. |
|
|
2396
|
+
| `range-for` | `string` | `''` | Id of a `<uvalib-date-range>` to keep in step with, both ways. |
|
|
2397
|
+
| `variant` | `string` | `''` | `strip`: a non-interactive per-year row (`role="img"`). Anything else is the bar chart. |
|
|
2398
|
+
| `unit` | `string` | `'items'` | Word after the count in each bar's name. Plural; a count of one drops a trailing s. |
|
|
2399
|
+
| `label` | `string` | `'Dates'` | Accessible name of the bar group, and the start of the strip's summary. |
|
|
2400
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2401
|
+
| `no-style` | `boolean` | `false` | |
|
|
2402
|
+
|
|
2403
|
+
#### Slots
|
|
2404
|
+
|
|
2405
|
+
| Slot | Description |
|
|
2406
|
+
|---|---|
|
|
2407
|
+
| (default) | A `<table>` of dates and counts: two columns (date, count) or a year-by-month grid. Without JavaScript it is the fallback. With JavaScript it supplies the counts when `items` is empty. Show as table lists those counts, including odd dates; once `items` is set it lists `items` instead. |
|
|
2408
|
+
|
|
2409
|
+
#### CSS parts
|
|
2410
|
+
|
|
2411
|
+
| Part | Description |
|
|
2412
|
+
|---|---|
|
|
2413
|
+
| `chart` | The bar chart (shadow mode). |
|
|
2414
|
+
| `bar` | A bar button, or a strip segment (shadow mode). |
|
|
2415
|
+
| `table` | The generated table in Show as table (shadow mode). |
|
|
2416
|
+
|
|
2417
|
+
#### Events
|
|
2418
|
+
|
|
2419
|
+
| Event | Description |
|
|
2420
|
+
|---|---|
|
|
2421
|
+
| `select` | A bar or an odd-date chip was chosen, or the current one chosen again to clear it. `detail` is `{ from, to }` (ISO dates, or the odd token). Empty strings clear the selection. Not fired when `selected` is set in script or when a linked date range changes. Bubbles and is composed. |
|
|
2422
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-date-histogram', 'select', '<from>–<to>']` when both ends are ISO dates, or `'other'` for any other choice. Not fired when the selection is cleared, set in script, or restored from a date range. Bubbles and is composed. |
|
|
2423
|
+
|
|
2424
|
+
#### CSS custom properties
|
|
2425
|
+
|
|
2426
|
+
| Property | Default | Description |
|
|
2427
|
+
|---|---|---|
|
|
2428
|
+
| `--uvalib-date-histogram-bar-size` | `8rem` | Height of each bar track. The chart reserves one track, or one per known year, before the counts arrive. |
|
|
2429
|
+
| `--uvalib-date-histogram-strip-size` | `1.5rem` | Height of `variant="strip"`. |
|
|
2430
|
+
| `--uva-brand-blue` | `#232d4b` | Bar fill. |
|
|
2431
|
+
| `--uva-brand-orange` | `#e57200` | Focus ring when `--uva-color-focus` is unset. |
|
|
2432
|
+
| `--uva-font-family` | `inherit` | Font family. |
|
|
2433
|
+
| `--uva-color-accent-bg` | | Dark-mode role token: bar fill (else `--uva-brand-blue`). |
|
|
2434
|
+
| `--uva-color-on-accent` | | Dark-mode role token: the selection stripe (else #fff). |
|
|
2435
|
+
| `--uva-color-text` | | Dark-mode role token: labels and the selection ring (else #2b2b2b). |
|
|
2436
|
+
| `--uva-color-text-muted` | | Dark-mode role token: the scroll hint (else #4b5563). |
|
|
2437
|
+
| `--uva-color-track` | | Dark-mode role token: the empty part of a bar (else #e5e7eb). |
|
|
2438
|
+
| `--uva-color-surface` | | Dark-mode role token: the sticky year label (else #fff). |
|
|
2439
|
+
| `--uva-color-surface-raised` | | Dark-mode role token: odd-date chips (else #fff). |
|
|
2440
|
+
| `--uva-color-control-border` | | Dark-mode role token: bar, chip and table borders (else #808080). |
|
|
2441
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
2442
|
+
|
|
1506
2443
|
### `<uvalib-date-range>`
|
|
1507
2444
|
|
|
1508
2445
|
A date-range picker: a two-thumb year slider plus "From" and "To" date inputs. `min` and `max` (ISO dates, `YYYY-MM-DD`) are required; without valid ones the element renders nothing and logs a console warning once. The start can never pass the end, and both stay within `min`..`max`.
|
|
@@ -1522,6 +2459,7 @@ A date-range picker: a two-thumb year slider plus "From" and "To" date inputs. `
|
|
|
1522
2459
|
|
|
1523
2460
|
| Event | Description |
|
|
1524
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. |
|
|
1525
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. |
|
|
1526
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. |
|
|
1527
2465
|
|
|
@@ -1587,6 +2525,117 @@ A faceted-search filter: a fieldset of checkboxes (value plus result count), opt
|
|
|
1587
2525
|
| `--uva-color-on-accent` | | Dark-mode role token: pressed chip text (else #fff). |
|
|
1588
2526
|
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1589
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
|
+
|
|
1590
2639
|
### `<uvalib-lightbox>`
|
|
1591
2640
|
|
|
1592
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.
|
|
@@ -1597,6 +2646,7 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
|
|
|
1597
2646
|
|---|---|---|---|
|
|
1598
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`. |
|
|
1599
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`). |
|
|
1600
2650
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1601
2651
|
| `no-style` | `boolean` | `false` | |
|
|
1602
2652
|
|
|
@@ -1617,6 +2667,7 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
|
|
|
1617
2667
|
| `image` | The image. |
|
|
1618
2668
|
| `controls` | Previous, Next, the counter and Full size. |
|
|
1619
2669
|
| `details` | The details panel. |
|
|
2670
|
+
| `regions` | The `<uvalib-image-regions>` around an image with regions. |
|
|
1620
2671
|
|
|
1621
2672
|
#### Events
|
|
1622
2673
|
|
|
@@ -1642,9 +2693,72 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
|
|
|
1642
2693
|
| `--uva-grey-darkest` | `#2b2b2b` | Text when `--uva-color-text` is unset. |
|
|
1643
2694
|
| `--uva-grey-100` | `#dadada` | Border when `--uva-color-border` is unset. |
|
|
1644
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
|
+
|
|
1645
2759
|
### `<uvalib-metadata>`
|
|
1646
2760
|
|
|
1647
|
-
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`).
|
|
1648
2762
|
|
|
1649
2763
|
#### Attributes
|
|
1650
2764
|
|
|
@@ -1657,6 +2771,7 @@ A record's details as a description list, as on the library's digital collection
|
|
|
1657
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`. |
|
|
1658
2772
|
| `citation` | `string \| undefined` | | "How to cite": the citation, as written. Wins over `citation-title`. |
|
|
1659
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. |
|
|
1660
2775
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1661
2776
|
| `no-style` | `boolean` | `false` | |
|
|
1662
2777
|
|
|
@@ -1664,7 +2779,7 @@ A record's details as a description list, as on the library's digital collection
|
|
|
1664
2779
|
|
|
1665
2780
|
| Event | Description |
|
|
1666
2781
|
|---|---|
|
|
1667
|
-
| `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. |
|
|
1668
2783
|
|
|
1669
2784
|
#### CSS custom properties
|
|
1670
2785
|
|
|
@@ -1676,7 +2791,7 @@ A record's details as a description list, as on the library's digital collection
|
|
|
1676
2791
|
| `--uva-color-text` | | Dark-mode role token: value colour (else `--uva-grey-darkest`). |
|
|
1677
2792
|
| `--uva-color-text-muted` | | Dark-mode role token: label and status colour (else #4b5563). |
|
|
1678
2793
|
| `--uva-color-border` | | Dark-mode role token: row dividers (else #dadada). |
|
|
1679
|
-
| `--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`). |
|
|
1680
2795
|
| `--uva-color-surface-raised` | | Dark-mode role token: the button's background (else #fff). |
|
|
1681
2796
|
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1682
2797
|
|
|
@@ -1711,7 +2826,7 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
|
|
|
1711
2826
|
|
|
1712
2827
|
### `<uvalib-pager>`
|
|
1713
2828
|
|
|
1714
|
-
Previous/next section links, as on a reading page, or a numbered page list. Previous/next: set `prev-href` and `next-href` (either may be omitted). Each link shows a “Previous” or “Next” kicker and, when `prev-label` or `next-label` is set, that title. A visually hidden “: ” sits between them, so the accessible name is punctuated even when CSS is off. A long title truncates visually; the full text stays in the accessible name. The links use `rel="prev"` and `rel="next"`. With neither href, nothing is rendered. Numbered pages: set `pages` (a positive count). `page` is the current page, clamped to `1…pages`. Each link’s href comes from `href-template`, which must contain `{page}` (the default is `?page={page}`). The current page is text with `aria-current="page"`, not a link. Long ranges collapse to the first page, a window around the current page, the last page, and an ellipsis where numbers are skipped. `pages` wins when previous/next attributes are also set, with one console warning. The landmark’s accessible name is `label`, or “Sections” for previous/next and “Pagination” for numbered pages. An empty `label` uses that default. Two pagers on one page need different labels: a repeated landmark name fails the accessibility check.
|
|
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.
|
|
1715
2830
|
|
|
1716
2831
|
#### Attributes
|
|
1717
2832
|
|
|
@@ -1721,7 +2836,12 @@ Previous/next section links, as on a reading page, or a numbered page list. Prev
|
|
|
1721
2836
|
| `prev-label` | `string \| undefined` | | Title of the previous section, under the “Previous” kicker. |
|
|
1722
2837
|
| `next-href` | `string \| undefined` | | Href of the next section. Omitted, that side is not shown. |
|
|
1723
2838
|
| `next-label` | `string \| undefined` | | Title of the next section, under the “Next” kicker. |
|
|
1724
|
-
| `
|
|
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. |
|
|
2840
|
+
| `shown` | `number \| undefined` | | How many results are already shown. Used by `mode="load-more"` as N 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`. |
|
|
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. |
|
|
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. |
|
|
1725
2845
|
| `pages` | `number \| undefined` | | How many pages. A positive number selects numbered pages and ignores previous/next. Zero, negative or non-numeric does not. |
|
|
1726
2846
|
| `href-template` | `string \| undefined` | | Href of each numbered page, with `{page}` where the number goes. Default `?page={page}` when omitted. Without `{page}`, numbered links are not made. |
|
|
1727
2847
|
| `label` | `string \| undefined` | | Accessible name of the navigation landmark. Default “Pagination” for numbered pages and “Sections” for previous/next. Empty uses that default. A second pager on the page needs its own name. |
|
|
@@ -1732,7 +2852,8 @@ Previous/next section links, as on a reading page, or a numbered page list. Prev
|
|
|
1732
2852
|
|
|
1733
2853
|
| Event | Description |
|
|
1734
2854
|
|---|---|
|
|
1735
|
-
| `
|
|
2855
|
+
| `load-more` | A primary click on Load more: `detail` is `{ page }` (the next page). Bubbles and is composed. |
|
|
2856
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: a primary-button click that was not already canceled, including a modified click, on a page link `['uvalib-pager', 'page-change', 'number', <n>]`, on a section link `['uvalib-pager', 'page-change', 'next'\|'previous']`, or on Load more `['uvalib-pager', 'load-more', '', <next page>]`. Never the label or URL. Nothing on render. Bubbles and is composed. |
|
|
1736
2857
|
| `uvalib-pager-navigate` | A plain click on a pager link: `detail` is `{ href, kind, page? }` (`kind` is `'next'`, `'previous'` or `'number'`; `page` is set for `'number'`). Cancel it (`preventDefault()`) to route in the app; the click’s default is then prevented. Bubbles and is composed. |
|
|
1737
2858
|
|
|
1738
2859
|
#### CSS custom properties
|
|
@@ -1745,10 +2866,13 @@ Previous/next section links, as on a reading page, or a numbered page list. Prev
|
|
|
1745
2866
|
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1746
2867
|
| `--uva-color-accent-bg` | | Dark-mode role token: current page background (else `--uva-brand-blue`). |
|
|
1747
2868
|
| `--uva-color-on-accent` | | Text on the current page background (else #fff). |
|
|
2869
|
+
| `--uva-color-button-bg` | | Load more background (else `--uva-blue-alt`). |
|
|
2870
|
+
| `--uva-color-button-text` | | Load more text (else #fff). Dark mode’s own text is dark on the light button. |
|
|
2871
|
+
| `--uva-color-button-hover-bg` | | Load more hover background (else `--uva-blue-alt-A`). |
|
|
1748
2872
|
|
|
1749
2873
|
### `<uvalib-photo-grid>`
|
|
1750
2874
|
|
|
1751
|
-
Justified rows of thumbnails. Each direct child that is a link or a button is one photo; its image keeps its shape from the `width` and `height` attributes, or from the loaded image, so the row does not jump when the picture arrives. The row is about 220px tall and shorter on a phone; `row-height` sets that height. Every item stays a real link or button. An image with no visible text gets a visible caption from its alt (the caption is then the accessible name, and a repeated alt is cleared). The original alt is kept in `data-uvalib-alt` so a lightbox still describes the picture. An item with no name at all is captioned “Photo N” and warned about once; that caption is renumbered when the photos change order. An `aria-label` is left as the name: the grid does not add a caption that would disagree with it. Put the grid inside `<uvalib-lightbox>` and a plain click opens the viewer.
|
|
2875
|
+
Justified rows of thumbnails. Each direct child that is a link or a button is one photo; its image keeps its shape from the `width` and `height` attributes, or from the loaded image, so the row does not jump when the picture arrives. The row is about 220px tall and shorter on a phone; `row-height` sets that height. Every item stays a real link or button. An image with no visible text gets a visible caption from its alt (the caption is then the accessible name, and a repeated alt is cleared). The original alt is kept in `data-uvalib-alt` so a lightbox still describes the picture. An item with no name at all is captioned “Photo N” and warned about once; that caption is renumbered when the photos change order. An `aria-label` is left as the name: the grid does not add a caption that would disagree with it. Put the grid inside `<uvalib-lightbox>` and a plain click opens the viewer. A badge sits on the thumbnail: `<span slot="badge">` inside the link or button, or `data-badge` on that item (for example “seq” or “3 photos”). It is read after the caption (“The Lawn, 3 photos”). When the item already has an `aria-label`, the badge is appended to that label (the author’s words stay in `data-uvalib-label`) and an alt that repeats those words is cleared. A badge does not replace the alt caption.
|
|
1752
2876
|
|
|
1753
2877
|
#### Attributes
|
|
1754
2878
|
|
|
@@ -1762,7 +2886,7 @@ Justified rows of thumbnails. Each direct child that is a link or a button is on
|
|
|
1762
2886
|
|
|
1763
2887
|
| Slot | Description |
|
|
1764
2888
|
|---|---|
|
|
1765
|
-
| (default) | The thumbnails: one `<a href>` or `<button>` per photo, each with an `<img>`. |
|
|
2889
|
+
| (default) | The thumbnails: one `<a href>` or `<button>` per photo, each with an `<img>`. A `<span slot="badge">` inside an item is drawn over that thumbnail. |
|
|
1766
2890
|
|
|
1767
2891
|
#### CSS custom properties
|
|
1768
2892
|
|
|
@@ -1774,6 +2898,112 @@ Justified rows of thumbnails. Each direct child that is a link or a button is on
|
|
|
1774
2898
|
| `--uva-grey-darkest` | `#2b2b2b` | Caption colour when `--uva-color-text` is unset. |
|
|
1775
2899
|
| `--uva-brand-orange` | `#e57200` | Focus ring when `--uva-color-focus` is unset. |
|
|
1776
2900
|
|
|
2901
|
+
### `<uvalib-results-count>`
|
|
2902
|
+
|
|
2903
|
+
The results summary of a search or listing page, such as “Showing 48 of 3,694 shoots”, and a polite live region that tells screen reader users when it changes. Set `total` (how many match), `shown` (how many are on the page) and `noun` (plural, default “results”; `singular` for a total of one). The visible text follows at once: “Showing 48 of 3,694 shoots”, “Showing all 12 shoots” (shown is the total, or unset), “Showing 1 shoot” or “No shoots” (a total of 0, or 0 shown); with only `shown`, “Showing 48 shoots”. Numbers use thousands separators. A missing or blank `shown` or `total` is unset, not 0. The announcement waits until the text has not changed for `announce-delay` milliseconds (default 1000, as `<bento-box>` and `<uvalib-pagefind-search>` settle), so typing in a filter box is announced once. The first render is never announced; when it has no count yet (the data still loading), the first count that arrives is. A count is announced again when it comes back after a different one (a new search with the same number of results), but not when nothing was shown in between. The announcement is cleared from the hidden region five seconds later, so reading the page finds the count once. `<bento-box>` and `<uvalib-pagefind-search>` announce their own counts: use this element for your own listings, not beside them.
|
|
2904
|
+
|
|
2905
|
+
#### Attributes
|
|
2906
|
+
|
|
2907
|
+
| Attribute | Type | Default | Description |
|
|
2908
|
+
|---|---|---|---|
|
|
2909
|
+
| `shown` | `number \| undefined` | | How many results are shown on the page. |
|
|
2910
|
+
| `total` | `number \| undefined` | | How many results match in all. |
|
|
2911
|
+
| `noun` | `string` | `'results'` | What is counted, plural: “results” by default. |
|
|
2912
|
+
| `singular` | `string` | `''` | What is counted, singular, for a total of one. Default: “result” when `noun` is unset, else `noun`. |
|
|
2913
|
+
| `announce-delay` | `number` | `1000` | Milliseconds the text must stay the same before it is announced. |
|
|
2914
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2915
|
+
| `no-style` | `boolean` | `false` | |
|
|
2916
|
+
|
|
2917
|
+
#### CSS parts
|
|
2918
|
+
|
|
2919
|
+
| Part | Description |
|
|
2920
|
+
|---|---|
|
|
2921
|
+
| `text` | The visible summary. |
|
|
2922
|
+
|
|
2923
|
+
#### CSS custom properties
|
|
2924
|
+
|
|
2925
|
+
| Property | Default | Description |
|
|
2926
|
+
|---|---|---|
|
|
2927
|
+
| `--uva-color-text-muted` | | Dark-mode role token: text colour (else `--uva-grey-A`, #4f4f4f). |
|
|
2928
|
+
|
|
2929
|
+
### `<uvalib-tabs>`
|
|
2930
|
+
|
|
2931
|
+
Tabs, as on library.virginia.edu: a row of buttons over one visible panel. Each panel is a child with `data-tab="Events"` (and an `id` when the tab should be linkable). Or put `<button slot="tab">` elements first and one panel element after each; the button text is the label and those buttons are hidden, because the component draws the real tabs. The selected panel stays visible across the upgrade. With `base.css`, later `data-tab` panels stay hidden before the element upgrades, and space is reserved for the tab row so the first panel does not jump. The tab row wraps on a narrow screen. Arrow keys, Home and End move between tabs. Selection follows the arrow unless `activation="manual"`, in which case Enter or Space selects the focused tab. `selected` is the panel id (a label or a 0-based index also selects). It reflects the panel id. `url-param` writes that id into the query string, or into the hash when the page is a hash route (`#/stories?tab=events`). `url-param="hash"` uses the hash itself (`#events`) and leaves a hash route (`#/…`) alone.
|
|
2932
|
+
|
|
2933
|
+
#### Attributes
|
|
2934
|
+
|
|
2935
|
+
| Attribute | Type | Default | Description |
|
|
2936
|
+
|---|---|---|---|
|
|
2937
|
+
| `selected` | `string` | `''` | The selected tab. A panel id, the tab label, or a 0-based index. Reflects the panel id once the tabs have been read. Empty selects the first tab. |
|
|
2938
|
+
| `activation` | `string` | `''` | `manual`: arrow keys move focus and Enter or Space selects. Anything else, including empty, selects as the arrow moves. |
|
|
2939
|
+
| `url-param` | `string` | `''` | Name of the query parameter that stores the selected panel id, so the tab is linkable and Back restores it. `hash` stores it in the hash (`#panel-id`) instead. Empty does not touch the URL. |
|
|
2940
|
+
| `label` | `string` | `''` | Accessible name of the tab list. Empty uses “Tabs”. |
|
|
2941
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2942
|
+
| `no-style` | `boolean` | `false` | |
|
|
2943
|
+
|
|
2944
|
+
#### Slots
|
|
2945
|
+
|
|
2946
|
+
| Slot | Description |
|
|
2947
|
+
|---|---|
|
|
2948
|
+
| (default) | The panels. Each element with `data-tab` is a panel, or each element that is not a `slot="tab"` button. |
|
|
2949
|
+
| `tab` | A `<button>` whose text labels the panel that follows. Hidden once the tabs are drawn. |
|
|
2950
|
+
|
|
2951
|
+
#### Events
|
|
2952
|
+
|
|
2953
|
+
| Event | Description |
|
|
2954
|
+
|---|---|
|
|
2955
|
+
| `change` | The selected tab changed after the first render, including a script setting `selected` and the Back button. `detail` is `{ id, label, index }` (`id` is the panel id, `index` from 0). Not fired on the first render. Bubbles and is composed. |
|
|
2956
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: a click or arrow-key selection, `['uvalib-tabs', 'change', '<tab label>']`. The label is cut to 100 characters. Not fired on the first render, when `selected` is set from script, or when Back or the hash restores a tab. |
|
|
2957
|
+
|
|
2958
|
+
#### CSS custom properties
|
|
2959
|
+
|
|
2960
|
+
| Property | Default | Description |
|
|
2961
|
+
|---|---|---|
|
|
2962
|
+
| `--uva-color-button-bg` | | Dark-mode role token: unselected tab background (else `--uva-blue-alt-base`). |
|
|
2963
|
+
| `--uva-color-button-text` | | Text on an unselected tab (else #fff). |
|
|
2964
|
+
| `--uva-color-button-hover-bg` | | Dark-mode role token: unselected tab hover (else `--uva-blue-alt-dark`). |
|
|
2965
|
+
| `--uva-color-accent-bg` | | Dark-mode role token: selected tab background (else `--uva-brand-blue`). |
|
|
2966
|
+
| `--uva-color-on-accent` | | Selected tab text and the selected underline (else #fff). |
|
|
2967
|
+
| `--uva-color-focus` | | Dark-mode role token: focus outline (else `--uva-brand-orange`). |
|
|
2968
|
+
| `--uva-blue-alt-base` | `#007BAC` | Unselected tab when `--uva-color-button-bg` is unset. |
|
|
2969
|
+
| `--uva-blue-alt-dark` | `#005679` | Unselected hover when `--uva-color-button-hover-bg` is unset. |
|
|
2970
|
+
| `--uva-brand-blue` | `#232D4B` | Selected tab when `--uva-color-accent-bg` is unset. |
|
|
2971
|
+
| `--uva-brand-orange` | `#E57200` | Focus outline when `--uva-color-focus` is unset. |
|
|
2972
|
+
|
|
2973
|
+
### `<uvalib-tag-list>`
|
|
2974
|
+
|
|
2975
|
+
A labelled list of keywords or subjects that wraps: each tag a link (for example a search for that term) or plain text. Link tags are outlined pills in the link colour; plain tags are filled chips (the card chip's colours), so a link never looks like a label. Every tag and the toggle are at least 2rem (34px) tall and wide, 0.5rem apart. Give the tags as children: `<a href>` for a link, any other element (`<span>`) for plain text. A child's `lang` and `dir` are kept, and so is inline markup inside it (`em`, `cite`, `abbr`, `bdi`, a `span lang`…), copied element by element (never parsed as HTML). Or set `href-template` (with `{tag}`, replaced by the URL-encoded text) to make every tag without its own href a link; a blank href counts as none. Apps can set the `items` property (`{ label, href?, lang?, dir? }`) instead; it wins over the children. Children with no text are skipped with one warning. `label` names the list (shown above it, or visually hidden with `hide-label`); without one a console warning is logged. `limit` shows that many tags and a “Show all N” button (`aria-expanded`, `aria-controls`), which reveals the rest in place and keeps focus. Analytics never sends a tag's text (record tags can be user-submitted or machine-made), and by default not the label either, which a template may fill from a record: the name is the list's place among the tag lists on the page, `list N`. Add `track-label` when the label is fixed text the page author wrote (“Subjects”), to send it instead.
|
|
2976
|
+
|
|
2977
|
+
#### Attributes
|
|
2978
|
+
|
|
2979
|
+
| Attribute | Type | Default | Description |
|
|
2980
|
+
|---|---|---|---|
|
|
2981
|
+
| `label` | `string` | `''` | The list's name: shown above the tags (and, with `track-label`, the analytics name). |
|
|
2982
|
+
| `hide-label` | `boolean` | `false` | Hide the label visually; it still names the list. |
|
|
2983
|
+
| `track-label` | `boolean` | `false` | Send the label as the analytics name. Only for fixed text the page author wrote, never a label filled from a record. Without it the name is `list N`. |
|
|
2984
|
+
| `limit` | `number \| undefined` | | Show this many tags and a “Show all N” button. Zero or empty shows every tag. |
|
|
2985
|
+
| `href-template` | `string` | `''` | Href for tags without their own, with `{tag}` where the URL-encoded text goes, for example `/search?q={tag}`. Empty: such tags are plain text. |
|
|
2986
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
2987
|
+
| `no-style` | `boolean` | `false` | |
|
|
2988
|
+
|
|
2989
|
+
#### Events
|
|
2990
|
+
|
|
2991
|
+
| Event | Description |
|
|
2992
|
+
|---|---|
|
|
2993
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: a primary-button click on a tag link, `['uvalib-tag-list', 'tag-click', '<name>', <n>]` (n from 1, the tag's place in the list), and the toggle, `['uvalib-tag-list', 'show-all'\|'show-fewer', '<name>']`. The name is `list N` (N from 1, the list's place among the tag lists in its document or shadow root), or with `track-label` the list's `label`; never the tag text or URL. Bubbles and is composed. |
|
|
2994
|
+
| `uvalib-tag-list-navigate` | A plain click on a tag link: `detail` is `{ href, tag, index }` (index from 0). Cancel it (`preventDefault()`) to route in the app; the click's default is then prevented. Bubbles and is composed. |
|
|
2995
|
+
|
|
2996
|
+
#### CSS custom properties
|
|
2997
|
+
|
|
2998
|
+
| Property | Default | Description |
|
|
2999
|
+
|---|---|---|
|
|
3000
|
+
| `--uva-blue-alt-300` | `#BFE7F7` | Plain tag background (the card chip's). |
|
|
3001
|
+
| `--uva-blue-alt-dark` | `#005679` | Plain tag text. |
|
|
3002
|
+
| `--uva-color-link` | | Dark-mode role token: link tag text (else `--uva-brand-blue`). |
|
|
3003
|
+
| `--uva-color-control-border` | | Dark-mode role token: link tag outline (else `--uva-grey`). |
|
|
3004
|
+
| `--uva-color-text` | | Dark-mode role token: the label (else `--uva-grey-darkest`). |
|
|
3005
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
3006
|
+
|
|
1777
3007
|
### `<website-section>`
|
|
1778
3008
|
|
|
1779
3009
|
The library website's first pages (pages, people, libraries, news) matching `query`, from Drupal's search index, with its excerpt (the matched words marked). The index sends no CORS headers, so this section works on library.virginia.edu (or wherever `BentoBox.endpoints.website` points to a same-origin copy) only.
|
|
@@ -1822,7 +3052,7 @@ The library website's first pages (pages, people, libraries, news) matching `que
|
|
|
1822
3052
|
|
|
1823
3053
|
### Quality checks
|
|
1824
3054
|
|
|
1825
|
-
Three automated checks guard accessibility, best practice and performance. The first two run in `pnpm test`; Lighthouse is slower and runs on its own (`pnpm lhci`,
|
|
3055
|
+
Three automated checks guard accessibility, best practice and performance. The first two run in `pnpm test`; Lighthouse is slower and runs on its own (`pnpm lhci`, the `lighthouse` job in the `CI` workflow on pull requests, and the `Pages` workflow on `main`). The results of the last build of `main` are in the [test report](#test-results).
|
|
1826
3056
|
|
|
1827
3057
|
- **axe, at every impact level, at least as strict as Lighthouse.** `expectNoAxeViolations` (`test/helpers/axe.ts`) fails on minor, moderate, serious and critical violations, so best-practice rules such as `heading-order`, `region` and the landmark rules count. It runs every axe rule and also turns on the ones Lighthouse's accessibility audit enables that a default axe run leaves off (`target-size`, `identical-links-same-purpose`, `table-fake-caption`, `td-has-header`), so a component that passes here cannot lose Lighthouse accessibility points to axe. Sites built with the components get the same setup for Playwright in the skill's [accessibility testing guide](skills/uvalib-web-components/reference/accessibility-testing.md). Every visual component is audited in shadow and light DOM, and in the states people use: menus and groups open (the header Menu popover at 390px, `site-main-nav` at 1280px and 390px), `uvalib-filter` expanded with a scope pressed and a box checked, `uvalib-date-range` with the sliders on one year and dates typed, the hours elements loading, loaded and failing, and `events-section` loading, loaded, empty and failing, on its own and in home-page markup in light and dark. Full-page tests use `expectNoPageAxeViolations`, which audits the whole document so the rules that only match `<html>` (`landmark-one-main`, `page-has-heading-one`) run too; it gives the test runner's bare page a `<title>` and `lang` first, and disables no rule. Tests never reach the network: `test/helpers/*-intercept.mjs` route the alerts, hours, events and main-nav hosts to fixtures.
|
|
1828
3058
|
- **Bundle-size budgets.** `test/size-budget.test.mjs` gzips (level 9) every entry in `dist-cdn/manifest.json` together with every chunk it imports, statically or with `import()` (site-page's lazy site-footer), each counted once, and fails if one exceeds its budget in `test/size-budgets.json` (about 12% over the sizes below). `node scripts/bundle-sizes.mjs` prints today's sizes against the budgets. When a change has to grow a bundle, raise its budget in the same PR and say why.
|
|
@@ -1847,7 +3077,7 @@ Three automated checks guard accessibility, best practice and performance. The f
|
|
|
1847
3077
|
| `tokens.css` | 592 | 670 |
|
|
1848
3078
|
| `base.css` | 226 | 260 |
|
|
1849
3079
|
|
|
1850
|
-
- **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/`.
|
|
1851
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.
|
|
1852
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).
|
|
1853
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: *`.
|
|
@@ -1865,7 +3095,7 @@ pnpm release <patch|minor|major> # lint, test, build, bump, tag vX.Y
|
|
|
1865
3095
|
|
|
1866
3096
|
The first release must be `pnpm release major` (0.0.0 → 1.0.0).
|
|
1867
3097
|
|
|
1868
|
-
Pull requests to `main` run `.github/workflows/ci.yml` in GitHub Actions (install, lint, test, Lighthouse) with a read-only token and no secrets. Pushes to `main` are
|
|
3098
|
+
Pull requests to `main` run `.github/workflows/ci.yml` in GitHub Actions (install, lint, test, Lighthouse) with a read-only token and no secrets. Pushes to `main` are tested and audited with Lighthouse by `.github/workflows/pages.yml`, which publishes the examples site with the [test report](#test-results) twice: as soon as the tests pass, then again with the Lighthouse results. A Lighthouse failure fails the run but still publishes, so the report shows what is over budget; a newer push cancels an older run. The CI workflow's Lighthouse job can also be started by hand (Actions → CI → Run workflow).
|
|
1869
3099
|
|
|
1870
3100
|
One `v*` tag starts two independent releases. Each can be re-run on its own, and no npm token is stored anywhere:
|
|
1871
3101
|
|