@uvalib/web-components 1.10.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 +13 -0
- package/README.md +43 -5
- package/dist/base.css +7 -1
- 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-pagefind-search/UvalibPagefindSearch.d.ts +27 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +92 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
- package/dist/custom-elements.json +400 -6
- package/dist/pagefind.css +144 -0
- package/dist/styles/base.js +7 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/pagefind.js +150 -0
- package/dist/styles/pagefind.js.map +1 -1
- package/dist-cdn/base.css +7 -1
- package/dist-cdn/chunks/{base-DXkGlSgH.js → base-DmImIMld.js} +8 -2
- package/dist-cdn/chunks/{base-DXkGlSgH.js.map → base-DmImIMld.js.map} +1 -1
- package/dist-cdn/custom-elements.json +400 -6
- package/dist-cdn/manifest.json +1 -1
- 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 +2 -2
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +13 -4
- package/dist-cdn/uvalib-contents.js +185 -47
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-pagefind-search.js +64 -34
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
- package/package.json +1 -1
- package/skills/uvalib-web-components/SKILL.md +2 -2
- package/skills/uvalib-web-components/reference/components.md +13 -4
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) {
|
|
@@ -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` (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.
|
|
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.
|
|
@@ -564,7 +564,7 @@ A static site (11ty, Jekyll, a generated collection) that searches with [Pagefin
|
|
|
564
564
|
|
|
565
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.
|
|
566
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). 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.
|
|
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.
|
|
568
568
|
|
|
569
569
|
```html
|
|
570
570
|
<!doctype html>
|
|
@@ -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). |
|
|
@@ -1502,7 +1509,7 @@ A record's details as a description list, as on the library's digital collection
|
|
|
1502
1509
|
|
|
1503
1510
|
## `<uvalib-pagefind-search>`
|
|
1504
1511
|
|
|
1505
|
-
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>`. 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.
|
|
1506
1513
|
|
|
1507
1514
|
### Attributes
|
|
1508
1515
|
|
|
@@ -1520,6 +1527,8 @@ Pagefind's default search UI (`PagefindUI`, from the site's own Pagefind bundle)
|
|
|
1520
1527
|
| `translations` | `string` | | JSON of Pagefind UI strings to override (`{"zero_results": "…"}`). |
|
|
1521
1528
|
| `options` | `string` | | JSON of any other `PagefindUI` options (`{"openFilters": ["author"]}`), applied last. |
|
|
1522
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). |
|
|
1523
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. |
|
|
1524
1533
|
|
|
1525
1534
|
### Events
|