From 0ff66cc1d3e52185e32bfbfcc9c69cee294662fe Mon Sep 17 00:00:00 2001 From: onmax Date: Fri, 4 Dec 2026 10:43:29 +0100 Subject: [PATCH 1/3] fix(annotate): a slider compare stays in the text column and no longer zooms --- e2e/annotate.e2e.ts | 12 ++-- e2e/zoom.e2e.ts | 38 +++---------- packages/annotate/docs/components/compare.md | 13 ++--- packages/annotate/src/html.ts | 7 ++- packages/annotate/src/script.ts | 56 +++---------------- packages/annotate/test/annotate.test.ts | 17 +++++- .../references/blocks.md | 2 +- skills/comark-ui/references/annotate.md | 2 +- 8 files changed, 47 insertions(+), 100 deletions(-) diff --git a/e2e/annotate.e2e.ts b/e2e/annotate.e2e.ts index fa9d61d83..1bc598d5f 100644 --- a/e2e/annotate.e2e.ts +++ b/e2e/annotate.e2e.ts @@ -398,7 +398,7 @@ The pigeons ate week 15. expect(Math.abs(note - (await middle(".ca-arrow-left")))).toBeLessThan(2); }); -test("a slider moves its divider by drag and by key, and a click without a drag zooms it", async ({ +test("a slider moves its divider by drag and by key, and no click on it zooms", async ({ page, }) => { await open( @@ -430,7 +430,6 @@ test("a slider moves its divider by drag and by key, and a click without a drag await page.mouse.up(); await expect(handle).toHaveAttribute("aria-valuenow", "25"); await expect(handle).toHaveAttribute("aria-valuetext", "Before 25%, After 75%"); - // The click that ends a drag doesn't zoom. await expect(page.locator(".cz-dialog")).toHaveCount(0); await handle.focus(); @@ -444,12 +443,9 @@ test("a slider moves its divider by drag and by key, and a click without a drag // Focusing and clicking the handle can scroll the page, so measure the pair again. const now = (await swipe.boundingBox())!; await page.mouse.click(now.x + now.width * 0.3, now.y + now.height * 0.6); - await expect(page.locator(".cz-item .ca-swipe")).toBeVisible(); - const zoomed = page.locator(".cz-item .ca-handle"); - await expect(zoomed).toHaveAttribute("aria-valuenow", "95"); - await zoomed.focus(); - await page.keyboard.press("Home"); - await expect(zoomed).toHaveAttribute("aria-valuenow", "0"); + await expect(page.locator(".cz-dialog")).toHaveCount(0); + await expect(swipe).not.toHaveAttribute("data-zoom"); + await expect(page.locator("main .ca-slider")).not.toHaveAttribute("data-wide"); }); test("Copy puts a screenshot on the clipboard with its marks, and a right-click on the image finds the same copy", async ({ diff --git a/e2e/zoom.e2e.ts b/e2e/zoom.e2e.ts index 6927fdf20..3f20663c1 100644 --- a/e2e/zoom.e2e.ts +++ b/e2e/zoom.e2e.ts @@ -747,7 +747,7 @@ test("figure navigation counts interleaved named groups at their first item", as await expect(page.locator("main [data-zoom]").first()).toBeFocused(); }); -test("Up and Down move between the page's figures, scroll a tall one first, and leave a slider its keys", async ({ +test("Up and Down move between the page's figures, scroll a tall one first, and don't wrap", async ({ page, }) => { await page.emulateMedia({ reducedMotion: "reduce" }); @@ -767,25 +767,15 @@ test("Up and Down move between the page's figures, scroll a tall one first, and const filler = "Pigeons home from far away. ".repeat(200); await fixture( page, - await render( - [ - image, - filler, - pair(), - filler, - pair('mode="slider"'), - filler, - "![Full page](/tall.svg)", - ].join("\n\n"), - ), + await render([image, filler, pair(), filler, "![Full page](/tall.svg)"].join("\n\n")), ); const dialog = page.locator(".cz-dialog"); const place = page.locator(".cz-place"); await page.locator("main img[data-zoom]").first().click(); - await expect(place).toHaveText("Figure 1 of 4"); + await expect(place).toHaveText("Figure 1 of 3"); await page.keyboard.press("ArrowDown"); - await expect(place).toHaveText("Figure 2 of 4"); + await expect(place).toHaveText("Figure 2 of 3"); await expect(page.locator(".cz-count")).toHaveText("1 / 2"); await expect(page.locator(".cz-title")).toHaveText("Before"); await expect(page.locator(".cz-thumb")).toHaveCount(2); @@ -793,33 +783,21 @@ test("Up and Down move between the page's figures, scroll a tall one first, and await page.keyboard.press("ArrowRight"); await expect(page.locator(".cz-title")).toHaveText("After"); - // A comparison keeps Up and Down for its divider. - await page.keyboard.press("ArrowDown"); - await expect(place).toHaveText("Figure 3 of 4"); - const handle = page.locator(".cz-item .ca-handle"); - await handle.focus(); - await page.keyboard.press("ArrowUp"); - await expect(handle).toHaveAttribute("aria-valuenow", "55"); - await expect(place).toHaveText("Figure 3 of 4"); - await dialog.focus(); - // A tall figure scrolls to its end before Down moves on, and the last figure doesn't wrap. await page.keyboard.press("ArrowDown"); - await expect(place).toHaveText("Figure 4 of 4"); + await expect(place).toHaveText("Figure 3 of 3"); await expect(page.locator(".cz-nav")).toHaveCount(0); const stage = page.locator(".cz-stage"); await page.keyboard.press("ArrowDown"); await expect.poll(() => stage.evaluate((node) => node.scrollTop)).toBeGreaterThan(0); await stage.evaluate((node) => (node.scrollTop = node.scrollHeight)); await page.keyboard.press("ArrowDown"); - await expect(place).toHaveText("Figure 4 of 4"); + await expect(place).toHaveText("Figure 3 of 3"); await stage.evaluate((node) => (node.scrollTop = 0)); - // Back up to the first comparison, then close: the page has scrolled to it and focus lands on it. - await page.keyboard.press("ArrowUp"); - await expect(place).toHaveText("Figure 3 of 4"); + // Back up to the comparison, then close: the page has scrolled to it and focus lands on it. await page.keyboard.press("ArrowUp"); - await expect(place).toHaveText("Figure 2 of 4"); + await expect(place).toHaveText("Figure 2 of 3"); await page.keyboard.press("Escape"); await expect(dialog).toHaveCount(0); const first = page.locator("main [data-zoom-gallery] [data-zoom]").first(); diff --git a/packages/annotate/docs/components/compare.md b/packages/annotate/docs/components/compare.md index 06dc3f0fb..541d7414d 100644 --- a/packages/annotate/docs/components/compare.md +++ b/packages/annotate/docs/components/compare.md @@ -29,7 +29,7 @@ Fixed. - The two screenshots sit side by side, and on a narrow screen they show one at a time. - They zoom as one gallery. - Notes are numbered on from the first screenshot to the second. -- A slider lays the pair in one frame, with a divider to drag. +- A slider lays the pair in one frame, with a divider to drag. It stays in the text column and doesn't zoom. - Without the script, a slider's screenshots stack. ## Usage @@ -51,7 +51,7 @@ Put exactly two [`screenshot`](/annotate/components/screenshot) blocks inside, t ### Title -Use the `title` prop to say what the comparison shows. Side by side, it's the name screen readers read, and defaults to "Comparison". In a slider, it titles the zoomed view, and defaults to the screenshots' titles, such as "Before / After". +Use the `title` prop to say what the comparison shows. Side by side, it's the name screen readers read, and defaults to "Comparison". In a slider, it names the pair for screen readers, and defaults to the screenshots' titles, such as "Before / After". ```md ::compare{title="Toolbar alignment"} @@ -65,7 +65,7 @@ Use the `title` prop to say what the comparison shows. Side by side, it's the na ### Slider -Use the `mode` prop set to `slider` to lay the two screenshots in one frame, Before left of a divider and After right of it. Use it for a small change in one spot, so the reader sees it at full width. +Use the `mode` prop set to `slider` to lay the two screenshots in one frame, Before left of a divider and After right of it. Use it for a small change in one spot. The slider is as wide as a single screenshot, in the text column, and doesn't open the zoomed view. ::example ```md @@ -86,7 +86,6 @@ Use the `mode` prop set to `slider` to lay the two screenshots in one frame, Bef :: - Drag anywhere on the pair to move the divider, or focus its handle and use the arrow keys. -- A click that doesn't drag zooms the pair. - Side notes join the numbered list. ### Ink @@ -139,13 +138,13 @@ Side by side, a note with `side="left"` or `side="right"` joins the numbered lis Side by side, the pair is a carousel region named by its `title`. Each screenshot is a slide, such as "1 of 2", and a tab stop that opens the [zoomed view](/zoom). -In a slider, the pair is one tab stop that zooms. Its divider is a slider named "Divider between Before and After", with a value such as "Before 50%, After 50%". It takes the arrow keys on the page and in the zoomed view. +In a slider, the pair is a group named by its `title`, and its divider is the only tab stop. The divider is a slider named "Divider between Before and After", with a value such as "Before 50%, After 50%". It takes the arrow keys. ### Keyboard interactions | Key | Description | | --- | --- | -| `Enter`, `Space` | Opens the focused screenshot, or the slider's pair, in the zoomed view. | +| `Enter`, `Space` | Opens the focused screenshot in the zoomed view. | | `ArrowLeft`, `ArrowRight` | Side by side, moves to the other screenshot when they show one at a time, and in the zoomed view. | | `ArrowLeft`, `ArrowDown` | On the slider's divider, moves it 5% left. | | `ArrowRight`, `ArrowUp` | On the slider's divider, moves it 5% right. | @@ -158,7 +157,7 @@ In a slider, the pair is one tab stop that zooms. Its divider is a slider named | Prop | Default | Description | | --- | --- | --- | -| `title` | "Comparison" | What the comparison shows. Screen readers read it side by side. In a slider, it titles the zoomed view, and defaults to the screenshots' titles joined by " / ". | +| `title` | "Comparison" | What the comparison shows. Screen readers read it side by side. In a slider, it names the pair, and defaults to the screenshots' titles joined by " / ". | | `mode` | `columns` | `columns` puts the screenshots side by side. `slider` lays one over the other with a divider to drag. | | `ink` | — | The color of every mark and note in both screenshots that doesn't set its own. A screenshot's own `ink` wins. | | `id` | — | An id for the comparison, such as `#fig-toolbar`, that links and [comark-xref](/xref) references point at. | diff --git a/packages/annotate/src/html.ts b/packages/annotate/src/html.ts index 77442c715..4ec2c7ee3 100644 --- a/packages/annotate/src/html.ts +++ b/packages/annotate/src/html.ts @@ -357,7 +357,8 @@ async function figure( const GRIP = ``; // Without the script the two screenshots stack, each under its title. The script lays them over each other and lets -// the reader drag the divider; the notes stay under the pair, and beside it when zoomed. +// the reader drag the divider; the notes stay under the pair. It sits in the text column and doesn't zoom, since +// zoom would show the pair no larger than the column and put the notes beside it. async function slider({ id: own, title, shots }: Compare, state: State, id: string) { const names = shots.map((shot) => shot.title || shot.alt); let sides = ""; @@ -373,8 +374,8 @@ async function slider({ id: own, title, shots }: Compare, state: State, id: stri ``; return ( - `
${sides}${shots.length === 2 ? handle : ""}
` + - `${notes && `
${notes}
`}${zoomRuntime(state)}${runtime(state)}` + `
${sides}${shots.length === 2 ? handle : ""}
` + + `${notes && `
${notes}
`}${runtime(state)}` ); } diff --git a/packages/annotate/src/script.ts b/packages/annotate/src/script.ts index b7b52ec46..43414a9bd 100644 --- a/packages/annotate/src/script.ts +++ b/packages/annotate/src/script.ts @@ -10,9 +10,9 @@ declare global { } /** - * Starts every `.ca-swipe` slider on the page: a drag anywhere on the pair moves the divider, the handle takes arrow - * keys, and a click that doesn't drag still zooms. The handle is a focusable `role="separator"`, a window splitter, so - * the motion layer, where the page runs it, bends its line past either edge and springs it back. Also lets a reader copy a screenshot with its + * Starts every `.ca-swipe` slider on the page: a drag anywhere on the pair moves the divider, and the handle takes + * arrow keys. The handle is a focusable `role="separator"`, a window splitter, so the motion layer, where the page + * runs it, bends its line past either edge and springs it back. Also lets a reader copy a screenshot with its * marks, by its Copy button, Control or Command+C, or the browser's menu on the image. Returns a function that stops it. The * function is self-contained: the HTML renderer inlines its source as a script, so it must not use anything from * outside its body. @@ -99,14 +99,11 @@ export function start(): () => void { () => document.querySelectorAll(comparisons).forEach(scheduleFit), { signal }, ); - // A press that moves less than this is a click, which zooms. + // A press that moves less than this isn't a drag. const SLOP = 4; type Drag = { swipe: HTMLElement; id: number; x: number; moved: boolean }; let drag: Drag | null = null; - // Whether the last press on each slider dragged. A browser may send that press's click late, even after the next - // press starts, so it's dropped when the click comes rather than on a timer. - const dragged = new WeakMap(); const splits = new WeakMap(); const swipeOf = (target: EventTarget | null) => @@ -165,26 +162,11 @@ export function start(): () => void { if (!drag || event.pointerId !== drag.id) return; const { swipe, moved } = drag; drag = null; - dragged.set(swipe, moved && event.type === "pointerup"); if (moved) swipe.removeAttribute("data-dragging"); }; document.addEventListener("pointerup", release, { signal }); document.addEventListener("pointercancel", release, { signal }); - // Zoom skips a click that's already handled: the one ending a drag, and any on the handle, which is there to drag. - addEventListener( - "click", - (event) => { - const swipe = swipeOf(event.target); - if (!swipe) return; - const handle = event.target instanceof Element && event.target.closest(".ca-handle"); - if (!handle && !dragged.get(swipe)) return; - dragged.delete(swipe); - event.preventDefault(); - }, - { capture: true, signal }, - ); - // Firefox drags the image out of the page otherwise. document.addEventListener( "dragstart", @@ -217,14 +199,6 @@ export function start(): () => void { { signal }, ); - // Zoom copies the slider without its tab stops; the handle needs its own back to move by key. - const focusable = () => { - for (const handle of document.querySelectorAll(".cz-dialog .ca-handle")) - handle.setAttribute("tabindex", "0"); - }; - document.addEventListener("comark-zoom:open", focusable, { signal }); - document.addEventListener("comark-zoom:change", focusable, { signal }); - // Copying. The marks are HTML and SVG over a plain image, so the browser's own Copy Image leaves them out. The copy // paints the screenshot's figure as it rests on the page (image, marks, stamps, arrows, and notes) onto a canvas. const copying = "clipboard" in navigator && "ClipboardItem" in window; @@ -245,14 +219,7 @@ export function start(): () => void { if (!(target instanceof Element)) return null; if (target.closest(".ca-zoom-tools")) return zoomed; if (target.closest(".cz-dialog")) - return zoomed && - target.closest( - zoomed.matches(".ca-side") || zoomed.matches(".ca-swipe") - ? ".ca-swipe" - : ".ca-screenshot", - ) - ? zoomed - : null; + return zoomed && target.closest(".ca-screenshot") ? zoomed : null; return target.closest(".ca-screenshot"); }; const keyOf = (figure: HTMLElement) => { @@ -757,7 +724,7 @@ export function start(): () => void { const figure = own ? figureOf(target) : target?.matches(".cz-dialog") - ? figureOf(target.querySelector(".ca-screenshot, .ca-swipe")) + ? figureOf(target.querySelector(".ca-screenshot")) : null; if (!target || !figure) return; event.preventDefault(); @@ -776,15 +743,8 @@ export function start(): () => void { const focused = active?.closest(".ca-hide") ? ".ca-hide input" : active ? ".ca-copy" : null; zoomCopy?.remove(); zoomCopy = null; - // A screenshot zooms its stage, inside the source that copy paints. Sliders zoom their pair, so use the first - // side as the screenshot source for the keyboard copy path. - zoomed = - item instanceof HTMLElement - ? (item.closest(".ca-screenshot") ?? - (item.matches(".ca-swipe") - ? item.querySelector(".ca-side-before .ca-stage") - : null)) - : null; + // A screenshot zooms its stage, inside the source that copy paints. + zoomed = item instanceof HTMLElement ? item.closest(".ca-screenshot") : null; // Zoom copies the figure as it was, a moment's "Copied" included; a thumbnail is a button and gets no button inside. for (const part of document.querySelectorAll( ".cz-thumb :is(.ca-copy,.ca-copy-status,.ca-hide)", diff --git a/packages/annotate/test/annotate.test.ts b/packages/annotate/test/annotate.test.ts index ede94e1ac..7a7345d65 100644 --- a/packages/annotate/test/annotate.test.ts +++ b/packages/annotate/test/annotate.test.ts @@ -89,7 +89,7 @@ describe("comark-annotate", () => { ); expect(issues).toEqual([]); expect(html).toContain( - '
Before
Before
After { expect(html).not.toContain('class="cc"'); }); + it("keeps a slider in the text column and doesn't zoom it, while a columns compare stays wide", async () => { + const { html } = await run( + compare.replace("::compare", '::compare{mode="slider" title="Toolbar"}'), + ); + const root = html.match(/
]*>/)![0]; + expect(root).not.toContain("data-wide"); + expect(root).toContain('role="group" aria-label="Toolbar"'); + const markup = html.replace(/<(style|script)>[^]*?<\/\1>/g, ""); + expect(markup).not.toContain("data-zoom"); + expect(markup.match(/tabindex="0"/g)).toHaveLength(1); + expect((await run(compare)).html).toMatch(/class="ca ca-compare"[^>]* data-wide/); + }); + it("carries the slider script once per render", async () => { const slider = compare.replace("::compare", '::compare{mode="slider"}'); const { html } = await run(`${slider}\n${slider.replaceAll(".png", "-2.png")}`); @@ -157,7 +170,7 @@ describe("comark-annotate", () => { ) ).html; expect(slider).toContain( - '
', + '
'); expect((await run('::screenshot{src="a.png" alt="A"}\n::')).html).toContain( diff --git a/skills/before-after-evidence/references/blocks.md b/skills/before-after-evidence/references/blocks.md index cdfbc238b..1a3471283 100644 --- a/skills/before-after-evidence/references/blocks.md +++ b/skills/before-after-evidence/references/blocks.md @@ -9,7 +9,7 @@ Two `:::screenshot` blocks inside, before then after. They're titled Before and | Prop | What it does | | --- | --- | | `title` | Names the comparison for screen readers. | -| `mode` | `columns` (default) side by side, or `slider`: one full-width image with a divider to drag. Use `slider` when the change is small and in the same spot, such as one label. | +| `mode` | `columns` (default) side by side, or `slider`: one image, as wide as a single screenshot and not zoomable, with a divider to drag. Use `slider` when the change is small and in the same spot, such as one label. | ## `:::screenshot` diff --git a/skills/comark-ui/references/annotate.md b/skills/comark-ui/references/annotate.md index 9444ea24d..1cfe804a9 100644 --- a/skills/comark-ui/references/annotate.md +++ b/skills/comark-ui/references/annotate.md @@ -8,7 +8,7 @@ Pick what explains the change best: - One `::screenshot` with marks, when a single state shows the point. - A `::compare` of two screenshots, when the change is the point. Capture both at the same viewport, zoom, scroll, and page state, and set the same `viewport` on both. Each image gets under half the page width, where the text of a full-page capture is too small to read, so clip both captures to the same region around the change, such as Playwright's `screenshot({ clip })`. -- `::compare{mode="slider"}` instead, when both screenshots show the same spot and the change is small, such as a number or a label at the same place. The reader drags a divider across one full-width image instead of reading two half-width ones. Side notes become numbered notes there, so skip `side`. +- `::compare{mode="slider"}` instead, when both screenshots show the same spot and the change is small, such as a number or a label at the same place. The reader drags a divider across one image, as wide as a single screenshot, instead of reading two half-width ones. It doesn't zoom. Side notes become numbered notes there, so skip `side`. - A side note for the two or three points that matter most. With `mark="none"` and `to` on the exact spot, the arrow alone points and nothing covers the screen, which reads cleanest. Other notes stay numbered in the list under the image. In a side-by-side compare only `top` and `bottom` keep their arrows; left and right notes join the list. For a review the reader should follow without a key, write it the way a designer marks up a board: the default ink with no `color`, every note a side note in the margin nearest its point, set off with `at` so its arrow sweeps in, and a `bracket` where a note covers a run of rows. Write the notes of a compare as a pair that argue the change: "The type gets the headline…" on the before, "The message becomes the starting point." on the after. From 262f86fee87181de5e8172d5a3741f3631a5dc22 Mon Sep 17 00:00:00 2001 From: "vite-hub[bot]" <320448255+vite-hub[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 11:03:02 +0100 Subject: [PATCH 2/3] fix(ui): keep slider compare headings in the text column --- e2e/wide.e2e.ts | 19 +++++++++++++++++-- packages/annotate/docs/components/compare.md | 2 +- packages/ui/src/typeset-css.ts | 4 ++-- .../references/blocks.md | 2 +- skills/comark-ui/references/annotate.md | 2 +- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/e2e/wide.e2e.ts b/e2e/wide.e2e.ts index b0aa6ed99..2f84f9ece 100644 --- a/e2e/wide.e2e.ts +++ b/e2e/wide.e2e.ts @@ -20,14 +20,15 @@ flowchart LR const small = "```mermaid\nflowchart TD\n A --> B\n```"; const compare = "## Checkout\n\n::compare\n![Before](https://example.com/a.png)\n![After](https://example.com/b.png)\n::"; +const slider = compare.replace("::compare", '::compare{mode="slider"}'); // A 46rem column in a 1440px window, the way a docs page or a review doc lays out its text. -async function column(page: Page, room?: { start: string; end: string }) { +async function column(page: Page, room?: { start: string; end: string }, comparison = compare) { await page.setViewportSize({ width: 1440, height: 900 }); const style = room ? `--comark-wide-start:${room.start};--comark-wide-end:${room.end};` : ""; await page.setContent( `
${await render( - [flowchart, small, compare].join("\n\n"), + [flowchart, small, comparison].join("\n\n"), )}
`, ); } @@ -83,6 +84,20 @@ test("a wide diagram grows to its own width, centered on the column, and a compa expect(wide.short).toBe(wide.main); }); +test("a slider and its heading stay aligned in the column even with room to widen", async ({ + page, +}) => { + const side = "calc((100vw - 100%) / 2 - 1.5rem)"; + await column(page, { start: side, end: side }, slider); + const layout = await widths(page); + const columnLeft = layout.center - layout.main / 2; + expect(layout.compare).toBe(layout.main); + expect(layout.compareLeft).toBe(columnLeft); + expect(layout.heading.width).toBe(layout.main); + expect(layout.heading.left).toBe(columnLeft); + expect(layout.title).toBe(columnLeft); +}); + test("with room on one side only, a wide diagram keeps its size and moves toward it", async ({ page, }) => { diff --git a/packages/annotate/docs/components/compare.md b/packages/annotate/docs/components/compare.md index 541d7414d..bc170d53f 100644 --- a/packages/annotate/docs/components/compare.md +++ b/packages/annotate/docs/components/compare.md @@ -65,7 +65,7 @@ Use the `title` prop to say what the comparison shows. Side by side, it's the na ### Slider -Use the `mode` prop set to `slider` to lay the two screenshots in one frame, Before left of a divider and After right of it. Use it for a small change in one spot. The slider is as wide as a single screenshot, in the text column, and doesn't open the zoomed view. +Use the `mode` prop set to `slider` to lay the two screenshots in one frame, Before left of a divider and After right of it. Use it for a small change in one spot. The slider fills the text column and doesn't open the zoomed view. ::example ```md diff --git a/packages/ui/src/typeset-css.ts b/packages/ui/src/typeset-css.ts index 2dc0d0dc5..9a58c544f 100644 --- a/packages/ui/src/typeset-css.ts +++ b/packages/ui/src/typeset-css.ts @@ -300,10 +300,10 @@ const rules = ` into the room the page gives it on each side, --comark-wide-start and --comark-wide-end, up to its own width (--comark-wide-width) and --comark-wide-max. It stays centered on the column while both sides have room, and moves toward the side that has more when one doesn't. Without room set, it keeps to the column. Only the document's own - blocks grow, not one inside a list or tabs. A heading right above a comparison grows with it, so it starts where + blocks grow, not one inside a list or tabs. A heading right above a wide comparison grows with it, so it starts where Before does and reads as its title. comark-links may wrap the heading, and the comparison's styles may sit between them. */ ${documentRoot} > [data-wide], -:scope > :is(h2, h3, h4, .cl-heading:has(> :is(h2, h3, h4))):has(+ .ca-compare, + style + .ca-compare) { +:scope > :is(h2, h3, h4, .cl-heading:has(> :is(h2, h3, h4))):has(+ .ca-compare[data-wide], + style + .ca-compare[data-wide]) { /* Room a page works out from the window can come out negative on a phone, where the column fills it: none, then. */ --_ty-start: max(0px, var(--comark-wide-start, 0px)); --_ty-end: max(0px, var(--comark-wide-end, 0px)); diff --git a/skills/before-after-evidence/references/blocks.md b/skills/before-after-evidence/references/blocks.md index 1a3471283..015323ec2 100644 --- a/skills/before-after-evidence/references/blocks.md +++ b/skills/before-after-evidence/references/blocks.md @@ -9,7 +9,7 @@ Two `:::screenshot` blocks inside, before then after. They're titled Before and | Prop | What it does | | --- | --- | | `title` | Names the comparison for screen readers. | -| `mode` | `columns` (default) side by side, or `slider`: one image, as wide as a single screenshot and not zoomable, with a divider to drag. Use `slider` when the change is small and in the same spot, such as one label. | +| `mode` | `columns` (default) side by side, or `slider`: one image that fills the text column, with a divider to drag and no zoom. Use `slider` when the change is small and in the same spot, such as one label. | ## `:::screenshot` diff --git a/skills/comark-ui/references/annotate.md b/skills/comark-ui/references/annotate.md index 1cfe804a9..a86057cd0 100644 --- a/skills/comark-ui/references/annotate.md +++ b/skills/comark-ui/references/annotate.md @@ -8,7 +8,7 @@ Pick what explains the change best: - One `::screenshot` with marks, when a single state shows the point. - A `::compare` of two screenshots, when the change is the point. Capture both at the same viewport, zoom, scroll, and page state, and set the same `viewport` on both. Each image gets under half the page width, where the text of a full-page capture is too small to read, so clip both captures to the same region around the change, such as Playwright's `screenshot({ clip })`. -- `::compare{mode="slider"}` instead, when both screenshots show the same spot and the change is small, such as a number or a label at the same place. The reader drags a divider across one image, as wide as a single screenshot, instead of reading two half-width ones. It doesn't zoom. Side notes become numbered notes there, so skip `side`. +- `::compare{mode="slider"}` instead, when both screenshots show the same spot and the change is small, such as a number or a label at the same place. The reader drags a divider across one image that fills the text column instead of reading two half-width ones. It doesn't zoom. Side notes become numbered notes there, so skip `side`. - A side note for the two or three points that matter most. With `mark="none"` and `to` on the exact spot, the arrow alone points and nothing covers the screen, which reads cleanest. Other notes stay numbered in the list under the image. In a side-by-side compare only `top` and `bottom` keep their arrows; left and right notes join the list. For a review the reader should follow without a key, write it the way a designer marks up a board: the default ink with no `color`, every note a side note in the margin nearest its point, set off with `at` so its arrow sweeps in, and a `bracket` where a note covers a run of rows. Write the notes of a compare as a pair that argue the change: "The type gets the headline…" on the before, "The message becomes the starting point." on the after. From 3c53d9b701be81e85289741dce83e28ac2308291 Mon Sep 17 00:00:00 2001 From: "vite-hub[bot]" <320448255+vite-hub[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 11:26:20 +0100 Subject: [PATCH 3/3] test(ui): expect only wide comparisons to widen headings --- packages/ui/test/ui.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/test/ui.test.ts b/packages/ui/test/ui.test.ts index afc779365..faef2ac60 100644 --- a/packages/ui/test/ui.test.ts +++ b/packages/ui/test/ui.test.ts @@ -388,7 +388,7 @@ describe("comark-ui", () => { expect(css).not.toContain("/*"); // Wide blocks grow only into the room the page gives them. expect(css).toContain( - ":is(:scope,:scope>.cr)>[data-wide],:scope>:is(h2,h3,h4,.cl-heading:has(>:is(h2,h3,h4))):has(+ .ca-compare,+ style + .ca-compare){--_ty-start:max(0px,var(--comark-wide-start,0px));--_ty-end:max(0px,var(--comark-wide-end,0px));", + ":is(:scope,:scope>.cr)>[data-wide],:scope>:is(h2,h3,h4,.cl-heading:has(>:is(h2,h3,h4))):has(+ .ca-compare[data-wide],+ style + .ca-compare[data-wide]){--_ty-start:max(0px,var(--comark-wide-start,0px));--_ty-end:max(0px,var(--comark-wide-end,0px));", ); const off = await renderHtml(markdown, { typeset: false }); expect(off).not.toContain("data-comark-typeset");