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;