@uvalib/web-components 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +515 -47
- package/dist/base/url-param.d.ts +23 -0
- package/dist/base/url-param.js +49 -0
- package/dist/base/url-param.js.map +1 -0
- package/dist/base.css +289 -1
- package/dist/components/uvalib-card/UvalibCard.d.ts +19 -5
- package/dist/components/uvalib-card/UvalibCard.js +112 -9
- package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
- package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +156 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js +747 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.d.ts +1 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.js +4 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.js.map +1 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +148 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +1248 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.d.ts +1 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js +4 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js.map +1 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +8 -1
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-lightbox/media.d.ts +1 -18
- package/dist/components/uvalib-lightbox/media.js +1 -42
- package/dist/components/uvalib-lightbox/media.js.map +1 -1
- package/dist/components/uvalib-pager/UvalibPager.d.ts +58 -4
- package/dist/components/uvalib-pager/UvalibPager.js +232 -8
- package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +27 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +192 -26
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
- package/dist/components/uvalib-results-count/UvalibResultsCount.d.ts +62 -0
- package/dist/components/uvalib-results-count/UvalibResultsCount.js +208 -0
- package/dist/components/uvalib-results-count/UvalibResultsCount.js.map +1 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.d.ts +1 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.js +4 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.js.map +1 -0
- package/dist/components/uvalib-tabs/UvalibTabs.d.ts +127 -0
- package/dist/components/uvalib-tabs/UvalibTabs.js +821 -0
- package/dist/components/uvalib-tabs/UvalibTabs.js.map +1 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.d.ts +1 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.js +4 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.js.map +1 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +89 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.js +411 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.d.ts +1 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.js +4 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.js.map +1 -0
- package/dist/custom-elements.json +7140 -2630
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/base.js +35 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +4 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +2 -0
- package/dist/styles/controls.js.map +1 -1
- package/dist/styles/results.d.ts +1 -0
- package/dist/styles/results.js +257 -0
- package/dist/styles/results.js.map +1 -0
- package/dist/tokens.css +4 -0
- package/dist-cdn/base.css +289 -1
- package/dist-cdn/chunks/{base-CAFQWnZG.js → base-p5pk0vb2.js} +36 -2
- package/dist-cdn/chunks/{base-CAFQWnZG.js.map → base-p5pk0vb2.js.map} +1 -1
- package/dist-cdn/chunks/inline-copy-BANQSMIR.js +69 -0
- package/dist-cdn/chunks/inline-copy-BANQSMIR.js.map +1 -0
- package/dist-cdn/chunks/{site-header-C9V7Wuw2.js → site-header-BlOYvQg1.js} +5 -1
- package/dist-cdn/chunks/site-header-BlOYvQg1.js.map +1 -0
- package/dist-cdn/chunks/source-children-BHsDwCvL.js +53 -0
- package/dist-cdn/chunks/source-children-BHsDwCvL.js.map +1 -0
- package/dist-cdn/chunks/url-param-C1sk_F1d.js +28 -0
- package/dist-cdn/chunks/url-param-C1sk_F1d.js.map +1 -0
- package/dist-cdn/custom-elements.json +7140 -2630
- package/dist-cdn/manifest.json +7 -2
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-page.js +2 -2
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +179 -19
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +220 -6
- package/dist-cdn/tokens.css +4 -0
- package/dist-cdn/uvalib-card.js +94 -20
- package/dist-cdn/uvalib-card.js.map +1 -1
- package/dist-cdn/uvalib-chip-group.js +496 -0
- package/dist-cdn/uvalib-chip-group.js.map +1 -0
- package/dist-cdn/uvalib-contents.js +2 -1
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-date-histogram.js +850 -0
- package/dist-cdn/uvalib-date-histogram.js.map +1 -0
- package/dist-cdn/uvalib-lightbox.js +26 -48
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-metadata.js +2 -1
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pager.js +141 -7
- package/dist-cdn/uvalib-pager.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +121 -19
- package/dist-cdn/uvalib-photo-grid.js.map +1 -1
- package/dist-cdn/uvalib-results-count.js +101 -0
- package/dist-cdn/uvalib-results-count.js.map +1 -0
- package/dist-cdn/uvalib-tabs.js +436 -0
- package/dist-cdn/uvalib-tabs.js.map +1 -0
- package/dist-cdn/uvalib-tag-list.js +267 -0
- package/dist-cdn/uvalib-tag-list.js.map +1 -0
- package/package.json +24 -3
- package/skills/uvalib-web-components/SKILL.md +179 -19
- package/skills/uvalib-web-components/reference/components.md +220 -6
- package/dist-cdn/chunks/site-header-C9V7Wuw2.js.map +0 -1
- package/dist-cdn/chunks/source-children-RuAec527.js +0 -119
- package/dist-cdn/chunks/source-children-RuAec527.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: uvalib-web-components
|
|
3
|
-
description: Use when building or editing UVA Library web pages or sites
|
|
3
|
+
description: Use when building or editing UVA Library web pages or sites with @uvalib/web-components: the header, footer, page wrapper and other page chrome (<site-page>, <site-header>, <site-main-nav>, <site-footer>, <site-alerts>, <site-analytics>/<uvalib-analytics>, <site-style>), and other uvalib-* components (breadcrumbs, cards, pager, tabs, contents, metadata, chips, tags, results count, filter, date range, date histogram, lightbox, photo grid, Pagefind search), the library hours, events and bento-box elements (e.g. <uvalib-card>, <uvalib-chip-group>, <library-weekly-hours>), base.css classes, or script/link URLs on unpkg.internal.lib.virginia.edu (incl. 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, requesting components via GitHub issues, 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), 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
|
|
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), `<uvalib-tabs>` (tabbed panels) and `<site-alerts>` (the live library alerts, which `<site-page>` shows itself). It also ships search-page components, `<uvalib-filter>`, `<uvalib-date-range>` and `<uvalib-date-histogram>`, and `<uvalib-chip-group>` for segmented controls, filter chips and suggestion chips (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, and `<uvalib-tag-list>`, `<uvalib-results-count>` and `base.css`'s badge, toolbar, empty-state and skeleton classes for results lists (section 6), and `<uvalib-lightbox>` 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
|
|
|
@@ -31,7 +31,7 @@ Loading rules:
|
|
|
31
31
|
|
|
32
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.
|
|
33
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.
|
|
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.
|
|
34
|
+
- npm: the define entries (`@uvalib/web-components/site-page.js`, `site-header.js`, `site-main-nav.js`, `site-footer.js`, `site-analytics.js`, `uvalib-analytics.js`, `site-style.js`, `uvalib-breadcrumbs.js`, `uvalib-card.js`, `uvalib-card-grid.js`, `uvalib-pager.js`, `uvalib-contents.js`, `uvalib-metadata.js`, `site-alerts.js`, `uvalib-filter.js`, `uvalib-date-range.js`, `uvalib-date-histogram.js`, `site-hours-section.js`, `library-weekly-hours.js`, `library-hours-setup.js`, `events-section.js`, `bento-box.js`, `uvalib-pagefind-search.js`, `uvalib-lightbox.js`, `uvalib-photo-grid.js`, `uvalib-tabs.js`, `uvalib-chip-group.js`, `uvalib-tag-list.js`, `uvalib-results-count.js`) register the element (`bento-box.js` also registers its four sections, `<catalog-section>`, `<articles-section>`, `<libguides-section>` and `<website-section>`). Importing the package root (`@uvalib/web-components`) gives the classes only and registers nothing. If you use the `SitePage` class directly, also import the header and footer define entries.
|
|
35
35
|
- Do not load the same component from both the CDN and npm on one page.
|
|
36
36
|
|
|
37
37
|
## 2. Required page structure
|
|
@@ -40,7 +40,7 @@ Loading rules:
|
|
|
40
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>`.
|
|
41
41
|
- Sidebars and article content go inside `<site-page>` as ordinary elements (use `<nav aria-label="...">` for navigation, no ARIA menu roles).
|
|
42
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
|
|
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, including an `actions` slot row (“Read the story”, “Photos (132)”). Do not put that row in a clickable card: the card link covers it, and the component warns. `media-shape="circle"` draws a person or avatar as a circle and keeps the image alt; the count badge still sits on it. An image needs a real alt, or `alt=""` when the heading already names it. Previous/next sections, numbered pages, or `mode="load-more"` (a Load more button and “Showing N of M”) are one `<uvalib-pager>` (`uvalib-pager.js`); a second pager on the same page needs its own `label`. Load more fires `load-more` (`detail: { page }`, the next page). Call `loaded(firstNew)`, or set `for` to the list id and call `loaded()`, so focus moves to the new item. `<uvalib-tabs>` (`uvalib-tabs.js`) is a tab set: each child with `data-tab` is a panel, or pair `<button slot="tab">` with panels. Arrow keys move, Home and End jump, and `activation="manual"` waits for Enter or Space. `url-param` (or `url-param="hash"`) makes the selected tab linkable and Back restores it. In a single-page app, listen for `uvalib-card-navigate` and `uvalib-pager-navigate` and call `preventDefault()` to route in place.
|
|
44
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
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.
|
|
46
46
|
- Content for a band above the footer: put an element with `slot="pre-footer"` inside `<site-page>`.
|
|
@@ -221,7 +221,7 @@ import '@uvalib/web-components/tokens.css'; // optional: tokens for your own CSS
|
|
|
221
221
|
|
|
222
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
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
|
|
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, page numbers and Load more; tab changes (the tab's label); alerts (impressions, dismiss, links, errors); event clicks; See all hours, week changes; filter facets, scopes and See more/less; date-range changes; histogram selections (`<from>–<to>` when both ends are ISO dates, otherwise `other`); bento searches, result and See all clicks, retries; lightbox opens, next, previous and full size (the name is `image N`, never the URL or the caption); load errors; and tag-list clicks and Show all (`list N`, or the label with `track-label`, and the tag's place; never the tag text). `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing. The README's "Analytics" section has the full table.
|
|
225
225
|
|
|
226
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
227
|
|
|
@@ -304,8 +304,10 @@ A collection grid, a photo card and previous/next sections. The card's `href` is
|
|
|
304
304
|
<uvalib-card href="#rotunda">
|
|
305
305
|
<img
|
|
306
306
|
slot="media"
|
|
307
|
-
alt="
|
|
308
|
-
src="
|
|
307
|
+
alt="The Rotunda and Lawn, about 1910"
|
|
308
|
+
src="https://iiif.lib.virginia.edu/iiif/uva-lib:1043731/full/!800,600/0/default.jpg"
|
|
309
|
+
width="5820"
|
|
310
|
+
height="4668"
|
|
309
311
|
/>
|
|
310
312
|
<span slot="badge">13 photos</span>
|
|
311
313
|
<span slot="heading">Rotunda</span>
|
|
@@ -409,12 +411,13 @@ A record page with its metadata and a contents sidebar (the sidebar is an ordina
|
|
|
409
411
|
|
|
410
412
|
## 6. Search facets
|
|
411
413
|
|
|
412
|
-
For a search results page that needs a checkbox facet
|
|
414
|
+
For a search results page that needs a checkbox facet, a date-range picker or date counts as bars, use `<uvalib-filter>`, `<uvalib-date-range>` and `<uvalib-date-histogram>` instead of hand-built fieldsets, sliders and charts. They are not page chrome: use them inside `<site-page>` alongside your own results, and load each from its own script (`uvalib-filter.js`, `uvalib-date-range.js`, `uvalib-date-histogram.js`; npm: `@uvalib/web-components/uvalib-filter.js`).
|
|
413
415
|
|
|
414
416
|
- `<uvalib-filter>`: set `filter` (`{ name, title, position, buckets: [{ key, doc_count, selected }] }`), `value` (selected keys), and optionally `scopes` (`[{ value, label }]` chips), `scopeValue` and `scopesLabel`. `limit="5"` shows five buckets with See more / See less. Events: `filter-change` (`detail: { name, value }`) and `scope-change` (`detail: { value }`).
|
|
415
417
|
- `<uvalib-date-range>`: `min` and `max` (`YYYY-MM-DD`) are required; without them nothing renders and a console warning is logged. Set `value` to `[start, end]`; `label` renames the legend. Event: `date-range-change` (`detail: { value: [start, end] }`).
|
|
416
|
-
-
|
|
417
|
-
-
|
|
418
|
+
- `<uvalib-date-histogram>`: set `items` (`[{ date: 'YYYY' | 'YYYY-MM', count }]`) or a child `<table>` (two columns, date and count, or a year-by-month grid). The table is the no-JS fallback and stays available; "Show as table" shows the same counts. `granularity` is `month` (bars grouped by year) or `year`. `unit` (default `items`) names each bar, for example "October 2015: 5,311 photos". Arrow keys move between bars; Enter or Space selects. `selected` is one bucket or a range (`2015-10` or `2015-10/2016-03`). A choice fires `select` (`detail: { from, to }` as ISO dates). `range-for` names a `<uvalib-date-range>`: a bar sets its `value`, and `date-range-change` highlights the bars the range covers. Setting `selected` in script updates that date range and does not fire `select`. Setting the date range's `value` in script does not update the histogram unless the histogram connects afterwards or the range fires `date-range-change`. A value equal to that range's own `min` and `max` selects nothing. `scale="log"` sizes bars by log(count + 1). On a narrow screen month rows scroll inside the chart ("Scroll sideways to see more."); year bars wrap. `variant="strip"` is a non-interactive per-year row (`role="img"`) for a card. A date that is not a bucket at that granularity is a chip. Analytics: one `select` named `<from>–<to>` when both ends are ISO dates, otherwise `other`; nothing when the selection is cleared, set in script, or restored from a date range.
|
|
419
|
+
- The filter and the date range are controlled: update `value` / `scopeValue` from your own state after each event, and re-run your search.
|
|
420
|
+
- Do not hard-code ids on the filter's or date range's inner inputs; ids are unique per instance and the markup is internal.
|
|
418
421
|
|
|
419
422
|
```html snippet
|
|
420
423
|
<!doctype html>
|
|
@@ -468,6 +471,58 @@ For a search results page that needs a checkbox facet or a date-range picker, us
|
|
|
468
471
|
</html>
|
|
469
472
|
```
|
|
470
473
|
|
|
474
|
+
### Chips
|
|
475
|
+
|
|
476
|
+
A year rail, a category filter, a sort or view toggle, or "Try:" suggestions are one `<uvalib-chip-group>` (`uvalib-chip-group.js`), never hand-built pill buttons or a `role="tablist"` (it is not tabs).
|
|
477
|
+
|
|
478
|
+
- `label` (required) names the group. `mode="single"` (default): one value, radios drawn as chips; arrow keys select. `mode="multi"`: toggles with `aria-pressed`, `value` an array. `mode="links"`: `<a href>` children (or buttons) that fire `select`, with no selected state.
|
|
479
|
+
- Chips are children (`<button value="2005" data-count="213">2005</button>`, `<a href>` for links) or the `items` property (`[{ value, label, count?, href?, disabled? }]`). Counts go in `data-count`/`count`, not in the label text; `count-label` is the word read after them ("2005, 213 shoots").
|
|
480
|
+
- Listen for `change` (`detail: { value }`); setting `value` from your state fires nothing. In a single-page app cancel `select` to route a link chip in place.
|
|
481
|
+
- `segmented` for a short sort or view toggle (one row), `scroll` for a long rail such as years (one scrolling row). `url-param="year"` keeps the value in the address and follows Back and Forward (then `change` has `restored: true`).
|
|
482
|
+
- It reports `change` (`<label>: <chip label>`, with the count) and `select` (the label only) to analytics itself: do not add your own tracking.
|
|
483
|
+
|
|
484
|
+
```html snippet
|
|
485
|
+
<!doctype html>
|
|
486
|
+
<html lang="en">
|
|
487
|
+
<head>
|
|
488
|
+
<meta charset="utf-8" />
|
|
489
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
490
|
+
<title>Browse by year</title>
|
|
491
|
+
<link
|
|
492
|
+
rel="stylesheet"
|
|
493
|
+
href="https://unpkg.internal.lib.virginia.edu/web-components/v1/base.css"
|
|
494
|
+
/>
|
|
495
|
+
<script
|
|
496
|
+
type="module"
|
|
497
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/site-page.js"
|
|
498
|
+
></script>
|
|
499
|
+
<script
|
|
500
|
+
type="module"
|
|
501
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-chip-group.js"
|
|
502
|
+
></script>
|
|
503
|
+
</head>
|
|
504
|
+
<body>
|
|
505
|
+
<site-page>
|
|
506
|
+
<h1>Browse by year</h1>
|
|
507
|
+
<uvalib-chip-group id="years" label="Year" count-label="shoots" value="" scroll>
|
|
508
|
+
<button value="" data-count="3694">All Years</button>
|
|
509
|
+
<button value="2004" data-count="213">2004</button>
|
|
510
|
+
<button value="2005" data-count="461">2005</button>
|
|
511
|
+
</uvalib-chip-group>
|
|
512
|
+
<uvalib-chip-group label="Sort by" segmented value="photos">
|
|
513
|
+
<button value="photos">Most photos</button>
|
|
514
|
+
<button value="date">Date</button>
|
|
515
|
+
</uvalib-chip-group>
|
|
516
|
+
</site-page>
|
|
517
|
+
<script type="module">
|
|
518
|
+
document.querySelector('#years').addEventListener('change', (e) => {
|
|
519
|
+
console.log(e.detail.value); // re-run your search for that year
|
|
520
|
+
});
|
|
521
|
+
</script>
|
|
522
|
+
</body>
|
|
523
|
+
</html>
|
|
524
|
+
```
|
|
525
|
+
|
|
471
526
|
### Static-site search (Pagefind)
|
|
472
527
|
|
|
473
528
|
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:
|
|
@@ -515,6 +570,96 @@ A static site (11ty, Jekyll, a generated collection) that searches with [Pagefin
|
|
|
515
570
|
</html>
|
|
516
571
|
```
|
|
517
572
|
|
|
573
|
+
### Results toolbar, badges and tags
|
|
574
|
+
|
|
575
|
+
For a results list of your own (a collection, a Virgo-like listing, a photo archive), use these instead of hand-made pills, counts and spinners. Classes are in `base.css`; the two elements load from `uvalib-tag-list.js` and `uvalib-results-count.js`.
|
|
576
|
+
|
|
577
|
+
- Badges: `.uvalib-badge` (neutral) with `--category` (the card chip), `--count` (on media, inside `.uvalib-media`; several in `.uvalib-media__badges`), `--status` plus `--success` / `--warning` / `--danger` / `--info`, `--new`, and `--body` for body size. A status badge always says its state in words; an icon in it gets `aria-hidden="true"`. Inside `<uvalib-card>` use its `badge` and `chip` slots instead.
|
|
578
|
+
- Toolbar: `.uvalib-toolbar` around `.uvalib-toolbar__field` (label over control; `--grow` takes the spare width), `.uvalib-toolbar__group` (`role="group"` with an `aria-label`, `.uvalib-button` toggles with `aria-pressed`) and `.uvalib-toolbar__summary`. It stacks on phones.
|
|
579
|
+
- `<uvalib-results-count shown total noun singular>`: the visible “Showing 48 of 3,694 shoots”, announced politely once it settles (1 s); never the first render, but the first count after an empty one (data loading) is. Leave `shown`/`total` unset while loading. Set `shown` and `total` after every filter change; do not add your own live region for the count. Not beside `<bento-box>` or `<uvalib-pagefind-search>`, which announce their own.
|
|
580
|
+
- `<uvalib-tag-list label="Subjects" track-label limit="8" href-template="/search?q={tag}">` with `<a href>` or `<span>` children (or `items`): links are outlined pills, plain tags filled chips; a child's `lang`/`dir` and inline markup are kept; `limit` adds “Show all N”. Always set `label` (`hide-label` hides it visually). It reports tag clicks as `list N` and the tag's position, never the tag text; add `track-label` only when the label is fixed text you wrote, never one filled from a record.
|
|
581
|
+
- No results: `.uvalib-empty-state` (decorative `__icon`, a heading, a sentence, one action). Loading: `.uvalib-skeleton` (give it a height, or `--media` for 3:2) and `.uvalib-skeleton-text` (one line), sized like what replaces them, inside an `aria-hidden="true"` container, with `aria-busy="true"` on the region while it loads.
|
|
582
|
+
|
|
583
|
+
```html snippet
|
|
584
|
+
<!doctype html>
|
|
585
|
+
<html lang="en">
|
|
586
|
+
<head>
|
|
587
|
+
<meta charset="utf-8" />
|
|
588
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
589
|
+
<title>Shoots</title>
|
|
590
|
+
<link
|
|
591
|
+
rel="stylesheet"
|
|
592
|
+
href="https://unpkg.internal.lib.virginia.edu/web-components/v1/base.css"
|
|
593
|
+
/>
|
|
594
|
+
<script
|
|
595
|
+
type="module"
|
|
596
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/site-page.js"
|
|
597
|
+
></script>
|
|
598
|
+
<script
|
|
599
|
+
type="module"
|
|
600
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-tag-list.js"
|
|
601
|
+
></script>
|
|
602
|
+
<script
|
|
603
|
+
type="module"
|
|
604
|
+
src="https://unpkg.internal.lib.virginia.edu/web-components/v1/uvalib-results-count.js"
|
|
605
|
+
></script>
|
|
606
|
+
</head>
|
|
607
|
+
<body>
|
|
608
|
+
<site-page>
|
|
609
|
+
<h1>Shoots</h1>
|
|
610
|
+
<div class="uvalib-toolbar">
|
|
611
|
+
<div class="uvalib-toolbar__field uvalib-toolbar__field--grow">
|
|
612
|
+
<label for="filter">Filter shoots</label>
|
|
613
|
+
<input class="uvalib-input" id="filter" type="search" />
|
|
614
|
+
</div>
|
|
615
|
+
<uvalib-results-count
|
|
616
|
+
class="uvalib-toolbar__summary"
|
|
617
|
+
shown="2"
|
|
618
|
+
total="2"
|
|
619
|
+
noun="shoots"
|
|
620
|
+
singular="shoot"
|
|
621
|
+
></uvalib-results-count>
|
|
622
|
+
</div>
|
|
623
|
+
<ul id="shoots">
|
|
624
|
+
<li>
|
|
625
|
+
Rotunda in snow
|
|
626
|
+
<span class="uvalib-badge uvalib-badge--category">Grounds</span>
|
|
627
|
+
<span class="uvalib-badge uvalib-badge--status uvalib-badge--success">Done</span>
|
|
628
|
+
</li>
|
|
629
|
+
<li>
|
|
630
|
+
Faculty portraits
|
|
631
|
+
<span class="uvalib-badge uvalib-badge--category">Faculty & Staff Portraits</span>
|
|
632
|
+
</li>
|
|
633
|
+
</ul>
|
|
634
|
+
<div class="uvalib-empty-state" id="empty" hidden>
|
|
635
|
+
<h2>No shoots match</h2>
|
|
636
|
+
<p>Try another word.</p>
|
|
637
|
+
</div>
|
|
638
|
+
<uvalib-tag-list label="Subjects" href-template="/search?q={tag}">
|
|
639
|
+
<span>Rotunda</span>
|
|
640
|
+
<span>Snow</span>
|
|
641
|
+
</uvalib-tag-list>
|
|
642
|
+
</site-page>
|
|
643
|
+
<script type="module">
|
|
644
|
+
const filter = document.querySelector('#filter');
|
|
645
|
+
const count = document.querySelector('uvalib-results-count');
|
|
646
|
+
const items = [...document.querySelectorAll('#shoots li')];
|
|
647
|
+
filter.addEventListener('input', () => {
|
|
648
|
+
const q = filter.value.toLowerCase();
|
|
649
|
+
let shown = 0;
|
|
650
|
+
for (const li of items) {
|
|
651
|
+
li.hidden = !li.textContent.toLowerCase().includes(q);
|
|
652
|
+
if (!li.hidden) shown++;
|
|
653
|
+
}
|
|
654
|
+
count.shown = shown;
|
|
655
|
+
count.total = shown;
|
|
656
|
+
document.querySelector('#empty').hidden = shown > 0;
|
|
657
|
+
});
|
|
658
|
+
</script>
|
|
659
|
+
</body>
|
|
660
|
+
</html>
|
|
661
|
+
```
|
|
662
|
+
|
|
518
663
|
## 7. Library hours
|
|
519
664
|
|
|
520
665
|
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.".
|
|
@@ -555,7 +700,7 @@ Use these instead of a hand-built gallery or a carousel. There is no autoplay.
|
|
|
555
700
|
- `<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
701
|
- `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
702
|
- 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.
|
|
703
|
+
- `<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 `<span slot="badge">` inside the item, or `data-badge` on it (“seq”, “3 photos”), is drawn over the thumbnail and stays in the accessible name; an existing `aria-label` gains the badge text. A grid inside a lightbox opens the viewer. The grid reports no analytics.
|
|
559
704
|
|
|
560
705
|
```html snippet
|
|
561
706
|
<!doctype html>
|
|
@@ -587,21 +732,36 @@ Use these instead of a hand-built gallery or a carousel. There is no autoplay.
|
|
|
587
732
|
<uvalib-lightbox url-param="photo">
|
|
588
733
|
<uvalib-photo-grid>
|
|
589
734
|
<a
|
|
590
|
-
href="
|
|
591
|
-
data-caption="
|
|
592
|
-
data-id="
|
|
735
|
+
href="https://iiif.lib.virginia.edu/iiif/uva-lib:1042806/full/!1600,1600/0/default.jpg"
|
|
736
|
+
data-caption="Rotunda, north front in snow, 1914"
|
|
737
|
+
data-id="1042806"
|
|
593
738
|
>
|
|
594
|
-
<img
|
|
739
|
+
<img
|
|
740
|
+
src="https://iiif.lib.virginia.edu/iiif/uva-lib:1042806/full/,440/0/default.jpg"
|
|
741
|
+
alt="Rotunda, north front in snow, 1914"
|
|
742
|
+
width="5805"
|
|
743
|
+
height="4729"
|
|
744
|
+
loading="lazy"
|
|
745
|
+
/>
|
|
595
746
|
</a>
|
|
596
747
|
<a
|
|
597
|
-
href="
|
|
748
|
+
href="https://iiif.lib.virginia.edu/iiif/uva-lib:1049095/full/!1600,1600/0/default.jpg"
|
|
598
749
|
data-caption="The Lawn"
|
|
599
|
-
data-id="
|
|
750
|
+
data-id="1049095"
|
|
600
751
|
>
|
|
601
|
-
<img
|
|
752
|
+
<img
|
|
753
|
+
src="https://iiif.lib.virginia.edu/iiif/uva-lib:1049095/full/,440/0/default.jpg"
|
|
754
|
+
alt="The Lawn"
|
|
755
|
+
width="5867"
|
|
756
|
+
height="4668"
|
|
757
|
+
loading="lazy"
|
|
758
|
+
/>
|
|
602
759
|
</a>
|
|
603
760
|
</uvalib-photo-grid>
|
|
604
|
-
<p slot="details">
|
|
761
|
+
<p slot="details">
|
|
762
|
+
Holsinger Studio Collection (MSS 9862), Albert and Shirley Small Special Collections
|
|
763
|
+
Library, University of Virginia.
|
|
764
|
+
</p>
|
|
605
765
|
</uvalib-lightbox>
|
|
606
766
|
</site-page>
|
|
607
767
|
</body>
|