From 85d09b79f304068409401c55ca4aaa820e41bb33 Mon Sep 17 00:00:00 2001 From: zurdi Date: Fri, 18 Sep 2026 15:04:40 +0200 Subject: [PATCH] review(review-polish): share the settings column, space the mobile arrows, add tests - Both gallery Settings tabs render in one `.r-settings-column` utility, so their shared 460px width has a single home. - On phones the previous / next arrows centre in the gap between the cover and the screen edge instead of hugging the cover. - Tests for SettingsLayout's `fill: "desktop"` mode and for PrevNextNav keeping its slot content when there's no list to step through. - Comments trimmed to two lines, and trunk fmt applied. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_017VhukP5AfTE36MxtiJR6vL --- .../v2/components/Gallery/CollectionHead.vue | 5 +- .../Gallery/CollectionSettingsTab.vue | 10 +--- .../v2/components/Gallery/GalleryTabShell.vue | 5 +- .../v2/components/Gallery/PlatformHead.vue | 5 +- .../src/v2/components/Gallery/SettingsTab.vue | 13 +--- .../GameDetails/PrevNextNav.test.ts | 60 +++++++++++++++++++ .../v2/components/GameDetails/PrevNextNav.vue | 12 +++- .../src/v2/layouts/SettingsLayout.test.ts | 60 +++++++++++++++++++ frontend/src/v2/styles/global.css | 10 ++++ 9 files changed, 148 insertions(+), 32 deletions(-) create mode 100644 frontend/src/v2/components/GameDetails/PrevNextNav.test.ts create mode 100644 frontend/src/v2/layouts/SettingsLayout.test.ts diff --git a/frontend/src/v2/components/Gallery/CollectionHead.vue b/frontend/src/v2/components/Gallery/CollectionHead.vue index 5ea28fa98..86060be7a 100644 --- a/frontend/src/v2/components/Gallery/CollectionHead.vue +++ b/frontend/src/v2/components/Gallery/CollectionHead.vue @@ -9,9 +9,8 @@ // head scrolls naturally with the cards (and the toolbar pins // below it). // -// 2. Settings tab: rendered inline above the tab body. It stays -// fixed on desktop (only the tab body scrolls) and scrolls with -// the content on mobile. +// 2. Settings tab: above the tab body, fixed on desktop and scrolling +// with the content on mobile. import { RBtn, RChip, RTabNav } from "@v2/lib"; import type { RTabNavItem } from "@v2/lib"; import { useI18n } from "vue-i18n"; diff --git a/frontend/src/v2/components/Gallery/CollectionSettingsTab.vue b/frontend/src/v2/components/Gallery/CollectionSettingsTab.vue index c0aa9658f..c66b9a95b 100644 --- a/frontend/src/v2/components/Gallery/CollectionSettingsTab.vue +++ b/frontend/src/v2/components/Gallery/CollectionSettingsTab.vue @@ -318,7 +318,7 @@ function discard() { diff --git a/frontend/src/v2/layouts/SettingsLayout.test.ts b/frontend/src/v2/layouts/SettingsLayout.test.ts new file mode 100644 index 000000000..289042a10 --- /dev/null +++ b/frontend/src/v2/layouts/SettingsLayout.test.ts @@ -0,0 +1,60 @@ +import { mount } from "@vue/test-utils"; +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { ref } from "vue"; +import SettingsLayout from "./SettingsLayout.vue"; + +const { routeMeta, mdAndUp } = vi.hoisted(() => ({ + routeMeta: { value: {} as Record }, + mdAndUp: { value: true }, +})); + +vi.mock("vue-router", async (importOriginal) => ({ + ...(await importOriginal()), + useRoute: () => ({ meta: routeMeta.value }), +})); + +vi.mock("@/v2/composables/useBreakpoint", () => ({ + useBreakpoint: () => ({ mdAndUp: ref(mdAndUp.value) }), +})); + +vi.mock("@/v2/composables/useBackgroundArt", () => ({ + useBackgroundArt: () => vi.fn(), +})); + +function mountLayout() { + return mount(SettingsLayout, { + global: { stubs: { SettingsSidebar: true, RouterView: true } }, + }); +} + +function isFill(wrapper: ReturnType): boolean { + return wrapper.find("section").classes().includes("r-v2-settings--fill"); +} + +describe("SettingsLayout fill mode", () => { + beforeEach(() => { + routeMeta.value = {}; + mdAndUp.value = true; + }); + + it("fills on every breakpoint for `fill: true`", () => { + routeMeta.value = { fill: true }; + mdAndUp.value = false; + expect(isFill(mountLayout())).toBe(true); + }); + + it('fills on desktop for `fill: "desktop"`', () => { + routeMeta.value = { fill: "desktop" }; + expect(isFill(mountLayout())).toBe(true); + }); + + it('keeps the document scroll on phones for `fill: "desktop"`', () => { + routeMeta.value = { fill: "desktop" }; + mdAndUp.value = false; + expect(isFill(mountLayout())).toBe(false); + }); + + it("does not fill without the meta", () => { + expect(isFill(mountLayout())).toBe(false); + }); +}); diff --git a/frontend/src/v2/styles/global.css b/frontend/src/v2/styles/global.css index eef326652..65cb8de0d 100644 --- a/frontend/src/v2/styles/global.css +++ b/frontend/src/v2/styles/global.css @@ -313,6 +313,16 @@ html.r-v2-reduced-motion *::after { color: var(--r-color-fg-muted); } +/* Column both gallery Settings tabs (platform, collection) render in, so they + share one width. */ +.r-settings-column { + display: flex; + flex-direction: column; + gap: 20px; + max-width: 460px; + margin-inline: auto; +} + /* Section header: icon + small uppercase label heading a settings block. */ .r-section-head { display: flex;