From 8feef65006ca7b73df10f17e271dd2d2df02ed2c Mon Sep 17 00:00:00 2001 From: zurdi Date: Sun, 20 Sep 2026 19:49:51 +0200 Subject: [PATCH] refactor(v2): give the list view's repeated parts one home The redesign wrote the same compact sort control into three headers, the same compact row anatomy into four components, and a second rAF tween beside the one it had just added. - Extract ListSortMenu, which also settles the three different answers the headers gave when no column carries the current sort. - Move the compact row's flex/stack/facts rules to global.css, beside the list chrome already there. - Share one `tween` helper between the two animating composables. - Let useAnimatedNumber take an already-formatted value, so Stat and PageHeader stop repeating the same number-or-string branch. - Make the tick column a layout token instead of a constant, a CSS variable declared only for phones, and three literal fallbacks. - Read the expansion duration from the motion token it documents. - Drop the `compact` aliases that only renamed `smAndDown`. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_016bZ7R3xC73MZu1vTNuatPK --- frontend/scripts/build-tokens.ts | 1 + .../Collections/CollectionListHeader.vue | 59 +++------- .../Collections/CollectionListRow.vue | 41 +------ .../v2/components/Gallery/GameListHeader.vue | 71 +++--------- .../src/v2/components/Gallery/GameListRow.vue | 25 ++--- .../Gallery/GameListSkeletonRow.vue | 20 +--- .../src/v2/components/Gallery/listColumns.ts | 2 +- .../Platforms/PlatformListHeader.vue | 61 +++-------- .../components/Platforms/PlatformListRow.vue | 43 ++------ .../src/v2/components/shared/ListSortMenu.vue | 102 ++++++++++++++++++ .../src/v2/components/shared/PageHeader.vue | 8 +- frontend/src/v2/components/shared/Stat.vue | 8 +- .../useAnimatedNumber/index.test.ts | 2 +- .../v2/composables/useAnimatedNumber/index.ts | 61 +++++------ .../v2/composables/useListExpansion/index.ts | 41 +++---- frontend/src/v2/styles/global.css | 35 ++++++ frontend/src/v2/styles/tokens.css | 1 + frontend/src/v2/tokens/index.ts | 2 + frontend/src/v2/utils/tween.ts | 57 ++++++++++ 19 files changed, 305 insertions(+), 335 deletions(-) create mode 100644 frontend/src/v2/components/shared/ListSortMenu.vue create mode 100644 frontend/src/v2/utils/tween.ts diff --git a/frontend/scripts/build-tokens.ts b/frontend/scripts/build-tokens.ts index a14d91de5..d1ed014b1 100644 --- a/frontend/scripts/build-tokens.ts +++ b/frontend/scripts/build-tokens.ts @@ -84,6 +84,7 @@ const NAME_OVERRIDES = { alphaStripWidth: "--r-alpha-strip-w", listRowHeight: "--r-list-row-h", listHeaderHeight: "--r-list-header-h", + listSelectWidth: "--r-list-select-w", listRowDetailHeight: "--r-list-row-detail-h", }, colorBrand: { diff --git a/frontend/src/v2/components/Collections/CollectionListHeader.vue b/frontend/src/v2/components/Collections/CollectionListHeader.vue index 359866bc1..5e201f2bf 100644 --- a/frontend/src/v2/components/Collections/CollectionListHeader.vue +++ b/frontend/src/v2/components/Collections/CollectionListHeader.vue @@ -3,9 +3,10 @@ // list-mode view. Mirrors GameListHeader's anatomy: each sortable // column is a button that toggles asc → desc → asc on the parent's // sort state via the `sort` event. -import { RIcon, RMenu, RMenuItem } from "@v2/lib"; +import { RIcon } from "@v2/lib"; import { computed } from "vue"; import { useI18n } from "vue-i18n"; +import ListSortMenu from "@/v2/components/shared/ListSortMenu.vue"; import { useBreakpoint } from "@/v2/composables/useBreakpoint"; import { COLLECTION_LIST_COLUMNS, @@ -36,15 +37,9 @@ const gridStyle = { gridTemplateColumns: COLLECTION_LIST_GRID_TEMPLATE }; // Phones and tablets drop the columns (the rows go compact), so the sort // key they carried moves into a menu — same as the gallery's list header. const { smAndDown } = useBreakpoint(); -const compact = computed(() => smAndDown.value); -const sortableColumns = computed(() => - COLLECTION_LIST_COLUMNS.filter((col) => col.sortKey), -); -const sortLabel = computed(() => - t( - sortableColumns.value.find((col) => col.key === props.sortKey)?.labelKey ?? - sortableColumns.value[0]?.labelKey ?? - "common.name", +const sortOptions = computed(() => + COLLECTION_LIST_COLUMNS.flatMap((col) => + col.sortKey ? [{ key: col.sortKey, label: t(col.labelKey) }] : [], ), ); @@ -60,46 +55,16 @@ function handleClick(col: CollectionListColumn) {