@uvalib/web-components 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +724 -33
  3. package/dist/base/analytics-state.d.ts +36 -0
  4. package/dist/base/analytics-state.js +44 -0
  5. package/dist/base/analytics-state.js.map +1 -0
  6. package/dist/base/analytics.d.ts +31 -27
  7. package/dist/base/analytics.js +48 -37
  8. package/dist/base/analytics.js.map +1 -1
  9. package/dist/base/inline-copy.d.ts +16 -0
  10. package/dist/base/inline-copy.js +92 -0
  11. package/dist/base/inline-copy.js.map +1 -0
  12. package/dist/base/source-children.d.ts +46 -0
  13. package/dist/base/source-children.js +116 -0
  14. package/dist/base/source-children.js.map +1 -0
  15. package/dist/base.css +199 -0
  16. package/dist/base.d.ts +2 -2
  17. package/dist/base.js +1 -1
  18. package/dist/base.js.map +1 -1
  19. package/dist/components/bento-box/BentoSection.d.ts +1 -1
  20. package/dist/components/bento-box/BentoSection.js +29 -6
  21. package/dist/components/bento-box/BentoSection.js.map +1 -1
  22. package/dist/components/events-section/EventsSection.d.ts +3 -0
  23. package/dist/components/events-section/EventsSection.js +12 -1
  24. package/dist/components/events-section/EventsSection.js.map +1 -1
  25. package/dist/components/library-weekly-hours/LibraryWeeklyHours.d.ts +1 -0
  26. package/dist/components/library-weekly-hours/LibraryWeeklyHours.js +5 -0
  27. package/dist/components/library-weekly-hours/LibraryWeeklyHours.js.map +1 -1
  28. package/dist/components/site-alerts/SiteAlerts.d.ts +109 -0
  29. package/dist/components/site-alerts/SiteAlerts.js +542 -0
  30. package/dist/components/site-alerts/SiteAlerts.js.map +1 -0
  31. package/dist/components/site-alerts/alerts-source.d.ts +36 -0
  32. package/dist/components/site-alerts/alerts-source.js +115 -0
  33. package/dist/components/site-alerts/alerts-source.js.map +1 -0
  34. package/dist/components/{site-page → site-alerts}/alerts.js +8 -3
  35. package/dist/components/site-alerts/alerts.js.map +1 -0
  36. package/dist/components/site-alerts/body.d.ts +10 -0
  37. package/dist/components/site-alerts/body.js +48 -0
  38. package/dist/components/site-alerts/body.js.map +1 -0
  39. package/dist/components/site-alerts/dismissed.d.ts +12 -0
  40. package/dist/components/site-alerts/dismissed.js +72 -0
  41. package/dist/components/site-alerts/dismissed.js.map +1 -0
  42. package/dist/components/site-alerts/icons.d.ts +8 -0
  43. package/dist/components/site-alerts/icons.js +15 -0
  44. package/dist/components/site-alerts/icons.js.map +1 -0
  45. package/dist/components/site-alerts/site-alerts.d.ts +1 -0
  46. package/dist/components/site-alerts/site-alerts.js +4 -0
  47. package/dist/components/site-alerts/site-alerts.js.map +1 -0
  48. package/dist/components/site-analytics/SiteAnalytics.d.ts +26 -2
  49. package/dist/components/site-analytics/SiteAnalytics.js +140 -4
  50. package/dist/components/site-analytics/SiteAnalytics.js.map +1 -1
  51. package/dist/components/site-footer/SiteFooter.d.ts +4 -0
  52. package/dist/components/site-footer/SiteFooter.js +28 -4
  53. package/dist/components/site-footer/SiteFooter.js.map +1 -1
  54. package/dist/components/site-header/SiteHeader.d.ts +47 -3
  55. package/dist/components/site-header/SiteHeader.js +198 -21
  56. package/dist/components/site-header/SiteHeader.js.map +1 -1
  57. package/dist/components/site-hours-section/SiteHoursSection.d.ts +4 -1
  58. package/dist/components/site-hours-section/SiteHoursSection.js +18 -3
  59. package/dist/components/site-hours-section/SiteHoursSection.js.map +1 -1
  60. package/dist/components/site-main-nav/SiteMainNav.d.ts +1 -1
  61. package/dist/components/site-main-nav/SiteMainNav.js +11 -1
  62. package/dist/components/site-main-nav/SiteMainNav.js.map +1 -1
  63. package/dist/components/site-page/SitePage.d.ts +43 -15
  64. package/dist/components/site-page/SitePage.js +161 -34
  65. package/dist/components/site-page/SitePage.js.map +1 -1
  66. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.d.ts +91 -0
  67. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js +310 -0
  68. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js.map +1 -0
  69. package/dist/components/uvalib-breadcrumbs/uvalib-breadcrumbs.d.ts +1 -0
  70. package/dist/components/uvalib-breadcrumbs/uvalib-breadcrumbs.js +4 -0
  71. package/dist/components/uvalib-breadcrumbs/uvalib-breadcrumbs.js.map +1 -0
  72. package/dist/components/uvalib-card/UvalibCard.d.ts +113 -0
  73. package/dist/components/uvalib-card/UvalibCard.js +643 -0
  74. package/dist/components/uvalib-card/UvalibCard.js.map +1 -0
  75. package/dist/components/uvalib-card/uvalib-card.d.ts +1 -0
  76. package/dist/components/uvalib-card/uvalib-card.js +4 -0
  77. package/dist/components/uvalib-card/uvalib-card.js.map +1 -0
  78. package/dist/components/uvalib-card-grid/UvalibCardGrid.d.ts +60 -0
  79. package/dist/components/uvalib-card-grid/UvalibCardGrid.js +305 -0
  80. package/dist/components/uvalib-card-grid/UvalibCardGrid.js.map +1 -0
  81. package/dist/components/uvalib-card-grid/uvalib-card-grid.d.ts +1 -0
  82. package/dist/components/uvalib-card-grid/uvalib-card-grid.js +4 -0
  83. package/dist/components/uvalib-card-grid/uvalib-card-grid.js.map +1 -0
  84. package/dist/components/uvalib-contents/UvalibContents.d.ts +134 -0
  85. package/dist/components/uvalib-contents/UvalibContents.js +613 -0
  86. package/dist/components/uvalib-contents/UvalibContents.js.map +1 -0
  87. package/dist/components/uvalib-contents/uvalib-contents.d.ts +1 -0
  88. package/dist/components/uvalib-contents/uvalib-contents.js +4 -0
  89. package/dist/components/uvalib-contents/uvalib-contents.js.map +1 -0
  90. package/dist/components/uvalib-date-range/UvalibDateRange.d.ts +10 -0
  91. package/dist/components/uvalib-date-range/UvalibDateRange.js +21 -0
  92. package/dist/components/uvalib-date-range/UvalibDateRange.js.map +1 -1
  93. package/dist/components/uvalib-filter/UvalibFilter.d.ts +1 -0
  94. package/dist/components/uvalib-filter/UvalibFilter.js +11 -1
  95. package/dist/components/uvalib-filter/UvalibFilter.js.map +1 -1
  96. package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +204 -0
  97. package/dist/components/uvalib-lightbox/UvalibLightbox.js +1115 -0
  98. package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -0
  99. package/dist/components/uvalib-lightbox/media.d.ts +51 -0
  100. package/dist/components/uvalib-lightbox/media.js +127 -0
  101. package/dist/components/uvalib-lightbox/media.js.map +1 -0
  102. package/dist/components/uvalib-lightbox/uvalib-lightbox.d.ts +1 -0
  103. package/dist/components/uvalib-lightbox/uvalib-lightbox.js +4 -0
  104. package/dist/components/uvalib-lightbox/uvalib-lightbox.js.map +1 -0
  105. package/dist/components/uvalib-metadata/UvalibMetadata.d.ts +124 -0
  106. package/dist/components/uvalib-metadata/UvalibMetadata.js +443 -0
  107. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -0
  108. package/dist/components/uvalib-metadata/rights.d.ts +8 -0
  109. package/dist/components/uvalib-metadata/rights.js +47 -0
  110. package/dist/components/uvalib-metadata/rights.js.map +1 -0
  111. package/dist/components/uvalib-metadata/uvalib-metadata.d.ts +1 -0
  112. package/dist/components/uvalib-metadata/uvalib-metadata.js +4 -0
  113. package/dist/components/uvalib-metadata/uvalib-metadata.js.map +1 -0
  114. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +103 -0
  115. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +410 -0
  116. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -0
  117. package/dist/components/uvalib-pagefind-search/uvalib-pagefind-search.d.ts +1 -0
  118. package/dist/components/uvalib-pagefind-search/uvalib-pagefind-search.js +7 -0
  119. package/dist/components/uvalib-pagefind-search/uvalib-pagefind-search.js.map +1 -0
  120. package/dist/components/uvalib-pager/UvalibPager.d.ts +94 -0
  121. package/dist/components/uvalib-pager/UvalibPager.js +390 -0
  122. package/dist/components/uvalib-pager/UvalibPager.js.map +1 -0
  123. package/dist/components/uvalib-pager/uvalib-pager.d.ts +1 -0
  124. package/dist/components/uvalib-pager/uvalib-pager.js +4 -0
  125. package/dist/components/uvalib-pager/uvalib-pager.js.map +1 -0
  126. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +59 -0
  127. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +350 -0
  128. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -0
  129. package/dist/components/uvalib-photo-grid/uvalib-photo-grid.d.ts +1 -0
  130. package/dist/components/uvalib-photo-grid/uvalib-photo-grid.js +4 -0
  131. package/dist/components/uvalib-photo-grid/uvalib-photo-grid.js.map +1 -0
  132. package/dist/custom-elements.json +12291 -4424
  133. package/dist/index.d.ts +16 -0
  134. package/dist/index.js +11 -0
  135. package/dist/index.js.map +1 -1
  136. package/dist/pagefind.css +388 -0
  137. package/dist/styles/base.js +11 -0
  138. package/dist/styles/base.js.map +1 -1
  139. package/dist/styles/color-scheme.js +24 -11
  140. package/dist/styles/color-scheme.js.map +1 -1
  141. package/dist/styles/controls.d.ts +2 -0
  142. package/dist/styles/controls.js +200 -0
  143. package/dist/styles/controls.js.map +1 -0
  144. package/dist/styles/pagefind.d.ts +1 -0
  145. package/dist/styles/pagefind.js +395 -0
  146. package/dist/styles/pagefind.js.map +1 -0
  147. package/dist/tokens.css +23 -20
  148. package/dist-cdn/base.css +199 -0
  149. package/dist-cdn/bento-box.js +117 -97
  150. package/dist-cdn/bento-box.js.map +1 -1
  151. package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js +243 -0
  152. package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js.map +1 -0
  153. package/dist-cdn/chunks/alerts-C5vkeb-f.js +39 -0
  154. package/dist-cdn/chunks/alerts-C5vkeb-f.js.map +1 -0
  155. package/dist-cdn/chunks/analytics-DTTihuBD.js +43 -0
  156. package/dist-cdn/chunks/analytics-DTTihuBD.js.map +1 -0
  157. package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js +39 -0
  158. package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js.map +1 -0
  159. package/dist-cdn/chunks/{base-DCGd2Oii.js → base-CAFQWnZG.js} +12 -1
  160. package/dist-cdn/chunks/{base-DCGd2Oii.js.map → base-CAFQWnZG.js.map} +1 -1
  161. package/dist-cdn/chunks/{library-weekly-hours-ByQ8ugxh.js → library-weekly-hours-COE7Vv6V.js} +47 -38
  162. package/dist-cdn/chunks/library-weekly-hours-COE7Vv6V.js.map +1 -0
  163. package/dist-cdn/chunks/{site-header-BwDkZ2LL.js → site-header-C9V7Wuw2.js} +169 -49
  164. package/dist-cdn/chunks/site-header-C9V7Wuw2.js.map +1 -0
  165. package/dist-cdn/chunks/{site-main-nav-BLAAunnr.js → site-main-nav-AaxZ9rQf.js} +11 -2
  166. package/dist-cdn/chunks/site-main-nav-AaxZ9rQf.js.map +1 -0
  167. package/dist-cdn/chunks/source-children-RuAec527.js +119 -0
  168. package/dist-cdn/chunks/source-children-RuAec527.js.map +1 -0
  169. package/dist-cdn/custom-elements.json +12291 -4424
  170. package/dist-cdn/events-section.js +78 -66
  171. package/dist-cdn/events-section.js.map +1 -1
  172. package/dist-cdn/library-hours-setup.js +1 -1
  173. package/dist-cdn/library-weekly-hours.js +1 -1
  174. package/dist-cdn/manifest.json +13 -2
  175. package/dist-cdn/pagefind.css +388 -0
  176. package/dist-cdn/site-alerts.js +516 -0
  177. package/dist-cdn/site-alerts.js.map +1 -0
  178. package/dist-cdn/site-analytics.js +1 -1
  179. package/dist-cdn/site-footer.js +33 -18
  180. package/dist-cdn/site-footer.js.map +1 -1
  181. package/dist-cdn/site-header.js +1 -1
  182. package/dist-cdn/site-hours-section.js +33 -21
  183. package/dist-cdn/site-hours-section.js.map +1 -1
  184. package/dist-cdn/site-main-nav.js +1 -1
  185. package/dist-cdn/site-page.js +116 -81
  186. package/dist-cdn/site-page.js.map +1 -1
  187. package/dist-cdn/site-style.js +1 -1
  188. package/dist-cdn/skills/uvalib-web-components/SKILL.md +367 -11
  189. package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +170 -0
  190. package/dist-cdn/skills/uvalib-web-components/reference/components.md +414 -12
  191. package/dist-cdn/skills/uvalib-web-components/reference/migration.md +37 -0
  192. package/dist-cdn/tokens.css +23 -20
  193. package/dist-cdn/uvalib-analytics.js +1 -1
  194. package/dist-cdn/uvalib-breadcrumbs.js +176 -0
  195. package/dist-cdn/uvalib-breadcrumbs.js.map +1 -0
  196. package/dist-cdn/uvalib-card-grid.js +163 -0
  197. package/dist-cdn/uvalib-card-grid.js.map +1 -0
  198. package/dist-cdn/uvalib-card.js +424 -0
  199. package/dist-cdn/uvalib-card.js.map +1 -0
  200. package/dist-cdn/uvalib-contents.js +381 -0
  201. package/dist-cdn/uvalib-contents.js.map +1 -0
  202. package/dist-cdn/uvalib-date-range.js +33 -18
  203. package/dist-cdn/uvalib-date-range.js.map +1 -1
  204. package/dist-cdn/uvalib-filter.js +32 -11
  205. package/dist-cdn/uvalib-filter.js.map +1 -1
  206. package/dist-cdn/uvalib-lightbox.js +662 -0
  207. package/dist-cdn/uvalib-lightbox.js.map +1 -0
  208. package/dist-cdn/uvalib-metadata.js +313 -0
  209. package/dist-cdn/uvalib-metadata.js.map +1 -0
  210. package/dist-cdn/uvalib-pagefind-search.js +207 -0
  211. package/dist-cdn/uvalib-pagefind-search.js.map +1 -0
  212. package/dist-cdn/uvalib-pager.js +278 -0
  213. package/dist-cdn/uvalib-pager.js.map +1 -0
  214. package/dist-cdn/uvalib-photo-grid.js +202 -0
  215. package/dist-cdn/uvalib-photo-grid.js.map +1 -0
  216. package/package.json +43 -1
  217. package/skills/uvalib-web-components/SKILL.md +367 -11
  218. package/skills/uvalib-web-components/reference/accessibility-testing.md +170 -0
  219. package/skills/uvalib-web-components/reference/components.md +414 -12
  220. package/skills/uvalib-web-components/reference/migration.md +37 -0
  221. package/dist/components/site-page/alerts.js.map +0 -1
  222. package/dist-cdn/chunks/SiteAnalytics-T1Wx3lsb.js +0 -174
  223. package/dist-cdn/chunks/SiteAnalytics-T1Wx3lsb.js.map +0 -1
  224. package/dist-cdn/chunks/analytics-C8D8n_wt.js +0 -55
  225. package/dist-cdn/chunks/analytics-C8D8n_wt.js.map +0 -1
  226. package/dist-cdn/chunks/library-weekly-hours-ByQ8ugxh.js.map +0 -1
  227. package/dist-cdn/chunks/site-header-BwDkZ2LL.js.map +0 -1
  228. package/dist-cdn/chunks/site-main-nav-BLAAunnr.js.map +0 -1
  229. /package/dist/components/{site-page → site-alerts}/alerts.d.ts +0 -0
@@ -1,14 +1,16 @@
1
1
  ---
2
2
  name: uvalib-web-components
3
- description: Use when building or editing UVA Library web pages or sites, adding the UVA Library header, footer or page wrapper to a page, using the custom elements <site-page>, <site-header>, <site-main-nav>, <site-footer>, <site-analytics>, <uvalib-analytics>, <site-style>, <uvalib-filter>, <uvalib-date-range>, <site-hours-section>, <library-weekly-hours>, <library-hours-setup>, <events-section> or <bento-box>, working with the @uvalib/web-components npm package, or editing script/link URLs on unpkg.internal.lib.virginia.edu (including migrating old /web-components/latest/ or cdn-v URLs). Covers CDN vs npm, version pinning, shadow vs light DOM, theming with --uva-* tokens, and a verification checklist.
3
+ description: Use when building or editing UVA Library web pages or sites, adding the UVA Library header, footer or page wrapper to a page, using <site-page>, <site-header>, <site-main-nav>, <site-footer>, <site-analytics>, <uvalib-analytics>, <site-style>, <uvalib-breadcrumbs>, <uvalib-card>, <uvalib-card-grid>, <uvalib-pager>, <uvalib-contents>, <uvalib-metadata>, <site-alerts>, <uvalib-filter>, <uvalib-date-range>, <site-hours-section>, <library-weekly-hours>, <library-hours-setup>, <events-section>, <bento-box>, <uvalib-pagefind-search>, <uvalib-lightbox> or <uvalib-photo-grid>, Pagefind site search (pagefind.css), working with the @uvalib/web-components npm package, or editing script/link URLs on unpkg.internal.lib.virginia.edu (including migrating old /web-components/latest/ or cdn-v URLs). Covers CDN vs npm, version pinning, shadow vs light DOM, theming with --uva-* tokens, WCAG 2.2 AA accessibility testing (axe-core in Playwright matched to Lighthouse, Lighthouse CI, manual checks), and a verification checklist.
4
4
  ---
5
5
 
6
6
  # UVA Library web components
7
7
 
8
- `@uvalib/web-components` provides the UVA Library page chrome as custom elements: `<site-page>` (skip link, header with the library main navigation, one `<main>`, footer), `<site-header>`, `<site-main-nav>` (the main navigation, rendered by the header), `<site-footer>`, `<site-analytics>` (Matomo; also registered as `<uvalib-analytics>`) and `<site-style>` (legacy compatibility). It also ships two search-page components, `<uvalib-filter>` and `<uvalib-date-range>` (section 6), and three library-hours elements for library.virginia.edu, `<site-hours-section>`, `<library-weekly-hours>` and `<library-hours-setup>`, `<events-section>` for upcoming library events and `<bento-box>` for the library's search results page (section 7). Tag names are stable.
8
+ `@uvalib/web-components` provides the UVA Library page chrome as custom elements: `<site-page>` (skip link, header with the library main navigation, one `<main>`, footer), `<site-header>`, `<site-main-nav>` (the main navigation, rendered by the header), `<site-footer>`, `<site-analytics>` (Matomo; also registered as `<uvalib-analytics>`) and `<site-style>` (legacy compatibility), plus `<uvalib-breadcrumbs>` (the breadcrumb trail), `<uvalib-contents>` (sub-navigation or a table of contents) and `<uvalib-metadata>` (a record's details, credit, rights and how to cite), all in section 2, `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>` (cards and paging, section 5) and `<site-alerts>` (the live library alerts, which `<site-page>` shows itself). It also ships two search-page components, `<uvalib-filter>` and `<uvalib-date-range>` (section 6), and three library-hours elements for library.virginia.edu, `<site-hours-section>`, `<library-weekly-hours>` and `<library-hours-setup>`, `<events-section>` for upcoming library events and `<bento-box>` for the library's search results page (section 7), and `pagefind.css` with `<uvalib-pagefind-search>` for a static site's Pagefind search (section 6), and `<uvalib-lightbox>` and `<uvalib-photo-grid>` for images (section 8). Tag names are stable.
9
9
 
10
10
  Authority rule: https://www.library.virginia.edu and the UVA Library design system are the source of truth for how the chrome looks and what it says. Do not re-create, copy or restyle the header, footer, logo or links by hand. Use the components, and change appearance only through the theming surface below.
11
11
 
12
+ Accessibility rule: everything you build with these components must meet **WCAG 2.2 AA at minimum and aim for AAA** (the Library's web standard; alerts and other critical messages meet AAA). The components are built and tested to that bar; your own markup, CSS and scripts around them must keep it. Test every change with axe-core in Playwright configured to be at least as strict as Lighthouse, with Lighthouse CI, and with a short manual keyboard and screen reader pass: see [reference/accessibility-testing.md](reference/accessibility-testing.md) for the ready-to-use setup. Do not finish a task with known accessibility failures; report anything you could not test.
13
+
12
14
  For the full attribute, slot, part, event and custom-property lists see [reference/components.md](reference/components.md). To update an existing project from old URLs or package names see [reference/migration.md](reference/migration.md).
13
15
 
14
16
  ## 1. Choose how to load it
@@ -29,21 +31,30 @@ Loading rules:
29
31
 
30
32
  - One script is enough for the page chrome: `site-page.js` also loads the header (with its main navigation) and footer. For Matomo, give `<site-page>` a `matomo-id` (it loads the analytics code itself), or add `site-analytics.js` and a `<site-analytics>` (or `uvalib-analytics.js` and `<uvalib-analytics>`) element; never both, and never alongside a hand-written Matomo snippet.
31
33
  - Also link `.../v1/base.css` in `<head>` (npm: `@uvalib/web-components/base.css`), unless the page sets `no-global-styles`. `<site-page>` installs the same base styles only after the first paint, so without the link the page shifts once (the default body margin goes away, and a heading's margin stops collapsing through the not-yet-defined `<site-page>`). The link also keeps `<site-page>` invisible until it is defined, with a two-second fallback.
32
- - npm: the define entries (`@uvalib/web-components/site-page.js`, `site-header.js`, `site-main-nav.js`, `site-footer.js`, `site-analytics.js`, `uvalib-analytics.js`, `site-style.js`, `uvalib-filter.js`, `uvalib-date-range.js`, `site-hours-section.js`, `library-weekly-hours.js`, `library-hours-setup.js`, `events-section.js`, `bento-box.js`) register the element (`bento-box.js` also registers its four sections). Importing the package root (`@uvalib/web-components`) gives the classes only and registers nothing. If you use the `SitePage` class directly, also import the header and footer define entries.
34
+ - npm: the define entries (`@uvalib/web-components/site-page.js`, `site-header.js`, `site-main-nav.js`, `site-footer.js`, `site-analytics.js`, `uvalib-analytics.js`, `site-style.js`, `uvalib-breadcrumbs.js`, `uvalib-card.js`, `uvalib-card-grid.js`, `uvalib-pager.js`, `uvalib-contents.js`, `uvalib-metadata.js`, `site-alerts.js`, `uvalib-filter.js`, `uvalib-date-range.js`, `site-hours-section.js`, `library-weekly-hours.js`, `library-hours-setup.js`, `events-section.js`, `bento-box.js`, `uvalib-pagefind-search.js`, `uvalib-lightbox.js`, `uvalib-photo-grid.js`) register the element (`bento-box.js` also registers its four sections). Importing the package root (`@uvalib/web-components`) gives the classes only and registers nothing. If you use the `SitePage` class directly, also import the header and footer define entries.
33
35
  - Do not load the same component from both the CDN and npm on one page.
34
36
 
35
37
  ## 2. Required page structure
36
38
 
37
39
  - Exactly one `<site-page>` per page, wrapping all page content.
38
40
  - `<site-page>` renders the one skip link, the header, one `<main id="main-content">` and the footer. Never add your own `<main>`, skip link, `<header>`/`<footer>` site chrome, or `role="main"`. If the page already has them, remove them and keep only the content that was inside `<main>`.
39
- - Sidebars, breadcrumbs and article content all go inside `<site-page>` as ordinary elements (use `<nav aria-label="...">` for navigation, no ARIA menu roles).
41
+ - Sidebars and article content go inside `<site-page>` as ordinary elements (use `<nav aria-label="...">` for navigation, no ARIA menu roles).
42
+ - Breadcrumbs: a `<uvalib-breadcrumbs slot="breadcrumbs">` (from `uvalib-breadcrumbs.js`) inside `<site-page>`, never a hand-built trail. Its children are `<a href>` links ending with the current page (`<span>Title</span>`, or `<a href aria-current="page">`); apps can set its `items` property (`[{ label, href? }]`) instead. `<site-page>` places it between the header and `<main>`, outside `<main>`. Outside `<site-page>` it goes first in the content, above the `<h1>`. In a single-page app with history routing, listen for `uvalib-breadcrumbs-navigate` and call `preventDefault()` to route in place (hash links need nothing).
43
+ - Cards and paging: a collection or photo is a `<uvalib-card>` (`uvalib-card.js`), inside `<uvalib-card-grid>` (`uvalib-card-grid.js`) when there are several. `href` makes the heading the one link for the whole card: never wrap the card in an `<a>`, and do not put another link, button or other control inside a clickable card. The heading needs an accessible name, or the link is hidden. A card with no `href` may contain its own links. An image needs a real alt, or `alt=""` when the heading already names it. Previous/next sections or numbered pages are one `<uvalib-pager>` (`uvalib-pager.js`); a second pager on the same page needs its own `label`. In a single-page app, listen for `uvalib-card-navigate` and `uvalib-pager-navigate` and call `preventDefault()` to route in place.
44
+ - Sub-navigation and tables of contents: a `<uvalib-contents>` (from `uvalib-contents.js`) holding one `<ol>`/`<ul>` of `<li><a href>` entries, nested lists for sub-entries (plain text in an `<li>` for a group label), never a hand-built `<nav>` list or `<details>` for it. It is the `<nav>` landmark (named and headed by `label`, default "Contents"; set `heading-level` to fit the outline) and marks the current page (`aria-current="page"`) and in-page section (`"location"`, from the hash) itself: do not add `aria-current` by hand unless the route is not the URL, and then prefer `current="<url>"`. It collapses into a disclosure button at 64rem and below (`collapse-below`), closed until opened. In a sidebar add `sticky`. Apps can set `items` (`[{ label, href?, children? }]`); with history routing, cancel `uvalib-contents-navigate` to route in place.
45
+ - Record details: a `<uvalib-metadata>` (from `uvalib-metadata.js`) around a plain `<dl>` (`<dt>` label, `<dd>` values; lists such as subjects as a `<ul>` in the `<dd>`). Downloads are `<a href download data-size="184 KB">EPUB</a>`. For credit and rights use its attributes, not your own rows: `creator`, `organization`, `rights` (a rightsstatements.org or Creative Commons URL; it shows the short name), `rights-info` (`https://www.library.virginia.edu/policies/use-of-materials`) and `citation` or `citation-title` (the Special Collections citation "<title>, Albert and Shirley Small Special Collections Library, University of Virginia"), which adds a Copy citation button. Do not add icons from rightsstatements.org or creativecommons.org.
40
46
  - Content for a band above the footer: put an element with `slot="pre-footer"` inside `<site-page>`.
41
47
  - `no-footer` on `<site-page>` hides the footer (and any pre-footer band). Use it only for tool or app-like pages, such as a full-screen editor, where the site footer does not belong; normal content pages keep the footer.
42
48
  - A site's own navigation (its home, sections, docs) goes in the header: give `<site-page>` `<a slot="site-links" href="…">` children and a `site-links-label` (see section 5). They replace the library utility links in the header and its Menu popover. Do not add a separate nav row or bar at the top of the content for it. Each must be an `<a href>` with visible text; other children and empty links are ignored with a console warning. Mark the current page with `aria-current="page"`. The `vendor` variant ignores site links: it is for third-party sites that only need the library logo and Ask a Librarian.
43
49
  - Main navigation: every full header shows the UVA Library main navigation (About, Using the Library, Research & teaching support, Get help) by default, as a row under the logo on wide screens and as accordions at the top of the Menu popover at 992px and below. Keep it on library sites. Do not build your own copy of it, add a second main-navigation bar, or hard-code its links: the component bundles the live menu (maintainers refresh it with `pnpm sync:main-nav`). Turn it off with `no-main-nav` only on sites that are not part of the library website's navigation (for example a standalone app that asks for it); the `vendor` variant never shows it. It is separate from site links: site links replace the utility links, the main navigation stays. To replace the main navigation's links (rare), give `<site-page>` a `<nav slot="main-nav"><ul>…</ul></nav>` child (`<li><a href>` for a link, `<li><span>Group</span><ul><li><a href>…</a></li></ul></li>` for a group; two levels only), or `main-nav-src="https://…/menu.json"` (CORS required; on failure the bundled menu stays and `site-main-nav-error` fires). Precedence: slot, then `main-nav-src`, then the bundle (a standalone `<site-main-nav>` also takes an `items` property, between the slot and `items-src`; `<site-page>` and `<site-header>` have none). It marks the current page itself (`aria-current`) and follows same-document navigations; an app whose route is not its URL sets `main-nav-current` on `<site-page>`. Do not add `aria-current` to its links by hand, and never use ARIA menu roles for it. Exactly one main-navigation landmark is visible at a time (the row above 992px, the accordion in the open Menu popover below). Above 992px it makes the header about 54px taller: do not hard-code the header height in host CSS.
44
- - Alerts: `<site-page>` shows live UVA Library alerts by default placed as in Virgo (a full-bleed header banner at the top of the header, the alert list in a full-bleed `Library alerts` region band between the header and `<main>`, hidden while empty, and regional alerts first in `<main>`), loading `<uvalib-alerts>` from the alerts CDN itself. Keep the default (production) on real sites. Use `alerts-env="staging"` only on staging or test deployments, and `alerts-src="https://…/"` only for a custom alerts domain or local development; it wins over `alerts-env`. Never add your own `<uvalib-alerts>` or its `<script>` inside or alongside a `<site-page>`. An app that renders alerts itself (Virgo, headless) sets `no-alerts`; nothing else should. A standalone `<site-header>` loads no alerts.
50
+ - Alerts: `<site-page>` shows live UVA Library alerts by default placed as in Virgo (a full-bleed header banner at the top of the header, the alert list in a full-bleed `Library alerts` region band between the header and `<main>`, hidden while empty, and regional alerts first in `<main>`), drawn by `<site-alerts>` in library.virginia.edu's look; the data comes from a headless `<uvalib-alerts>` that it loads from the alerts CDN itself. Keep the default (production) on real sites. Use `alerts-env="staging"` only on staging or test deployments, and `alerts-src="https://…/"` only for a custom alerts domain or local development; it wins over `alerts-env`. Never add your own `<site-alerts>`, `<uvalib-alerts>` or alerts `<script>` inside or alongside a `<site-page>`. An app that renders alerts itself (Virgo, headless) sets `no-alerts`; nothing else should. A standalone `<site-header>` loads no alerts.
51
+ - Alerts without `<site-page>`: `<site-alerts show="sitewide">` near the top of the page and `<site-alerts show="regional">` where the content starts (from `site-alerts.js`; `show` is `header`, `list`, `regional`, `sitewide` or `all`), inside landmarks (the banner in your `<header>`, the list in a labelled `<section aria-label="Library alerts">`, regional in `<main>`). They share one hidden headless element, created for them. List titles are `<h2>`; set `heading-level` if your page's outline needs another level. A site still using the alerts project's UI (`<uvalib-alerts show="…">` and its script) switches to `<site-alerts show="…">` and drops that script.
52
+ - Alerts accessibility is built in (AAA text contrast in light and dark, severity in text as well as icon and colour, a polite status banner, `role="alert"` only for critical alerts, 44px dismiss buttons that move focus to the next alert or `<main>`, forced-colors borders). Do not restyle alert colours or hide the visually hidden severity labels. Theme dark mode through the `--uva-color-alert-*` tokens only, keeping 7:1 text contrast.
53
+ - Alerts report to analytics on their own (with an analytics element on the page): a content impression per alert shown per page view ('Library alert', '<severity>: <title>'), and `site-alerts` events `dismiss`, `link-click` (never the URL) and `error` (`alerts-script`). Do not add your own tracking for them.
45
54
  - If the site sends a Content Security Policy, it must allow the alerts host (production `https://d2q6t6fdv76k7r.cloudfront.net`) in `script-src` and `connect-src`, `wss://*.appsync-realtime-api.us-east-1.amazonaws.com` in `connect-src`, and the hosts of images used in alert bodies in `img-src`. Alert bodies are inserted as HTML, so a page that enforces Trusted Types (`require-trusted-types-for`) cannot show alerts: use `no-alerts` there.
46
- - In light mode the regional `<uvalib-alerts>` is the first child of `<main>`, the banner the first child of the header's `<header>`, and the `section.alerts-list` band (the alert list) sits between `<site-header>` and `<main>`; do not write host CSS like `main > :first-child` or `site-header + *` that assumes your content comes first, and do not restyle the band's full-bleed layout.
55
+ - In light mode the regional `<site-alerts>` is the first child of `<main>`, the banner the first child of the header's `<header>`, and the `section.alerts-list` band (the alert list) sits between `<site-header>` and `<main>`; do not write host CSS like `main > :first-child` or `site-header + *` that assumes your content comes first, and do not restyle the band's full-bleed layout.
56
+ - A sub-site's name (Electronic Text Collections, an exhibit or project site): `site-name="…"` on `<site-page>` (and `site-name-href` when its home is not `/`). The header shows it after the logo as a link to the site's home; the logo still links to library.virginia.edu. Never add your own banner, title bar or second logo row for it, and never make it the page's `<h1>` (the page keeps its own). Keep it short (two lines at most on wide screens).
57
+ - Buttons, toggles and search boxes in the page's own content: use `base.css`'s classes, never hand-rolled button CSS: `.uvalib-button` (on `<button>` or `<a>`), `--secondary` (outline), `--subtle`, `--small`, `--large`; a toggle is a `.uvalib-button` with `aria-pressed="true|false"` (flip it in script); fields are `.uvalib-input` with a visible `<label>`, and a search box is `<form class="uvalib-search-form" role="search">` holding the label, the field and a `.uvalib-button` submit. They need `base.css` linked (`<site-page>` does not install them); it carries the dark-mode role tokens they read. Disable with `disabled` (or `aria-disabled="true"` while busy); a pressed toggle is filled whatever its variant.
47
58
  - Third-party or vendor sites that are not library.virginia.edu: `<site-page header-variant="vendor">` (logo plus Ask a Librarian only). Links default to `root-link-domain="https://www.library.virginia.edu"`; set it only for a non-production domain.
48
59
  - Do not replace a light-mode page's children wholesale (`innerHTML` or `textContent` on `<site-page>`): that destroys the chrome. Append, or update a child container inside it.
49
60
 
@@ -132,6 +143,52 @@ A site with its own navigation (links replace the library utility links in the h
132
143
  </html>
133
144
  ```
134
145
 
146
+ A sub-site with its name in the header, its own links, and a search box and a toggle in its content (`base.css` styles the classes):
147
+
148
+ ```html snippet
149
+ <!doctype html>
150
+ <html lang="en">
151
+ <head>
152
+ <meta charset="utf-8" />
153
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
154
+ <title>Electronic Text Collections</title>
155
+ <link
156
+ rel="stylesheet"
157
+ href="https://unpkg.internal.lib.virginia.edu/web-components/v1/base.css"
158
+ />
159
+ <script
160
+ type="module"
161
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/site-page.js"
162
+ ></script>
163
+ </head>
164
+ <body>
165
+ <site-page
166
+ site-name="Electronic Text Collections"
167
+ site-name-href="/"
168
+ site-links-label="Collections"
169
+ >
170
+ <a slot="site-links" href="/collections/">Collections</a>
171
+ <a slot="site-links" href="/search/">Search</a>
172
+ <h1>Electronic Text Collections</h1>
173
+ <form class="uvalib-search-form" role="search" action="/search/">
174
+ <label for="q">Search the texts</label>
175
+ <input class="uvalib-input" id="q" name="q" type="search" />
176
+ <button class="uvalib-button" type="submit">Search</button>
177
+ </form>
178
+ <p>
179
+ <button class="uvalib-button" type="button" aria-pressed="false">
180
+ Show original line breaks
181
+ </button>
182
+ </p>
183
+ <p>
184
+ <a class="uvalib-button uvalib-button--secondary" href="/texts/1/">Previous</a>
185
+ <a class="uvalib-button uvalib-button--secondary" href="/texts/3/">Next</a>
186
+ </p>
187
+ </site-page>
188
+ </body>
189
+ </html>
190
+ ```
191
+
135
192
  More complete pages (host-CSS `no-shadow-dom`, page with a sidebar and its own `<main>`, vendor header, analytics) are in [reference/snippets.md](reference/snippets.md).
136
193
 
137
194
  11ty (Nunjucks layout). Wrap the layout's content in `<site-page>`; remove the layout's own `<main>`, header and footer markup. With `@uvalib/11ty-template`, its custom-elements plugin adds the script for each known tag in the page and pins the major with the `webComponentsVersion` option (default `"1"`; set an exact version to pin). The plugin option `webComponentsVersion` lands with the monorepo migration (11ty-template change); until then add the script tag yourself:
@@ -162,7 +219,193 @@ import '@uvalib/web-components/tokens.css'; // optional: tokens for your own CSS
162
219
  // <site-page> is then used in your HTML or templates exactly as in the plain HTML snippet.
163
220
  ```
164
221
 
165
- Analytics: only when the site needs Matomo, set `<site-page matomo-id="N">`, or add `site-analytics.js` and a `<site-analytics matomoid="N">`; see the analytics page in [reference/snippets.md](reference/snippets.md). `<uvalib-analytics>` (`uvalib-analytics.js`) is the same element under its original name, for existing markup. It listens on `document` for `uvalib-analytics-*` and `site-analytics-*` events (`event`, `search`, `pageview`) and queues them for Matomo, so events fired before Matomo loads are kept, and a page never counts twice. The library's own components (bento-box searches and result clicks, main-nav menu opens, the header's colour-scheme choice) already report; do not add tracking for those. Never put titles, URLs or personal data in events.
222
+ Analytics: only when the site needs Matomo, set `<site-page matomo-id="N">`, or add `site-analytics.js` and a `<site-analytics matomoid="N">`; see the analytics page in [reference/snippets.md](reference/snippets.md). `<uvalib-analytics>` (`uvalib-analytics.js`) is the same element under its original name, for existing markup. It listens on `document` for `uvalib-analytics-*` and `site-analytics-*` events (`event`, `search`, `pageview`, `content`) and queues them for Matomo, so events fired before Matomo loads are kept, and a page never counts twice. A single-page app whose router uses `pushState` or hashes can set `spa="auto"` to have each route change counted (after the new title is set, never twice for one URL); bare `spa` means the app sends its own `uvalib-analytics-pageview` events.
223
+
224
+ The library's components already report what visitors do with them; do not add tracking for any of it: header utility and site links, logo, skip link, Menu and colour scheme; main-nav menu opens and links; footer links; breadcrumb and contents levels, the contents disclosure, Copy citation; card clicks (the card's place in its grid, or single); pager next, previous and page numbers; alerts (impressions, dismiss, links, errors); event clicks; See all hours, week changes; filter facets, scopes and See more/less; date-range changes; bento searches, result and See all clicks, retries; lightbox opens, next, previous and full size (the name is `image N`, never the URL or the caption); and load errors. `<uvalib-photo-grid>` reports nothing. The README's "Analytics" section has the full table.
225
+
226
+ For the host page's own content, tag the clickable element (or a wrapper) with `data-uvalib-track="category,action[,name[,value]]"` instead of writing a listener, for example `<a href="/spaces" data-uvalib-track="home-page,banner-click,Study spaces">`: the category is your page or widget, the action a fixed kebab-case verb, the name a short fixed label, the value a number. It works inside shadow DOM too. Never put titles, URLs, search text, ids, email addresses, phone numbers or other personal data in events.
227
+
228
+ To opt out: `no-analytics` on an element (or any ancestor) silences it and everything inside; `<html data-uvalib-analytics="off">` turns analytics off for the whole page (no Matomo, no page view, no events). Browsers that send Do Not Track or Global Privacy Control get no Matomo at all, with nothing to configure.
229
+
230
+ A page with a breadcrumb trail (between the header and `<main>`):
231
+
232
+ ```html snippet
233
+ <!doctype html>
234
+ <html lang="en">
235
+ <head>
236
+ <meta charset="utf-8" />
237
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
238
+ <title>Writing &amp; publication</title>
239
+ <link
240
+ rel="stylesheet"
241
+ href="https://unpkg.internal.lib.virginia.edu/web-components/v1/base.css"
242
+ />
243
+ <script
244
+ type="module"
245
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/site-page.js"
246
+ ></script>
247
+ <script
248
+ type="module"
249
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-breadcrumbs.js"
250
+ ></script>
251
+ </head>
252
+ <body>
253
+ <site-page>
254
+ <uvalib-breadcrumbs slot="breadcrumbs">
255
+ <a href="/">Home</a>
256
+ <a href="/research-and-teaching">Research &amp; teaching support</a>
257
+ <span>Writing &amp; publication</span>
258
+ </uvalib-breadcrumbs>
259
+ <h1>Writing &amp; publication</h1>
260
+ <p>Page content goes here.</p>
261
+ </site-page>
262
+ </body>
263
+ </html>
264
+ ```
265
+
266
+ A collection grid, a photo card and previous/next sections. The card's `href` is the only link; the image alt is not the heading. Load `uvalib-card.js`, `uvalib-card-grid.js` and `uvalib-pager.js` as well as `site-page.js`.
267
+
268
+ ```html snippet
269
+ <!doctype html>
270
+ <html lang="en">
271
+ <head>
272
+ <meta charset="utf-8" />
273
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
274
+ <title>Collections</title>
275
+ <link
276
+ rel="stylesheet"
277
+ href="https://unpkg.internal.lib.virginia.edu/web-components/v1/base.css"
278
+ />
279
+ <script
280
+ type="module"
281
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/site-page.js"
282
+ ></script>
283
+ <script
284
+ type="module"
285
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-card.js"
286
+ ></script>
287
+ <script
288
+ type="module"
289
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-card-grid.js"
290
+ ></script>
291
+ <script
292
+ type="module"
293
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-pager.js"
294
+ ></script>
295
+ </head>
296
+ <body>
297
+ <site-page>
298
+ <h1>Collections</h1>
299
+ <uvalib-card-grid>
300
+ <uvalib-card href="#early-american-fiction">
301
+ <span slot="heading">Early American Fiction</span>
302
+ 128 texts
303
+ </uvalib-card>
304
+ <uvalib-card href="#rotunda">
305
+ <img
306
+ slot="media"
307
+ alt="A courtyard arch"
308
+ src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
309
+ />
310
+ <span slot="badge">13 photos</span>
311
+ <span slot="heading">Rotunda</span>
312
+ <time slot="meta" datetime="1910">1910</time>
313
+ <span slot="chip">Architecture</span>
314
+ The west colonnade after the annex fire.
315
+ </uvalib-card>
316
+ </uvalib-card-grid>
317
+ <uvalib-pager
318
+ prev-href="#the-opening"
319
+ prev-label="The opening"
320
+ next-href="#what-follows"
321
+ next-label="What follows"
322
+ ></uvalib-pager>
323
+ </site-page>
324
+ </body>
325
+ </html>
326
+ ```
327
+
328
+ A record page with its metadata and a contents sidebar (the sidebar is an ordinary element inside `<site-page>`):
329
+
330
+ ```html snippet
331
+ <!doctype html>
332
+ <html lang="en">
333
+ <head>
334
+ <meta charset="utf-8" />
335
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
336
+ <title>The actress of Padua, and other tales</title>
337
+ <link
338
+ rel="stylesheet"
339
+ href="https://unpkg.internal.lib.virginia.edu/web-components/v1/base.css"
340
+ />
341
+ <script
342
+ type="module"
343
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/site-page.js"
344
+ ></script>
345
+ <script
346
+ type="module"
347
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-contents.js"
348
+ ></script>
349
+ <script
350
+ type="module"
351
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-metadata.js"
352
+ ></script>
353
+ <style>
354
+ .reader {
355
+ display: grid;
356
+ gap: 2rem;
357
+ }
358
+ @media (width > 64rem) {
359
+ .reader {
360
+ grid-template-columns: 18rem minmax(0, 1fr);
361
+ }
362
+ }
363
+ </style>
364
+ </head>
365
+ <body>
366
+ <site-page>
367
+ <h1>The actress of Padua, and other tales</h1>
368
+ <uvalib-metadata
369
+ creator="Smith, Richard Penn"
370
+ rights="http://rightsstatements.org/vocab/NoC-US/1.0/"
371
+ rights-info="https://www.library.virginia.edu/policies/use-of-materials"
372
+ citation-title="The actress of Padua, and other tales"
373
+ >
374
+ <dl>
375
+ <dt>Date</dt>
376
+ <dd>1836</dd>
377
+ <dt>Subjects</dt>
378
+ <dd>
379
+ <ul>
380
+ <li>Short stories</li>
381
+ <li>American literature -- 19th century</li>
382
+ </ul>
383
+ </dd>
384
+ <dt>Download</dt>
385
+ <dd><a href="eaf375v1.epub" download data-size="184 KB">EPUB</a></dd>
386
+ </dl>
387
+ </uvalib-metadata>
388
+ <div class="reader">
389
+ <uvalib-contents sticky>
390
+ <ol>
391
+ <li><a href="#preface">Preface</a></li>
392
+ <li>
393
+ <a href="#padua">The actress of Padua</a>
394
+ <ol>
395
+ <li><a href="#part-1">Part I. The Key</a></li>
396
+ </ol>
397
+ </li>
398
+ </ol>
399
+ </uvalib-contents>
400
+ <article>
401
+ <h2 id="preface">Preface</h2>
402
+ <p>Text goes here.</p>
403
+ </article>
404
+ </div>
405
+ </site-page>
406
+ </body>
407
+ </html>
408
+ ```
166
409
 
167
410
  ## 6. Search facets
168
411
 
@@ -225,6 +468,53 @@ For a search results page that needs a checkbox facet or a date-range picker, us
225
468
  </html>
226
469
  ```
227
470
 
471
+ ### Static-site search (Pagefind)
472
+
473
+ A static site (11ty, Jekyll, a generated collection) that searches with [Pagefind](https://pagefind.app) keeps Pagefind's own index and `pagefind-ui.js`, and gets the library look and the accessibility fixes from this package:
474
+
475
+ - Link `pagefind.css` (npm: `@uvalib/web-components/pagefind.css`) **instead of** Pagefind's `pagefind-ui.css`; never both (the stock rules out-rank the theme's). It styles Pagefind's default UI (`.pagefind-ui__*`): the field and Clear like `.uvalib-input`, the filters like `<uvalib-filter>`, link-coloured result titles, the library `<mark>`, Load more as a `.uvalib-button`, with dark mode and forced colors. Pagefind's `--pagefind-ui-*` properties still work for small changes.
476
+ - Use `<uvalib-pagefind-search>` (from `uvalib-pagefind-search.js`) rather than `new PagefindUI(...)`: it loads `<bundle-path>pagefind-ui.js` from the site's bundle and adds what CSS cannot: a visible label (the stock field has only a title), a polite result-count status (the stock message is not announced), focus that stays in the field after Clear and Escape and moves to the first new result after Load more, `?q=` read and written (`query-param`), and analytics (`trackSearch(…, 'Pagefind', count)` once results settle, and `filter-change` events). Do not add your own `?q=` script or live region.
477
+ - Attributes: `bundle-path` (default `/pagefind/`), `merge-index` (JSON array, for sharded indexes), `page-size` (10), `show-sub-results`, `show-images`, `excerpt-length`, `placeholder`, `label`, `label-hidden`, `translations` and `options` (JSON). For filters from the URL, call `el.ready.then((ui) => ui.triggerFilters({ collection: ['…'] }))`.
478
+
479
+ ```html
480
+ <!doctype html>
481
+ <html lang="en">
482
+ <head>
483
+ <meta charset="utf-8" />
484
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
485
+ <title>Search · Electronic Text Collections · UVA Library</title>
486
+ <link
487
+ rel="stylesheet"
488
+ href="https://unpkg.internal.lib.virginia.edu/web-components/v1/base.css"
489
+ />
490
+ <link
491
+ rel="stylesheet"
492
+ href="https://unpkg.internal.lib.virginia.edu/web-components/v1/pagefind.css"
493
+ />
494
+ <script
495
+ type="module"
496
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/site-page.js"
497
+ ></script>
498
+ <script
499
+ type="module"
500
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-pagefind-search.js"
501
+ ></script>
502
+ </head>
503
+ <body>
504
+ <site-page site-name="Electronic Text Collections">
505
+ <h1>Search</h1>
506
+ <uvalib-pagefind-search
507
+ bundle-path="/pagefind/s0/"
508
+ merge-index='[{"bundlePath": "/pagefind/s1/"}, {"bundlePath": "/pagefind/s2/"}]'
509
+ placeholder="Search all texts"
510
+ show-sub-results
511
+ excerpt-length="30"
512
+ ></uvalib-pagefind-search>
513
+ </site-page>
514
+ </body>
515
+ </html>
516
+ ```
517
+
228
518
  ## 7. Library hours
229
519
 
230
520
  Use these only on library.virginia.edu (or with the data endpoints repointed): the library list is the site's own same-origin Drupal JSON:API, so on any other origin they show "Hours are unavailable right now.".
@@ -258,7 +548,67 @@ Use these only on library.virginia.edu (or with the data endpoints repointed): t
258
548
  - On library.virginia.edu use `no-shadow-dom no-style` inside the page's `.uvalib-bento-search` body class: the Drupal theme styles its classes (`bento-search-bar`, `bs-header`, `bs-results-container`, `bs-results--block`, `bs-results--header`, `bs-results--list`, `ul-0`, `ul-1`, …).
259
549
  - Migrating Drupal: `…/web-components/cdn-v2.2.38/@uvalib/bento-box/bento-box.js` becomes `https://unpkg.internal.lib.virginia.edu/web-components/v1/bento-box.js`; the markup stays (`<bento-box no-style no-shadow-dom limit="3">`).
260
550
 
261
- ## 8. Verification checklist
551
+ ## 8. Images
552
+
553
+ Use these instead of a hand-built gallery or a carousel. There is no autoplay.
554
+
555
+ - `<uvalib-lightbox>` from `uvalib-lightbox.js`: progressive enhancement over plain links. Wrap them (`<a href="full.jpg" data-caption="Page 2"><img alt="Page 2" width="1600" height="2000"></a>`), or point at links elsewhere with `selector="a.pb-image"`. Without JavaScript, and on a modified click, the link opens the image as before. A primary click opens a native `<dialog>` (`showModal()`): the caption names it, Close takes focus, focus returns to the trigger, Escape and the backdrop close it. With more than one image, Previous and Next and the arrow keys move through the set (wrapping; Left is previous in left-to-right), with a polite "3 of 13". Full size opens the original image in a new tab and says so in its accessible name. It is offered for an http(s) URL or a PNG, JPEG, GIF or WebP `data:` image, never an SVG `data:` URL. A IIIF Image API URL keeps its region and only the size becomes `!W,H` for the viewport; TIFF and JPEG2000 URLs are left as written. Full size stays the original href.
556
+ - `url-param="photo"` keeps `?photo=<id>` in sync (the id is `data-id`, else `id`, else the IIIF identifier, else the position from 1): opening pushes a history entry, stepping replaces it, Back closes. On a hash route the parameter is written inside the hash. Opening from a URL that already has it is not an analytics event. With `spa="auto"`, that opening push may count as one Matomo page view.
557
+ - Details: a child with `slot="details"` (`data-for` selects one item by id or position from 1; without it the details show for every image), or `data-details-id` on a link naming an element elsewhere. It is put back when the viewer moves on or closes.
558
+ - `<uvalib-photo-grid>` from `uvalib-photo-grid.js`: justified rows. Each direct `<a href>` or `<button>` is one photo and stays a real control. The row is about 220px, and 140px at 767px and below, unless `row-height` is set (a bare number is pixels). Give each image `width` and `height` so the row does not jump when it loads. An image with no visible text gets a caption from its alt, and a repeated alt is cleared (the original is kept for a lightbox). A different alt is kept. Do not set an `aria-label` that differs from the visible text; the grid will not add a caption beside one. Generated "Photo N" captions renumber when the photos change order. A grid inside a lightbox opens the viewer. The grid reports no analytics.
559
+
560
+ ```html snippet
561
+ <!doctype html>
562
+ <html lang="en">
563
+ <head>
564
+ <meta charset="utf-8" />
565
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
566
+ <title>Photographs</title>
567
+ <link
568
+ rel="stylesheet"
569
+ href="https://unpkg.internal.lib.virginia.edu/web-components/v1/base.css"
570
+ />
571
+ <script
572
+ type="module"
573
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/site-page.js"
574
+ ></script>
575
+ <script
576
+ type="module"
577
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-lightbox.js"
578
+ ></script>
579
+ <script
580
+ type="module"
581
+ src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-photo-grid.js"
582
+ ></script>
583
+ </head>
584
+ <body>
585
+ <site-page>
586
+ <h1>Photographs</h1>
587
+ <uvalib-lightbox url-param="photo">
588
+ <uvalib-photo-grid>
589
+ <a
590
+ href="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
591
+ data-caption="The Rotunda"
592
+ data-id="rotunda"
593
+ >
594
+ <img alt="The Rotunda" width="160" height="80" />
595
+ </a>
596
+ <a
597
+ href="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
598
+ data-caption="The Lawn"
599
+ data-id="lawn"
600
+ >
601
+ <img alt="The Lawn" width="80" height="80" />
602
+ </a>
603
+ </uvalib-photo-grid>
604
+ <p slot="details">Photographs of the University.</p>
605
+ </uvalib-lightbox>
606
+ </site-page>
607
+ </body>
608
+ </html>
609
+ ```
610
+
611
+ ## 9. Verification checklist
262
612
 
263
613
  Before finishing, load the page in a browser (or test) and confirm:
264
614
 
@@ -266,11 +616,17 @@ Before finishing, load the page in a browser (or test) and confirm:
266
616
  2. Exactly one `<main>` in the page, including inside open shadow roots (shadow mode puts it in `site-page`'s shadow root), and exactly one skip link.
267
617
  3. No `<script>`/`<link>` URL contains `/web-components/latest/` or `/cdn-v`; the URL pins `v1` or `vX.Y.Z`.
268
618
  4. No console errors and no failed network requests for the component files (including `v1/uvalib-alerts.js` from the alerts CDN, unless `no-alerts` is set).
269
- 5. An axe pass (for example `axe-core` or the axe browser extension) reports no new violations.
619
+ 5. Accessibility, as in [reference/accessibility-testing.md](reference/accessibility-testing.md):
620
+ - axe-core in Playwright, with Lighthouse's rules forced on plus the WCAG 2.1/2.2 AA and best-practice tags, reports **no violations at any impact level** on every page you changed, at desktop and phone widths, after the components upgrade (and in each open state: menus, dialogs, errors);
621
+ - Lighthouse CI scores accessibility 1 (and layout shift ≤ 0.05) on those pages;
622
+ - a keyboard-only pass (visible focus, skip link, Escape closes, focus returns) and a screen reader spot check found no problems.
623
+ If you cannot run one of these, say so explicitly instead of reporting the page as accessible.
270
624
  6. `no-shadow-dom` appears only where the host CSS is meant to own the styling.
271
625
  7. A full header shows the library main navigation (unless the site deliberately set `no-main-nav`), and the page has no second hand-built copy of it.
272
- 8. `color-scheme-switch` appears only where the user asked for dark mode and the site's own content supports it; if it is set, the page passes axe in both Light and Dark.
626
+ 8. `color-scheme-switch` appears only where the user asked for dark mode and the site's own content supports it; if it is set, the page passes the axe test in both Light and Dark.
627
+ 9. A sub-site's name is `site-name` on `<site-page>`, not a hand-built title bar; buttons and search boxes in the content use the `.uvalib-button` / `.uvalib-input` / `.uvalib-search-form` classes, toggles carry `aria-pressed`, and every field has a label.
628
+ 10. With analytics: no hand-written listener duplicates what the components already report, host-page tracking uses `data-uvalib-track`, and no event name holds a title, URL, search text or personal data.
273
629
 
274
- ## 9. Keeping this skill current
630
+ ## 10. Keeping this skill current
275
631
 
276
632
  This skill is a copy. `installed.json` next to this file records the package version it came from. When the user asks about updating it, or the page loads a newer component version than that, check it with `npx @uvalib/web-components@latest install-skill --check --dir <skills-dir>` (`<skills-dir>` is the folder that holds this skill, usually `.claude/skills`); it prints the update command when a newer release exists.
@@ -0,0 +1,170 @@
1
+ # Accessibility testing
2
+
3
+ UVA Library's web standard (Web Implementation Group, "Web Standards for UVA Library"): every page meets
4
+ **WCAG 2.2 AA at minimum and aims for AAA**; critical communications such as alerts meet AAA. The components
5
+ are tested to that bar. Keep it in everything you build around them: your own markup, styles and scripts
6
+ can still break it.
7
+
8
+ Test three ways, every time: automated axe in Playwright, Lighthouse, and a short manual pass. Run the
9
+ automated checks in Light and Dark when dark mode is on, at desktop and phone widths, and after the
10
+ components have upgraded.
11
+
12
+ ## 1. axe-core in Playwright, at least as strict as Lighthouse
13
+
14
+ Lighthouse's accessibility score is axe-core with the `wcag2a` and `wcag2aa` tags plus about 25 extra
15
+ rules, a few of which a default axe run leaves off (`target-size`, `identical-links-same-purpose`,
16
+ `table-fake-caption`, `td-has-header`). Run axe with those rules forced on and the WCAG 2.1/2.2 AA and
17
+ best-practice tags added, and fail on **every** impact level (minor included), so a page that passes this
18
+ test cannot lose Lighthouse accessibility points to axe.
19
+
20
+ ```bash
21
+ npm i -D @playwright/test @axe-core/playwright
22
+ ```
23
+
24
+ `tests/a11y.spec.mjs`:
25
+
26
+ ```js
27
+ import { test, expect } from '@playwright/test';
28
+ import AxeBuilder from '@axe-core/playwright';
29
+
30
+ // Lighthouse 12's axe rules on top of the wcag2a/wcag2aa tags (some are off in a default axe run).
31
+ const LIGHTHOUSE_RULES = [
32
+ 'accesskeys',
33
+ 'aria-allowed-role',
34
+ 'aria-conditional-attr',
35
+ 'aria-deprecated-role',
36
+ 'aria-dialog-name',
37
+ 'aria-prohibited-attr',
38
+ 'aria-text',
39
+ 'aria-treeitem-name',
40
+ 'empty-heading',
41
+ 'heading-order',
42
+ 'html-xml-lang-mismatch',
43
+ 'identical-links-same-purpose',
44
+ 'image-redundant-alt',
45
+ 'input-button-name',
46
+ 'label-content-name-mismatch',
47
+ 'landmark-one-main',
48
+ 'link-in-text-block',
49
+ 'meta-viewport',
50
+ 'select-name',
51
+ 'skip-link',
52
+ 'tabindex',
53
+ 'table-duplicate-name',
54
+ 'table-fake-caption',
55
+ 'target-size',
56
+ 'td-has-header',
57
+ ];
58
+
59
+ async function axe(page, { exclude = [] } = {}) {
60
+ // Audit the upgraded page, not the markup before the components render.
61
+ await page.waitForFunction(() => customElements.get('site-page') !== undefined);
62
+ await page.evaluate(() => document.querySelector('site-page')?.updateComplete);
63
+ let builder = new AxeBuilder({ page }).options({
64
+ runOnly: {
65
+ type: 'tag',
66
+ values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa', 'best-practice'],
67
+ },
68
+ rules: Object.fromEntries(LIGHTHOUSE_RULES.map((id) => [id, { enabled: true }])),
69
+ });
70
+ for (const selector of exclude) builder = builder.exclude(selector);
71
+ return builder.analyze();
72
+ }
73
+
74
+ const PAGES = ['./', './about/'];
75
+
76
+ for (const path of PAGES) {
77
+ for (const colorScheme of ['light', 'dark']) {
78
+ test(`${path}: no axe violations at any impact (${colorScheme})`, async ({ page }) => {
79
+ await page.emulateMedia({ colorScheme });
80
+ await page.goto(path);
81
+ const { violations } = await axe(page);
82
+ expect(
83
+ violations.map((v) => `${v.impact} ${v.id}: ${v.nodes.map((n) => n.target).join(', ')}`),
84
+ ).toEqual([]);
85
+ });
86
+ }
87
+ }
88
+ ```
89
+
90
+ `playwright.config.mjs`, desktop and phone:
91
+
92
+ ```js
93
+ import { defineConfig, devices } from '@playwright/test';
94
+ export default defineConfig({
95
+ testDir: 'tests',
96
+ use: { baseURL: process.env.BASE_URL ?? 'http://localhost:8080/' },
97
+ webServer: {
98
+ command: 'npm run preview -- --port 8080',
99
+ url: 'http://localhost:8080/',
100
+ reuseExistingServer: true,
101
+ },
102
+ projects: [
103
+ { name: 'desktop', use: { ...devices['Desktop Chrome'] } },
104
+ { name: 'phone', use: { ...devices['Pixel 7'] } },
105
+ ],
106
+ });
107
+ ```
108
+
109
+ Notes:
110
+
111
+ - Use relative paths (`'./'`, `'./about/'`) in `page.goto` when `baseURL` has a path (for example a GitHub Pages
112
+ project site): `'/'` goes to the host's root, not your site.
113
+ - Test the page with real content in each state that matters: an open menu or dialog, an error state, an
114
+ empty result. Axe only checks what is rendered.
115
+ - `exclude` is for third-party widgets you cannot change (a code editor, an embedded map). Exclude the
116
+ smallest selector, say why in a comment, and report the issue to its owner; never exclude the library's
117
+ own elements. An iframe showing another full page (a preview) makes landmark and heading rules compare
118
+ two documents; test that page on its own instead.
119
+ - Dark mode: when the page has `color-scheme-switch`, `emulateMedia({ colorScheme: 'dark' })` with the
120
+ System choice covers it. Contrast is checked per scheme.
121
+
122
+ ## 2. Lighthouse CI
123
+
124
+ Assert a perfect accessibility score (it rounds, so 1 means no failing weighted audit) and keep layout
125
+ shift low. `lighthouserc.json`:
126
+
127
+ ```json
128
+ {
129
+ "ci": {
130
+ "collect": {
131
+ "numberOfRuns": 3,
132
+ "url": ["http://localhost:8080/", "http://localhost:8080/about/"],
133
+ "startServerCommand": "npm run preview -- --port 8080",
134
+ "settings": { "onlyCategories": ["accessibility", "best-practices", "performance"] }
135
+ },
136
+ "assert": {
137
+ "assertions": {
138
+ "categories:accessibility": ["error", { "minScore": 1, "aggregationMethod": "median" }],
139
+ "categories:best-practices": ["error", { "minScore": 0.95, "aggregationMethod": "median" }],
140
+ "cumulative-layout-shift": [
141
+ "error",
142
+ { "maxNumericValue": 0.05, "aggregationMethod": "median" }
143
+ ]
144
+ }
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ ```bash
151
+ npx @lhci/cli autorun
152
+ ```
153
+
154
+ Run it in CI on every change (for example a GitHub Actions job on pull requests and pushes to main).
155
+ Lighthouse alone is not enough: it skips some rules and reports some checks as "manual"; the Playwright
156
+ test above is the stricter gate, Lighthouse adds layout shift and best practices.
157
+
158
+ ## 3. Manual checks (automated tools find about a third of problems)
159
+
160
+ - **Keyboard only:** Tab through the page. Every control is reachable, in a sensible order, with a visible
161
+ focus ring; the skip link is first and lands on `<main>`; menus and dialogs open, close with Escape, and
162
+ return focus where it came from; nothing traps focus.
163
+ - **Screen reader spot check:** VoiceOver (macOS/iOS) or NVDA (Windows). Headings outline the page, links
164
+ and buttons say what they do, images have useful alt text (or `alt=""` when decorative), status
165
+ messages are announced.
166
+ - **Zoom and reflow:** 200% zoom and a 320px-wide window: no horizontal scrolling, nothing cut off.
167
+ - **Motion and colour:** `prefers-reduced-motion` turns off non-essential motion; information is never
168
+ conveyed by colour alone; Windows High Contrast (forced colors) keeps borders and focus visible.
169
+ - **Content:** link text makes sense out of context, `aria-label` matches the visible text (so voice
170
+ control works), and the page has one `<h1>` with headings in order.