Compare commits

...
11 changed files with 465 additions and 70 deletions

No files matched your search

+3 -2
View File
@@ -22,10 +22,10 @@ Explore maps your app: a screenshot of every screen, connected by the taps betwe
<a href="docs/screenshots/readme-screens-light.png">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/screenshots/readme-screens-dark.png">
<img width="100%" alt="The Screens view of a euxy review showing Changed 7 of All 19: the app/ route tree on the left, and beside it a grid of the changed screens in the same order, each with its route below the screenshot: a red dot for the removed /lane-editor, orange for the modified /new-pattern and /channel-surf, green for the new /lane-editor/0, and Changed in dark under /p and /patterns" src="docs/screenshots/readme-screens-light.png">
<img width="100%" alt="The Screens view of a euxy review showing Changed 7 of All 19: a Search field and the app/ route tree on the left, and beside it a grid of the changed screens in the same order, each with its route below the screenshot: a red dot for the removed /lane-editor, orange for the modified /new-pattern and /channel-surf, green for the new /lane-editor/0, and Changed in dark under /p, /patterns and a /p/ link; at the top right, a switch between Grid and Filmstrip" src="docs/screenshots/readme-screens-light.png">
</picture>
</a>
<strong>Screens</strong>: every capture in one grid, or only the changed ones, beside the route tree, with a dot for what changed.
<strong>Screens</strong>: every capture, or only the changed ones, in a grid or one at a time in a filmstrip, beside the route tree, with a dot for what changed.
</td>
<td width="50%" valign="top">
<a href="docs/screenshots/readme-pr-comment-light.png">
@@ -579,6 +579,7 @@ sequenceDiagram
- The review workflow runs on open, non-draft PRs from the repository whose author has write access. Bots such as Devin go under `ci.trustedAuthors` in `.expo-explore/config.yaml`.
- A screen with a source change is **Modified** if its captures differ.
- If EAS fails to start a session, Explore starts a new one, up to five times within 30 minutes. On your machine, a local simulator can stand in for EAS Simulator.
- Each capture job's summary shows where its time went, phase by phase, and its diagnostics artifact keeps the timings (`timings.jsonl`). When a review waits for the baseline of its base commit, its log and the PR comment name the step that baseline job is in.
The same review runs for any two commits without a PR ([`explore-compare.yml`](#compare-any-two-commits), linking the report from the run summary) and on your machine (`capture`, [above](#quick-start)). The workflows' logic lives in `expo-explore ci:*` commands, so a fix reaches CI with the `@expo/explore` version the workflows pin.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 KiB

After

Width:  |  Height:  |  Size: 324 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 KiB

After

Width:  |  Height:  |  Size: 326 KiB

+12 -2
View File
@@ -85,10 +85,20 @@ jobs:
- *install-explore
- name: Install the launch recording decoder
shell: bash
# Launch recordings (capture.launch) are decoded with ffmpeg; GitHub's Ubuntu runners do not ship it.
# Launch recordings (capture.launch) are decoded with ffmpeg; GitHub's Ubuntu runners do not ship it. A package
# mirror can stall without failing, so each apt-get call has network timeouts and a time limit, and a stalled
# attempt is tried once more: the step fails in minutes rather than holding the job to its timeout.
timeout-minutes: 10
run: |
set -euo pipefail
command -v ffmpeg > /dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq --no-install-recommends ffmpeg > /dev/null; }
if ! command -v ffmpeg > /dev/null; then
apt=(sudo apt-get -qq -o Acquire::Retries=3 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 -o DPkg::Lock::Timeout=120)
for attempt in 1 2; do
if timeout 120 "${apt[@]}" update && timeout 120 "${apt[@]}" install -y --no-install-recommends ffmpeg > /dev/null; then break; fi
if [ "$attempt" = 2 ]; then echo '::error title=LAUNCH_DECODER_INSTALL_FAILED::apt-get could not install ffmpeg; rerun the job.'; exit 1; fi
echo "::warning title=LAUNCH_DECODER_INSTALL_RETRY::apt-get did not install ffmpeg on attempt $attempt; trying again."
done
fi
ffmpeg -version | head -1
- name: Verify deterministic source planning
shell: bash
+12 -2
View File
@@ -122,10 +122,20 @@ jobs:
- *install-explore
- name: Install the launch recording decoder
shell: bash
# Launch recordings (capture.launch) are decoded with ffmpeg; GitHub's Ubuntu runners do not ship it.
# Launch recordings (capture.launch) are decoded with ffmpeg; GitHub's Ubuntu runners do not ship it. A package
# mirror can stall without failing, so each apt-get call has network timeouts and a time limit, and a stalled
# attempt is tried once more: the step fails in minutes rather than holding the job to its timeout.
timeout-minutes: 10
run: |
set -euo pipefail
command -v ffmpeg > /dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq --no-install-recommends ffmpeg > /dev/null; }
if ! command -v ffmpeg > /dev/null; then
apt=(sudo apt-get -qq -o Acquire::Retries=3 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 -o DPkg::Lock::Timeout=120)
for attempt in 1 2; do
if timeout 120 "${apt[@]}" update && timeout 120 "${apt[@]}" install -y --no-install-recommends ffmpeg > /dev/null; then break; fi
if [ "$attempt" = 2 ]; then echo '::error title=LAUNCH_DECODER_INSTALL_FAILED::apt-get could not install ffmpeg; rerun the job.'; exit 1; fi
echo "::warning title=LAUNCH_DECODER_INSTALL_RETRY::apt-get did not install ffmpeg on attempt $attempt; trying again."
done
fi
ffmpeg -version | head -1
- name: Verify deterministic source planning
env:
+12 -2
View File
@@ -111,10 +111,20 @@ jobs:
with: { ref: '${{ steps.pr.outputs.head }}', path: app-head, fetch-depth: 0, persist-credentials: false }
- name: Install the launch recording decoder
shell: bash
# Launch recordings (capture.launch) are decoded with ffmpeg; GitHub's Ubuntu runners do not ship it.
# Launch recordings (capture.launch) are decoded with ffmpeg; GitHub's Ubuntu runners do not ship it. A package
# mirror can stall without failing, so each apt-get call has network timeouts and a time limit, and a stalled
# attempt is tried once more: the step fails in minutes rather than holding the job to its timeout.
timeout-minutes: 10
run: |
set -euo pipefail
command -v ffmpeg > /dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq --no-install-recommends ffmpeg > /dev/null; }
if ! command -v ffmpeg > /dev/null; then
apt=(sudo apt-get -qq -o Acquire::Retries=3 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 -o DPkg::Lock::Timeout=120)
for attempt in 1 2; do
if timeout 120 "${apt[@]}" update && timeout 120 "${apt[@]}" install -y --no-install-recommends ffmpeg > /dev/null; then break; fi
if [ "$attempt" = 2 ]; then echo '::error title=LAUNCH_DECODER_INSTALL_FAILED::apt-get could not install ffmpeg; rerun the job.'; exit 1; fi
echo "::warning title=LAUNCH_DECODER_INSTALL_RETRY::apt-get did not install ffmpeg on attempt $attempt; trying again."
done
fi
ffmpeg -version | head -1
- name: Verify deterministic source planning
env:
+141 -1
View File
@@ -1493,8 +1493,40 @@ test("Screens' filmstrip: switched from the corner switch, stepped with the arro
await page.mouse.down({ clickCount: 2 });
await page.mouse.up({ clickCount: 2 });
await expect(middle).toHaveAttribute("data-screen-id", last);
// In the filmstrip the Inspector opens only from a click on the middle screen, so the one the first click opened closes.
await expect(inspector).toBeHidden();
// With the sidebar folded, the middle screen is at the centre of the canvas.
await expect(view.getByRole("button", { name: "Show sidebar" })).toBeVisible();
const centre = await middle.evaluate(element => { const box = element.getBoundingClientRect(); return box.left + box.width / 2; });
expect(Math.abs(centre - page.viewportSize()!.width / 2)).toBeLessThan(2);
// A sideways trackpad swipe moves the strip with it, and a short one springs back when it ends; a wheel notch steps.
const lastAt = ids.indexOf(last);
await middle.hover();
// Measured in the page two frames after the event: the swipe ends, and the strip settles, 100 ms after the last one.
const moved = await middle.evaluate(async element => {
element.dispatchEvent(new WheelEvent("wheel", { deltaX: -40, bubbles: true, cancelable: true }));
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
const box = element.getBoundingClientRect();
return { centre: box.left + box.width / 2, swiping: element.parentElement!.classList.contains("swiping") };
});
expect(moved.swiping).toBe(true);
expect(moved.centre - centre).toBeGreaterThan(20);
expect(moved.centre - centre).toBeLessThan(60);
await expect(strip.locator(".screens-strip-stage")).not.toHaveClass(/swiping/);
await expect(middle).toHaveAttribute("data-screen-id", last);
await expect.poll(() => middle.evaluate(element => { const box = element.getBoundingClientRect(); return Math.round(box.left + box.width / 2); }))
.toBe(Math.round(centre));
await page.mouse.wheel(0, -100);
await expect(middle).toHaveAttribute("data-screen-id", ids[lastAt - 1]!);
await page.waitForTimeout(300);
await page.mouse.wheel(100, 0);
await expect(middle).toHaveAttribute("data-screen-id", last);
// A click on the middle screen opens the Inspector; Esc closes it first, then steps back out to the grid.
await middle.locator(".screens-strip-target").click();
await expect(inspector).toBeVisible();
// Esc closes the Inspector first, then steps back out to the grid with the screen still picked.
await page.keyboard.press("Escape");
await expect(inspector).toBeHidden();
await expect(strip).toBeVisible();
@@ -1581,6 +1613,63 @@ test("Screens' filmstrip keeps Changed across a layout switch, opens only from a
await expect(page).toHaveURL(/[?&]layout=filmstrip/);
});
test("Screens' filmstrip gestures: a short flick lands where it carries the strip, and a step made during a swipe is not undone by it", async ({ page }) => {
await serveWorkspace(page);
await page.goto("/screens");
const view = page.getByRole("main", { name: "Screens" });
await view.getByRole("button", { name: /^All/ }).click();
const ids = await view.locator(".screens-grid .screens-cell").evaluateAll(elements => elements.map(element => element.getAttribute("data-screen-id")!));
await page.getByRole("group", { name: "Screens layout" }).getByRole("button", { name: "Filmstrip" }).click();
const strip = view.getByRole("region", { name: "Filmstrip" });
const middle = strip.locator(".screens-strip-frame.focused");
const stage = strip.locator(".screens-strip-stage");
await expect(middle).toHaveAttribute("data-screen-id", ids[0]!);
const historyLength = await page.evaluate(() => history.length);
// A finger drags a quarter of a screen and lifts while still moving: the flick carries the strip past halfway, so it
// lands on the next screen though the finger never got there.
await stage.evaluate(async element => {
const box = element.getBoundingClientRect();
const y = box.top + box.height / 2, x = box.left + box.width * 0.6;
const pitch = (() => {
const [a, b] = [...element.querySelectorAll(".screens-strip-frame")].map(frame => { const r = frame.getBoundingClientRect(); return r.left + r.width / 2; });
return Math.abs(b! - a!);
})();
const fire = (type: string, at: number) => element.dispatchEvent(new PointerEvent(type, { pointerId: 9, pointerType: "touch", isPrimary: true,
clientX: at, clientY: y, bubbles: true, cancelable: true }));
fire("pointerdown", x);
const step = pitch / 16;
for (let n = 1; n <= 4; n++) { fire("pointermove", x - n * step); await new Promise(resolve => setTimeout(resolve, 16)); }
fire("pointerup", x - 4 * step);
});
await expect(middle).toHaveAttribute("data-screen-id", ids[1]!);
await expect(stage).not.toHaveClass(/swiping/);
// However many screens a swipe passes, it is one step back.
expect(await page.evaluate(() => history.length)).toBe(historyLength + 1);
// A short wheel swipe whose momentum is still coming in when ← steps back: the arrow's screen stays in the middle,
// neither settled over by the swipe nor dragged off by its momentum.
await middle.hover();
await page.evaluate(() => {
const stage = document.querySelector(".screens-strip-stage")!;
stage.dispatchEvent(new WheelEvent("wheel", { deltaX: 100, bubbles: true, cancelable: true }));
let left = 30;
const momentum = setInterval(() => {
stage.dispatchEvent(new WheelEvent("wheel", { deltaX: 1, bubbles: true, cancelable: true }));
if (--left === 0) clearInterval(momentum);
}, 16);
});
await page.keyboard.press("ArrowLeft");
await expect(middle).toHaveAttribute("data-screen-id", ids[0]!);
await page.waitForTimeout(900);
await expect(middle).toHaveAttribute("data-screen-id", ids[0]!);
await expect(stage).not.toHaveClass(/swiping/);
// A pinch (a wheel with Control) zooms; it does not move the strip.
await page.evaluate(() => document.querySelector(".screens-strip-stage")!.dispatchEvent(new WheelEvent("wheel", { deltaX: 400, ctrlKey: true, bubbles: true, cancelable: true })));
await page.waitForTimeout(300);
await expect(middle).toHaveAttribute("data-screen-id", ids[0]!);
});
test("Screens' layouts switch with G and E, and the sidebar folds by its own buttons and on each switch to the filmstrip", async ({ page }) => {
await serveWorkspace(page);
await page.goto("/screens");
@@ -5559,6 +5648,56 @@ test.describe("phone layout", () => {
await expect(page.getByRole("navigation", { name: "Views" })).toBeVisible();
await expect(page.locator(".map-canvas")).toBeVisible();
});
test("the filmstrip on a phone: switched beside Changed / All, swiped by a finger, and its middle screen opens the Inspector", async ({ page }) => {
await serveWorkspace(page);
await page.goto("/screens");
const view = page.getByRole("main", { name: "Screens" });
await view.getByRole("button", { name: /^All/ }).tap();
const layouts = view.getByRole("group", { name: "Screens layout" });
await expect(layouts.getByRole("button", { name: "Grid" })).toHaveAttribute("aria-pressed", "true");
await layouts.getByRole("button", { name: "Filmstrip" }).tap();
await expect(page).toHaveURL(/[?&]layout=filmstrip/);
const strip = view.getByRole("region", { name: "Filmstrip" });
const middle = strip.locator(".screens-strip-frame.focused");
const first = await middle.getAttribute("data-screen-id");
// The section chips give way to the path above the strip; the Tree still jumps anywhere.
await expect(view.locator(".screens-jump-chip:not(.tree)")).toHaveCount(0);
await expect(view.getByRole("button", { name: "Tree" })).toBeVisible();
await expectNoHorizontalOverflow(page);
// A finger dragged left moves the strip under it while it is down, and the strip settles on the next screen.
const stage = strip.locator(".screens-strip-stage");
const dragged = await stage.evaluate(async element => {
const box = element.getBoundingClientRect();
const y = box.top + box.height / 2, x = box.left + box.width * 0.7;
const fire = (type: string, at: number) => element.dispatchEvent(new PointerEvent(type, { pointerId: 7, pointerType: "touch", isPrimary: true,
clientX: at, clientY: y, bubbles: true, cancelable: true }));
const centre = () => { const frame = element.querySelector(".screens-strip-frame.focused")!.getBoundingClientRect(); return frame.left + frame.width / 2; };
const before = centre();
fire("pointerdown", x);
for (let step = 1; step <= 3; step++) { fire("pointermove", x - step * 20); await new Promise(resolve => setTimeout(resolve, 16)); }
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
const during = centre();
for (let step = 4; step <= 6; step++) { fire("pointermove", x - step * 20); await new Promise(resolve => setTimeout(resolve, 16)); }
fire("pointerup", x - 120);
return { moved: before - during, swiping: element.classList.contains("swiping") };
});
expect(dragged.moved).toBeGreaterThan(50);
expect(dragged.moved).toBeLessThan(70);
await expect(middle).not.toHaveAttribute("data-screen-id", first!);
await expect(stage).not.toHaveClass(/swiping/);
// A tap on the middle screen opens the Inspector; a tap on a neighbour only brings it to the middle.
const inspector = page.getByRole("complementary", { name: "Inspector panel" });
// The next screen peeks in at the right edge: a tap on the part that shows.
const next = strip.locator(".screens-strip-frame.focused + .screens-strip-frame");
const nextId = await next.getAttribute("data-screen-id");
await next.locator(".screens-strip-target").tap({ position: { x: 12, y: 60 } });
await expect(middle).toHaveAttribute("data-screen-id", nextId!);
await expect(inspector).toHaveCount(0);
await middle.locator(".screens-strip-target").tap();
await expect(inspector).toBeVisible();
});
});
test("the theme is Auto until the More menu picks one: it follows the system, and a pick outlives a reload", async ({ page }) => {
@@ -6098,4 +6237,5 @@ test.describe("a wide Inspector in a short window", () => {
await expect.poll(async () => (await frame.boundingBox())!.height).toBeLessThanOrEqual(421);
await expect.poll(async () => (await frame.boundingBox())!.height).toBeGreaterThan(300);
});
});
+10 -6
View File
@@ -888,6 +888,8 @@ const ViewerApp = memo(function ViewerApp({ reportKey }: { reportKey: number })
if (!rightCollapsedRef.current) inspectorDismissedRef.current = true;
setRightCollapsed((current) => !current);
}, []);
// A double-click that opens the filmstrip closes the Inspector its first click opened; it is not the reader dismissing it.
const closeInspector = useCallback(() => setRightCollapsed(true), []);
// Every canvas opens with the panel showing and the Inspector out of the way.
// The sidebar keeps whatever state the reader gave it; only the Inspector closes, because a
@@ -901,9 +903,9 @@ const ViewerApp = memo(function ViewerApp({ reportKey }: { reportKey: number })
// into the destination view.
// The report Screens' layout is remembered for: the loaded one, however it was loaded.
const runId = payload?.map.run.id;
/** Screens opens in the layout the reader last left it in for this report; phones have only their list. */
/** Screens opens in the layout the reader last left it in for this report. */
const rememberedScreensLayout = useCallback((canvas: CanvasView): Partial<Route> => (
canvas === "screens" && routeRef.current.canvas !== "screens" && !phoneRef.current ? { layout: readScreensLayout(runId) } : {}
canvas === "screens" && routeRef.current.canvas !== "screens" ? { layout: readScreensLayout(runId) } : {}
), [runId]);
const commitCanvasSelection = useCallback((canvas: CanvasView) => {
const current = routeRef.current;
@@ -950,8 +952,8 @@ const ViewerApp = memo(function ViewerApp({ reportKey }: { reportKey: number })
}, [navigate, runId]);
// A link that opens the filmstrip is remembered as a switch to it is.
useEffect(() => {
if (route.canvas === "screens" && route.layout === "filmstrip" && !phone) writeScreensLayout(runId, "filmstrip");
}, [phone, route.canvas, route.layout, runId]);
if (route.canvas === "screens" && route.layout === "filmstrip") writeScreensLayout(runId, "filmstrip");
}, [route.canvas, route.layout, runId]);
// The logo returns to the Map root, the equivalent of the "/map" URL.
const openMapHome = useCallback(() => {
@@ -1128,10 +1130,11 @@ const ViewerApp = memo(function ViewerApp({ reportKey }: { reportKey: number })
const pickedInPlaceRef = useRef<string | undefined>(undefined);
// The Screens tree and jump bar pick a screen in place: it is selected and scrolled to, and the
// Inspector stays as it was. A click on the screenshot, or I, opens it.
const pickScreenInPlace = useCallback((id: string) => {
const pickScreenInPlace = useCallback((id: string, options?: { replace?: boolean }) => {
const sameSelection = resolveScreenId(routeRef.current, contextRef.current) === id;
if (!sameSelection) pickedInPlaceRef.current = id;
navigate(screenPatch(id), { replace: sameSelection, focus: { target: "screen", id } });
// A swipe through the filmstrip is one step back, however many screens it passed.
navigate(screenPatch(id), { replace: sameSelection || options?.replace === true, focus: { target: "screen", id } });
}, [navigate, screenPatch]);
// On a phone the Inspector covers the map, so a tap selects the screen first (its ring, its
// connections, the Open hint) and only a second tap on the selected screen opens it.
@@ -1690,6 +1693,7 @@ const ViewerApp = memo(function ViewerApp({ reportKey }: { reportKey: number })
onClearSelection={clearSelectedScreen}
layout={route.layout ?? "grid"}
onChangeLayout={changeScreensLayout}
onCloseInspector={closeInspector}
/>
) : null}
{comparing && phone && diff && selectedScreenId && comparePicker ? (
+196 -36
View File
@@ -1,4 +1,4 @@
import { useLayoutEffect, useMemo, useState } from "react";
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent, type WheelEvent } from "react";
import { ChevronRight } from "lucide-react";
import { artifactUrl, isLaunchScreen, type MapIndex, type Screen } from "../../utils/model";
import { primaryScreenshotForScreen, screenshotSize, type ScreenshotSize } from "../../utils/screen-images";
@@ -7,10 +7,29 @@ import { screenLabel } from "../../utils/screen-path";
import { treeNodeKey, type ScreenTree, type ScreenTreeIndex, type ScreenTreeNode } from "../../utils/screen-tree";
import { ScreenshotImage } from "../shared/screenshot-image";
/** A neighbour's size and opacity by its distance from the screen in the middle. */
const SCALES = [1, 0.74, 0.54, 0.4];
const OPACITIES = [1, 0.9, 0.6, 0.3];
/**
* A neighbour's size and opacity by its distance from the screen in the middle. The last, invisible, place is where a
* screen waits to come in, so a swipe or a step fades it in rather than popping it.
*/
const SCALES = [1, 0.74, 0.54, 0.4, 0.3];
const OPACITIES = [1, 0.9, 0.6, 0.3, 0];
const GAP = 32;
/** A swipe has ended once its wheel events (and the trackpad's momentum after it) stop for this long. */
const SWIPE_END_MS = 100;
/**
* At the end of a swipe the strip settles on the next screen in its direction once it has moved this far towards it,
* so one wheel notch steps a screen and a twitch springs back.
*/
const SWIPE_COMMIT = 0.2;
/** How far a finger moves before a touch is a swipe rather than a tap. */
const TAP_SLOP_PX = 8;
/** How far ahead a flick's speed carries the strip when the finger lifts: its velocity times this. */
const FLICK_MS = 160;
/**
* How long the strip takes to settle after a gesture: longer the further it has left to go, so that a short way home
* is not crossed at the speed of a whole step and a long one does not snap.
*/
const settleMs = (distance: number) => Math.round(260 + 260 * Math.min(1, distance));
/** An iPhone's portrait shape, for a run with no screenshot sizes at all. */
const FALLBACK_SIZE: ScreenshotSize = { imageWidth: 390, imageHeight: 844 };
@@ -30,10 +49,12 @@ export type ScreensFilmstripProps = {
/** The tree's dot class for a screen: its status, shown beside its name as the grid and the tree show it. */
dot: (id: string) => string | undefined;
dimmed: (id: string) => boolean;
/** Brings a screen to the middle without opening the Inspector. */
onPick: (id: string) => void;
/** Brings a screen to the middle without opening the Inspector; `replace` keeps it out of the history. */
onPick: (id: string, options?: { replace?: boolean }) => void;
/** Selects a screen and opens it in the Inspector, as a click on its card does. */
onOpen: (id: string) => void;
/** The phone layout: the middle screen takes most of the width, and a finger swipes the strip. */
phone?: boolean | undefined;
};
function labelOf(screen: Screen, index: MapIndex): string {
@@ -64,6 +85,24 @@ function useSize(): [(element: HTMLDivElement | null) => void, { width: number;
export function ScreensFilmstrip(props: ScreensFilmstripProps) {
const [stageRef, stage] = useSize();
const at = props.order.indexOf(props.focusedId);
// While a swipe lasts, the strip sits at a fractional position in `order`, following the gesture.
const [swipe, setSwipe] = useState<{ position: number; direction: number } | null>(null);
// Once the gesture lets go, the strip eases the rest of the way on a timing of its own (settleMs).
const [settling, setSettling] = useState<number | null>(null);
const settled = useRef<ReturnType<typeof setTimeout>>(undefined);
// The swipe's position as of the last wheel event, which can arrive before the render that shows the one before it.
const live = useRef<number | null>(null);
// A finger on the strip: where it went down, the strip's position then, and its latest speed in px/ms.
const touch = useRef<{ id: number; x: number; from: number; lastX: number; lastAt: number; velocity: number; moved: boolean } | null>(null);
// A swipe ends with the finger lifting over a screen; the click that follows is not a tap on it.
const swallowClick = useRef(false);
const swipeEnd = useRef<ReturnType<typeof setTimeout>>(undefined);
useEffect(() => () => { clearTimeout(swipeEnd.current); clearTimeout(settled.current); }, []);
// The gesture under way: the screens it has put in the middle, the last of them, and whether it has added its one
// history entry. A screen put in the middle by anything else (an arrow key, the tree, a click) ends it.
const gesture = useRef<{ shown: string; ids: Set<string>; pushed: boolean; start: number } | null>(null);
const focusedNow = useRef(props.focusedId);
useEffect(() => { focusedNow.current = props.focusedId; });
const focused = props.index.screens.get(props.focusedId);
// A row of the tree by its fold key, as the path above the frame names it.
@@ -91,36 +130,155 @@ export function ScreensFilmstrip(props: ScreensFilmstripProps) {
return size.imageWidth / size.imageHeight;
};
// Every frame is laid out as the middle one would be, filling the stage's height short of growing wider than half
// the stage, so a landscape capture beside portrait ones is as wide as it may be rather than as tall; then it is scaled
// the stage (on a phone, most of it, with the neighbours peeking in at the sides), so a landscape capture beside portrait ones is as wide as it may be rather than as tall; then it is scaled
// down around its centre, and the centres are spaced so the scaled frames sit a gap apart, the gap shrinking with them.
const frameSize = (screen: Screen) => {
const height = Math.max(0, Math.min(stage.height - 16, (stage.width * 0.5) / aspect(screen)));
const height = Math.max(0, Math.min(stage.height - 16, (stage.width * (props.phone ? 0.7 : 0.5)) / aspect(screen)));
return { width: height * aspect(screen), height };
};
const middle = frameSize(focused);
const frames: { id: string; screen: Screen; distance: number; x: number; width: number; height: number }[] = [
{ id: props.focusedId, screen: focused, distance: 0, x: 0, ...middle },
];
for (const direction of [-1, 1]) {
let edge = middle.width / 2;
for (let distance = 1; distance < SCALES.length; distance++) {
const id = props.order[at + direction * distance];
const screen = id ? props.index.screens.get(id) : undefined;
if (!id || !screen) break;
const size = frameSize(screen);
const scaled = size.width * SCALES[distance]!;
const centre = edge + GAP * SCALES[distance]! + scaled / 2;
frames.push({ id, screen, distance, x: direction * centre, ...size });
edge = centre + scaled / 2;
// Where each screen sits with the screen at `centre` in the middle: its distance and its centre's offset.
const layout = (centre: number) => {
const placed = new Map<string, { distance: number; x: number }>();
const middle = props.index.screens.get(props.order[centre] ?? "");
if (!middle) return placed;
placed.set(props.order[centre]!, { distance: 0, x: 0 });
for (const direction of [-1, 1]) {
let edge = frameSize(middle).width / 2;
for (let distance = 1; distance < SCALES.length; distance++) {
const id = props.order[centre + direction * distance];
const screen = id ? props.index.screens.get(id) : undefined;
if (!id || !screen) break;
const scaled = frameSize(screen).width * SCALES[distance]!;
const x = edge + GAP * SCALES[distance]! + scaled / 2;
placed.set(id, { distance, x: direction * x });
edge = x + scaled / 2;
}
}
}
return placed;
};
// A swipe someone else's step overtook (an arrow key, a click) no longer places the strip.
const swiping = swipe !== null && Math.round(swipe.position) === at;
const position = swiping ? swipe.position : at;
const base = Math.floor(position), fraction = position - base;
const from = layout(base), to = fraction > 0 ? layout(base + 1) : from;
const lerp = (a: number, b: number) => a + (b - a) * fraction;
const last = SCALES.length - 1;
// In the strip's order, so the frames' elements keep their order in the page as the middle changes: React moves an
// element that changes place among its siblings, and a moved element jumps instead of easing to where it goes.
const placeOf = new Map(props.order.map((id, place) => [id, place]));
const frames = [...new Set([...from.keys(), ...to.keys()])].sort((a, b) => placeOf.get(a)! - placeOf.get(b)!).flatMap(id => {
const screen = props.index.screens.get(id);
if (!screen) return [];
const a = from.get(id), b = to.get(id);
// A screen in only one of the two places is coming in or going out at the invisible end.
const distance = lerp(a?.distance ?? last, b?.distance ?? last);
const x = lerp(a?.x ?? b!.x, b?.x ?? a!.x);
const scale = lerp(SCALES[a?.distance ?? last]!, SCALES[b?.distance ?? last]!);
const opacity = lerp(OPACITIES[a?.distance ?? last]!, OPACITIES[b?.distance ?? last]!);
return [{ id, screen, distance, x, scale, opacity, ...frameSize(screen) }];
});
// The frames' gap at rest, which one screen of swipe travels.
const pitch = Math.abs(layout(at).get(props.order[at + 1] ?? props.order[at - 1] ?? "")?.x ?? frameSize(focused).width) || 1;
const clamp = (value: number) => Math.max(0, Math.min(props.order.length - 1, value));
const abandon = () => { clearTimeout(swipeEnd.current); gesture.current = null; live.current = null; };
const overtaken = () => !gesture.current || !gesture.current.ids.has(focusedNow.current);
// Where a gesture starts: where the one under way has the strip, or the screen in the middle for a new one.
const begin = (): number => {
if (!overtaken() && live.current !== null) return live.current;
abandon();
const index = props.order.indexOf(focusedNow.current);
const start = index < 0 ? at : index;
gesture.current = { shown: focusedNow.current, ids: new Set([focusedNow.current]), pushed: false, start };
return start;
};
// Puts a screen in the middle for the gesture: its first pick is one step back in the history, the rest replace it.
const show = (id: string) => {
const current = gesture.current;
if (!current || id === current.shown) return;
current.shown = id; current.ids.add(id);
props.onPick(id, current.pushed ? { replace: true } : undefined);
current.pushed = true;
};
// Puts the strip at `next` while a gesture lasts; the middle screen, and with it the path above, follows the swipe as
// it passes halfway.
const moveTo = (next: number, direction: number) => {
live.current = next;
setSwipe({ position: next, direction });
show(props.order[Math.round(next)]!);
};
// When the gesture ends, the strip settles on the next screen in its direction once it is SWIPE_COMMIT of the way
// there; `next` may be ahead of where the strip is, carried on by a flick.
const settle = (next: number, direction: number) => {
if (overtaken()) { abandon(); setSwipe(null); return; }
const index = clamp(direction > 0 ? Math.floor(next + 1 - SWIPE_COMMIT) : direction < 0 ? Math.ceil(next - 1 + SWIPE_COMMIT) : Math.round(next));
show(props.order[index]!);
gesture.current = null;
const ms = settleMs(Math.abs(index - (live.current ?? next)));
clearTimeout(settled.current);
setSettling(ms);
settled.current = setTimeout(() => setSettling(null), ms);
live.current = null;
setSwipe(null);
};
// A swipe along either axis moves the strip with it, so a mouse wheel works as well as a trackpad; it has ended when
// its events stop.
const onWheel = (event: WheelEvent) => {
// A pinch arrives as a wheel with Control held; it zooms the page, not the strip.
if (event.ctrlKey) return;
const delta = Math.abs(event.deltaX) > Math.abs(event.deltaY) ? event.deltaX : event.deltaY;
const pixels = event.deltaMode === 1 ? delta * 16 : event.deltaMode === 2 ? delta * stage.width : delta;
if (!pixels) return;
const next = clamp(begin() + pixels / pitch);
// The way the whole swipe went, not its last event: momentum's last 1px back must not turn a swipe around.
const direction = Math.sign(next - gesture.current!.start) || Math.sign(pixels);
moveTo(next, direction);
clearTimeout(swipeEnd.current);
swipeEnd.current = setTimeout(() => settle(next, direction), SWIPE_END_MS);
};
// A finger drags the strip under it; on lifting, a flick carries it on by its speed before it settles. A mouse
// keeps its clicks and wheel.
const onPointerDown = (event: PointerEvent) => {
// A browser that sent no click after the last swipe must not have this press's click swallowed, by finger or mouse.
swallowClick.current = false;
// A touch whose end never reached the strip (it slid off before it moved enough to be held) gives way to this one.
if (event.pointerType === "mouse" || touch.current?.id === event.pointerId) return;
touch.current = { id: event.pointerId, x: event.clientX, from: begin(), lastX: event.clientX, lastAt: event.timeStamp, velocity: 0, moved: false };
};
const onPointerMove = (event: PointerEvent) => {
const current = touch.current;
if (!current || current.id !== event.pointerId) return;
const dx = event.clientX - current.x;
if (!current.moved && Math.abs(dx) < TAP_SLOP_PX) return;
// A wheel swipe's settle waits until the finger takes over; a tap leaves it to settle.
if (!current.moved) { current.moved = true; clearTimeout(swipeEnd.current); event.currentTarget.setPointerCapture(event.pointerId); }
const elapsed = event.timeStamp - current.lastAt;
if (elapsed > 0) current.velocity = (event.clientX - current.lastX) / elapsed;
current.lastX = event.clientX; current.lastAt = event.timeStamp;
moveTo(clamp(current.from - dx / pitch), -Math.sign(dx));
};
const onPointerEnd = (event: PointerEvent) => {
const current = touch.current;
if (!current || current.id !== event.pointerId) return;
touch.current = null;
if (!current.moved) return;
swallowClick.current = true;
// A finger that stopped before lifting carries nothing on.
const velocity = event.timeStamp - current.lastAt > 80 ? 0 : current.velocity;
const next = clamp((live.current ?? position) - (velocity * FLICK_MS) / pitch);
settle(next, velocity ? -Math.sign(velocity) : -Math.sign(event.clientX - current.x));
};
const path = (props.shape.ancestors.get(props.focusedId) ?? []).flatMap(key => rowLabels.get(key) ?? []);
const plain = props.index.plainTitles || isLaunchScreen(focused);
const dot = props.dot(props.focusedId);
return (
<section className="screens-strip" aria-label="Filmstrip">
<section className={`screens-strip${props.phone ? " phone" : ""}`} aria-label="Filmstrip" onWheel={onWheel}
onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={onPointerEnd} onPointerCancel={onPointerEnd}
onClickCapture={(event) => { if (swallowClick.current) { swallowClick.current = false; event.preventDefault(); event.stopPropagation(); } }}>
<div className="screens-strip-path">
{path.map((label, position) => (
<span key={position} className="screens-strip-crumb" title={label}>
@@ -134,34 +292,36 @@ export function ScreensFilmstrip(props: ScreensFilmstripProps) {
</span>
</div>
<div ref={stageRef} className="screens-strip-stage">
{stage.width > 0 ? frames.map(({ id, screen, distance, x, width, height }) => {
<div ref={stageRef} className={`screens-strip-stage${swiping ? " swiping" : settling ? " settling" : ""}`}
style={settling ? ({ "--strip-settle-ms": `${settling}ms` } as CSSProperties) : undefined}>
{stage.width > 0 ? frames.map(({ id, screen, distance, x, scale, opacity, width, height }) => {
const artifact = primaryScreenshotForScreen(screen, props.index);
const url = artifactUrl(artifact);
const size = screenshotSize(artifact);
const placeholder = <span className="screens-strip-placeholder" aria-hidden="true" />;
const frameDiff = props.diff?.screens.get(id);
const scale = SCALES[distance]!;
const label = labelOf(screen, props.index);
const middle = id === props.focusedId;
const hidden = opacity === 0;
return (
<div key={id} id={props.frameId(id)} data-screen-id={id}
className={`screens-strip-frame${distance === 0 ? " focused" : ""}${frameDiff ? ` ${diffClass(frameDiff)}` : ""}${props.dimmed(id) ? " dimmed" : ""}`}
className={`screens-strip-frame${middle ? " focused" : ""}${frameDiff ? ` ${diffClass(frameDiff)}` : ""}${props.dimmed(id) ? " dimmed" : ""}`}
style={{
width,
height,
opacity: OPACITIES[distance],
zIndex: SCALES.length - distance,
opacity,
zIndex: Math.round((SCALES.length - distance) * 10),
transform: `translate(-50%, -50%) translateX(${x}px) scale(${scale})`,
}}>
{/* Only the middle frame is in the tab order: the arrows step the strip, and focus on a neighbour the stage
clips would scroll it off its centre. */}
<button type="button" className="screens-strip-target" aria-label={label} title={distance === 0 ? undefined : label}
tabIndex={distance === 0 ? undefined : -1}
aria-pressed={props.selectedId === id} aria-current={distance === 0 ? "true" : undefined}
onClick={() => (distance === 0 ? props.onOpen(id) : props.onPick(id))}>
<button type="button" className="screens-strip-target" aria-label={label} title={middle ? undefined : label}
tabIndex={middle ? undefined : -1} aria-hidden={hidden || undefined} disabled={hidden}
aria-pressed={props.selectedId === id} aria-current={middle ? "true" : undefined}
onClick={() => (middle ? props.onOpen(id) : props.onPick(id))}>
{/* A downloaded report's screenshot is a reference that ScreenshotImage resolves. */}
{url ? (
<ScreenshotImage src={url} alt="" draggable={false} decoding="async" loading={distance <= 1 ? "eager" : "lazy"}
<ScreenshotImage src={url} alt="" draggable={false} decoding="async" loading={distance <= 1.5 ? "eager" : "lazy"}
{...(size ? { width: size.imageWidth, height: size.imageHeight } : {})} fallback={placeholder} />
) : placeholder}
</button>
+46 -1
View File
@@ -335,6 +335,21 @@ button.screens-tree-row:hover { color: var(--text); background: var(--panel-hove
.screens-jump-chip > svg { width: 14px; height: 14px; }
.screens-jump-chip .path { font-family: var(--screens-mono); }
.screens-page.phone .screens-body { display: block; margin: 0; }
/* Grid or Filmstrip as two icons at the end of the Changed / All row. */
.screens-page.phone .screens-head { display: flex; align-items: center; gap: 8px; }
.screens-layout-toggle { display: inline-flex; flex: none; gap: 2px; margin-left: auto; padding: 3px; border-radius: 999px; background: var(--element); }
.screens-layout-toggle > button { display: grid; width: 40px; height: 28px; place-items: center; border-radius: 999px; color: var(--secondary); }
.screens-layout-toggle > button[aria-pressed="true"] { color: var(--text); background: var(--selected); }
.screens-layout-toggle svg { width: 16px; height: 16px; }
/* The phone's filmstrip fills what the bars leave: the head and the Tree button above it, the tab bar below. */
.screens-page.phone.filmstrip { display: flex; flex-direction: column; overflow: hidden; }
.screens-page.phone.filmstrip::before,
.screens-page.phone.filmstrip :is(.screens-head, .screens-jump) { flex: none; }
.screens-page.phone.filmstrip .screens-body { display: flex; min-height: 0; flex: 1; height: auto; }
.screens-page.phone.filmstrip .screens-sections { padding: 4px 0 0; }
.screens-strip.phone .screens-strip-path { padding: 0 16px; }
/* On a phone the fade is narrower, so the neighbours peeking in at the sides stay legible. */
.screens-strip.phone .screens-strip-stage { mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent); }
/* Sections flow side by side, as on desktop, so a section of one screen leaves no empty row. Every
card takes a fraction of the page width, so cards from neighbouring sections share columns. */
.screens-page.phone .screens-sections { container-type: inline-size; gap: 32px 12px; padding: 20px 16px 0; }
@@ -383,6 +398,17 @@ button.screens-tree-row:hover { color: var(--text); background: var(--panel-hove
/* ── Filmstrip: one screen at a time, its neighbours smaller and fainter on either side ── */
/* The page stops scrolling; the strip fills the height between the pill and the bottom toolbar. */
.screens-page.filmstrip { overflow: hidden; padding-bottom: calc(84px * var(--ui-scale)); }
/* With the sidebar folded, its button floats where the sidebar starts and the strip takes the page's width, with the same
gap either side, so the middle screen sits at the centre of the canvas (beside an open Inspector, of what it leaves). */
.screens-page.filmstrip.side-folded { padding-left: 28px; }
.screens-page.filmstrip.side-folded .screens-side.collapsed {
position: absolute;
z-index: 3;
top: calc(var(--chrome-top) + var(--chrome-height) + 20px);
left: var(--canvas-chrome-inline-inset);
}
/* A sideways swipe steps the strip; it must not also take the browser back a page. */
html:has(.screens-page.filmstrip) { overscroll-behavior-x: none; }
.screens-page.filmstrip .screens-body { height: 100%; }
.screens-page.filmstrip .screens-side { max-height: 100%; }
.screens-page.filmstrip .screens-sections { display: flex; height: 100%; flex-wrap: nowrap; align-items: stretch; }
@@ -410,7 +436,18 @@ button.screens-tree-row:hover { color: var(--text); background: var(--panel-hove
.screens-strip-crumb.current > .screens-tree-dot[class*="diff-"] { background: var(--diff); }
.screens-strip-crumb-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.screens-strip-crumb-label.path { font-size: 12px; }
.screens-strip-stage { position: relative; width: 100%; min-height: 0; flex: 1; overflow: hidden; overflow: clip; }
.screens-strip-stage {
position: relative;
width: 100%;
min-height: 0;
flex: 1;
overflow: hidden;
overflow: clip;
/* The outer frames fade out towards the edges rather than being cut off. */
mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);
/* A finger's sideways swipe moves the strip, on any touch screen; an upward one still scrolls the page. */
touch-action: pan-y;
}
.screens-strip-frame {
position: absolute;
top: 50%;
@@ -419,6 +456,14 @@ button.screens-tree-row:hover { color: var(--text); background: var(--panel-hove
transition: transform 300ms cubic-bezier(0.2, 0.75, 0.2, 1), width 300ms cubic-bezier(0.2, 0.75, 0.2, 1), height 300ms cubic-bezier(0.2, 0.75, 0.2, 1), opacity 300ms ease;
will-change: transform;
}
/* During a swipe the frames follow the gesture directly; they ease only when it lets go and the strip settles. */
.screens-strip-stage.swiping .screens-strip-frame { transition: none; }
/* After it lets go, the strip eases home from rest: by then the gesture (and a trackpad's momentum) has slowed to
nearly nothing, and a curve that starts fast, as a step's does, would jerk it into motion. */
.screens-strip-stage.settling .screens-strip-frame {
transition-duration: var(--strip-settle-ms);
transition-timing-function: cubic-bezier(0.45, 0, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) { .screens-strip-frame { transition: none; } }
.screens-strip-frame.dimmed:not(.focused) { opacity: calc(var(--dim-out) * 0.6) !important; }
.screens-strip-target {
+33 -18
View File
@@ -50,13 +50,15 @@ export type ScreensViewProps = {
onFindRequestDone?: (() => void) | undefined;
onSelectScreen: (id: string) => void;
/** The tree and jump bar pick a screen without opening the Inspector; a screenshot click selects it as the canvas does. */
onPickScreen?: ((id: string) => void) | undefined;
onPickScreen?: ((id: string, options?: { replace?: boolean }) => void) | undefined;
/** A click on the page around the cards clears the selection, as a click on a canvas's pane does. */
onClearSelection?: (() => void) | undefined;
/** Desktop only: every card in a grid, or one screen at a time in a filmstrip. */
/** Every card in a grid, or one screen at a time in a filmstrip. */
layout?: ScreensLayout | undefined;
/** A double-click on a card opens it in the filmstrip. */
onChangeLayout?: ((layout: ScreensLayout) => void) | undefined;
/** Closes the Inspector the first click of a double-click opened; in the filmstrip a click on its middle screen opens it. */
onCloseInspector?: (() => void) | undefined;
};
function statusOf(diff: BuildDiff | undefined, id: string): DiffStatus | undefined {
@@ -298,9 +300,9 @@ function Legend(props: { others: Appearance[] }) {
}
/**
* Screens as a page that scrolls. On desktop, one grid of every screen in the order of the tree beside it, or the same
* screens one at a time in a filmstrip (screens-filmstrip.tsx); on a phone, a section per route folder (or per tab,
* when there are no route files), with the tree behind a Tree button.
* Screens as a page that scrolls. On desktop, one grid of every screen in the order of the tree beside it; on a phone,
* a section per route folder (or per tab, when there are no route files), with the tree behind a Tree button. Either
* can show the same screens one at a time in a filmstrip (screens-filmstrip.tsx), which a finger swipes on a phone.
*/
export function ScreensView(props: ScreensViewProps) {
// The report's screens, as the Map draws them: a public report's routes it never captured are not among them.
@@ -336,7 +338,7 @@ export function ScreensView(props: ScreensViewProps) {
const treeOrder = useMemo(() => treeScreenOrder(tree), [tree]);
const order = props.phone ? sections.flatMap(section => section.screenIds) : treeOrder.filter(id => shown.has(id));
const others = [...new Set([...(props.changedElsewhere?.values() ?? [])].flat())];
const filmstrip = !props.phone && props.layout === "filmstrip";
const filmstrip = props.layout === "filmstrip";
// The filmstrip always has a screen in the middle: the selection when it is shown; else, when Changed or a find hides
// it, the nearest shown screen after it in the tree (before it, at the end), as the grid's arrows step from it; else
// the first screen.
@@ -631,6 +633,7 @@ export function ScreensView(props: ScreensViewProps) {
const openFilmstripRef = useRef<((id: string) => void) | undefined>(undefined);
openFilmstripRef.current = !props.phone && !filmstrip && props.onChangeLayout ? (id: string) => {
(props.onPickScreen ?? props.onSelectScreen)(id);
props.onCloseInspector?.();
props.onChangeLayout!("filmstrip");
} : undefined;
useEffect(() => {
@@ -677,6 +680,16 @@ export function ScreensView(props: ScreensViewProps) {
</div>
) : null;
// On a phone the switch is a pair of icons at the end of the Changed / All row.
const phoneLayoutSwitch = props.phone && props.onChangeLayout ? (
<div className="screens-layout-toggle" role="group" aria-label="Screens layout">
{([["grid", "Grid", <LayoutGrid key="grid" aria-hidden="true" />], ["filmstrip", "Filmstrip", <GalleryHorizontal key="filmstrip" aria-hidden="true" />]] as const)
.map(([value, label, icon]) => (
<button key={value} type="button" aria-label={label} aria-pressed={(filmstrip ? "filmstrip" : "grid") === value}
onClick={() => props.onChangeLayout!(value)}>{icon}</button>
))}
</div>
) : null;
const dimmed = (id: string) => Boolean(props.focus?.length) && !props.focus!.some((state) => state === focusStatusOf(props.diff?.screens.get(id)));
const cell = (id: string) => {
const screen = props.index.screens.get(id);
@@ -698,6 +711,14 @@ export function ScreensView(props: ScreensViewProps) {
) : null;
};
const strip = stripFocus ? (
<ScreensFilmstrip order={order} focusedId={stripFocus} selectedId={props.selectedScreenId}
index={props.index} diff={props.diff} tree={tree} shape={shape}
typicalSize={typicalSize} frameId={cardId} dimmed={dimmed} phone={props.phone}
dot={(id) => dotClass(props.diff, props.changedElsewhere, id)}
onPick={props.onPickScreen ?? props.onSelectScreen} onOpen={props.onSelectScreen} />
) : null;
// A find inside Changed can match only screens Changed hides; the empty state says so and offers All.
const noMatch = `No ${inChanged ? "changed " : ""}screens match “${findQuery.trim()}”`;
const matchedElsewhere = matches && inChanged ? [...matches].filter(id => !inFilter.has(id)).length : 0;
@@ -713,21 +734,22 @@ export function ScreensView(props: ScreensViewProps) {
return (
<>
{layoutSwitch}
<main ref={scroller} className={`screens-page${props.phone ? " phone" : ""}${filmstrip ? " filmstrip" : ""}`} aria-label="Screens" style={style}
<main ref={scroller} className={`screens-page${props.phone ? " phone" : ""}${filmstrip ? " filmstrip" : ""}${filmstrip && sideCollapsed && !props.phone ? " side-folded" : ""}`} aria-label="Screens" style={style}
onClick={(event) => {
// The filmstrip always shows a screen; clearing the pick there would only jump it back to the first.
if (!props.onClearSelection || !props.selectedScreenId || filmstrip) return;
if ((event.target as Element).closest("button, a, input, .screens-cell, .screens-side")) return;
props.onClearSelection();
}}>
{props.phone && filterChips ? <div className="screens-head">{filterChips}</div> : null}
{props.phone && (filterChips || phoneLayoutSwitch) ? <div className="screens-head">{filterChips}{phoneLayoutSwitch}</div> : null}
{props.phone ? (
<nav className="screens-jump" aria-label="Sections">
<button type="button" className="screens-jump-chip tree" onClick={() => setTreeOpen(true)}>
<ListTree aria-hidden="true" />Tree
</button>
{sections.map(section => {
{/* The filmstrip's path names where the screen is; the Tree jumps anywhere. */}
{filmstrip ? null : sections.map(section => {
const dot = section.screenIds.map(id => dotClass(props.diff, props.changedElsewhere, id)).find(Boolean);
return (
<a key={section.id} className="screens-jump-chip" href={`#${sectionAnchor(section.id)}`}
@@ -776,7 +798,7 @@ export function ScreensView(props: ScreensViewProps) {
</aside>
)}
<div className="screens-sections">
{props.phone ? sections.map(section => (
{props.phone ? strip ?? sections.map(section => (
<section key={section.id} id={sectionAnchor(section.id)} className="screens-section" aria-label={section.name ?? section.title}>
<header className="screens-section-head">
<h2>{section.name ?? section.title}</h2>
@@ -794,14 +816,7 @@ export function ScreensView(props: ScreensViewProps) {
<button type="button" className="screens-empty-all" onPointerDown={(event) => event.preventDefault()}
onClick={() => { setFilter("all"); focusFind(); }}>Show all</button></p>
: <p>Try part of a route, or press Esc to show every {inChanged ? "changed " : ""}screen.</p>}</div>
: stripFocus ? (
<ScreensFilmstrip order={order} focusedId={stripFocus} selectedId={props.selectedScreenId}
index={props.index} diff={props.diff} tree={tree} shape={shape}
typicalSize={typicalSize} frameId={cardId} dimmed={dimmed}
dot={(id) => dotClass(props.diff, props.changedElsewhere, id)}
onPick={props.onPickScreen ?? props.onSelectScreen} onOpen={props.onSelectScreen} />
)
: <div className="screens-grid">{order.map(cell)}</div>
: strip ?? <div className="screens-grid">{order.map(cell)}</div>
)}
</div>
</div>