Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ component contracts, verification gates, and current implementation status.
algorithm, or change its breakpoints, column counts, item distribution/order,
gutters, or loading behavior. Grid work is limited to equivalent presentation
migration, preserving the contract in DESIGN.md.
- Clover was upgraded to exact `4.0.0-rc.2` before slider edits, then pinned to
exact stable `3.17.0` (October 14, 2026) for an upstream viewer fix. For
subsequent upgrades, query published versions/tags; do not assume `latest`,
- Clover is `@nulib/clover` (the 4.x line, from nulib-ds), pinned exact:
currently `4.9.2` (November 11, 2026); DESIGN.md records the compatibility
notes. For upgrades, query published versions/tags; do not assume `latest`,
`next`, or `rc` selects the intended line. Use Node 24.11.1 as recorded in
`.tool-versions`.
- Inspect the installed Clover API/DOM, not old Swiper assumptions. Keep slider
CSS card counts/gaps synchronized with group-size breakpoints. Clover 3.17.0
(like RC.2) ignores its fetch credentials option, so retain SliderWrapper's credentialed fetch
and abort handling until that upstream issue is verified fixed.
- Inspect the installed Clover API/DOM (`.clover-*` classes, `--clover-*`
properties in `@layer clover`), not Clover 3 or Swiper assumptions. Slider
card counts/gaps live only in `SliderWrapper.module.css`. Keep
SliderWrapper's credentialed, abortable collection fetch and
`CLOVER_REQUEST` (credentials for JSON, none for public VTT).
- Use Clover's public exports and types. Verify viewer, primitives, content
search, media, embeds, and sliders after upgrades. The homepage still uses
Swiper; keep that dependency.
Expand Down
44 changes: 40 additions & 4 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ application callers. Radix still owns accessible interaction behavior.

The migration preserves the existing design and Pages Router. It does not
redesign Masonry or change React/Next.js versions. Clover was upgraded to the
latest published 4.x release candidate before slider code or styles changed.
latest published 4.x release candidate before slider code or styles changed,
and is now the stable 4.x line, `@nulib/clover` (see Clover compatibility).
The homepage still uses Swiper; that dependency remains necessary.

The initial audit found 101 Stitches-importing files, 330 styled definitions,
Expand Down Expand Up @@ -150,8 +151,9 @@ Keep these properties narrowly typed and owned by their component. Do not
introduce arbitrary style-object props or generate CSS rules in JavaScript.
SVG `fill` remains an ordinary SVG presentation attribute.

Clover's distribution injects its own bundled CSS. Radix, Next Image, Swiper,
OpenSeadragon, and other rendering/positioning libraries still manage inline
Clover 4's stylesheet (`@nulib/clover/styles.css`, imported in `_app.tsx`) is
in `@layer clover`, so DC's unlayered module overrides win. Radix, Next Image,
Swiper, Clover, and other rendering/positioning libraries still manage inline
geometry where necessary. These are vendor boundaries, not application
CSS-in-JS. Vendor overrides stay scoped in the relevant module, and Clover's
palette is mapped to `--dc-*` in `components/Clover/clover-tokens.css`.
Expand Down Expand Up @@ -184,7 +186,41 @@ library, or another distribution algorithm.

## Clover compatibility

**Current pin: exact `3.17.0`.** On October 14, 2026, Clover was moved from
**Current pin: exact `@nulib/clover` `4.9.2`** (November 11, 2026, the
`latest` tag). Clover 4 moved to the nulib-ds organization under a new package
name; `@samvera/clover-iiif` is removed. Integration notes:

- Its `exports` are ESM-only (`import` condition), which `next/dynamic`'s
`require.resolveWeak` cannot resolve, so the viewer loads through
`components/Clover/CloverViewer.tsx`. Jest maps the package to
`dist/index.mjs` and transforms it. Upstream has an unreleased fix (nulib-ds
clover #415) adding a `default` condition; the wrapper can go once released.
- Viewer props replace `options`: `header`, `panelLayout: "tabs"`,
`panelSections` (About added during a content search), `panelLabels`
("Chapters" for A/V), `defaultPanelOpen`, `searchQuery`, `request` and
`onContentStateChange`. There is no `contentSearchCallback`, so a search in
the viewer is not written to the URL. Since 4.5.0 a search opened with
`searchQuery` stays on the content state's Canvas.
- `CLOVER_REQUEST` (`components/Clover/clover-request.ts`) sends credentials
for JSON and none for VTT, which `/public/` serves with `ACAO: *`.
SliderWrapper still fetches collections itself (credentialed, abortable) to
drop nested collections and add the View all `homepage`.
- Content states are `FragmentSelector`s (`t=…` or `xywh=…`), not Clover 3's
`PointSelector.t`; `selectorStartTime` reads both for Download and Share.
- A IIIF value is HTML only when wrapped in a tag, so the error pages'
summaries are wrapped in `<span>`.
- Clover's rem tokens scale with DC's 19px root. ViewerWrapper rescales the
panel's text tokens and pins the thumbnail rail's `--clover-items-height` to
128px, each picture cropped to fill a box from square to twice as wide. SliderWrapper sizes
cards by width (Clover sets an inline `flex: 0 0 auto`), squares and crops
them, and sets `--clover-items-height` to the card width through container
units on `.clover-items-frame`, so Clover centres its arrows and edge shades
on the pictures. Its arrows hang half off the slider at 1160px and wider.
Cards run 2/3/4/5 across from 334/767/991/1199px (the 6 across from 1439px
was dropped), 20px apart (`--dc-space-legacy-4`) at every width, the same
space as under the subheading.

**Previous pin: exact `3.17.0`.** On October 14, 2026, Clover was moved from
`4.0.0-rc.2` to stable `3.17.0` (published that day, the `latest` tag) to pick
up an upstream viewer fix. 3.17.0 ships the same Embla slider, slider DOM
hooks, public exports, and `.d.ts` set as RC.2; its type changes are additive
Expand Down
4 changes: 4 additions & 0 deletions components/Clover/CloverViewer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// next/dynamic resolves its target with `require.resolveWeak`, which fails on
// @nulib/clover's import-only `exports`. Dynamically importing this local
// module instead keeps the package behind an ordinary static ESM import.
export { default } from "@nulib/clover";
117 changes: 94 additions & 23 deletions components/Clover/SliderWrapper.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,99 @@
position: relative;
z-index: 0;
--slider-columns: 1;
--slider-gap: 19px;
--clover-thumbnail-width: 100%;
/* One space between cards and under the subheading, at every width. */
--slider-gap: var(--dc-space-legacy-4);
}
/* RC.2 sizes cards with CSS. Match the previous Swiper viewport breakpoints
and the numeric gaps/group sizes in SliderWrapper.tsx. */
.styledSliderIIIFWrapper :global(.clover-slider-slide) {
/* Clover 4's slider is a fixed-height strip of natural-width pictures. Keep
DC's column counts per breakpoint, up to 5 across (formerly also mirrored by
the Clover 3 breakpoints in SliderWrapper.tsx; CSS is now the only source). */
.styledSliderIIIFWrapper :global(.clover-items) {
--clover-items-gap: var(--slider-gap);
/* Clover centres its arrows and sizes its edge shades by the picture
height (`--clover-items-height`, default 8rem). DC sizes cards by width
and squares them, so the height is the card width. Container units keep
it a length; a percentage would resolve against each element using it. */
--clover-items-height: calc(
(100cqw - (var(--slider-columns) - 1) * var(--slider-gap)) /
var(--slider-columns)
);
}
.styledSliderIIIFWrapper :global(.clover-items-frame) {
container-type: inline-size;
}
/* Clover sets an inline `flex: 0 0 auto` on each item, so size it by width. */
.styledSliderIIIFWrapper :global(.clover-items-item) {
width: calc(
(100% - (var(--slider-columns) - 1) * var(--slider-gap)) /
var(--slider-columns)
);
min-width: 0;
}
.styledSliderIIIFWrapper :global(.clover-items-figure) {
grid-template-columns: 1fr;
}
.styledSliderIIIFWrapper :global(.clover-slider-item) {
/* Clover 3.x cropped every thumbnail to a square; Clover 4 keeps each
picture's own proportions. */
.styledSliderIIIFWrapper :global(.clover-items-picture) img {
width: 100%;
min-width: 0;
height: auto;
aspect-ratio: 1;
object-fit: cover;
}
/* A clamped title's full text, shown on hover and focus, as a popover like
"View as IIIF" (components/Shared/IIIF/Share.module.css). */
.styledSliderIIIFWrapper :global(.clover-items-label-full) {
padding: var(--dc-space-gr2);
border-radius: 3px;
background-color: var(--dc-color-white);
box-shadow: 5px 5px 19px 0 #0002;
}
/* Header: a purple title, with "View all" as a text link and arrow like
SectionHeading's "View Collections" (Clover renders it as bare text, so
the arrow is drawn by ::after). */
.styledSliderIIIFWrapper :global(.clover-items-header) {
align-items: center;
margin-bottom: var(--slider-gap);
}
.styledSliderIIIFWrapper :global(.clover-items-title) {
font-family: var(--dc-font-northwestern-sans-regular);
font-weight: 400;
font-size: 1.25rem;
line-height: 1.12;
color: var(--dc-color-purple);
}
.styledSliderIIIFWrapper :global(.clover-items-homepage) {
display: flex;
align-items: center;
height: var(--dc-size-gr4);
color: var(--dc-color-purple);
font-size: var(--dc-font-size-gr4);
text-decoration: none;
}
.styledSliderIIIFWrapper :global(.clover-items-homepage):hover {
color: var(--dc-color-purple120);
}
/* IconArrowForward in Icon's 31px box with its 0.5em padding. */
.styledSliderIIIFWrapper :global(.clover-items-homepage)::after {
content: "";
flex-shrink: 0;
width: 31px;
height: 31px;
background-color: var(--dc-color-purple60);
-webkit-mask: var(--slider-arrow) center / calc(100% - 1em) no-repeat;
mask: var(--slider-arrow) center / calc(100% - 1em) no-repeat;
--slider-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M268 112l144 144-144 144M392 256H100'/%3E%3C/svg%3E");
}
/* Arrows hang half off the slider's edges while the page has room beside
the 1120px Container: half of Clover's 42.5px control past its 19px gutter,
allowing for a classic 17px scrollbar. Narrower, they stay inset. */
@media (min-width: 1160px) {
.styledSliderIIIFWrapper :global(.clover-items-scroll-prev) {
inset-inline-start: calc(var(--clover-control) / -2);
}
.styledSliderIIIFWrapper :global(.clover-items-scroll-next) {
inset-inline-end: calc(var(--clover-control) / -2);
}
}
@media (min-width: 334px) {
.styledSliderIIIFWrapper {
Expand All @@ -30,32 +109,24 @@
@media (min-width: 991px) {
.styledSliderIIIFWrapper {
--slider-columns: 4;
--slider-gap: 30.742px;
}
}
@media (min-width: 1199px) {
.styledSliderIIIFWrapper {
--slider-columns: 5;
}
}
@media (min-width: 1439px) {
.styledSliderIIIFWrapper {
--slider-columns: 6;
--slider-gap: 49.740556px;
}
}
.styledSliderIIIFWrapper :global(.clover-slider-header-view-all) {
color: var(--dc-color-white);
}
.styledSliderIIIFWrapper :global(.clover-slider-slide)[data-type="collection"] {
display: none;
}
@media (max-width: 575px) {
.styledSliderIIIFWrapper > div > div {
.styledSliderIIIFWrapper :global(.clover-items-header) {
flex-direction: column;
align-items: center;
text-align: center;
}
.styledSliderIIIFWrapper > div > div > div:last-child {
padding-top: var(--dc-space-gr2);
.styledSliderIIIFWrapper :global(.clover-items-homepage) {
margin-inline-start: 0;
margin-top: var(--dc-space-gr2);
}
.styledSliderIIIFWrapper :global(.clover-items-caption) {
text-align: center;
}
}
27 changes: 17 additions & 10 deletions components/Clover/SliderWrapper.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { render, waitFor } from "@testing-library/react";
import Slider from "@samvera/clover-iiif/slider";
import { Items } from "@nulib/clover";
import SliderWrapper from "./SliderWrapper";

jest.mock("@samvera/clover-iiif/slider", () => ({
jest.mock("@nulib/clover", () => ({
__esModule: true,
default: jest.fn(() => null),
Items: jest.fn(() => null),
}));

const originalFetch = global.fetch;
Expand All @@ -18,7 +18,10 @@ it("loads a collection with credentials and supplies the resolved items to Clove
type: "Collection",
label: { en: ["Collection"] },
summary: { en: ["Summary"] },
items: [{ id: "https://example.org/manifest", type: "Manifest" }],
items: [
{ id: "https://example.org/manifest", type: "Manifest" },
{ id: "https://example.org/nested", type: "Collection" },
],
};
const fetchMock = jest
.fn()
Expand All @@ -30,16 +33,20 @@ it("loads a collection with credentials and supplies the resolved items to Clove
customViewAll="/search?collection=test"
/>,
);
await waitFor(() => expect(Slider).toHaveBeenCalled());
await waitFor(() => expect(Items).toHaveBeenCalled());
expect(fetchMock).toHaveBeenCalledWith("https://example.org/collection", {
credentials: "include",
signal: expect.any(AbortSignal),
});
expect(jest.mocked(Slider).mock.calls[0][0]).toMatchObject({
items: collection.items,
label: collection.label,
summary: collection.summary,
options: { customViewAll: "/search?collection=test" },
expect(jest.mocked(Items).mock.calls[0][0]).toMatchObject({
layout: "slider",
request: { credentials: "include" },
iiifContent: {
items: [collection.items[0]],
label: collection.label,
summary: collection.summary,
homepage: [{ id: "/search?collection=test" }],
},
});
});

Expand Down
Loading