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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017VhukP5AfTE36MxtiJR6vL
This commit is contained in:
zurdi
2026-09-18 15:04:40 +02:00
parent 8022fe1a1c
commit 85d09b79f3
9 changed files with 148 additions and 32 deletions

View File

@@ -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";

View File

@@ -318,7 +318,7 @@ function discard() {
</script>
<template>
<div class="r-v2-coll-set">
<div class="r-settings-column">
<!-- Cover artwork — regular collections only. Smart collections
derive their cover from the contained ROMs at runtime, so an
upload UI here would be misleading. -->
@@ -503,14 +503,6 @@ function discard() {
</template>
<style scoped>
.r-v2-coll-set {
display: flex;
flex-direction: column;
gap: 20px;
max-width: 460px;
margin-inline: auto;
}
/* ── Cover ──────────────────────────────────────────────────────── */
.r-v2-coll-set__cover {
display: flex;

View File

@@ -39,9 +39,8 @@ defineSlots<{
margin: 0 0 24px;
}
/* Desktop: the shell fits the viewport, the head stays fixed and only the
panel scrolls. The panel's inset (cancelled by the negative margin) keeps
focus rings inside its clip. */
/* Desktop: the head stays fixed and only the panel scrolls; its inset,
cancelled by the negative margin, keeps focus rings inside the clip. */
html[data-bp~="md-and-up"] .gallery-tab-shell {
height: calc(100vh - var(--r-nav-h));
height: calc(100dvh - var(--r-nav-h));

View File

@@ -8,9 +8,8 @@
// head scrolls naturally with the cards (and the toolbar pins
// below it). Matches the pre-tabs experience.
//
// 2. Firmware / Settings tabs: rendered inline above the tab body.
// It stays fixed on desktop (only the tab body scrolls) and
// scrolls with the content on mobile.
// 2. Firmware / Settings tabs: above the tab body, fixed on desktop and
// scrolling with the content on mobile.
//
// All admin actions are forwarded as events; permission gating lives
// on the parent so the bar stays in sync with `useCan`.

View File

@@ -158,7 +158,7 @@ const details = computed<DetailRow[]>(() => {
</script>
<template>
<div class="r-v2-plat-settings">
<div class="r-settings-column">
<section class="r-v2-plat-settings__section">
<header class="r-section-head">
<RIcon icon="mdi-information-outline" size="14" />
@@ -207,9 +207,6 @@ const details = computed<DetailRow[]>(() => {
</div>
</RForm>
<!-- Read-only details. Kept as a hairline-divided table for
scan-ability without competing with the editable field
above. -->
<div class="r-v2-plat-settings__details">
<div
v-for="row in details"
@@ -249,14 +246,6 @@ const details = computed<DetailRow[]>(() => {
</template>
<style scoped>
.r-v2-plat-settings {
display: flex;
flex-direction: column;
gap: 20px;
max-width: 460px;
margin-inline: auto;
}
/* ── Name form ────────────────────────────────────────────────── */
.r-v2-plat-settings__form {
display: flex;

View File

@@ -0,0 +1,60 @@
import { mount } from "@vue/test-utils";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { ref } from "vue";
import PrevNextNav from "./PrevNextNav.vue";
const { gallery, fromGallery } = vi.hoisted(() => ({
gallery: { romIdIndex: [] as number[], getRomAt: () => null },
fromGallery: { value: true },
}));
vi.mock("vue-i18n", () => ({
useI18n: () => ({ t: (key: string) => key }),
}));
vi.mock("vue-router", async (importOriginal) => ({
...(await importOriginal<typeof import("vue-router")>()),
useRoute: () => ({ query: {} }),
useRouter: () => ({ push: vi.fn() }),
}));
vi.mock("@/v2/stores/galleryRoms", () => ({
default: () => gallery,
}));
vi.mock("@/v2/composables/useGalleryProvenance", () => ({
useGalleryProvenance: () => ({ enteredFromGallery: ref(fromGallery.value) }),
}));
function mountNav(withSlot: boolean) {
return mount(PrevNextNav, {
props: { romId: 2 },
slots: withSlot ? { default: '<div class="cover" />' } : {},
global: { stubs: { RBtn: { template: "<button />" } } },
});
}
describe("PrevNextNav", () => {
beforeEach(() => {
gallery.romIdIndex = [1, 2, 3];
fromGallery.value = true;
});
it("puts the arrows either side of the slot content", () => {
const html = mountNav(true).html();
expect(html.indexOf("<button")).toBeLessThan(html.indexOf("cover"));
expect(html.lastIndexOf("<button")).toBeGreaterThan(html.indexOf("cover"));
});
it("still renders the slot content when there is no list to step through", () => {
fromGallery.value = false;
const wrapper = mountNav(true);
expect(wrapper.find(".cover").exists()).toBe(true);
expect(wrapper.findAll("button")).toHaveLength(0);
});
it("renders nothing without a list or slot content", () => {
gallery.romIdIndex = [2];
expect(mountNav(false).html()).toBe("<!--v-if-->");
});
});

View File

@@ -123,8 +123,16 @@ function go(position: number | null) {
gap: 6px;
flex-shrink: 0;
}
/* Reaches out to the screen edges so each arrow centres in the gap between the
slot content (the cover) and the edge. */
.prev-next-nav--around {
justify-content: center;
gap: 12px;
display: grid;
grid-template-columns: 1fr auto 1fr;
justify-items: center;
gap: 0;
margin-inline: calc(-1 * var(--r-row-pad));
}
.prev-next-nav--around :slotted(*) {
grid-column: 2;
}
</style>

View File

@@ -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<string, unknown> },
mdAndUp: { value: true },
}));
vi.mock("vue-router", async (importOriginal) => ({
...(await importOriginal<typeof import("vue-router")>()),
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<typeof mountLayout>): 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);
});
});

View File

@@ -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;