@uvalib/web-components 1.9.0 → 1.11.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 +39 -0
- package/README.md +277 -18
- package/bin/install-skill.mjs +174 -54
- package/dist/base.css +121 -2
- package/dist/components/uvalib-contents/UvalibContents.d.ts +66 -2
- package/dist/components/uvalib-contents/UvalibContents.js +277 -29
- package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
- package/dist/components/uvalib-list-filter/UvalibListFilter.d.ts +162 -0
- package/dist/components/uvalib-list-filter/UvalibListFilter.js +685 -0
- package/dist/components/uvalib-list-filter/UvalibListFilter.js.map +1 -0
- package/dist/components/uvalib-list-filter/uvalib-list-filter.d.ts +1 -0
- package/dist/components/uvalib-list-filter/uvalib-list-filter.js +4 -0
- package/dist/components/uvalib-list-filter/uvalib-list-filter.js.map +1 -0
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +54 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +230 -3
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
- package/dist/custom-elements.json +7757 -6209
- package/dist/edition.css +758 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pagefind.css +144 -0
- package/dist/styles/base.js +78 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/controls.js +2 -0
- package/dist/styles/controls.js.map +1 -1
- package/dist/styles/edition.d.ts +1 -0
- package/dist/styles/edition.js +747 -0
- package/dist/styles/edition.js.map +1 -0
- package/dist/styles/hidden.js +2 -0
- package/dist/styles/hidden.js.map +1 -1
- package/dist/styles/layout.d.ts +1 -0
- package/dist/styles/layout.js +92 -0
- package/dist/styles/layout.js.map +1 -0
- package/dist/styles/pagefind.js +150 -0
- package/dist/styles/pagefind.js.map +1 -1
- package/dist-cdn/base.css +121 -2
- package/dist-cdn/chunks/{base-CHMHBPeI.js → base-DmImIMld.js} +79 -2
- package/dist-cdn/chunks/base-DmImIMld.js.map +1 -0
- package/dist-cdn/custom-elements.json +7757 -6209
- package/dist-cdn/edition.css +758 -0
- package/dist-cdn/manifest.json +5 -3
- package/dist-cdn/pagefind.css +144 -0
- package/dist-cdn/site-page.js +1 -1
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +29 -8
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +65 -4
- package/dist-cdn/uvalib-contents.js +185 -47
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-list-filter.js +451 -0
- package/dist-cdn/uvalib-list-filter.js.map +1 -0
- package/dist-cdn/uvalib-pagefind-search.js +149 -49
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
- package/package.json +6 -1
- package/skills/uvalib-web-components/SKILL.md +29 -8
- package/skills/uvalib-web-components/reference/components.md +65 -4
- package/dist-cdn/chunks/base-CHMHBPeI.js.map +0 -1
package/dist-cdn/manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.11.0",
|
|
3
3
|
"elements": {
|
|
4
4
|
"site-page": "site-page.js",
|
|
5
5
|
"site-header": "site-header.js",
|
|
@@ -36,12 +36,14 @@
|
|
|
36
36
|
"uvalib-filter-drawer": "uvalib-filter-drawer.js",
|
|
37
37
|
"uvalib-back-to-top": "uvalib-back-to-top.js",
|
|
38
38
|
"uvalib-dialog": "uvalib-dialog.js",
|
|
39
|
-
"uvalib-citation": "uvalib-citation.js"
|
|
39
|
+
"uvalib-citation": "uvalib-citation.js",
|
|
40
|
+
"uvalib-list-filter": "uvalib-list-filter.js"
|
|
40
41
|
},
|
|
41
42
|
"styles": [
|
|
42
43
|
"tokens.css",
|
|
43
44
|
"base.css",
|
|
44
|
-
"pagefind.css"
|
|
45
|
+
"pagefind.css",
|
|
46
|
+
"edition.css"
|
|
45
47
|
],
|
|
46
48
|
"modules": [
|
|
47
49
|
"analytics.js"
|
package/dist-cdn/pagefind.css
CHANGED
|
@@ -365,6 +365,138 @@
|
|
|
365
365
|
font-weight: 700;
|
|
366
366
|
line-height: 1.5;
|
|
367
367
|
}
|
|
368
|
+
/* While a search from the URL loads (issue #37): at least a screen's height, so what follows
|
|
369
|
+
stays below the fold, and placeholder results in place of Pagefind's results area until
|
|
370
|
+
they are drawn. A page may set searching in its HTML, so this holds from first paint. */
|
|
371
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]) {
|
|
372
|
+
min-block-size: 100vh;
|
|
373
|
+
}
|
|
374
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]) .pagefind-ui__drawer {
|
|
375
|
+
display: none;
|
|
376
|
+
}
|
|
377
|
+
/* Before the element's script runs: the same placeholders, drawn as still bars where the
|
|
378
|
+
label, field, results message and rows will be (::before the message, ::after the rows,
|
|
379
|
+
each row a repeating tile of gradient bars; with show-sub-results, two sections a row). */
|
|
380
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined) {
|
|
381
|
+
--_bar: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));
|
|
382
|
+
--_top: calc(1.5em + 0.35rem + 56px + 1.25rem);
|
|
383
|
+
--_msg: calc(1.95rem + 1.5em);
|
|
384
|
+
--_row: calc(1px + 4.41rem + 4.5em);
|
|
385
|
+
/* A row: its top border, title and short last line (60% wide), then two full lines. */
|
|
386
|
+
--_l: calc(1px + 3.16rem + 0.25em);
|
|
387
|
+
--_rows:
|
|
388
|
+
linear-gradient(var(--_bar) 0 1px, transparent 0),
|
|
389
|
+
linear-gradient(transparent 0 calc(1px + 1.43rem), var(--_bar) 0 calc(1px + 2.63rem), transparent 0 calc(var(--_l) + 3em), var(--_bar) 0 calc(var(--_l) + 4em), transparent 0),
|
|
390
|
+
linear-gradient(transparent 0 calc(var(--_l)), var(--_bar) 0 calc(var(--_l) + 1em), transparent 0 calc(var(--_l) + 1.5em), var(--_bar) 0 calc(var(--_l) + 2.5em), transparent 0);
|
|
391
|
+
--_sizes: 100% var(--_row), 60% var(--_row), 100% var(--_row);
|
|
392
|
+
}
|
|
393
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined)[label-hidden] {
|
|
394
|
+
--_top: calc(56px + 1.25rem);
|
|
395
|
+
}
|
|
396
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined)::before,
|
|
397
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined)::after {
|
|
398
|
+
content: '';
|
|
399
|
+
display: block;
|
|
400
|
+
background-repeat: no-repeat;
|
|
401
|
+
}
|
|
402
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined)::before {
|
|
403
|
+
/* No margin: it would collapse with the margin above the element. */
|
|
404
|
+
block-size: calc(var(--_top) + var(--_msg));
|
|
405
|
+
background-image: linear-gradient(var(--_bar) 0 0);
|
|
406
|
+
background-position: 0 calc(var(--_top) + 0.6rem + 0.25em);
|
|
407
|
+
background-size: min(14rem, 70%) 1em;
|
|
408
|
+
}
|
|
409
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined)::after {
|
|
410
|
+
block-size: calc(100vh - var(--_top) - var(--_msg));
|
|
411
|
+
background-repeat: repeat-y;
|
|
412
|
+
background-image: var(--_rows);
|
|
413
|
+
background-size: var(--_sizes);
|
|
414
|
+
}
|
|
415
|
+
/* Each section: a 3px bar beside a title and two lines (the last 60%), 0.75rem below. */
|
|
416
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined)[show-sub-results] {
|
|
417
|
+
--_row: calc(1px + 8.51rem + 10.5em);
|
|
418
|
+
--_s: calc(1px + 3.91rem + 4.5em);
|
|
419
|
+
--_t: calc(var(--_s) + 2.05rem + 3em);
|
|
420
|
+
}
|
|
421
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined)[show-sub-results]::after {
|
|
422
|
+
--_in: calc(100% - 1rem - 3px);
|
|
423
|
+
background-image:
|
|
424
|
+
var(--_rows),
|
|
425
|
+
linear-gradient(transparent 0 calc(var(--_s)), var(--_bar) 0 calc(var(--_s) + 1.3rem + 3em), transparent 0 calc(var(--_t)), var(--_bar) 0 calc(var(--_t) + 1.3rem + 3em), transparent 0),
|
|
426
|
+
linear-gradient(transparent 0 calc(var(--_s) + 0.15rem), var(--_bar) 0 calc(var(--_s) + 1.15rem), transparent 0 calc(var(--_t) + 0.15rem), var(--_bar) 0 calc(var(--_t) + 1.15rem), transparent 0),
|
|
427
|
+
linear-gradient(transparent 0 calc(var(--_s) + 1.3rem + 0.25em), var(--_bar) 0 calc(var(--_s) + 1.3rem + 1.25em), transparent 0 calc(var(--_t) + 1.3rem + 0.25em), var(--_bar) 0 calc(var(--_t) + 1.3rem + 1.25em), transparent 0),
|
|
428
|
+
linear-gradient(transparent 0 calc(var(--_s) + 1.3rem + 1.75em), var(--_bar) 0 calc(var(--_s) + 1.3rem + 2.75em), transparent 0 calc(var(--_t) + 1.3rem + 1.75em), var(--_bar) 0 calc(var(--_t) + 1.3rem + 2.75em), transparent 0);
|
|
429
|
+
background-position:
|
|
430
|
+
0 0,
|
|
431
|
+
0 0,
|
|
432
|
+
0 0,
|
|
433
|
+
0 0,
|
|
434
|
+
calc(1rem + 3px) 0,
|
|
435
|
+
calc(1rem + 3px) 0,
|
|
436
|
+
calc(1rem + 3px) 0;
|
|
437
|
+
background-size:
|
|
438
|
+
var(--_sizes),
|
|
439
|
+
3px var(--_row),
|
|
440
|
+
calc(var(--_in) * 0.45) var(--_row),
|
|
441
|
+
var(--_in) var(--_row),
|
|
442
|
+
calc(var(--_in) * 0.6) var(--_row);
|
|
443
|
+
}
|
|
444
|
+
/* The field's height before Pagefind draws it, so the placeholders below it stay put. */
|
|
445
|
+
uvalib-pagefind-search[searching] > .uvalib-pagefind-search__ui {
|
|
446
|
+
min-block-size: 56px;
|
|
447
|
+
}
|
|
448
|
+
/* Sized like the results area: its message, then rows like .pagefind-ui__result. The bars
|
|
449
|
+
are base.css's .uvalib-skeleton-text (its shimmer, reduced motion and forced colors); the
|
|
450
|
+
sizes and colour here hold without base.css. */
|
|
451
|
+
/* Flex columns, so the bars' margins add up (no collapsing) to 1.5em lines. */
|
|
452
|
+
.uvalib-pagefind-search__skeleton,
|
|
453
|
+
.uvalib-pagefind-search__skeleton-result,
|
|
454
|
+
.uvalib-pagefind-search__skeleton-sub {
|
|
455
|
+
display: flex;
|
|
456
|
+
flex-direction: column;
|
|
457
|
+
}
|
|
458
|
+
.uvalib-pagefind-search__skeleton {
|
|
459
|
+
margin-block-start: 1.25rem;
|
|
460
|
+
line-height: 1.5;
|
|
461
|
+
}
|
|
462
|
+
.uvalib-pagefind-search__skeleton .uvalib-skeleton-text {
|
|
463
|
+
display: block;
|
|
464
|
+
box-sizing: border-box;
|
|
465
|
+
inline-size: 100%;
|
|
466
|
+
block-size: 1em;
|
|
467
|
+
margin-block: 0.25em;
|
|
468
|
+
border-radius: 0.2rem;
|
|
469
|
+
background-color: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));
|
|
470
|
+
}
|
|
471
|
+
.uvalib-pagefind-search__skeleton .uvalib-pagefind-search__skeleton-message {
|
|
472
|
+
inline-size: min(14rem, 70%);
|
|
473
|
+
margin-block: calc(0.6rem + 0.25em) calc(1.35rem + 0.25em);
|
|
474
|
+
}
|
|
475
|
+
.uvalib-pagefind-search__skeleton-result {
|
|
476
|
+
padding-block: 1.25rem;
|
|
477
|
+
border-block-start: 1px solid var(--pagefind-ui-tag);
|
|
478
|
+
}
|
|
479
|
+
.uvalib-pagefind-search__skeleton-result:last-child {
|
|
480
|
+
border-block-end: 1px solid var(--pagefind-ui-tag);
|
|
481
|
+
}
|
|
482
|
+
.uvalib-pagefind-search__skeleton .uvalib-pagefind-search__skeleton-title {
|
|
483
|
+
inline-size: 60%;
|
|
484
|
+
block-size: 1.2rem;
|
|
485
|
+
margin-block: 0.18rem 0.53rem;
|
|
486
|
+
}
|
|
487
|
+
.uvalib-pagefind-search__skeleton .uvalib-pagefind-search__skeleton-short {
|
|
488
|
+
inline-size: 60%;
|
|
489
|
+
}
|
|
490
|
+
.uvalib-pagefind-search__skeleton-sub {
|
|
491
|
+
margin-block-start: 0.75rem;
|
|
492
|
+
padding-inline-start: 1rem;
|
|
493
|
+
border-inline-start: 3px solid var(--pagefind-ui-tag);
|
|
494
|
+
}
|
|
495
|
+
.uvalib-pagefind-search__skeleton-sub .uvalib-pagefind-search__skeleton-title {
|
|
496
|
+
inline-size: 45%;
|
|
497
|
+
block-size: 1rem;
|
|
498
|
+
margin-block: 0.15rem;
|
|
499
|
+
}
|
|
368
500
|
/* Both set display, which would beat the hidden attribute's (issue #7). */
|
|
369
501
|
:where(uvalib-pagefind-search, .uvalib-pagefind-search__label)[hidden] {
|
|
370
502
|
display: none !important;
|
|
@@ -392,6 +524,18 @@
|
|
|
392
524
|
border: 1px solid GrayText;
|
|
393
525
|
color: GrayText;
|
|
394
526
|
}
|
|
527
|
+
/* The drawn bars in GrayText (forced colors would drop the gradients). */
|
|
528
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined) {
|
|
529
|
+
--_bar: GrayText;
|
|
530
|
+
}
|
|
531
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined)::before,
|
|
532
|
+
uvalib-pagefind-search[searching]:not([no-skeleton]):not(:defined)::after {
|
|
533
|
+
forced-color-adjust: none;
|
|
534
|
+
}
|
|
535
|
+
/* As base.css's skeletons: an outline, for a page without base.css. */
|
|
536
|
+
.uvalib-pagefind-search__skeleton .uvalib-skeleton-text {
|
|
537
|
+
border: 1px solid GrayText;
|
|
538
|
+
}
|
|
395
539
|
.pagefind-ui :is(.pagefind-ui__search-clear, .pagefind-ui__button):hover {
|
|
396
540
|
border-color: Highlight;
|
|
397
541
|
color: Highlight;
|
package/dist-cdn/site-page.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as e, f as t, i as n, l as r, m as i, n as a, o, r as s, t as c } from "./chunks/UvalibElement-pGONDAwB.js";
|
|
2
2
|
import { t as l } from "./chunks/if-defined-COiQb-gl.js";
|
|
3
|
-
import { a as u, i as d, n as f, r as p, t as m } from "./chunks/base-
|
|
3
|
+
import { a as u, i as d, n as f, r as p, t as m } from "./chunks/base-DmImIMld.js";
|
|
4
4
|
import { t as h } from "./chunks/accessible-DJv7YOtS.js";
|
|
5
5
|
import { t as g } from "./chunks/site-header-B78a_ldi.js";
|
|
6
6
|
import { a as _ } from "./chunks/analytics-DTTihuBD.js";
|
package/dist-cdn/site-style.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as e, l as t, m as n, n as r, o as i, r as a, t as o } from "./chunks/UvalibElement-pGONDAwB.js";
|
|
2
|
-
import { a as s, i as c, n as l, r as u } from "./chunks/base-
|
|
2
|
+
import { a as s, i as c, n as l, r as u } from "./chunks/base-DmImIMld.js";
|
|
3
3
|
// src/components/site-style/SiteStyle.ts
|
|
4
4
|
var d = class extends o {
|
|
5
5
|
constructor(...e) {
|
|
@@ -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 with @uvalib/web-components:
|
|
3
|
+
description: Use when building or editing UVA Library web pages or sites with @uvalib/web-components: 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, citation, chips, tags, results count, filter, filter drawer, dialog, date range, date histogram, combobox, list filter, map (Leaflet), lightbox, photo grid, image regions, back to top, Pagefind search, edition.css for TEI texts), the library hours, events and bento-box elements (e.g. <uvalib-card>, <uvalib-chip-group>, <library-weekly-hours>), base.css classes (incl. tables, sidebar layout), or script/link URLs on unpkg.internal.lib.virginia.edu (incl. 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), `<uvalib-metadata>` (a record's details, credit, rights and how to cite) and `<uvalib-citation>` (a citation in several formats with Copy citation), all in section 2, `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>` (cards and paging, section 5), `<uvalib-tabs>` (tabbed panels), `<uvalib-back-to-top>` (a back-to-top button for long pages) 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>`, `<uvalib-chip-group>` for segmented controls, filter chips and suggestion chips, `<uvalib-combobox>`, a text field that suggests values as you type, and `<uvalib-filter-drawer>`, the filters as a sidebar or a modal panel on phones, and `<uvalib-dialog>`, a modal dialog for search tips, Cite and short forms (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>`, `<uvalib-photo-grid>` and `<uvalib-image-regions>` for images and `<uvalib-map>` for a map of places over the page's own Leaflet, with a linked list (section 8). 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), `<uvalib-metadata>` (a record's details, credit, rights and how to cite) and `<uvalib-citation>` (a citation in several formats with Copy citation), all in section 2, `<uvalib-card>`, `<uvalib-card-grid>` and `<uvalib-pager>` (cards and paging, section 5), `<uvalib-tabs>` (tabbed panels), `<uvalib-back-to-top>` (a back-to-top button for long pages) 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>`, `<uvalib-chip-group>` for segmented controls, filter chips and suggestion chips, `<uvalib-combobox>`, a text field that suggests values as you type, `<uvalib-list-filter>`, a field that filters a long list on the page as you type, and `<uvalib-filter-drawer>`, the filters as a sidebar or a modal panel on phones, and `<uvalib-dialog>`, a modal dialog for search tips, Cite and short forms (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, `edition.css` for reading TEI texts converted to HTML, 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>`, `<uvalib-photo-grid>` and `<uvalib-image-regions>` for images and `<uvalib-map>` for a map of places over the page's own Leaflet, with a linked list (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`, `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`, `uvalib-combobox.js`, `uvalib-image-regions.js`, `uvalib-map.js`, `uvalib-filter-drawer.js`, `uvalib-back-to-top.js`, `uvalib-dialog.js`, `uvalib-citation.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.
|
|
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`, `uvalib-combobox.js`, `uvalib-image-regions.js`, `uvalib-map.js`, `uvalib-filter-drawer.js`, `uvalib-back-to-top.js`, `uvalib-dialog.js`, `uvalib-citation.js`, `uvalib-list-filter.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
|
|
@@ -41,7 +41,7 @@ Loading rules:
|
|
|
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>`. To return to the search the visitor came from, give that crumb `data-return-from="<search path>"` (it links to the same-origin referrer when it is that path with a query), never an inline script. 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
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”, or “Showing N” with no `total`; with an unknown total add `has-more` and remove it, or set `hasMore = false`, after the last page) 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
|
-
- 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`. For a long document's table of contents without a build-time list, `headings-from="#article"` (with `levels="2-3"`, `min`) builds it from the headings and adds ids; a build-time list (children) is better where possible, since it works without JavaScript. Apps can set `items` (`[{ label, href?, children? }]`); with history routing, cancel `uvalib-contents-navigate` 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` (or, in a `.uvalib-sidebar-layout`, the layout's `--sticky`; never both). For a long document's table of contents without a build-time list, `headings-from="#article"` (with `levels="2-3"`, `min`) builds it from the headings and adds ids; a build-time list (children) is better where possible, since it works without JavaScript. Apps can set `items` (`[{ label, href?, children? }]`); with history routing, cancel `uvalib-contents-navigate` to route in place. For a very long contents (hundreds of sections, each a page), write only the entries near the current one (with their parents) and set `full-href` to the full contents and `total` (its entry count): the component draws "Full contents (243 sections)" after the list and tells screen readers the list is partial; never add that link as a last `<li>`. With the whole list in the page, `window="12"` shows the current entry and 12 either side (a Show all button without `full-href`).
|
|
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. A long list (30 participants) gets `list-limit="8"` (or `data-limit` on its `<dd>`), not your own Show more script. Do not add icons from rightsstatements.org or creativecommons.org. With `base.css` linked the page does not move when it upgrades, including `list-limit` (or `data-limit`) from 1 to 12; for a larger limit add the page rule from the README ("No jump on upgrade").
|
|
46
46
|
- Citations in several formats (a record's Cite dialog or a "Cite this item" block): a `<uvalib-citation>` (from `uvalib-citation.js`), never a hand-built tab set, select, copy script or toast. Give each format as `<blockquote data-format="MLA">…</blockquote>` (keep `<i>` for titles; nothing else is kept as markup), or set `citations` (`[{ format, text, html? }]`) in an app; never fetch HTML into it. It draws a "Citation format" radio group (not tabs), the selected citation as selectable text, a 44px Copy citation button (plain text plus HTML, so italics survive a paste) with a polite "MLA citation copied" status, and with `ris-href` a Download RIS link; more export links go in `slot="actions"`. `format` picks the default; `remember` keeps the visitor's last choice per site. In a dialog, add `hide-label` when the dialog's heading says "Cite this item". With `base.css` linked the page does not move when it upgrades. For one simple citation in a record's details, `<uvalib-metadata citation="…">` remains the right choice. It reports `format`, `copy` and `download` (the format name only) to analytics itself.
|
|
47
47
|
- Long pages (minutes, finding aids, transcriptions, long result lists): a `<uvalib-back-to-top>` (from `uvalib-back-to-top.js`) last in the content inside `<site-page>`, never a hand-built button and scroll script. It stays hidden (`visibility: hidden`, not a tab stop) until the top 400px (`offset`) scroll away, then floats in the bottom corner; activating it scrolls to the top (smooth unless reduced motion) and moves focus to the page's `<h1>` (or `target`, a selector), adding `tabindex="-1"`. The element keeps 4.75rem of space at the end and the button rests there at the bottom, so it never covers the last lines or the footer: do not add your own padding for it. `label` changes its text. `<site-page>` has no attribute for it. It reports `click` to analytics itself.
|
|
@@ -59,6 +59,7 @@ Loading rules:
|
|
|
59
59
|
- 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.
|
|
60
60
|
- Messages in the page's own content (a search error, a "keyword results only" notice): `<div class="uvalib-message uvalib-message--error" role="alert">` (`--warning`, `--info`/`--notice`, `--success`), starting with the severity in words in `<strong class="uvalib-message__label">Error:</strong>`; `role="alert"` only for an error caused by what the visitor did, `role="status"` for notices. Never hand-rolled alert boxes, and never a `<site-alerts>` for them. `hidden` hides every `base.css` class (`el.hidden = true`); no `[hidden]` reset is needed.
|
|
61
61
|
- Data tables (holdings, schedules, statistics): `<table class="uvalib-table">` with a `<caption>` (or `aria-labelledby`) and `<th scope="col|row">`; `--striped`, `--compact`, `.uvalib-table__num` for right-aligned numbers. Wide ones go in `<div class="uvalib-table-scroll" role="region" tabindex="0" aria-labelledby="CAPTION-ID">` (scrolls inside itself, never the page). Grouped data (holdings by library) is a heading per group, at the level the page outline needs, then its table. The opt-in stack variant (`.uvalib-table-stack` > `.uvalib-table--stack`, cells with `data-label`) needs explicit ARIA table roles. Never hand-styled or W3.CSS tables, and never a table for layout.
|
|
62
|
+
- Sidebar pages (a contents or sub-navigation sidebar beside the text, related links beside an article): `<div class="uvalib-sidebar-layout">` with two children, `class="uvalib-sidebar-layout__sidebar"` and `class="uvalib-sidebar-layout__main"`, never a hand-built grid, W3 columns or media queries. Side by side from 913px of the layout's own width (a container query: the library's 993px breakpoint less `<site-page>`'s gutters), the sidebar a quarter (`clamp(14rem, 25%, 20rem)`, `--uvalib-sidebar-width`) 3.5rem from the content (`--uvalib-sidebar-gap`); stacked below that. Source order is the order everywhere: sidebar first for a reading page's contents (they stack above the text), after the main content for a right-hand sidebar (stacks below); never reorder with CSS. The sidebar is the `<nav>` itself (the class on `<uvalib-contents>` or a `<nav aria-label>`) or an `<aside>` named by its heading; never wrap a `<nav>` in `role="navigation"`. `--sticky` keeps it in view only when side by side (use it or `<uvalib-contents sticky>`, not both); `--print-hide-sidebar` leaves it out of print. Keep `<uvalib-contents>`'s default `collapse-below`.
|
|
62
63
|
- Printing: `<site-page>` prints only `<main>` (no header, nav, alerts, breadcrumbs or footer), black on white with underlined links and a "UVA Library — site, URL" line; `print-chrome` keeps the chrome. Do not add print rules for the chrome yourself.
|
|
63
64
|
- 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.
|
|
64
65
|
- 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.
|
|
@@ -227,7 +228,7 @@ import '@uvalib/web-components/tokens.css'; // optional: tokens for your own CSS
|
|
|
227
228
|
|
|
228
229
|
Analytics: only when the site needs Matomo, set `<site-page matomo-id="N">`, or add `site-analytics.js` and a `<site-analytics matomoid="N">` (add `downloads="event"`, or `matomo-downloads="event"` on `<site-page>`, when file URLs carry ids: downloads are then counted as `['download', '<extension>']` events without URLs); 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.
|
|
229
230
|
|
|
230
|
-
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) and version comparisons (`compare`, the mode and the version's place, never its label); 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); and combobox choices and clears (the field's label and the suggestion's place; never the typed text or the suggestion); and image-region outline clicks (the list's label and the region's number; never a region's label); and map marker choices and zoom-button presses (the map's label and the place's position or the zoom level; never the place's name, coordinates or URL). `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing. The README's "Analytics" section has the full table.
|
|
231
|
+
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) and version comparisons (`compare`, the mode and the version's place, never its label); 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); and combobox choices and clears (the field's label and the suggestion's place; never the typed text or the suggestion); and list-filter queries and clears (how many items match; never the typed text); and image-region outline clicks (the list's label and the region's number; never a region's label); and map marker choices and zoom-button presses (the map's label and the place's position or the zoom level; never the place's name, coordinates or URL). `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing. The README's "Analytics" section has the full table.
|
|
231
232
|
|
|
232
233
|
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.
|
|
233
234
|
|
|
@@ -546,13 +547,24 @@ A person, place or subject picker, or any text field that suggests values as you
|
|
|
546
547
|
- For no-JavaScript visitors, put `<input name list aria-label>` and its `<datalist>` inside: base.css shows the label and the field before the script runs.
|
|
547
548
|
- It reports `select` (the label and position) and `clear` to analytics itself, never what was typed: do not add your own tracking.
|
|
548
549
|
|
|
550
|
+
### List filter
|
|
551
|
+
|
|
552
|
+
A field that narrows a long list already on the page (a collection's texts, a directory, a table of databases) is one `<uvalib-list-filter>` (`uvalib-list-filter.js`), never your own `input` listener that toggles `hidden`.
|
|
553
|
+
|
|
554
|
+
- `for="list-id"` names the list: its children are the items (`ul`/`ol`, a `dl` of `div` rows, a card grid; a `<table>`'s body rows). Or `selector` for the items. Put the words to match in `data-filter-text` on each item when its text is not enough (title, author, date); otherwise its text is used. Every typed word must match, in any order, ignoring case and accents.
|
|
555
|
+
- `label` (default "Filter"; `hide-label` when a heading says it), `placeholder`, `noun`/`singular` ("Showing 12 of 473 texts"). It has its own 44px Clear button, Escape, a polite count announced after typing settles, and a "No texts match …" message: do not add your own live region or empty-state text.
|
|
556
|
+
- Headed groups: wrap each heading and its list in an element with `data-filter-group` and use `selector` for the items; empty groups hide.
|
|
557
|
+
- `query-param` (bare: `?filter=`) keeps the filter in the URL. `results-count="id"` drives a `<uvalib-results-count total="473" noun="texts">` placed elsewhere instead of its own count.
|
|
558
|
+
- Listen for `uvalib-list-filter-change` (`detail: { query, shown, total }`). After changing an item's text in script call `refresh()`.
|
|
559
|
+
- With `base.css` linked nothing moves when it upgrades, and the whole list shows without the script. It reports `filter` (the match count) and `clear` itself, never the typed text.
|
|
560
|
+
|
|
549
561
|
### Static-site search (Pagefind)
|
|
550
562
|
|
|
551
563
|
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:
|
|
552
564
|
|
|
553
565
|
- 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.
|
|
554
|
-
- 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.
|
|
555
|
-
- 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).
|
|
566
|
+
- 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`), Pagefind filters read from and written to the URL (`filter-params`), and analytics (`trackSearch(…, 'Pagefind', count)` once results settle, and `filter-change` events). Do not add your own `?q=` or `triggerFilters` URL script or live region.
|
|
567
|
+
- 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), `query-param` (default `q`) and `filter-params` (space-separated filter names, such as `collection author`: `?collection=Manuscripts` lands with that filter checked and its group open, applied with `?q=` as one search; repeated parameters check several values; values the index lacks are ignored; checkbox changes are written back), `searching` and `no-skeleton`. A search page opened with `?q=` must hold still while results load (CLS): add `searching` when the URL has a query, before any script runs, with one line after the element (`<script>if (new URLSearchParams(location.search).get('q')) document.querySelector('uvalib-pagefind-search').setAttribute('searching', '')</script>`, or server-side); `pagefind.css` then holds a window's height and draws placeholder results from first paint until the results load, and the element keeps the footer below the fold until the visitor uses the search. Do not add your own `min-height` hold. For a "Search this collection" link, use `filter-params` and link to `/search/?collection=…`; `el.ready.then((ui) => ui.triggerFilters(…))` is for filters set from your own script.
|
|
556
568
|
|
|
557
569
|
```html
|
|
558
570
|
<!doctype html>
|
|
@@ -587,12 +599,21 @@ A static site (11ty, Jekyll, a generated collection) that searches with [Pagefin
|
|
|
587
599
|
placeholder="Search all texts"
|
|
588
600
|
show-sub-results
|
|
589
601
|
excerpt-length="30"
|
|
602
|
+
filter-params="collection"
|
|
590
603
|
></uvalib-pagefind-search>
|
|
591
604
|
</site-page>
|
|
592
605
|
</body>
|
|
593
606
|
</html>
|
|
594
607
|
```
|
|
595
608
|
|
|
609
|
+
### Reading texts (edition.css)
|
|
610
|
+
|
|
611
|
+
For a TEI text converted to class-annotated HTML (the class is the TEI element name, as in ETC, TEI Boilerplate and most converters), link `edition.css` (npm `@uvalib/web-components/edition.css`) and put the text in `<div class="uvalib-edition" lang="…">`. Do not copy a facsimile's serif or write your own reading CSS: the rules are zero-specificity (`:where()`), so override only what the site needs.
|
|
612
|
+
|
|
613
|
+
- Classes: `div`/`div-*`, `head`, `p`, `ab`, `seg-*`, `lb`, `pb` (`pb-n`, `a.pb-image`), `lg`, `l` (`data-n`), `sp`, `speaker`, `stage`, `opener`, `closer`, `dateline`, `salute`, `signed`, `postscript`, `epigraph`, `argument`, `trailer`, `byline`, `bibl`, `cit`, `figure`, `figDesc`, `add`, `del`, `sic`, `orig`, `reg`, `unclear`, `gap`, `noteref`, `footnotes`, `note`, `note-inline`, `ornament`, `textbreak`, `titlepage`/`titlePage`, `list`, `rend-*` (italic, smallcaps, center, right, indent, indent2, indent3, hang, underline…).
|
|
614
|
+
- Keep whitespace before each `<br class="lb">` (CSS cannot space a `<br>`), or write `<span class="lb"></span>`. Line breaks: a `<label class="uvalib-edition__lines"><input type="checkbox"> Show original line breaks</label>` before or inside the edition (or the class `uvalib-edition--lines`); readings in `title`: `.uvalib-edition__readings` (a title alone is hover-only).
|
|
615
|
+
- Additions and deletions are announced by generated text; do not add your own. Page images: `<uvalib-lightbox selector=".uvalib-edition a.pb-image">`. README: "Reading texts (edition.css)".
|
|
616
|
+
|
|
596
617
|
### Results toolbar, badges and tags
|
|
597
618
|
|
|
598
619
|
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`.
|
|
@@ -880,7 +901,7 @@ Before finishing, load the page in a browser (or test) and confirm:
|
|
|
880
901
|
|
|
881
902
|
## 10. Keeping this skill current
|
|
882
903
|
|
|
883
|
-
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,
|
|
904
|
+
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, such as `.claude/skills`, `.agents/skills` or `~/.agents/skills`); it prints the update command when a newer release exists. `install-skill --force` updates the copies in this project (`.claude/skills` and `.agents/skills`), `--global --force` those in the home folder.
|
|
884
905
|
|
|
885
906
|
## 11. Requesting components, features and fixes
|
|
886
907
|
|
|
@@ -883,7 +883,7 @@ An editable text field that suggests values as you type, from a local list or a
|
|
|
883
883
|
|
|
884
884
|
## `<uvalib-contents>`
|
|
885
885
|
|
|
886
|
-
Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a `<nav>` landmark (named by `label`, "Contents" by default) with the label as a visible headline, and a nested list of links with dividers between the top-level entries and a bar beside each nested level. Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>` (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any depth. Other children (a heading) are ignored. The list follows changes to the children. Apps set the `items` property instead (`{ label, href?, children? }`, winning over the children while set). The current entry gets `aria-current`: `page` for the link to this page, `location` for the link to the section of it in the URL's hash. It is found from the page URL (path, and hash for in-page sections), followed through same-document navigations (`hashchange`, `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like the links). An entry whose href has a query string matches only that query (`?part=2`); one without matches the page whatever its query. Hash-only hrefs are places on that page. With `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is used instead, the first of each kind. `lang` and `dir` on the source links and items, and inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element, never as HTML), are kept. On narrow screens the list collapses into a disclosure: the headline becomes a button with `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents does on phones, so the text comes first) until the reader opens it, or while the `open` attribute is set; opening it shows the current entry. Narrow means the viewport (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is always far narrower than 64rem, so a container query could not tell a phone from a desktop. `sticky` keeps it in view in a sidebar on wide screens; a list longer than the window then scrolls, and the current entry is scrolled into view inside it (never the page). A table of contents for a long document: `headings-from="#article"` builds the list from the headings in that element (`levels`, `2-3` by default; nothing shown below `min` top-level entries, 2 by default). Headings without text or hidden with `aria-hidden` are skipped; one without an id gets one from its text (`budget-report`, then `budget-report-2`), and existing ids are kept, so links to sections keep working. It follows headings added, removed or retitled; `refresh()` reads them again after other changes. The children and `items` win while they give a list. Without JavaScript there is no list: a list rendered at build time, as children, works everywhere. Single-page apps: the list is drawn from copies of the children, so a router's own click handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in place; hash links need nothing.
|
|
886
|
+
Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation: a `<nav>` landmark (named by `label`, "Contents" by default) with the label as a visible headline, and a nested list of links with dividers between the top-level entries and a bar beside each nested level. Give the list as a child: an `<ol>` or `<ul>` of `<li>` elements, each with an `<a href>` (or plain text for a group label) and, for sub-entries, a nested `<ol>`/`<ul>`, to any depth. Other children (a heading) are ignored. The list follows changes to the children. Apps set the `items` property instead (`{ label, href?, children? }`, winning over the children while set). The current entry gets `aria-current`: `page` for the link to this page, `location` for the link to the section of it in the URL's hash. It is found from the page URL (path, and hash for in-page sections), followed through same-document navigations (`hashchange`, `popstate` and the Navigation API), or from the `current` attribute (a URL, resolved like the links). An entry whose href has a query string matches only that query (`?part=2`); one without matches the page whatever its query. Hash-only hrefs are places on that page. With `current` unset, a valid `aria-current` on a source link (`page`, `location` or `true`) is used instead, the first of each kind. `lang` and `dir` on the source links and items, and inline markup in their text (`em`, `cite`, `code`, `abbr`…, copied element by element, never as HTML), are kept. On narrow screens the list collapses into a disclosure: the headline becomes a button with `aria-expanded`, and the list starts closed (as the Electronic Text Collections' Contents does on phones, so the text comes first) until the reader opens it, or while the `open` attribute is set; opening it shows the current entry. Narrow means the viewport (`collapse-below`, 64rem by default), not the element's own width: a contents sidebar is always far narrower than 64rem, so a container query could not tell a phone from a desktop. `sticky` keeps it in view in a sidebar on wide screens; a list longer than the window then scrolls, and the current entry is scrolled into view inside it (never the page). A table of contents for a long document: `headings-from="#article"` builds the list from the headings in that element (`levels`, `2-3` by default; nothing shown below `min` top-level entries, 2 by default). Headings without text or hidden with `aria-hidden` are skipped; one without an id gets one from its text (`budget-report`, then `budget-report-2`), and existing ids are kept, so links to sections keep working. It follows headings added, removed or retitled; `refresh()` reads them again after other changes. The children and `items` win while they give a list. Without JavaScript there is no list: a list rendered at build time, as children, works everywhere. A very long contents (a text with hundreds of sections, each its own page) can show only part of the list, with a link to the whole. `full-href` adds that link after the list: not an entry but a call to action (bold, underlined, with an arrow), its text `full-label` ("Full contents") followed by the count when `total` (the entries in the full contents) is set: "Full contents (243 sections)" (`noun`, "sections" by default; `singular` for one). A static site writes only the entries near the current one (with their parents) and sets these. `window="12"` does it in the browser when the whole list is given: only the current entry and the 12 before and after it in document order (25 entries, shifted at either end) are shown, with their parents so the nesting still makes sense; the others are hidden, not removed, and a gap between the entries shown is marked with an ellipsis (hidden from assistive technology). It follows the current entry, and applies to `items` and `headings-from` too. Without `full-href`, a "Show all 243 sections" button shows the rest in place ("Show fewer" goes back). While part of the list is shown, a visually hidden line before it says so ("Showing 25 of 243 sections."); the headline and the landmark keep the visible label as their name. On narrow screens the link and the button are inside the disclosure. Single-page apps: the list is drawn from copies of the children, so a router's own click handlers on them do not run. Listen for `uvalib-contents-navigate` and cancel it to route in place; hash links need nothing.
|
|
887
887
|
|
|
888
888
|
### Attributes
|
|
889
889
|
|
|
@@ -898,6 +898,12 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
898
898
|
| `headings-from` | `string \| undefined` | | Build the list from the headings in the element this selector names (`#article`): each heading at `levels` gets an entry linking to it (an id is added when it has none), the lower levels nested under the heading before them. The children and `items` win while they give a list. |
|
|
899
899
|
| `levels` | | `DEFAULT_LEVELS` | With `headings-from`: the heading levels to list, `2-3` (the default) or one level, `2`. |
|
|
900
900
|
| `min` | | `DEFAULT_MIN` | With `headings-from`: the fewest top-level entries worth a list (default 2). With fewer, nothing is shown. |
|
|
901
|
+
| `full-href` | `string \| undefined` | | The URL of the full contents, when the list is only part of it: a "Full contents" link after the list (`full-label`, with the count from `total`). |
|
|
902
|
+
| `full-label` | | `DEFAULT_FULL_LABEL` | The full-contents link's text, before the count: "Full contents" by default. |
|
|
903
|
+
| `total` | `number \| undefined` | | How many entries the full contents has, for the link ("Full contents (243 sections)") and the screen-reader line ("Showing 25 of 243 sections."). With `window`, the whole list's count when unset. |
|
|
904
|
+
| `noun` | | `DEFAULT_NOUN` | What the entries are, plural, in the counts: "sections" by default. |
|
|
905
|
+
| `singular` | `string` | `''` | What an entry is, singular, for a count of one. Default: "section" for the default `noun`, else `noun`. |
|
|
906
|
+
| `window` | `number \| undefined` | | Show only the current entry and this many before and after it in document order (and their parents); the others are hidden. Unset or blank: every entry. |
|
|
901
907
|
| `no-shadow-dom` | `boolean` | `false` | |
|
|
902
908
|
| `no-style` | `boolean` | `false` | |
|
|
903
909
|
|
|
@@ -905,8 +911,8 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
905
911
|
|
|
906
912
|
| Event | Description |
|
|
907
913
|
|---|---|
|
|
908
|
-
| `uvalib-analytics-event` | For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level),
|
|
909
|
-
| `uvalib-contents-navigate` | A plain click on an entry: `detail` is `{ href, level }` (href as written). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed. |
|
|
914
|
+
| `uvalib-analytics-event` | For `<site-analytics>`: a click on an entry, `['uvalib-contents', 'link-click', 'level <N>', <N>]` (N from 1, the top level), on the full-contents link, `['uvalib-contents', 'full-contents-click']`, opening or closing the disclosure, `['uvalib-contents', 'toggle', 'open' \| 'close']`, and the window's button, `['uvalib-contents', 'show-all' \| 'show-fewer']`; never the label or URL. Bubbles and is composed. |
|
|
915
|
+
| `uvalib-contents-navigate` | A plain click on an entry or the full-contents link: `detail` is `{ href, level }` (href as written; level 0 for the full-contents link). Cancel it (`preventDefault()`) to navigate in the app; the click's default is then prevented. Bubbles and is composed. |
|
|
910
916
|
|
|
911
917
|
### CSS custom properties
|
|
912
918
|
|
|
@@ -922,6 +928,7 @@ Sub-navigation or a table of contents, as library.virginia.edu's sub-navigation:
|
|
|
922
928
|
| `--uva-color-text` | | Dark-mode role token: text and current entry (else `--uva-grey-darkest`). |
|
|
923
929
|
| `--uva-color-link` | | Dark-mode role token: the current entry's bar and the button's text (else `--uva-brand-blue`). |
|
|
924
930
|
| `--uva-color-current` | | Dark-mode role token: the nested levels' bar (else `--uva-brand-orange`). |
|
|
931
|
+
| `--uva-color-text-muted` | | Dark-mode role token: the ellipsis between the entries a window shows (else #4f4f4f). |
|
|
925
932
|
| `--uva-color-border` | | Dark-mode role token: dividers (else #dadada). |
|
|
926
933
|
| `--uva-color-control-border` | | Dark-mode role token: the button's border (else #808080). |
|
|
927
934
|
| `--uva-color-surface-raised` | | Dark-mode role token: the button's background (else #fff). |
|
|
@@ -1346,6 +1353,57 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
|
|
|
1346
1353
|
| `--uva-grey-darkest` | `#2b2b2b` | Text when `--uva-color-text` is unset. |
|
|
1347
1354
|
| `--uva-grey-100` | `#dadada` | Border when `--uva-color-border` is unset. |
|
|
1348
1355
|
|
|
1356
|
+
## `<uvalib-list-filter>`
|
|
1357
|
+
|
|
1358
|
+
A text field that filters a long list on the page as you type: a collection's 473 texts, a staff directory, a table of databases. The list is the page's own markup and stays fully visible without the script. `for` is the id of the list: any element whose children are the items (a `<ul>` or `<ol>`, a `<dl>` of `<div>` rows, a grid of cards; for a `<table>`, the rows of its bodies). `selector` picks the items instead (inside `for` when both are set, else in the page). An item matches when every word typed appears in its `data-filter-text`, or else its text, in any order, ignoring case and accents (“eneide” finds “Énéide”). Items that do not match get the `hidden` attribute (kept hidden whatever `display` the page gives them); clearing the field shows them all again. Thousands of items filter at once on every keystroke: the text is read once, and only items whose state changes are touched. Groups: give each group's wrapper `data-filter-group` (a `<section>` with its heading and its list) and point `selector` at the items; a group whose items are all hidden is hidden too, heading and all. The visible `label` (default “Filter”; `hide-label` hides it visually) names the field, and a Clear button (“Clear <label>”, 44px, shown only with text) or Escape empties it, keeping focus in the field. Under the field a count follows at once (“Showing 12 of 473 texts”; `noun`, plural, and `singular` name the items), and a polite status announces it once the typing settles (a second after the last keystroke), never on every key or at load. When nothing matches, a message says “No texts match “…”.” To put the count elsewhere, point `results-count` at a `<uvalib-results-count>` (give it `total` and `noun` in the markup): the element then sets its `shown` and `total` and leaves the count and announcement to it. With `query-param` (bare: `filter`) the filter is read from that URL parameter at start and written back with `history.replaceState` as you type, so a filtered list can be shared and Back returns to it. The list's content is read once; call `refresh()` after changing an item's text in script (added or removed items and `data-filter-text` changes are noticed). Before it upgrades, `base.css` holds the label, field and count's height, so nothing moves.
|
|
1359
|
+
|
|
1360
|
+
### Attributes
|
|
1361
|
+
|
|
1362
|
+
| Attribute | Type | Default | Description |
|
|
1363
|
+
|---|---|---|---|
|
|
1364
|
+
| `for` | `string` | `''` | The id of the list whose children are the items (for a table, its body rows). |
|
|
1365
|
+
| `selector` | `string` | `''` | A CSS selector for the items, inside `for` when it is set, else in the page. |
|
|
1366
|
+
| `label` | `string` | `'Filter'` | The field's visible label and accessible name. |
|
|
1367
|
+
| `hide-label` | `boolean` | `false` | Hide the label visually (it still names the field), when a heading beside it says it. |
|
|
1368
|
+
| `placeholder` | `string` | `''` | Placeholder text in the empty field, such as “Title or author”. |
|
|
1369
|
+
| `noun` | `string` | `'items'` | What the items are, plural: “items” by default. |
|
|
1370
|
+
| `singular` | `string` | `''` | What one item is. Default: “item” when `noun` is unset, else `noun`. |
|
|
1371
|
+
| `results-count` | `string` | `''` | The id of a `<uvalib-results-count>` to drive instead of the element's own count. |
|
|
1372
|
+
| `query-param` | `string \| null` | `null` | The URL parameter to read the filter from and write it to; a bare attribute uses `filter`. Off by default. |
|
|
1373
|
+
| `value` | `string` | `''` | The text in the field. Setting it filters the list (not reported to analytics). |
|
|
1374
|
+
| `no-shadow-dom` | `boolean` | `false` | |
|
|
1375
|
+
| `no-style` | `boolean` | `false` | |
|
|
1376
|
+
|
|
1377
|
+
### CSS parts
|
|
1378
|
+
|
|
1379
|
+
| Part | Description |
|
|
1380
|
+
|---|---|
|
|
1381
|
+
| `label` | The visible label. |
|
|
1382
|
+
| `field` | The box around the field and its clear button. |
|
|
1383
|
+
| `input` | The text field. |
|
|
1384
|
+
| `clear` | The clear button. |
|
|
1385
|
+
| `count` | The visible count under the field. |
|
|
1386
|
+
| `empty` | The “No … match” message. |
|
|
1387
|
+
|
|
1388
|
+
### Events
|
|
1389
|
+
|
|
1390
|
+
| Event | Description |
|
|
1391
|
+
|---|---|
|
|
1392
|
+
| `uvalib-list-filter-change` | The filter was applied with a new query (typing, Clear, Escape, `value` set in script, the URL at start, Back and Forward). `detail` is `{ query, shown, total }`. Not fired at load without a query. Bubbles and is composed. |
|
|
1393
|
+
| `uvalib-analytics-event` | For `<site-analytics>`, on the visitor's actions only: `['uvalib-list-filter', 'filter', '', <shown>]` once the typing settles on a new query, and `['uvalib-list-filter', 'clear']` when the visitor empties the field. Never the typed text. Bubbles and is composed. |
|
|
1394
|
+
|
|
1395
|
+
### CSS custom properties
|
|
1396
|
+
|
|
1397
|
+
| Property | Default | Description |
|
|
1398
|
+
|---|---|---|
|
|
1399
|
+
| `--uva-color-surface-raised` | | Dark-mode role token: field background (else #fff). |
|
|
1400
|
+
| `--uva-color-control-border` | | Dark-mode role token: field border (else `--uva-grey`, #808080). |
|
|
1401
|
+
| `--uva-color-input-text` | | Dark-mode role token: field text (else #2b2b2b). |
|
|
1402
|
+
| `--uva-color-text` | | Dark-mode role token: label text (else #2b2b2b). |
|
|
1403
|
+
| `--uva-color-text-muted` | | Dark-mode role token: placeholder, count and the clear icon (else #4f4f4f). |
|
|
1404
|
+
| `--uva-color-alert-info-bg` | | Dark-mode role token: the no-match message background. |
|
|
1405
|
+
| `--uva-color-focus` | | Dark-mode role token: focus ring (else `--uva-brand-orange`). |
|
|
1406
|
+
|
|
1349
1407
|
## `<uvalib-map>`
|
|
1350
1408
|
|
|
1351
1409
|
A map of places with a linked list of the same places: buildings, rooms or outdoor spaces, each a marker sized by a count, with a link to the place's page. It wraps [Leaflet](https://leafletjs.com) 1.9, which the page provides (the library never bundles it): set the `leaflet` property to the Leaflet module (`import * as L from 'leaflet'`), or load leaflet.js so that `window.L` exists. Without Leaflet only the list is shown, with one console warning. Leaflet's leaflet.css is optional: the element carries the layout rules it needs, in shadow DOM and light DOM alike. Places come from `items` (`{ id?, name, lat, lng, count?, href?, description? }`) or from a child `<ul>`/`<ol>` of `<li><a href data-lat data-lng data-count>Name</a></li>`, which is the list before the script runs (and without it). The list always stays, under the map: it is the text equivalent. Each marker is a real link (a button when the place has no `href`) named like "The Rotunda, 2,702 photos" (`count-label` is the noun), sized by the square root of its count (a 24 to 56px dot in a hit area of at least 44px). Tab or the arrow keys move between markers, Enter follows the link (or chooses the place), and Escape hides the tooltip. Hovering or focusing a marker shows a tooltip with its name and count and highlights its list entry; hovering or focusing a list entry highlights its marker (a ring and a larger dot, not colour alone) and brings it into view. Markers whose 44px targets would overlap at the current zoom are drawn as one group marker (regrouped after every zoom and resize): a button showing how many places it holds, sized by their summed count and named like "The Rotunda and 2 more places, 3,610 photos" (the largest place's name; `place-label` is the noun). Choosing it zooms in until its places part; when they cannot (one point, or the maximum zoom) it spreads them in a ring around it instead, with focus on the first; Escape or a zoom closes the ring and focus returns to the group. The arrow keys move between the markers shown (a group is one); a place in the list that is in a group highlights the group, whose tooltip names the place. The map is a region named by `label`, after a "Skip map, go to the list" link and a line of key instructions. It opens on the bounds of the places, or on `center` and `zoom`. The zoom buttons are 44px with a visible focus ring; the attribution stays. Tiles come from `tile-url` (OpenStreetMap by default: low-traffic use only) with `attribution`. In the page's dark mode the tiles are inverted with a CSS filter (`--uvalib-map-dark-filter`) unless `dark-tile-url` gives dark tiles; markers and controls are never filtered. With `prefers-reduced-motion` nothing animates.
|
|
@@ -1451,7 +1509,7 @@ A record's details as a description list, as on the library's digital collection
|
|
|
1451
1509
|
|
|
1452
1510
|
## `<uvalib-pagefind-search>`
|
|
1453
1511
|
|
|
1454
|
-
Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle) with the library's defaults and the accessibility fixes that need script. Use it with pagefind.css, in place of Pagefind's pagefind-ui.css. It renders in light DOM, so the page's styles reach Pagefind's markup. It loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI` already exists. What it adds to the stock UI: a visible `<label>` for the field (the stock field is named only by its title); a polite status region that announces the result count ("12 results for virginia") once results settle (the stock message is not a live region); focus kept in the field after Clear or Escape (the stock UI blurs it, dropping focus to the page) and moved to the first new result after "Load more results"; the loading placeholders' dots hidden from screen readers; `?q=` read at start (and on Back and Forward) and the settled query written back with `history.replaceState`, so a search can be shared; and reports to `<site-analytics>`. The `ui` property is the `PagefindUI` instance (for `triggerFilters`), and `ready` resolves with it. Attributes are read once, when the element is first connected.
|
|
1512
|
+
Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle) with the library's defaults and the accessibility fixes that need script. Use it with pagefind.css, in place of Pagefind's pagefind-ui.css. It renders in light DOM, so the page's styles reach Pagefind's markup. It loads `<bundle-path>pagefind-ui.js` unless `window.PagefindUI` already exists. What it adds to the stock UI: a visible `<label>` for the field (the stock field is named only by its title); a polite status region that announces the result count ("12 results for virginia") once results settle (the stock message is not a live region); focus kept in the field after Clear or Escape (the stock UI blurs it, dropping focus to the page) and moved to the first new result after "Load more results"; the loading placeholders' dots hidden from screen readers; `?q=` read at start (and on Back and Forward) and the settled query written back with `history.replaceState`, so a search can be shared; with `filter-params`, the named Pagefind filters read from and written to the URL the same way; and reports to `<site-analytics>`. While a search from the URL loads, it can hold the page still (issue #37): with `searching` set in the page's HTML when the URL has a query, the element holds a screen's height from first paint, and placeholder results (aria-hidden) stand in for Pagefind's until they, or "no results", are drawn; the element then still reaches the bottom of the window until the visitor uses the search, so a short list does not pull the footer up. It does the same on Back and Forward to a new query. The `ui` property is the `PagefindUI` instance (for `triggerFilters`), and `ready` resolves with it. Attributes are read once, when the element is first connected.
|
|
1455
1513
|
|
|
1456
1514
|
### Attributes
|
|
1457
1515
|
|
|
@@ -1469,6 +1527,9 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
|
|
|
1469
1527
|
| `translations` | `string` | | JSON of Pagefind UI strings to override (`{"zero_results": "…"}`). |
|
|
1470
1528
|
| `options` | `string` | | JSON of any other `PagefindUI` options (`{"openFilters": ["author"]}`), applied last. |
|
|
1471
1529
|
| `query-param` | `string` | `q` | The URL parameter that holds the query; empty turns it off. |
|
|
1530
|
+
| `searching` | `boolean` | | Set it in the page's HTML when the URL has a query (server-side, or with a one-line inline script after the element): from first paint, before any script loads, it holds a screen's height for the results, and placeholder results show until they are drawn. The element removes it then (and at start without a query), and sets it itself on Back and Forward to a new query. |
|
|
1531
|
+
| `no-skeleton` | `boolean` | | Never hold space or show placeholder results (`searching` is ignored). |
|
|
1532
|
+
| `filter-params` | `string` | | Space-separated Pagefind filter names read from and written to URL parameters of the same name (`collection author`: `?collection=A&collection=B`). URL filters are applied with the query as one search, their filter groups open; values not in the index are ignored. Empty (the default) turns it off. |
|
|
1472
1533
|
|
|
1473
1534
|
### Events
|
|
1474
1535
|
|