From 63d9a3965691f052d826a2544e79a9a7e6381d9a Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Sun, 1 Nov 2026 09:28:17 -0600 Subject: [PATCH] feat(platforms): facet filters and a group-by menu on the platforms index (#5434) --- .../components/Gallery/GalleryToolbar.test.ts | 44 ++++ .../src/components/Gallery/GalleryToolbar.vue | 34 ++- .../Platforms/PlatformFilterDrawer.vue | 122 ++++++++++ frontend/src/locales/bg_BG/platform.json | 5 + frontend/src/locales/cs_CZ/platform.json | 5 + frontend/src/locales/de_DE/platform.json | 5 + frontend/src/locales/en_GB/platform.json | 5 + frontend/src/locales/en_US/platform.json | 5 + frontend/src/locales/es_ES/platform.json | 5 + frontend/src/locales/fr_FR/platform.json | 5 + frontend/src/locales/hu_HU/platform.json | 5 + frontend/src/locales/it_IT/platform.json | 5 + frontend/src/locales/ja_JP/platform.json | 5 + frontend/src/locales/ko_KR/platform.json | 5 + frontend/src/locales/pl_PL/platform.json | 5 + frontend/src/locales/pt_BR/platform.json | 5 + frontend/src/locales/ro_RO/platform.json | 5 + frontend/src/locales/ru_RU/platform.json | 5 + frontend/src/locales/sv_SE/platform.json | 5 + frontend/src/locales/tr_TR/platform.json | 5 + frontend/src/locales/zh_CN/platform.json | 5 + frontend/src/locales/zh_TW/platform.json | 5 + frontend/src/utils/platformFacets.test.ts | 136 +++++++++++ frontend/src/utils/platformFacets.ts | 100 +++++++++ frontend/src/views/PlatformsIndex.test.ts | 150 ++++++++++++- frontend/src/views/PlatformsIndex.vue | 212 +++++++++++++++++- 26 files changed, 879 insertions(+), 14 deletions(-) create mode 100644 frontend/src/components/Platforms/PlatformFilterDrawer.vue create mode 100644 frontend/src/utils/platformFacets.test.ts create mode 100644 frontend/src/utils/platformFacets.ts diff --git a/frontend/src/components/Gallery/GalleryToolbar.test.ts b/frontend/src/components/Gallery/GalleryToolbar.test.ts index fbc55c539..10389caab 100644 --- a/frontend/src/components/Gallery/GalleryToolbar.test.ts +++ b/frontend/src/components/Gallery/GalleryToolbar.test.ts @@ -227,3 +227,47 @@ describe("GalleryToolbar sort axis", () => { wrapper.unmount(); }); }); + +describe("GalleryToolbar group-by control", () => { + const MANY_MODES = [ + { id: "none", icon: "mdi-view-agenda-outline", title: "Flat view" }, + { + id: "letter", + icon: "mdi-alphabetical-variant", + title: "Group by letter", + }, + { id: "family", icon: "mdi-family-tree", title: "Group by family" }, + ]; + + it("keeps the segmented slider for the default two modes", () => { + const wrapper = mountToolbar({}, RMenuPassthrough); + + expect( + wrapper + .findAllComponents({ name: "RSegmentedControl" }) + .some((c) => c.props("items")?.length === 2), + ).toBe(true); + wrapper.unmount(); + }); + + it("lists more than two modes in a labelled menu with the active one checked", () => { + const wrapper = mountToolbar( + { groupBy: "family", groupByItems: MANY_MODES }, + RMenuPassthrough, + ); + + expect( + wrapper + .findAllComponents({ name: "RSegmentedControl" }) + .some((c) => c.props("items") === MANY_MODES), + ).toBe(false); + const family = wrapper + .findAllComponents({ name: "RMenuItem" }) + .filter((item) => item.props("label") === "Group by family"); + expect(family.length).toBeGreaterThan(0); + expect(family.some((item) => item.props("variant") === "active")).toBe( + true, + ); + wrapper.unmount(); + }); +}); diff --git a/frontend/src/components/Gallery/GalleryToolbar.vue b/frontend/src/components/Gallery/GalleryToolbar.vue index f974c7c47..825497a24 100644 --- a/frontend/src/components/Gallery/GalleryToolbar.vue +++ b/frontend/src/components/Gallery/GalleryToolbar.vue @@ -228,6 +228,14 @@ const autofocusSearchField = computed( shouldAutofocusSearch(), ); +// Two modes fit a segmented slider; more read better as a labelled menu. +const groupByAsMenu = computed(() => effectiveGroupByItems.value.length > 2); +const activeGroupByIcon = computed( + () => + effectiveGroupByItems.value.find((i) => i.id === groupByValue.value) + ?.icon ?? "mdi-format-list-group", +); + function setGroupBy(value: GroupByMode) { emit("update:groupBy", value); } @@ -335,13 +343,37 @@ const { smAndUp } = useBreakpoint();