fix(v2): rebuild the gallery list view for phones

The list header was built for a desktop table: it floated as its own
island over the rows, which showed through its blur, and the table
underneath it scrolled sideways on a phone.

- Pin the header edge to edge as one glass surface with the toolbar,
  tinted only once pinned, keeping its border as the divider.
- Trade the columns on sm-and-down for a two-line row (cover, title,
  facts) with a chevron that rolls a three-column detail panel open,
  so nothing scrolls sideways.
- Swap the alpha strip for an A-Z menu in the toolbar on phones and
  tablets, and land letter jumps flush under the toolbar in both
  layouts.
- Give the platforms and collections indexes, and the missing-games
  list, the same row.
- Move the selection counter into a notch above the floating bar and
  animate the bar in.
- Roll every counter up to its new value (useAnimatedNumber).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016bZ7R3xC73MZu1vTNuatPK
This commit is contained in:
zurdi
2026-09-20 17:43:28 +02:00
parent 8e61199d7b
commit 9696de8ee8
37 changed files with 2179 additions and 420 deletions

View File

@@ -82,9 +82,9 @@ const NAME_OVERRIDES = {
collectionCoverWidthXs: "--r-coll-cover-w-xs",
collectionCoverHeightXs: "--r-coll-cover-h-xs",
alphaStripWidth: "--r-alpha-strip-w",
alphaStripWidthXs: "--r-alpha-strip-w-xs",
listRowHeight: "--r-list-row-h",
listHeaderHeight: "--r-list-header-h",
listRowDetailHeight: "--r-list-row-detail-h",
},
colorBrand: {
fav: "--r-color-fav",

View File

@@ -3,8 +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 } from "@v2/lib";
import { RIcon, RMenu, RMenuItem } from "@v2/lib";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
import {
COLLECTION_LIST_COLUMNS,
COLLECTION_LIST_GRID_TEMPLATE,
@@ -31,6 +33,21 @@ const emit = defineEmits<{
const { t } = useI18n();
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",
),
);
function handleClick(col: CollectionListColumn) {
if (!col.sortKey) return;
// Toggle direction when re-clicking the active column; otherwise
@@ -42,7 +59,50 @@ function handleClick(col: CollectionListColumn) {
</script>
<template>
<div class="coll-list-header" :style="gridStyle" role="row">
<div
v-if="compact"
class="coll-list-header coll-list-header--compact"
role="row"
>
<RMenu location="bottom start" :offset="6" sheet-on-mobile>
<template #activator="{ props: activatorProps }">
<button
v-bind="activatorProps"
type="button"
class="coll-list-header__cell coll-list-header__cell--sortable coll-list-header__cell--active"
>
<span class="coll-list-header__label">{{ sortLabel }}</span>
<RIcon
:icon="
sortDir === 'asc' ? 'mdi-arrow-up-thin' : 'mdi-arrow-down-thin'
"
size="14"
class="coll-list-header__icon"
/>
</button>
</template>
<RMenuItem
v-for="col in sortableColumns"
:key="col.key"
:label="t(col.labelKey)"
:variant="sortKey === col.sortKey ? 'active' : 'default'"
@click="handleClick(col)"
>
<template #append>
<RIcon
v-if="sortKey === col.sortKey"
:icon="
sortDir === 'asc' ? 'mdi-arrow-up-thin' : 'mdi-arrow-down-thin'
"
size="14"
class="coll-list-header__icon"
/>
</template>
</RMenuItem>
</RMenu>
</div>
<div v-else class="coll-list-header" :style="gridStyle" role="row">
<button
v-for="col in COLLECTION_LIST_COLUMNS"
:key="col.key"
@@ -83,9 +143,15 @@ function handleClick(col: CollectionListColumn) {
gap: 0 var(--r-space-3);
padding: 0 var(--r-space-3);
height: var(--r-list-header-h);
background: var(--r-color-bg-elevated);
border-bottom: 1px solid var(--r-color-border);
backdrop-filter: blur(10px);
/* Overridable so a pinned header can run it edge to edge (r-pinned-list-header). */
border-bottom: var(--r-list-header-border, 1px solid var(--r-color-border));
}
/* Compact (phones / tablets): one sort control instead of the columns. */
.coll-list-header--compact {
display: flex;
align-items: center;
padding: 0 var(--r-row-pad);
}
.coll-list-header__cell {

View File

@@ -12,6 +12,7 @@ import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import CollectionMosaic from "@/v2/components/Collections/CollectionMosaic.vue";
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
import {
pendingMorphName,
useViewTransition,
@@ -43,6 +44,10 @@ const props = withDefaults(defineProps<Props>(), {
});
const { t } = useI18n();
// Phones and tablets have no room for the columns: the row goes two-line,
// same as the gallery's list rows.
const { smAndDown } = useBreakpoint();
const compact = computed(() => smAndDown.value);
const router = useRouter();
const coverEl = ref<HTMLElement | null>(null);
const { morphTransition } = useViewTransition();
@@ -92,6 +97,39 @@ function onRowClick(e: MouseEvent) {
<template>
<a
v-if="compact"
class="coll-list-row coll-list-row--compact"
:href="to"
:aria-label="t('rom.open-game', { name })"
@click="onRowClick"
>
<div ref="coverEl" class="coll-list-row__thumb" :style="morphStyle">
<CollectionMosaic :covers="covers" />
</div>
<div class="coll-list-row__stack">
<div class="coll-list-row__name">{{ name }}</div>
<div class="coll-list-row__facts">
<RIcon :icon="kindBadge.icon" size="13" />
<span>{{ kindBadge.label }}</span>
<span class="coll-list-row__dot">·</span>
<span>{{
t("collection.games-count", romCount, { named: { n: romCount } })
}}</span>
</div>
</div>
<!-- Private is the state worth flagging; public is the default and
would mark almost every row. -->
<RIcon
v-if="visibility && !isPublic"
class="coll-list-row__lock"
:icon="visibility.icon"
size="18"
:aria-label="visibility.label"
/>
</a>
<a
v-else
class="coll-list-row"
:style="gridStyle"
:href="to"
@@ -163,6 +201,44 @@ function onRowClick(e: MouseEvent) {
background: var(--r-color-bg-elevated);
}
/* Compact (phones / tablets): cover + name, and the columns collapse into
one line of facts. */
.coll-list-row--compact {
display: flex;
align-items: center;
gap: var(--r-space-3);
padding: 0 var(--r-row-pad);
}
/* Clear of the screen edge, which the row itself runs to. */
.coll-list-row__lock {
margin-inline-end: var(--r-space-2);
color: var(--r-color-fg-muted);
}
.coll-list-row__stack {
display: flex;
flex-direction: column;
justify-content: center;
gap: 3px;
flex: 1;
min-width: 0;
}
.coll-list-row__facts {
display: flex;
align-items: center;
gap: 5px;
font-size: var(--r-font-size-sm);
color: var(--r-color-fg-muted);
min-width: 0;
}
.coll-list-row__facts > span {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.coll-list-row__dot {
color: var(--r-color-fg-faint);
}
.coll-list-row:focus-visible {
outline: none;
background: var(--r-color-bg-elevated);

View File

@@ -0,0 +1,90 @@
/* eslint-disable vue/one-component-per-file */
import { mount } from "@vue/test-utils";
import { describe, expect, it, vi } from "vitest";
import { defineComponent, h, nextTick, ref } from "vue";
import AlphaJumpMenu from "./AlphaJumpMenu.vue";
vi.mock("vue-i18n", () => ({
useI18n: () => ({ t: (key: string) => key }),
}));
const modality = ref<"mouse" | "key">("mouse");
vi.mock("@/v2/composables/useInputModality", () => ({
useInputModality: () => ({ modality }),
}));
vi.mock("@/v2/composables/useWrapGridNav", () => ({
useWrapGridNav: vi.fn(),
}));
// Renders the panel inline while open, and toggles it from the activator.
const RMenuStub = defineComponent({
props: { modelValue: { type: Boolean, default: false } },
emits: ["update:modelValue"],
setup(props, { slots, emit }) {
const toggle = () => emit("update:modelValue", !props.modelValue);
return () =>
h("div", [
slots.activator?.({ props: { onClick: toggle } }),
props.modelValue ? slots.default?.() : null,
]);
},
});
const RBtnStub = defineComponent({
setup(_, { slots }) {
return () => h("button", { class: "jump-btn" }, slots.default?.());
},
});
function mountMenu() {
return mount(AlphaJumpMenu, {
attachTo: document.body,
props: {
available: new Set(["A", "M", "Z"]),
current: "M",
direction: "asc",
},
global: { stubs: { RMenu: RMenuStub, RBtn: RBtnStub } },
});
}
function letter(wrapper: ReturnType<typeof mountMenu>, l: string) {
return wrapper.get(`[data-letter="${l}"]`);
}
describe("AlphaJumpMenu", () => {
it("emits the picked letter", async () => {
const wrapper = mountMenu();
await wrapper.get(".jump-btn").trigger("click");
await letter(wrapper, "Z").trigger("click");
expect(wrapper.emitted("pick")).toEqual([["Z"]]);
wrapper.unmount();
});
it("ignores letters with no games", async () => {
const wrapper = mountMenu();
await wrapper.get(".jump-btn").trigger("click");
await letter(wrapper, "B").trigger("click");
expect(wrapper.emitted("pick")).toBeUndefined();
wrapper.unmount();
});
it("starts keyboard users on the current letter", async () => {
modality.value = "key";
const wrapper = mountMenu();
await wrapper.get(".jump-btn").trigger("click");
await nextTick();
await new Promise<void>((resolve) =>
requestAnimationFrame(() => resolve()),
);
expect(document.activeElement).toBe(letter(wrapper, "M").element);
modality.value = "mouse";
wrapper.unmount();
});
});

View File

@@ -0,0 +1,85 @@
<script setup lang="ts">
// AlphaJumpMenu — the gallery's jump-to-letter on phones and tablets, where
// the AlphaStrip column would eat into the grid: a toolbar button that opens
// the same letters as a grid.
import { RBtn, RMenu } from "@v2/lib";
import { nextTick, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import AlphaStrip from "@/v2/components/Gallery/AlphaStrip.vue";
import { useInputModality } from "@/v2/composables/useInputModality";
import { useWrapGridNav } from "@/v2/composables/useWrapGridNav";
interface Props {
available: Set<string>;
current: string;
direction: "asc" | "desc";
}
defineProps<Props>();
const emit = defineEmits<{
(e: "pick", letter: string): void;
}>();
const { t } = useI18n();
const LETTER_SELECTOR = ".alpha-strip__btn:not(:disabled)";
const open = ref(false);
const gridEl = ref<HTMLElement | null>(null);
useWrapGridNav(gridEl, { cellSelector: LETTER_SELECTOR });
// Opened from a keyboard or pad, start on the current letter so the arrows
// have somewhere to move from.
const { modality } = useInputModality();
watch(open, async (isOpen) => {
if (!isOpen || (modality.value !== "key" && modality.value !== "pad")) {
return;
}
await nextTick();
// RMenu positions the panel on the next frame; focusing earlier scrolls.
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
const grid = gridEl.value;
const target =
grid?.querySelector<HTMLElement>(
".alpha-strip__btn--current:not(:disabled)",
) ?? grid?.querySelector<HTMLElement>(LETTER_SELECTOR);
target?.focus();
});
</script>
<template>
<RMenu v-model="open" location="bottom end" sheet-on-mobile>
<template #activator="{ props: activatorProps }">
<RBtn
v-bind="activatorProps"
variant="outlined"
surface
:icon="true"
rounded="circle"
class="alpha-jump__btn"
:aria-label="t('gallery.jump-to-letter')"
>
A–Z
</RBtn>
</template>
<div ref="gridEl">
<AlphaStrip
grid
:available="available"
:current="current"
:direction="direction"
@pick="emit('pick', $event)"
/>
</div>
</RMenu>
</template>
<style scoped>
.alpha-jump__btn {
flex: none;
font-size: var(--r-font-size-sm);
font-weight: var(--r-font-weight-bold);
letter-spacing: 0.02em;
}
</style>

View File

@@ -11,6 +11,9 @@
//
// When both are set, `visible` wins visually because it reflects the real
// scroll position. Letters that don't fit scroll within the strip.
//
// `grid` lays the letters out as a wrapping grid instead of a column, for the
// phone and tablet jump menu (AlphaJumpMenu).
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
@@ -33,6 +36,8 @@ interface Props {
visible?: Set<string> | string[];
/** Render order — reversed when the gallery sorts descending. */
direction?: "asc" | "desc";
/** Lay the letters out as a wrapping grid instead of a column. */
grid?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
@@ -40,6 +45,7 @@ const props = withDefaults(defineProps<Props>(), {
current: "",
visible: () => new Set<string>(),
direction: "asc",
grid: false,
});
const letters = computed(() =>
@@ -99,6 +105,7 @@ watch(
v-bind="$attrs"
ref="rootEl"
class="alpha-strip r-v2-scroll-hidden"
:class="{ 'alpha-strip--grid': grid }"
:aria-label="t('gallery.jump-to-letter')"
>
<button
@@ -180,21 +187,20 @@ watch(
background: color-mix(in srgb, var(--r-color-brand-primary) 12%, transparent);
}
/* On phones the gallery section extends UNDER the translucent bottom tab bar
(the glass effect), so centring the strip in the section drops the letters
low — nearer the bottom bar than the top nav. Reserve the bar's height as
bottom padding so the letters centre in the VISIBLE content band instead. */
html[data-bp~="sm-and-down"] .alpha-strip {
padding-bottom: calc(
var(--r-space-2) + var(--r-bottom-nav-h) + env(safe-area-inset-bottom)
);
.alpha-strip--grid {
width: auto;
display: grid;
grid-template-columns: repeat(7, var(--r-touch-target));
justify-content: center;
gap: var(--r-space-1);
overflow: visible;
padding: var(--r-space-2);
margin-right: 0;
}
/* Phones: the column width / edge gap come from the section vars (see
`.alpha-strip`), which are widened on `xs`; tighter letters so fewer scroll. */
html[data-bp~="xs"] .alpha-strip__btn {
font-size: 11px;
padding: 2px 0;
margin-top: 2px;
.alpha-strip--grid .alpha-strip__btn {
height: var(--r-touch-target);
margin-top: 0;
font-size: var(--r-font-size-lg);
border-radius: var(--r-radius-sm);
}
</style>

View File

@@ -25,6 +25,7 @@ import {
RLetterHeading,
RVirtualScroller,
} from "@v2/lib";
import { useIntersectionObserver } from "@vueuse/core";
import { storeToRefs } from "pinia";
import {
computed,
@@ -39,6 +40,7 @@ import { useI18n } from "vue-i18n";
import { onBeforeRouteLeave, onBeforeRouteUpdate, useRoute } from "vue-router";
import { useUISettings } from "@/composables/useUISettings";
import storeGalleryFilter from "@/stores/galleryFilter";
import AlphaJumpMenu from "@/v2/components/Gallery/AlphaJumpMenu.vue";
import AlphaStrip from "@/v2/components/Gallery/AlphaStrip.vue";
import FilterDrawer from "@/v2/components/Gallery/FilterDrawer.vue";
import GalleryToolbar from "@/v2/components/Gallery/GalleryToolbar.vue";
@@ -68,6 +70,7 @@ import {
type GalleryItem,
} from "@/v2/composables/useGalleryVirtualItems";
import { useGridNav } from "@/v2/composables/useGridNav";
import { useListExpansion } from "@/v2/composables/useListExpansion";
import { usePinnedToolbar } from "@/v2/composables/usePinnedToolbar";
import { useResponsiveColumns } from "@/v2/composables/useResponsiveColumns";
import { useVirtualScrollDebug } from "@/v2/composables/useVirtualScrollDebug";
@@ -75,6 +78,7 @@ import { useWebpSupport } from "@/v2/composables/useWebpSupport";
import storeGalleryRoms from "@/v2/stores/galleryRoms";
import storeGallerySelection from "@/v2/stores/gallerySelection";
import storeScrollRestoration from "@/v2/stores/scrollRestoration";
import { layout as layoutTokens } from "@/v2/tokens";
interface Props {
/** Whether the header slot has content to render. False suppresses
@@ -333,6 +337,20 @@ const { ratioVersion, ratioAt, onCardRatio } = useGalleryCoverRatios();
// them. Also drives the sticky column header's width so it scrolls in step.
const listMinWidth = computed(() => getListMinWidth(props.showPlatformColumn));
// Compact list rows (phones / tablets) open one detail panel at a time; the
// virtualiser reads the same position to give that row its taller slot.
const listExpansion = useListExpansion();
watch(
[
layout,
smAndDown,
() => galleryRoms.total,
() => galleryRoms.orderBy,
() => galleryRoms.orderDir,
],
listExpansion.collapse,
);
// 2D arrow / gamepad nav for both layouts of the gallery. Two passes:
// * Grid mode — rows are `.r-v2-shell__row` (the per-virtualizer-item
// wrapper around the row's GameCards). ArrowLeft/Right within a row,
@@ -384,6 +402,7 @@ const { virtualItems, letterToIndex, availableLetters, getItemHeight } =
gap: CARD_GAP_PX,
ratioAt,
ratioVersion,
listDetailHeight: listExpansion.detailHeight,
fallbackRatio: coverAspectRatio,
});
@@ -393,6 +412,26 @@ const scrollerRef = ref<InstanceType<typeof RVirtualScroller> | null>(null);
const scrollTopNow = computed(() => scrollerRef.value?.scrollTop ?? 0);
const { toolbarHeight, pinDistance, pinned, bindToolbar, bindSentinel } =
usePinnedToolbar(scrollTopNow);
// The floating dock leaves no toolbar to pin, so a sentinel above the column
// header marks when that header reaches the top bar.
const listHeaderSentinel = ref<HTMLElement | null>(null);
const listHeaderAtTop = ref(false);
useIntersectionObserver(
listHeaderSentinel,
([entry]) => {
listHeaderAtTop.value =
!!entry?.rootBounds &&
!entry.isIntersecting &&
entry.boundingClientRect.top < entry.rootBounds.top;
},
{
root: computed(() => scrollerRef.value?.containerEl ?? null),
rootMargin: `-${layoutTokens.navHeight} 0px 0px 0px`,
},
);
const listHeaderPinned = computed(() =>
toolbarPosition.value === "floating" ? listHeaderAtTop.value : pinned.value,
);
// The AlphaStrip follows the toolbar down until it pins: a scroll-driven
// animation (hence `timeline-scope`), else a style write on the strip alone.
const supportsScrollTimeline =
@@ -584,7 +623,14 @@ watch(virtualItems, () => {
syncFetches(viewportRange.value);
});
function scrollToLetter(letter: string) {
// A jump holds its letter under the toolbar until the user scrolls again, so
// a slow landing window still ends up anchored. The cap is a backstop for the
// viewer who walks away: past it the gallery is nobody's to move.
const LETTER_JUMP_MAX_MS = 15000;
const jumpLetter = ref<string | null>(null);
let jumpDeadline = 0;
function anchorLetter(letter: string, smooth: boolean) {
const idx = letterToIndex.value.get(letter);
if (idx == null) return;
// The section runs under the top bar, so rows land below it in either dock.
@@ -596,13 +642,52 @@ function scrollToLetter(letter: string) {
navHeight +
toolbarHeight.value +
(layout.value === "list" ? LIST_HEADER_HEIGHT_PX : 0);
scrollerRef.value?.scrollToIndex(idx, { smooth: true, stickyOffset });
scrollerRef.value?.scrollToIndex(idx, { smooth, stickyOffset });
}
function scrollToLetter(letter: string) {
jumpLetter.value = letter;
jumpDeadline = Date.now() + LETTER_JUMP_MAX_MS;
anchorLetter(letter, true);
// The viewport-driven fetch sync handles the destination — once the
// smooth scroll settles, `update:viewportRange` fires and the windows at
// the landing zone start loading via `syncFetches` (both layouts). No
// manual prefetch needed.
}
/** Gives the scroll back to the user, whatever a jump was still correcting. */
function endLetterJump() {
jumpLetter.value = null;
}
// The smooth scroll animates towards the target the jump computed; anything
// that moved meanwhile (a re-pack, the header rendering) leaves it short, so
// settle onto the letter once the animation stops.
function onScrollEnd() {
if (jumpLetter.value) anchorLetter(jumpLetter.value, false);
}
// Three things move a letter out from under the toolbar after the jump: the
// landing window arriving, the covers it brings re-packing the rows (the map
// is rebuilt with them), and the view header rendering late, which grows the
// band above the virtualised rows. Re-anchor on each.
watch(
[
letterToIndex,
() => scrollerRef.value?.innerOffsetTop ?? 0,
() => galleryRoms.loadedWindows.size,
],
() => {
const letter = jumpLetter.value;
if (!letter) return;
if (Date.now() > jumpDeadline) {
endLetterJump();
return;
}
anchorLetter(letter, false);
},
);
// ── Search filter (debounced) ───────────────────────────────────────
const searchInput = ref(searchTerm.value ?? "");
let searchDebounce: ReturnType<typeof setTimeout> | null = null;
@@ -799,7 +884,7 @@ defineExpose({
'--r-v2-shell-toolbar-h': `${toolbarHeight}px`,
'--r-v2-shell-pin-distance': `${pinDistance}px`,
'--r-cover-ratio': coverAspectRatio,
'--r-list-min-w': `${listMinWidth}px`,
'--r-list-min-w': smAndDown ? 'auto' : `${listMinWidth}px`,
}"
>
<RVirtualScroller
@@ -808,9 +893,15 @@ defineExpose({
:get-item-height="getItemHeight"
:get-item-key="galleryItemKey"
:overscan="virtualOverscan"
:min-content-width="layout === 'list' ? listMinWidth : undefined"
:min-content-width="
layout === 'list' && !smAndDown ? listMinWidth : undefined
"
class="r-v2-shell__scroller r-v2-scroll-hidden"
:tabindex="-1"
@wheel.passive="endLetterJump"
@pointerdown.passive="endLetterJump"
@keydown="endLetterJump"
@scrollend="onScrollEnd"
@update:viewport-range="onViewportRangeChange"
>
<!-- HEADER (Section 1) + TOOLBAR (Section 2). Both live in the
@@ -851,7 +942,17 @@ defineExpose({
@update:sort-key="galleryRoms.setOrderBy"
@update:search="setSearch"
@click:filter="filterDrawerOpen = true"
/>
>
<template #actions>
<AlphaJumpMenu
v-if="smAndDown"
:available="availableLetters"
:current="currentLetter"
:direction="orderDir"
@pick="scrollToLetter"
/>
</template>
</GalleryToolbar>
</div>
</template>
@@ -859,14 +960,21 @@ defineExpose({
Shares `LIST_GRID_TEMPLATE` with every GameListRow underneath
so columns align. Header click cycles asc/desc into the
store's orderBy/orderDir. -->
<GameListHeader
v-if="layout === 'list'"
class="r-v2-shell__list-header"
:sort-key="listSortKey"
:sort-dir="orderDir"
:show-platform-column="showPlatformColumn"
@sort="onListSort"
/>
<template v-if="layout === 'list'">
<div
v-if="toolbarPosition === 'floating'"
ref="listHeaderSentinel"
aria-hidden="true"
/>
<GameListHeader
class="r-v2-shell__list-header"
:class="{ 'r-pinned-list-header': listHeaderPinned }"
:sort-key="listSortKey"
:sort-dir="orderDir"
:show-platform-column="showPlatformColumn"
@sort="onListSort"
/>
</template>
</template>
<!-- GRID / TABLE (Section 3) — letter-headers + rows of cards in
@@ -909,7 +1017,19 @@ defineExpose({
:position="asListRow(item as GalleryItem).position"
:webp="supportsWebp"
:show-platform-column="showPlatformColumn"
expandable
:expanded="
listExpansion.isExpanded(asListRow(item as GalleryItem).position)
"
:detail-height="
listExpansion.detailHeight(
asListRow(item as GalleryItem).position,
)
"
@ratio="onCardRatio"
@toggle-expand="
listExpansion.toggle(asListRow(item as GalleryItem).position)
"
/>
<GameListSkeletonRow
@@ -940,8 +1060,10 @@ defineExpose({
</template>
</RVirtualScroller>
<!-- ALPHASTRIP — A-Z jump column on the right edge of the section. -->
<!-- ALPHASTRIP — A-Z jump column on the right edge of the section.
Phones and tablets jump from the toolbar instead (AlphaJumpMenu). -->
<AlphaStrip
v-if="!smAndDown"
ref="stripRef"
class="r-v2-shell__strip"
:available="availableLetters"
@@ -970,7 +1092,17 @@ defineExpose({
@update:sort-dir="galleryRoms.setOrderDir"
@update:sort-key="galleryRoms.setOrderBy"
@click:filter="filterDrawerOpen = true"
/>
>
<template #actions>
<AlphaJumpMenu
v-if="smAndDown"
:available="availableLetters"
:current="currentLetter"
:direction="orderDir"
@pick="scrollToLetter"
/>
</template>
</GalleryToolbar>
<!-- FILTER DRAWER — owned by the shell so every gallery view gets
it for free. Forwards `showPlatformsInFilter` from the view so
@@ -1030,10 +1162,18 @@ html[data-bp~="sm-and-down"] .r-v2-shell {
-1 * (var(--r-bottom-nav-h) + env(safe-area-inset-bottom))
);
}
/* Phones: a wider letter column (bigger, more tappable letters). */
html[data-bp~="xs"] .r-v2-shell {
--r-alpha-strip-w: var(--r-alpha-strip-w-xs);
--r-alpha-strip-gap: var(--r-space-2);
/* Phones and tablets have no strip column to leave room for. */
html[data-bp~="sm-and-down"] .r-v2-shell {
--r-v2-shell-strip: 0px;
}
/* Compact list mode: the rows and their column header run to the screen
edges, out of the scroller's gutter — each keeps that gutter as its own
padding, so only the separators and the row fill reach the edge. */
html[data-bp~="sm-and-down"] .r-v2-shell__list-header,
html[data-bp~="sm-and-down"] .r-v2-shell .game-list-row,
html[data-bp~="sm-and-down"] .r-v2-shell .r-glr-skel {
margin-inline: calc(-1 * var(--r-row-pad));
}
/* The horizontal pads live here so all in-flow content (header, toolbar,
@@ -1121,6 +1261,10 @@ html[data-bp~="xs"] .r-v2-shell {
step with them when the list is wider than the viewport. */
min-width: var(--r-list-min-w);
}
/* Its pinned glass also runs under the strip column, out to the right edge. */
.r-v2-shell__list-header::before {
right: calc(-1 * (var(--r-row-pad) + var(--r-v2-shell-strip)));
}
/* The strip overlays the scroller's right gutter from the pinned toolbar's
bottom edge, shifted down with the toolbar until it pins. */

View File

@@ -27,6 +27,10 @@ defineSlots<{
.gallery-tab-shell {
padding: 32px var(--r-row-pad) 24px;
}
/* GalleryShell's phone header gap, so the head holds still across tabs. */
html[data-bp~="xs"] .gallery-tab-shell {
padding-top: 16px;
}
.gallery-tab-shell__divider {
margin: 0 0 24px;

View File

@@ -132,6 +132,11 @@ const emit = defineEmits<{
(e: "click:filter"): void;
}>();
defineSlots<{
/** Extra controls right after the filter button. */
actions?(): unknown;
}>();
// Support both a Ref or a plain value — keeps consumption flexible.
function toValue<T>(source: Ref<T> | T): T {
return source && typeof source === "object" && "value" in (source as object)
@@ -289,6 +294,8 @@ const { smAndUp } = useBreakpoint();
/>
</RBadge>
<slot name="actions" />
<template v-if="smAndUp">
<RSliderBtnGroup
v-for="sf in segmentFilters"

View File

@@ -9,13 +9,15 @@
// Sticky positioning is owned by the parent (`GalleryShell` pins this
// below the toolbar at `top: --r-v2-shell-toolbar-h`). The header
// itself only paints — it doesn't manage scroll.
import { RCheckbox, RIcon } from "@v2/lib";
import { RCheckbox, RIcon, RMenu, RMenuItem } from "@v2/lib";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
import { useGallerySelectAll } from "@/v2/composables/useGallerySelectAll";
import storeGallerySelection from "@/v2/stores/gallerySelection";
import {
getListColumns,
getSortOptions,
isSortableColumn,
getListGridTemplate,
type ListColumn,
@@ -49,6 +51,18 @@ const gridStyle = computed(() => ({
gridTemplateColumns: getListGridTemplate(props.showPlatformColumn),
}));
// Phones and tablets drop the columns (the rows go compact), so the sort
// key they used to carry moves into a menu on the header.
const { smAndDown } = useBreakpoint();
const compact = computed(() => smAndDown.value);
const sortOptions = computed(() => getSortOptions(props.showPlatformColumn));
const sortLabel = computed(
() =>
sortOptions.value.find((option) => option.key === props.sortKey)?.label ??
sortOptions.value[0]?.label ??
"",
);
const selection = storeGallerySelection();
// Whole-result select-all shared with the SelectionBar and Ctrl/Cmd+A;
// `selectionState` drives the tri-state checkbox glyph.
@@ -66,19 +80,81 @@ function onSelectAllClick(e: MouseEvent) {
}
}
function handleClick(col: ListColumn) {
if (!isSortableColumn(col)) return;
// Toggle direction when re-clicking the active column; otherwise
// start the new column at ascending — consistent behaviour with
// every other sortable table in the app.
function sortBy(key: ListSortKey) {
// Toggle direction when re-picking the active key; otherwise start the
// new one ascending, like every other sortable table in the app.
const nextDir: "asc" | "desc" =
props.sortKey === col.key && props.sortDir === "asc" ? "desc" : "asc";
emit("sort", { key: col.key, dir: nextDir });
props.sortKey === key && props.sortDir === "asc" ? "desc" : "asc";
emit("sort", { key, dir: nextDir });
}
function handleClick(col: ListColumn) {
if (isSortableColumn(col)) sortBy(col.key);
}
</script>
<template>
<div class="game-list-header" :style="gridStyle" role="row">
<div
v-if="compact"
class="game-list-header game-list-header--compact"
role="row"
>
<RCheckbox
class="game-list-header__check"
:model-value="selectionState === 'all'"
:indeterminate="selectionState === 'some'"
shape="circle"
size="sm"
color="primary"
bare
hide-details
:aria-label="
selectionState === 'all'
? t('gallery.selection-deselect-all')
: t('gallery.selection-select-all')
"
@click="onSelectAllClick"
/>
<RMenu location="bottom start" :offset="6" sheet-on-mobile>
<template #activator="{ props: activatorProps }">
<button
v-bind="activatorProps"
type="button"
class="game-list-header__cell game-list-header__cell--sortable game-list-header__cell--active"
>
<span class="game-list-header__label">{{ sortLabel }}</span>
<RIcon
:icon="
sortDir === 'asc' ? 'mdi-arrow-up-thin' : 'mdi-arrow-down-thin'
"
size="14"
class="game-list-header__icon"
/>
</button>
</template>
<RMenuItem
v-for="option in sortOptions"
:key="String(option.key)"
:label="option.label"
:variant="sortKey === option.key ? 'active' : 'default'"
@click="sortBy(option.key)"
>
<template #append>
<RIcon
v-if="sortKey === option.key"
:icon="
sortDir === 'asc' ? 'mdi-arrow-up-thin' : 'mdi-arrow-down-thin'
"
size="14"
class="game-list-header__icon"
/>
</template>
</RMenuItem>
</RMenu>
</div>
<div v-else class="game-list-header" :style="gridStyle" role="row">
<template v-for="col in columns" :key="String(col.key)">
<!-- Tri-state select-all checkbox (off → some → all), judged
against the whole filtered result. -->
@@ -141,10 +217,20 @@ function handleClick(col: ListColumn) {
gap: 0 var(--r-space-5);
padding: 0 var(--r-space-3);
height: var(--r-list-header-h);
background: var(--r-color-bg-elevated);
border-bottom: 1px solid var(--r-color-border);
/* Glass so rows scrolling under the pinned header read soft behind it. */
backdrop-filter: blur(10px);
/* Overridable so a pinned header can run it edge to edge (r-pinned-list-header). */
border-bottom: var(--r-list-header-border, 1px solid var(--r-color-border));
}
/* Compact (phones / tablets): the tick plus one sort control. */
.game-list-header--compact {
display: flex;
align-items: center;
gap: var(--r-space-3);
padding: 0 var(--r-row-pad);
}
.game-list-header--compact .game-list-header__check {
flex: none;
width: var(--r-list-select-w, 36px);
}
.game-list-header__cell {

View File

@@ -15,20 +15,23 @@
import {
RCheckbox,
RChip,
RIcon,
RPlatformIcon,
RSkeletonBlock,
RTooltip,
} from "@v2/lib";
import { formatPlaytime, formatReleaseDate } from "@v2/utils/time";
import { formatPlaytime, formatReleaseDate, releaseYear } from "@v2/utils/time";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import storeCollections from "@/stores/collections";
import storePlatforms from "@/stores/platforms";
import { formatBytes, toBrowserLocale } from "@/utils";
import GameActionBtn from "@/v2/components/GameActions/GameActionBtn.vue";
import GameCard from "@/v2/components/GameCard/GameCard.vue";
import SiblingBadge from "@/v2/components/GameCard/SiblingBadge.vue";
import { useBackgroundArt } from "@/v2/composables/useBackgroundArt";
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
import { useGallerySelectionInput } from "@/v2/composables/useGallerySelectionInput";
import { useViewTransition } from "@/v2/composables/useViewTransition";
import { toWebpUrl } from "@/v2/composables/useWebpSupport";
@@ -69,6 +72,14 @@ interface Props {
/** Include the `platform` column. Mirrors `GameListHeader` so the row
* stays aligned with the column header above it. */
showPlatformColumn?: boolean;
/** Offer the chevron that opens the detail panel (phones and tablets).
* Only for surfaces whose virtualiser accounts for the taller row —
* the gallery shell does, via `expandedPosition`. */
expandable?: boolean;
/** Whether this row's detail panel is open. */
expanded?: boolean;
/** Px of that panel currently showing — it rolls open and shut. */
detailHeight?: number;
}
const props = withDefaults(defineProps<Props>(), {
@@ -76,12 +87,17 @@ const props = withDefaults(defineProps<Props>(), {
rom: undefined,
webp: false,
showPlatformColumn: true,
expandable: false,
expanded: false,
detailHeight: 0,
});
const emit = defineEmits<{
/** Forwards the cover's measured natural ratio so the shell's flow-packer
* can pack the grid by true cover shape. */
(e: "ratio", payload: { romId: number; ratio: number }): void;
/** Chevron pressed — the parent owns which row is open. */
(e: "toggle-expand"): void;
}>();
const router = useRouter();
@@ -89,6 +105,7 @@ const galleryRoms = storeGalleryRoms();
const selection = storeGallerySelection();
const selectionInput = useGallerySelectionInput();
const platformsStore = storePlatforms();
const collectionsStore = storeCollections();
const { morphTransition } = useViewTransition();
const setBgArt = useBackgroundArt();
const { locale, t } = useI18n();
@@ -136,6 +153,41 @@ function cellModifiers(key: ListColumn["key"]) {
};
}
// Phones and tablets have no room for the columns: the row collapses to a
// title plus the facts line, and the rest moves into the detail panel.
const { smAndDown } = useBreakpoint();
const compact = computed(() => smAndDown.value);
/** Column header label, so the detail panel's captions and the desktop
* column titles can't drift apart. */
function labelOf(key: ListColumn["key"]): string {
return columns.value.find((col) => col.key === key)?.label ?? "";
}
function listValue(values: string[] | null | undefined): string {
return values && values.length > 0 ? values.join(", ") : "—";
}
/** The facts line under the title: what a library owner scans for, in the
* order the columns had them. */
const facts = computed(() => {
const item = rom.value;
if (!item) return "";
const year = releaseYear(item.metadatum?.first_release_date);
const rating = ratingValue(item);
return [
item.fs_size_bytes ? formatBytes(item.fs_size_bytes) : null,
year ? String(year) : null,
rating === "—" ? null : `★ ${rating}`,
]
.filter(Boolean)
.join(" · ");
});
const isFavorited = computed(() =>
rom.value ? collectionsStore.isFavorite(rom.value) : false,
);
const platformMeta = computed(() => {
const item = rom.value;
if (!item || item.platform_id == null) return null;
@@ -269,6 +321,7 @@ function onRowPointerEnd() {
:class="{
'game-list-row--clickable': !!rom,
'game-list-row--selected': isSelected,
'game-list-row--expanded': expanded,
}"
:style="gridStyle"
:href="rom ? `/rom/${rom.id}` : undefined"
@@ -289,189 +342,390 @@ function onRowPointerEnd() {
@pointercancel="onRowPointerEnd"
>
<template v-if="rom">
<!-- Selection cell — leftmost column. Click toggles this row;
shift-click extends the range from the last toggled position.
Hidden at rest; reveals on row hover / focus or whenever the
row is selected so the user always knows which rows are
picked. RCheckbox provides the box / fill / draw animations
— same animation language as the GameCard checkbox in grid
mode. -->
<div class="game-list-row__cell game-list-row__select">
<RCheckbox
v-if="!isStatic"
class="game-list-row__check"
:model-value="isSelected"
shape="circle"
size="sm"
color="primary"
bare
hide-details
tabindex="-1"
@click="onCheckboxClick"
/>
</div>
<!-- COMPACT (phones / tablets) — two lines plus the chevron; the
columns move into the detail panel below. -->
<template v-if="compact">
<div class="game-list-row__compact">
<div class="game-list-row__select">
<RCheckbox
v-if="!isStatic"
class="game-list-row__check"
:model-value="isSelected"
shape="circle"
size="sm"
color="primary"
bare
hide-details
tabindex="-1"
@click="onCheckboxClick"
/>
</div>
<div class="game-list-row__cell game-list-row__cover">
<GameCard
:rom="rom"
size="xs"
:webp="webp"
decorative
:show-title="false"
:show-platform-icon="false"
@ratio="emit('ratio', $event)"
/>
</div>
<div class="game-list-row__cover">
<GameCard
:rom="rom"
size="xs"
:webp="webp"
decorative
:show-title="false"
:show-platform-icon="showPlatformColumn"
@ratio="emit('ratio', $event)"
/>
</div>
<div class="game-list-row__cell game-list-row__title">
<div class="game-list-row__meta">
<div class="game-list-row__name-row">
<div class="game-list-row__stack">
<div class="game-list-row__name">
{{ rom.name ?? rom.fs_name_no_ext }}
</div>
<div class="game-list-row__facts">
{{ facts }}
<RIcon
v-if="isFavorited"
icon="mdi-heart"
size="11"
class="game-list-row__fav"
:aria-label="t('rom.favorite')"
/>
</div>
<div class="game-list-row__badges" @click.stop>
<GameActionBtn
v-if="hasStatus"
:rom="rom"
action="status"
size="x-small"
variant="surface"
orientation="horizontal"
/>
<SiblingBadge :rom="rom" orientation="horizontal" />
</div>
</div>
<div class="game-list-row__filename">{{ rom.fs_name }}</div>
<div
v-if="providers.length > 0"
class="game-list-row__providers"
@click.stop
>
<span
v-for="provider in providers"
:key="provider.key"
class="game-list-row__provider"
:style="provider.bg ? { background: provider.bg } : undefined"
<div class="game-list-row__actions" @click.stop>
<GameActionBtn
:rom="rom"
action="more"
size="small"
variant="bare"
/>
<button
v-if="expandable"
type="button"
class="game-list-row__chevron"
:class="{ 'game-list-row__chevron--open': expanded }"
:aria-expanded="expanded"
:aria-label="t('common.details')"
@click.stop.prevent="emit('toggle-expand')"
>
<img
:src="`/assets/scrappers/${provider.logo}`"
:alt="provider.title"
width="14"
height="14"
/>
<RTooltip
activator="parent"
:text="provider.title"
location="top"
/>
</span>
<RIcon icon="mdi-chevron-down" size="18" />
</button>
</div>
</div>
</div>
<div
v-if="showPlatformColumn"
class="game-list-row__cell game-list-row__platform"
>
<RPlatformIcon
v-if="platformMeta?.slug"
:slug="platformMeta.slug"
:size="24"
/>
<span class="game-list-row__platform-name">
{{ platformMeta?.name ?? "—" }}
</span>
</div>
<div class="game-list-row__cell" :class="cellModifiers('fs_size_bytes')">
{{ rom.fs_size_bytes ? formatBytes(rom.fs_size_bytes) : "—" }}
</div>
<div class="game-list-row__cell" :class="cellModifiers('created_at')">
{{ formatDate(rom.created_at) }}
</div>
<div
class="game-list-row__cell"
:class="cellModifiers('first_release_date')"
>
{{ releaseDate(rom) }}
</div>
<div class="game-list-row__cell" :class="cellModifiers('average_rating')">
{{ ratingValue(rom) }}
</div>
<div
class="game-list-row__cell"
:class="cellModifiers('hltb_main_story')"
>
{{ lengthValue(rom) }}
</div>
<div class="game-list-row__cell game-list-row__cell--pills">
<div class="game-list-row__pills">
<RChip
v-for="l in (rom.languages ?? []).slice(0, PILLS_VISIBLE)"
:key="`lang-${l}`"
size="x-small"
variant="translucent"
>
{{ l }}
</RChip>
<RChip
v-if="(rom.languages?.length ?? 0) > PILLS_VISIBLE"
size="x-small"
variant="translucent"
>
+{{ (rom.languages?.length ?? 0) - PILLS_VISIBLE }}
</RChip>
<div
v-if="expanded"
class="game-list-row__detail"
:style="{ height: `${detailHeight}px` }"
@click.stop
>
<div class="game-list-row__detail-inner">
<div class="game-list-row__field game-list-row__field--wide">
<span class="game-list-row__field-label">{{
t("rom.filename")
}}</span>
<span class="game-list-row__field-value">{{ rom.fs_name }}</span>
</div>
<div class="game-list-row__field">
<span class="game-list-row__field-label">{{
labelOf("created_at")
}}</span>
<span class="game-list-row__field-value">{{
formatDate(rom.created_at)
}}</span>
</div>
<div class="game-list-row__field">
<span class="game-list-row__field-label">{{
labelOf("first_release_date")
}}</span>
<span class="game-list-row__field-value">{{
releaseDate(rom)
}}</span>
</div>
<div class="game-list-row__field">
<span class="game-list-row__field-label">{{
labelOf("hltb_main_story")
}}</span>
<span class="game-list-row__field-value">{{
lengthValue(rom)
}}</span>
</div>
<div class="game-list-row__field">
<span class="game-list-row__field-label">{{
labelOf("languages")
}}</span>
<span class="game-list-row__field-value">{{
listValue(rom.languages)
}}</span>
</div>
<div class="game-list-row__field">
<span class="game-list-row__field-label">{{
labelOf("regions")
}}</span>
<span class="game-list-row__field-value">{{
listValue(rom.regions)
}}</span>
</div>
<div class="game-list-row__field game-list-row__field--wide">
<span class="game-list-row__field-label">{{
t("scan.metadata-sources")
}}</span>
<span
v-if="providers.length > 0"
class="game-list-row__providers"
@click.stop
>
<span
v-for="provider in providers"
:key="provider.key"
class="game-list-row__provider"
:style="provider.bg ? { background: provider.bg } : undefined"
>
<img
:src="`/assets/scrappers/${provider.logo}`"
:alt="provider.title"
width="14"
height="14"
/>
<RTooltip
activator="parent"
:text="provider.title"
location="top"
/>
</span>
</span>
<span v-else class="game-list-row__field-value">—</span>
</div>
</div>
</div>
<RTooltip
v-if="(rom.languages?.length ?? 0) > PILLS_VISIBLE"
activator="parent"
:text="rom.languages?.join(', ')"
location="top"
/>
</div>
<div class="game-list-row__cell game-list-row__cell--pills">
<div class="game-list-row__pills">
<RChip
v-for="r in (rom.regions ?? []).slice(0, PILLS_VISIBLE)"
:key="`reg-${r}`"
size="x-small"
variant="translucent"
>
{{ r }}
</RChip>
<RChip
v-if="(rom.regions?.length ?? 0) > PILLS_VISIBLE"
size="x-small"
variant="translucent"
>
+{{ (rom.regions?.length ?? 0) - PILLS_VISIBLE }}
</RChip>
</div>
<RTooltip
v-if="(rom.regions?.length ?? 0) > PILLS_VISIBLE"
activator="parent"
:text="rom.regions?.join(', ')"
location="top"
/>
</div>
</template>
<div class="game-list-row__cell" :class="cellModifiers('actions')">
<div class="game-list-row__actions" @click.stop>
<GameActionBtn
:rom="rom"
action="favorite"
size="small"
variant="bare"
<template v-else>
<!-- Selection cell — leftmost column. Click toggles this row;
shift-click extends the range from the last toggled position.
Hidden at rest; reveals on row hover / focus or whenever the
row is selected so the user always knows which rows are
picked. RCheckbox provides the box / fill / draw animations
— same animation language as the GameCard checkbox in grid
mode. -->
<div class="game-list-row__cell game-list-row__select">
<RCheckbox
v-if="!isStatic"
class="game-list-row__check"
:model-value="isSelected"
shape="circle"
size="sm"
color="primary"
bare
hide-details
tabindex="-1"
@click="onCheckboxClick"
/>
<GameActionBtn :rom="rom" action="more" size="small" variant="bare" />
</div>
</div>
<div class="game-list-row__cell game-list-row__cover">
<GameCard
:rom="rom"
size="xs"
:webp="webp"
decorative
:show-title="false"
:show-platform-icon="false"
@ratio="emit('ratio', $event)"
/>
</div>
<div class="game-list-row__cell game-list-row__title">
<div class="game-list-row__meta">
<div class="game-list-row__name-row">
<div class="game-list-row__name">
{{ rom.name ?? rom.fs_name_no_ext }}
</div>
<div class="game-list-row__badges" @click.stop>
<GameActionBtn
v-if="hasStatus"
:rom="rom"
action="status"
size="x-small"
orientation="horizontal"
/>
<SiblingBadge :rom="rom" orientation="horizontal" />
</div>
</div>
<div class="game-list-row__filename">{{ rom.fs_name }}</div>
<div
v-if="providers.length > 0"
class="game-list-row__providers"
@click.stop
>
<span
v-for="provider in providers"
:key="provider.key"
class="game-list-row__provider"
:style="provider.bg ? { background: provider.bg } : undefined"
>
<img
:src="`/assets/scrappers/${provider.logo}`"
:alt="provider.title"
width="14"
height="14"
/>
<RTooltip
activator="parent"
:text="provider.title"
location="top"
/>
</span>
</div>
</div>
</div>
<div
v-if="showPlatformColumn"
class="game-list-row__cell game-list-row__platform"
>
<RPlatformIcon
v-if="platformMeta?.slug"
:slug="platformMeta.slug"
:size="24"
/>
<span class="game-list-row__platform-name">
{{ platformMeta?.name ?? "—" }}
</span>
</div>
<div
class="game-list-row__cell"
:class="cellModifiers('fs_size_bytes')"
>
{{ rom.fs_size_bytes ? formatBytes(rom.fs_size_bytes) : "—" }}
</div>
<div class="game-list-row__cell" :class="cellModifiers('created_at')">
{{ formatDate(rom.created_at) }}
</div>
<div
class="game-list-row__cell"
:class="cellModifiers('first_release_date')"
>
{{ releaseDate(rom) }}
</div>
<div
class="game-list-row__cell"
:class="cellModifiers('average_rating')"
>
{{ ratingValue(rom) }}
</div>
<div
class="game-list-row__cell"
:class="cellModifiers('hltb_main_story')"
>
{{ lengthValue(rom) }}
</div>
<div class="game-list-row__cell game-list-row__cell--pills">
<div class="game-list-row__pills">
<RChip
v-for="l in (rom.languages ?? []).slice(0, PILLS_VISIBLE)"
:key="`lang-${l}`"
size="x-small"
variant="translucent"
>
{{ l }}
</RChip>
<RChip
v-if="(rom.languages?.length ?? 0) > PILLS_VISIBLE"
size="x-small"
variant="translucent"
>
+{{ (rom.languages?.length ?? 0) - PILLS_VISIBLE }}
</RChip>
</div>
<RTooltip
v-if="(rom.languages?.length ?? 0) > PILLS_VISIBLE"
activator="parent"
:text="rom.languages?.join(', ')"
location="top"
/>
</div>
<div class="game-list-row__cell game-list-row__cell--pills">
<div class="game-list-row__pills">
<RChip
v-for="r in (rom.regions ?? []).slice(0, PILLS_VISIBLE)"
:key="`reg-${r}`"
size="x-small"
variant="translucent"
>
{{ r }}
</RChip>
<RChip
v-if="(rom.regions?.length ?? 0) > PILLS_VISIBLE"
size="x-small"
variant="translucent"
>
+{{ (rom.regions?.length ?? 0) - PILLS_VISIBLE }}
</RChip>
</div>
<RTooltip
v-if="(rom.regions?.length ?? 0) > PILLS_VISIBLE"
activator="parent"
:text="rom.regions?.join(', ')"
location="top"
/>
</div>
<div class="game-list-row__cell" :class="cellModifiers('actions')">
<div class="game-list-row__actions" @click.stop>
<GameActionBtn
:rom="rom"
action="favorite"
size="small"
variant="bare"
/>
<GameActionBtn
:rom="rom"
action="more"
size="small"
variant="bare"
/>
</div>
</div>
</template>
</template>
<template v-else>
<!-- Compact skeleton — same two-line shape as the compact row. -->
<div v-if="compact" class="game-list-row__compact">
<div class="game-list-row__select" />
<div class="game-list-row__cover">
<RSkeletonBlock
:width="LIST_COVER_WIDTH_PX"
:height="LIST_COVER_HEIGHT_PX"
/>
</div>
<div class="game-list-row__stack" :style="titleSkeletonGapStyle">
<RSkeletonBlock
v-for="(bar, i) in LIST_TITLE_SKELETON_BARS"
:key="i"
:width="bar.width"
:height="bar.height"
/>
</div>
</div>
<!-- Column-driven, so the per-cell shapes stay in step with
`GameListSkeletonRow` and the row does not reflow on data arrival. -->
<template v-for="col in listSkeletonColumns" :key="String(col.key)">
<template
v-for="col in compact ? [] : listSkeletonColumns"
:key="String(col.key)"
>
<div
v-if="col.key === 'select'"
class="game-list-row__cell game-list-row__select"
@@ -549,6 +803,122 @@ function onRowPointerEnd() {
transition: background var(--r-motion-fast) var(--r-motion-ease-out);
}
/* ── Compact layout (phones / tablets) ───────────────────────────────
No columns: a two-line block, and a detail panel whose fixed height the
virtualiser mirrors (`LIST_ROW_DETAIL_HEIGHT_PX`) so the rows below an
open row sit clear of it. */
html[data-bp~="sm-and-down"] .game-list-row {
display: block;
height: auto;
padding: 0;
border-bottom: 0;
}
.game-list-row__compact {
display: flex;
align-items: center;
gap: var(--r-space-3);
height: var(--r-list-row-h);
padding: 0 var(--r-row-pad);
border-bottom: 1px solid var(--r-color-border);
}
.game-list-row--expanded .game-list-row__compact {
border-bottom-color: transparent;
}
.game-list-row__compact > .game-list-row__select {
flex: none;
width: var(--r-list-select-w, 36px);
}
.game-list-row__stack {
display: flex;
flex-direction: column;
justify-content: center;
gap: 3px;
flex: 1;
min-width: 0;
}
/* Two lines of title: most names fit whole, and the row keeps its height
(cover 64 + two lines + the facts line still sit inside it). */
.game-list-row__compact .game-list-row__name {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
white-space: normal;
line-height: 1.25;
}
/* The line the owner scans: size, year, rating, and the favourite mark. */
.game-list-row__facts {
font-size: var(--r-font-size-sm);
color: var(--r-color-fg-muted);
font-variant-numeric: tabular-nums;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.game-list-row__fav {
color: var(--r-color-brand-primary);
vertical-align: -1px;
margin-inline-start: 2px;
}
.game-list-row__chevron {
appearance: none;
background: transparent;
border: 0;
padding: 4px;
display: inline-flex;
align-items: center;
color: var(--r-color-fg-muted);
cursor: pointer;
transition: transform var(--r-motion-fast) var(--r-motion-ease-out);
}
.game-list-row__chevron--open {
transform: rotate(180deg);
color: var(--r-color-fg);
}
/* Rolls open and shut: the height comes from `useListExpansion`, which the
virtualiser reads too, so the panel and the slot it sits in move together.
The inner block keeps its full height and is clipped meanwhile. */
.game-list-row__detail {
overflow: hidden;
border-bottom: 1px solid var(--r-color-border);
background: var(--r-color-bg-elevated);
cursor: default;
}
.game-list-row__detail-inner {
height: var(--r-list-row-detail-h);
padding: var(--r-space-4) var(--r-row-pad);
display: grid;
/* Three equal columns across the full width, so the fields land in the
same place whatever the title or the file name measure. */
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: var(--r-space-4);
align-content: start;
}
.game-list-row__field {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
}
.game-list-row__field-label {
font-size: var(--r-font-size-xs);
font-weight: var(--r-font-weight-bold);
letter-spacing: 0.07em;
text-transform: uppercase;
color: var(--r-color-fg-muted);
}
.game-list-row__field--wide {
grid-column: 1 / -1;
}
.game-list-row__field-value {
font-size: var(--r-font-size-md);
color: var(--r-color-fg-secondary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.game-list-row--clickable {
cursor: pointer;
}

View File

@@ -0,0 +1,92 @@
import { mount } from "@vue/test-utils";
import { createPinia, setActivePinia } from "pinia";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { ref } from "vue";
import GameListRow from "./GameListRow.vue";
import { rom } from "./listRowFixture";
vi.mock("vue-i18n", () => ({
useI18n: () => ({ t: (key: string) => key, locale: { value: "en" } }),
}));
vi.mock("vue-router", async (importOriginal) => ({
...(await importOriginal<typeof import("vue-router")>()),
useRouter: () => ({ push: vi.fn() }),
}));
const smAndDown = ref(true);
vi.mock("@/v2/composables/useBreakpoint", () => ({
useBreakpoint: () => ({ smAndDown }),
}));
function mountRow(props: Record<string, unknown> = {}) {
return mount(GameListRow, {
props: { rom: rom(), ...props },
global: {
stubs: {
GameActionBtn: true,
GameCard: true,
RCheckbox: true,
RChip: true,
RIcon: true,
RPlatformIcon: true,
RTooltip: true,
SiblingBadge: true,
},
},
});
}
describe("list row on phones and tablets", () => {
beforeEach(() => {
setActivePinia(createPinia());
smAndDown.value = true;
});
it("trades the columns for a title and a facts line", () => {
const wrapper = mountRow();
expect(wrapper.find(".game-list-row__compact").exists()).toBe(true);
expect(wrapper.find(".game-list-row__cell").exists()).toBe(false);
// Size, release year and rating — the columns worth scanning. Length
// formats through the real i18n bundle, so it sits out of this one.
expect(wrapper.find(".game-list-row__facts").text()).toBe(
"4 MB · 1995 · ★ 9.1",
);
});
it("keeps the columns on wider viewports", () => {
smAndDown.value = false;
const wrapper = mountRow();
expect(wrapper.find(".game-list-row__compact").exists()).toBe(false);
expect(wrapper.find(".game-list-row__cell").exists()).toBe(true);
});
it("asks the parent to open its detail panel", async () => {
const wrapper = mountRow({ expandable: true });
await wrapper.get(".game-list-row__chevron").trigger("click");
expect(wrapper.emitted("toggle-expand")).toHaveLength(1);
});
it("offers no chevron where the row cannot grow", () => {
const wrapper = mountRow();
expect(wrapper.find(".game-list-row__chevron").exists()).toBe(false);
});
it("moves the remaining columns into the open panel", () => {
const wrapper = mountRow({ expandable: true, expanded: true });
const fields = wrapper
.findAll(".game-list-row__field-value")
.map((el) => el.text());
// The file name, plus what the facts line leaves out.
expect(fields).toContain("Chrono Trigger.sfc");
expect(fields).toContain("USA");
expect(fields).toContain("en");
});
});

View File

@@ -1,11 +1,10 @@
import { mount } from "@vue/test-utils";
import { createPinia, setActivePinia } from "pinia";
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { RomMetadataSchema, RomUserSchema } from "@/__generated__";
import type { SimpleRom } from "@/v2/stores/galleryRoms";
import GameListRow from "./GameListRow.vue";
import GameListSkeletonRow from "./GameListSkeletonRow.vue";
import { getListColumns, LIST_COVER_TRACK_PX } from "./listColumns";
import { rom } from "./listRowFixture";
vi.mock("vue-i18n", () => ({
useI18n: () => ({ t: (key: string) => key, locale: { value: "en" } }),
@@ -40,132 +39,6 @@ function tabularFigures(row: HTMLElement): boolean[] {
);
}
const ROM_USER: RomUserSchema = {
id: 1,
user_id: 1,
rom_id: 1,
created_at: "2026-01-02T00:00:00Z",
updated_at: "2026-01-02T00:00:00Z",
last_played: null,
is_main_sibling: true,
backlogged: false,
now_playing: false,
hidden: false,
rating: 0,
difficulty: 0,
completion: 0,
status: null,
};
const METADATUM: RomMetadataSchema = {
rom_id: 1,
genres: [],
franchises: [],
collections: [],
companies: [],
publishers: [],
developers: [],
game_modes: [],
age_ratings: [],
player_count: "1",
first_release_date: Date.UTC(1995, 7, 11),
average_rating: 9.1,
};
/** A complete `SimpleRom`, so a new required field breaks the build instead of
* hiding behind a cast. Tests override only the fields they read. */
const ROM_DEFAULTS: SimpleRom = {
id: 1,
igdb_id: null,
sgdb_id: null,
moby_id: null,
ss_id: null,
ra_id: null,
launchbox_id: null,
hasheous_id: null,
tgdb_id: null,
flashpoint_id: null,
hltb_id: null,
demozoo_id: null,
pouet_id: null,
csdb_id: null,
steam_id: null,
gamelist_id: null,
libretro_id: null,
platform_id: 1,
platform_slug: "snes",
platform_fs_slug: "snes",
platform_custom_name: null,
platform_display_name: "Super Nintendo",
fs_name: "Chrono Trigger.sfc",
fs_name_no_tags: "Chrono Trigger",
fs_name_no_ext: "Chrono Trigger",
fs_extension: "sfc",
fs_path: "snes/Chrono Trigger.sfc",
fs_size_bytes: 4_194_304,
name: "Chrono Trigger",
name_sort_key: "chrono trigger",
slug: "chrono-trigger",
summary: null,
alternative_names: [],
youtube_video_id: null,
metadatum: METADATUM,
igdb_metadata: null,
moby_metadata: null,
ss_metadata: null,
launchbox_metadata: null,
hasheous_metadata: null,
flashpoint_metadata: null,
hltb_metadata: { main_story: 23 },
demozoo_metadata: null,
pouet_metadata: null,
csdb_metadata: null,
steam_metadata: null,
gamelist_metadata: null,
manual_metadata: null,
path_cover_small: null,
path_cover_large: null,
url_cover: null,
has_manual: false,
has_soundtrack: false,
path_manual: null,
url_manual: null,
path_video: null,
is_unidentified: false,
is_identified: true,
revision: null,
regions: ["USA"],
languages: ["en"],
tags: [],
crc_hash: null,
md5_hash: null,
sha1_hash: null,
ra_hash: null,
title_id: null,
save_target: null,
save_target_layout: null,
has_simple_single_file: true,
has_nested_single_file: false,
has_multiple_files: false,
full_path: "/romm/library/snes/Chrono Trigger.sfc",
created_at: "2026-01-02T00:00:00Z",
updated_at: "2026-01-02T00:00:00Z",
missing_from_fs: false,
is_physical: false,
has_file_on_disk: true,
upc: null,
has_notes: false,
rom_user: ROM_USER,
merged_screenshots: [],
merged_ra_metadata: null,
files: [],
sibling_roms: [],
};
function rom(overrides: Partial<SimpleRom> = {}): SimpleRom {
return { ...ROM_DEFAULTS, ...overrides };
}
function mountHydratedRow() {
return mount(GameListRow, {
props: { rom: rom() },

View File

@@ -13,6 +13,7 @@
// both flavours stay visually identical.
import { RSkeletonBlock } from "@v2/lib";
import { computed } from "vue";
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
import {
getListColumns,
getListGridTemplate,
@@ -40,10 +41,32 @@ const gridStyle = computed(() => ({
gridTemplateColumns: getListGridTemplate(props.showPlatformColumn),
}));
const titleGapStyle = { gap: `${LIST_TITLE_SKELETON_GAP_PX}px` };
// Phones and tablets render the compact two-line row, so the placeholder
// follows it instead of the columns.
const { smAndDown } = useBreakpoint();
const compact = computed(() => smAndDown.value);
</script>
<template>
<div class="r-glr-skel" :style="gridStyle">
<div v-if="compact" class="r-glr-skel r-glr-skel--compact">
<div class="r-glr-skel__cell r-glr-skel__cover">
<RSkeletonBlock
:width="LIST_COVER_WIDTH_PX"
:height="LIST_COVER_HEIGHT_PX"
/>
</div>
<div class="r-glr-skel__stack" :style="titleGapStyle">
<RSkeletonBlock
v-for="(bar, i) in LIST_TITLE_SKELETON_BARS"
:key="i"
:width="bar.width"
:height="bar.height"
/>
</div>
</div>
<div v-else class="r-glr-skel" :style="gridStyle">
<template v-for="col in columns" :key="String(col.key)">
<div v-if="col.key === 'select'" class="r-glr-skel__cell" />
<div
@@ -114,6 +137,20 @@ const titleGapStyle = { gap: `${LIST_TITLE_SKELETON_GAP_PX}px` };
border-bottom: 1px solid var(--r-color-border);
}
.r-glr-skel--compact {
display: flex;
align-items: center;
gap: var(--r-space-3);
padding: 0 var(--r-row-pad);
}
.r-glr-skel__stack {
display: flex;
flex-direction: column;
justify-content: center;
flex: 1;
min-width: 0;
}
.r-glr-skel__cell {
min-width: 0;
}

View File

@@ -12,21 +12,22 @@
//
// All admin actions are forwarded as events; permission gating lives
// on the parent so the bar stays in sync with `useCan`.
import { RBtn, RChip, RPlatformIcon, RTabNav } from "@v2/lib";
import { RBtn, RChip, RIcon, RPlatformIcon, RTabNav } from "@v2/lib";
import type { RTabNavItem } from "@v2/lib";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import type { Platform } from "@/stores/platforms";
import InfoPanel from "@/v2/components/Gallery/InfoPanel.vue";
import Stat from "@/v2/components/shared/Stat.vue";
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
import {
playTooltip,
usePlatformPlayable,
} from "@/v2/composables/usePlatformPlayable";
import type { StatRow } from "@/v2/types/stats";
defineOptions({ inheritAttrs: false });
interface StatRow {
label: string;
value: string;
}
interface ProviderChip {
key: string;
label: string;
@@ -35,7 +36,7 @@ interface ProviderChip {
title?: string;
}
defineProps<{
const props = defineProps<{
platform: Platform;
tab: string;
tabs: RTabNavItem[];
@@ -75,6 +76,12 @@ defineEmits<{
// the icon to a fixed box height, which — for a tall icon — either overflowed
// (overlap) or, once clipped, cut it off.
const { xs } = useBreakpoint();
const { t } = useI18n();
// Same play-mode marker the platforms list carries, so a platform reads the
// same in its own header as it does in the index.
const { mode, emulator, streamLabel } = usePlatformPlayable(
() => props.platform.slug,
);
const iconSize = computed(() => (xs.value ? 116 : 148));
</script>
@@ -94,7 +101,22 @@ const iconSize = computed(() => (xs.value ? 116 : 148));
</div>
</template>
<template v-if="tags.length || description" #tags>
<template v-if="tags.length || description || mode" #tags>
<RChip
v-if="mode"
size="small"
variant="translucent"
:rounded="20"
:title="playTooltip(mode, emulator, streamLabel)"
>
<RIcon
icon="mdi-play-circle"
size="14"
:color="mode === 'stream' ? 'romm-blue' : 'success'"
class="r-v2-plat__playable-icon"
/>
{{ t("platform.playable") }}
</RChip>
<RChip
v-for="tag in tags"
:key="tag"

View File

@@ -55,7 +55,7 @@ import romApi from "@/services/api/rom";
import storeCollections from "@/stores/collections";
import type { Events } from "@/types/emitter";
import { romStatusMap } from "@/utils";
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
import { useAnimatedNumber } from "@/v2/composables/useAnimatedNumber";
import { useCan } from "@/v2/composables/useCan";
import { useGallerySelectAll } from "@/v2/composables/useGallerySelectAll";
import { useRomSync } from "@/v2/composables/useRomSync";
@@ -82,12 +82,12 @@ defineProps<Props>();
defineOptions({ inheritAttrs: false });
const { t } = useI18n();
// On phones the bar drops the "N selected" phrase down to just the
// number so the action row fits a 320px width without overflowing.
const { xs } = useBreakpoint();
const emitter = inject<Emitter<Events>>("emitter");
const snackbar = useSnackbar();
const selection = storeGallerySelection();
// The count rolls up to its new value rather than snapping, so a selection
// that grew by a tap is a number you see move.
const rollingCount = useAnimatedNumber(() => selection.count);
const collectionsStore = storeCollections();
const galleryRomsStore = storeGalleryRoms();
const { ensureFavoriteCollection } = useFavoriteToggle();
@@ -312,30 +312,23 @@ function clear() {
:class="{ 'selection-bar--visible': selection.enabled }"
:aria-hidden="!selection.enabled"
>
<!-- Count: a notch rising from the bar's top edge, centred. Its lower
half hides behind the bar, so the two read as one surface. -->
<div
class="selection-bar__notch"
role="status"
:aria-label="t('gallery.selection-n-selected', { n: selection.count })"
>
<span class="selection-bar__notch-count">{{ rollingCount }}</span>
</div>
<RToolbar
density="compact"
rounded="full"
flat
class="selection-bar__panel"
>
<!-- Prepend region: count chip — leftmost item, separated from
the action buttons by RToolbar's built-in inter-region
spacing. -->
<template #prepend>
<div class="selection-bar__count">
<RIcon
icon="mdi-check-circle"
size="18"
class="selection-bar__count-icon"
/>
<span>
<template v-if="xs">{{ selection.count }}</template>
<template v-else>
{{ t("gallery.selection-n-selected", { n: selection.count }) }}
</template>
</span>
</div>
<!-- Extends the selection to the whole filtered result; the
sole grid-mode affordance (list mode has the header checkbox). -->
<RTooltip :text="selectAllLabel">
@@ -542,7 +535,13 @@ function clear() {
(z 2400) so a confirm opened from a selection covers it. */
z-index: 101;
pointer-events: none;
transition: transform var(--r-motion-mid) var(--r-motion-ease-out);
opacity: 0;
/* Rises with a little overshoot when the first ROM is picked, and drops
straight back out. (`--r-motion-mid` never existed, so this transition
had been resolving to 0s and the bar appeared in one frame.) */
transition:
transform var(--r-motion-med) var(--r-motion-ease-back),
opacity var(--r-motion-fast) var(--r-motion-ease-out);
/* Respect the platform's reduced-motion preference: skip the
slide-up so the bar appears instantly without animation. */
@media (prefers-reduced-motion: reduce) {
@@ -552,6 +551,7 @@ function clear() {
.selection-bar--visible {
transform: translate(-50%, 0);
opacity: 1;
pointer-events: auto;
}
@@ -575,39 +575,75 @@ html[data-bp~="sm-and-down"] .selection-bar--visible {
Border + shadow + backdrop-blur are stacked on top of the
primitive's flat pill. `max-width` keeps it inside a 320px viewport. */
.selection-bar__panel {
/* Over the hill, so the part that laps into the bar is hidden behind it
instead of painting across the buttons' own backgrounds. */
position: relative;
z-index: 1;
--r-toolbar-color: var(--r-color-panel);
max-width: calc(100vw - 16px);
border: 1px solid var(--r-color-panel-border);
box-shadow:
0 12px 32px color-mix(in srgb, black 32%, transparent),
0 0 0 1px color-mix(in srgb, white 4%, transparent) inset;
/* No border or inset line: the counter's hill grows out of this edge, and
any stroke would end where the two meet and read as a seam. The fill is
near-opaque, so the shadow alone carries the silhouette. */
box-shadow: 0 12px 32px color-mix(in srgb, black 32%, transparent);
backdrop-filter: blur(18px) saturate(140%);
}
.selection-bar__count {
/* A hill rising from the bar's top edge. It shares the bar's fill and laps
into it, and the two pseudo-elements curve its foot out into the bar, so
bar and hill read as one surface. Nothing here carries a stroke: an edge
that stopped at the join is exactly what makes a seam. */
.selection-bar__notch {
position: absolute;
z-index: 0;
left: 50%;
bottom: calc(100% - 6px);
transform: translateX(-50%);
display: inline-flex;
align-items: center;
gap: 8px;
padding: 0 4px;
padding: 9px 16px 13px;
/* Round over the top with the bar's own pill radius; the foot stays square
so the sides run straight down into the fillets below — rounding it would
pull the edge inward and open a gap between hill, fillet and bar. The
square corners themselves sit inside the bar, out of sight. */
border-radius: var(--r-radius-pill) var(--r-radius-pill) 0 0;
background: var(--r-color-panel);
/* The bar's glass too, or the fill reads a shade off against it. */
backdrop-filter: blur(18px) saturate(140%);
color: var(--r-color-fg);
font-size: var(--r-font-size-md);
font-weight: var(--r-font-weight-semibold);
color: var(--r-color-fg);
white-space: nowrap;
font-variant-numeric: tabular-nums;
line-height: 1;
--r-notch-fillet: 12px;
}
.selection-bar__count-icon {
color: var(--r-color-brand-primary);
.selection-bar__notch-count {
display: inline-block;
}
html[data-bp~="xs"] .selection-bar__count {
padding: 0 2px;
font-size: var(--r-font-size-sm);
.selection-bar__notch::before,
.selection-bar__notch::after {
content: "";
position: absolute;
bottom: 6px;
width: var(--r-notch-fillet);
height: var(--r-notch-fillet);
pointer-events: none;
}
/* The count icon is decorative; on xs its width budget goes to the
select-all button so the bar still fits a 320px viewport. */
html[data-bp~="xs"] .selection-bar__count-icon {
display: none;
.selection-bar__notch::before {
/* 1px under the hill, so no hairline survives between the two fills. */
right: calc(100% - 1px);
background: radial-gradient(
circle var(--r-notch-fillet) at top left,
transparent 0 var(--r-notch-fillet),
var(--r-color-panel) var(--r-notch-fillet)
);
}
.selection-bar__notch::after {
left: calc(100% - 1px);
background: radial-gradient(
circle var(--r-notch-fillet) at top right,
transparent 0 var(--r-notch-fillet),
var(--r-color-panel) var(--r-notch-fillet)
);
}
/* Tighten the action row on phones so all buttons + the count + divider

View File

@@ -144,6 +144,10 @@ export function getListColumns(showPlatform: boolean): readonly ListColumn[] {
// Fixed track widths (px) — kept as data so the grid template AND the row's
// natural min-width (below) derive from the same numbers.
const LIST_SELECT_TRACK_PX = 36;
// Phones shrink the tick column (see global.css). The template reads the
// variable so the header and every row narrow together; the min-width math
// below stays on the desktop track, which only over-reserves by a few px.
const LIST_SELECT_TRACK = `var(--r-list-select-w, ${LIST_SELECT_TRACK_PX}px)`;
const LIST_PLATFORM_TRACK_PX = 200;
const LIST_METRIC_TRACKS_PX = [88, 96, 96, 56, 72, 110, 110, 88];
/** Minimum width of the title column so it stays readable when the row is
@@ -160,6 +164,20 @@ export const LIST_TITLE_MIN_PX = 200;
// skeleton placeholder paints at the same footprint as the real card.
export const LIST_ROW_HEIGHT_PX = parseInt(layout.listRowHeight, 10);
export const LIST_HEADER_HEIGHT_PX = parseInt(layout.listHeaderHeight, 10);
/** Height a row grows by while its detail panel is open (phones and tablets).
* The panel is a fixed three-row grid so this stays exact. */
export const LIST_ROW_DETAIL_HEIGHT_PX = parseInt(
layout.listRowDetailHeight,
10,
);
/** The slot a list row needs with `detailHeight` px of its panel showing —
* the panel rolls open, so this lands anywhere between the bare row and the
* row plus a full panel. Every surface that virtualises `GameListRow`
* reserves its rows with this. */
export function listRowHeight(detailHeight = 0): number {
return LIST_ROW_HEIGHT_PX + Math.round(detailHeight);
}
export const LIST_COVER_WIDTH_PX = parseInt(layout.cardArtWidthXs, 10);
export const LIST_COVER_HEIGHT_PX = parseInt(layout.cardArtHeightXs, 10);
@@ -183,7 +201,7 @@ export function getListGridTemplate(showPlatform: boolean): string {
const metrics = LIST_METRIC_TRACKS_PX.map((w) => `${w}px`).join(" ");
// A fixed cover track keeps the title column at the same x in every row,
// including the loading placeholders.
return `${LIST_SELECT_TRACK_PX}px ${LIST_COVER_TRACK_PX}px minmax(${LIST_TITLE_MIN_PX}px, 1.6fr)${platformTrack} ${metrics}`;
return `${LIST_SELECT_TRACK} ${LIST_COVER_TRACK_PX}px minmax(${LIST_TITLE_MIN_PX}px, 1.6fr)${platformTrack} ${metrics}`;
}
// The row/header grids also carry a `--r-space-5` column gap and a

View File

@@ -0,0 +1,131 @@
// Shared list-row fixture: a complete `SimpleRom`, so a new required field
// breaks the build instead of hiding behind a cast. Tests override only the
// fields they read.
import type { RomMetadataSchema, RomUserSchema } from "@/__generated__";
import type { SimpleRom } from "@/v2/stores/galleryRoms";
export const ROM_USER: RomUserSchema = {
id: 1,
user_id: 1,
rom_id: 1,
created_at: "2026-01-02T00:00:00Z",
updated_at: "2026-01-02T00:00:00Z",
last_played: null,
is_main_sibling: true,
backlogged: false,
now_playing: false,
hidden: false,
rating: 0,
difficulty: 0,
completion: 0,
status: null,
};
export const METADATUM: RomMetadataSchema = {
rom_id: 1,
genres: [],
franchises: [],
collections: [],
companies: [],
publishers: [],
developers: [],
game_modes: [],
age_ratings: [],
player_count: "1",
first_release_date: Date.UTC(1995, 7, 11),
average_rating: 9.1,
};
/** A complete `SimpleRom`, so a new required field breaks the build instead of
* hiding behind a cast. Tests override only the fields they read. */
export const ROM_DEFAULTS: SimpleRom = {
id: 1,
igdb_id: null,
sgdb_id: null,
moby_id: null,
ss_id: null,
ra_id: null,
launchbox_id: null,
hasheous_id: null,
tgdb_id: null,
flashpoint_id: null,
hltb_id: null,
demozoo_id: null,
pouet_id: null,
csdb_id: null,
steam_id: null,
gamelist_id: null,
libretro_id: null,
platform_id: 1,
platform_slug: "snes",
platform_fs_slug: "snes",
platform_custom_name: null,
platform_display_name: "Super Nintendo",
fs_name: "Chrono Trigger.sfc",
fs_name_no_tags: "Chrono Trigger",
fs_name_no_ext: "Chrono Trigger",
fs_extension: "sfc",
fs_path: "snes/Chrono Trigger.sfc",
fs_size_bytes: 4_194_304,
name: "Chrono Trigger",
name_sort_key: "chrono trigger",
slug: "chrono-trigger",
summary: null,
alternative_names: [],
youtube_video_id: null,
metadatum: METADATUM,
igdb_metadata: null,
moby_metadata: null,
ss_metadata: null,
launchbox_metadata: null,
hasheous_metadata: null,
flashpoint_metadata: null,
hltb_metadata: { main_story: 23 },
demozoo_metadata: null,
pouet_metadata: null,
csdb_metadata: null,
steam_metadata: null,
gamelist_metadata: null,
manual_metadata: null,
path_cover_small: null,
path_cover_large: null,
url_cover: null,
has_manual: false,
has_soundtrack: false,
path_manual: null,
url_manual: null,
path_video: null,
is_unidentified: false,
is_identified: true,
revision: null,
regions: ["USA"],
languages: ["en"],
tags: [],
crc_hash: null,
md5_hash: null,
sha1_hash: null,
ra_hash: null,
title_id: null,
save_target: null,
save_target_layout: null,
has_simple_single_file: true,
has_nested_single_file: false,
has_multiple_files: false,
full_path: "/romm/library/snes/Chrono Trigger.sfc",
created_at: "2026-01-02T00:00:00Z",
updated_at: "2026-01-02T00:00:00Z",
missing_from_fs: false,
is_physical: false,
has_file_on_disk: true,
upc: null,
has_notes: false,
rom_user: ROM_USER,
merged_screenshots: [],
merged_ra_metadata: null,
files: [],
sibling_roms: [],
};
export function rom(overrides: Partial<SimpleRom> = {}): SimpleRom {
return { ...ROM_DEFAULTS, ...overrides };
}

View File

@@ -3,12 +3,11 @@
// view. Mirrors GameListHeader: shared CSS-grid template with every
// row underneath, clickable sortable columns that toggle asc → desc.
//
// The four metadata columns (Family / Category / Generation / Playable)
// drop out on narrow viewports (see the `html[data-bp~="xs"]` rules
// below) so the row stays legible on mobile without horizontal scroll.
// The grid template flips in the same breakpoint so the cells re-align
// with the row's compact layout.
import { RIcon } from "@v2/lib";
// Phones and tablets have no columns to head (the rows go compact), so the
// sort key they carried moves into a menu — same as the collections list.
import { RIcon, RMenu, RMenuItem } from "@v2/lib";
import { computed } from "vue";
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
import {
PLATFORM_COLUMNS,
type PlatformColumn,
@@ -26,6 +25,18 @@ const emit = defineEmits<{
(e: "sort", payload: { key: PlatformSortKey; dir: "asc" | "desc" }): void;
}>();
const { smAndDown } = useBreakpoint();
const compact = computed(() => smAndDown.value);
const sortableColumns = computed(() =>
PLATFORM_COLUMNS.filter((col) => col.sortable),
);
const sortLabel = computed(
() =>
sortableColumns.value.find((col) => col.key === props.sortKey)?.label ??
sortableColumns.value[0]?.label ??
"",
);
function handleClick(col: PlatformColumn) {
if (!col.sortable) return;
const nextDir: "asc" | "desc" =
@@ -35,7 +46,50 @@ function handleClick(col: PlatformColumn) {
</script>
<template>
<div class="plat-list-header" role="row">
<div
v-if="compact"
class="plat-list-header plat-list-header--compact"
role="row"
>
<RMenu location="bottom start" :offset="6" sheet-on-mobile>
<template #activator="{ props: activatorProps }">
<button
v-bind="activatorProps"
type="button"
class="plat-list-header__cell plat-list-header__cell--sortable plat-list-header__cell--active"
>
<span class="plat-list-header__label">{{ sortLabel }}</span>
<RIcon
:icon="
sortDir === 'asc' ? 'mdi-arrow-up-thin' : 'mdi-arrow-down-thin'
"
size="14"
class="plat-list-header__icon"
/>
</button>
</template>
<RMenuItem
v-for="col in sortableColumns"
:key="col.key"
:label="col.label"
:variant="sortKey === col.key ? 'active' : 'default'"
@click="handleClick(col)"
>
<template #append>
<RIcon
v-if="sortKey === col.key"
:icon="
sortDir === 'asc' ? 'mdi-arrow-up-thin' : 'mdi-arrow-down-thin'
"
size="14"
class="plat-list-header__icon"
/>
</template>
</RMenuItem>
</RMenu>
</div>
<div v-else class="plat-list-header" role="row">
<button
v-for="col in PLATFORM_COLUMNS"
:key="col.key"
@@ -78,10 +132,15 @@ function handleClick(col: PlatformColumn) {
gap: 0 var(--r-space-3);
padding: 0 var(--r-space-3);
height: var(--r-list-header-h);
background: var(--r-color-bg-elevated);
border-bottom: 1px solid var(--r-color-border);
/* Glass so rows scrolling under the pinned header read soft behind it. */
backdrop-filter: blur(10px);
/* Overridable so a pinned header can run it edge to edge (r-pinned-list-header). */
border-bottom: var(--r-list-header-border, 1px solid var(--r-color-border));
}
/* Compact (phones / tablets): one sort control instead of the columns. */
.plat-list-header--compact {
display: flex;
align-items: center;
padding: 0 var(--r-row-pad);
}
.plat-list-header__cell {

View File

@@ -9,6 +9,7 @@ import { RPlatformIcon } from "@v2/lib";
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
import { usePlatformPlayable } from "@/v2/composables/usePlatformPlayable";
import {
pendingMorphName,
@@ -47,6 +48,10 @@ const props = withDefaults(defineProps<Props>(), {
const router = useRouter();
const { t } = useI18n();
// Phones and tablets have no room for the columns: the row goes two-line,
// the same shape the collections list takes.
const { smAndDown } = useBreakpoint();
const compact = computed(() => smAndDown.value);
const iconEl = ref<HTMLElement | null>(null);
const { morphTransition } = useViewTransition();
@@ -85,6 +90,51 @@ function onRowClick(e: MouseEvent) {
<template>
<a
v-if="compact"
class="plat-list-row plat-list-row--compact"
:href="href"
:aria-label="t('common.open-item', { name: displayName })"
@click="onRowClick"
>
<div ref="iconEl" class="plat-list-row__thumb" :style="morphStyle">
<RPlatformIcon
:slug="slug"
:fs-slug="fsSlug"
:alt="displayName"
:size="40"
:show-tooltip="false"
/>
</div>
<div class="plat-list-row__stack">
<div class="plat-list-row__name">{{ displayName }}</div>
<div class="plat-list-row__facts">
<span>{{
t("collection.games-count", romCount ?? 0, {
named: { n: romCount ?? 0 },
})
}}</span>
<template v-if="categoryLabel">
<span class="plat-list-row__dot">·</span>
<span>{{ categoryLabel }}</span>
</template>
<template v-if="familyName">
<span class="plat-list-row__dot">·</span>
<span>{{ familyName }}</span>
</template>
</div>
</div>
<PlayModeBadge
v-if="mode"
class="plat-list-row__playable"
:mode="mode"
:emulator="emulator"
:stream-label="streamLabel"
:size="18"
/>
</a>
<a
v-else
class="plat-list-row"
:href="href"
:aria-label="t('common.open-item', { name: displayName })"
@@ -180,6 +230,43 @@ function onRowClick(e: MouseEvent) {
background: var(--r-color-bg-elevated);
}
/* Compact (phones / tablets): icon + name, and the columns collapse into
one line of facts. */
.plat-list-row--compact {
display: flex;
align-items: center;
gap: var(--r-space-3);
padding: 0 var(--r-row-pad);
}
/* Clear of the screen edge, which the row itself runs to. */
.plat-list-row--compact .plat-list-row__playable {
margin-inline-end: var(--r-space-2);
}
.plat-list-row__stack {
display: flex;
flex-direction: column;
justify-content: center;
gap: 3px;
flex: 1;
min-width: 0;
}
.plat-list-row__facts {
display: flex;
align-items: center;
gap: 5px;
font-size: var(--r-font-size-sm);
color: var(--r-color-fg-muted);
min-width: 0;
}
.plat-list-row__facts > span {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.plat-list-row__dot {
color: var(--r-color-fg-faint);
}
.plat-list-row:focus-visible {
outline: none;
background: var(--r-color-bg-elevated);

View File

@@ -44,6 +44,7 @@ import {
} from "@/v2/components/Gallery/listColumns";
import CachedPlatformIcon from "@/v2/components/shared/CachedPlatformIcon.vue";
import { useConfirm } from "@/v2/composables/useConfirm";
import { useListExpansion } from "@/v2/composables/useListExpansion";
import { useLoadingPhase } from "@/v2/composables/useLoadingPhase";
import { useSnackbar } from "@/v2/composables/useSnackbar";
import { useTaskCompletion } from "@/v2/composables/useTaskCompletion";
@@ -142,8 +143,15 @@ const virtualItems = computed<VItem[]>(() => {
return items;
});
function vItemHeight(_item: unknown): number {
return LIST_ROW_HEIGHT_PX;
// The rows are the gallery's, detail panel and all, so their heights come
// from the same place.
const listExpansion = useListExpansion();
function vItemHeight(item: unknown): number {
const v = item as VItem;
return isListRow(v)
? listExpansion.rowHeight(v.position)
: LIST_ROW_HEIGHT_PX;
}
interface VListRow {
@@ -211,6 +219,7 @@ function onViewportRange(range: { first: number; last: number }) {
// (rows 0..N are visible in both), so the scroller may not re-emit. Sync
// immediately against the current viewport so the first window loads.
watch(virtualItems, () => {
listExpansion.collapse();
if (fetchDebounceTimer) {
clearTimeout(fetchDebounceTimer);
fetchDebounceTimer = null;
@@ -378,6 +387,10 @@ onBeforeUnmount(() => {
v-if="isListRow(item as VItem)"
:position="rowPosition(item)"
:webp="supportsWebp"
expandable
:expanded="listExpansion.isExpanded(rowPosition(item))"
:detail-height="listExpansion.detailHeight(rowPosition(item))"
@toggle-expand="listExpansion.toggle(rowPosition(item))"
/>
<GameListSkeletonRow v-else />
</template>

View File

@@ -59,7 +59,11 @@ const { toolbarHeight, pinned, bindToolbar, bindSentinel } = usePinnedToolbar();
<slot name="toolbar" />
</div>
<div v-if="listMode" class="r-v2-idx-shell__list-header">
<div
v-if="listMode"
class="r-v2-idx-shell__list-header"
:class="{ 'r-pinned-list-header': pinned }"
>
<slot name="listHeader" />
</div>
@@ -84,4 +88,13 @@ html[data-bp~="xs"] .r-v2-idx-shell {
top: calc(var(--r-nav-h) + var(--r-v2-idx-shell-toolbar-h));
z-index: 3;
}
/* Compact list mode: the column header and the rows run to the screen
edges, out of the shell's gutter — each keeps that gutter as its own
padding, so only the separators and the row fill reach the edge. */
html[data-bp~="sm-and-down"] .r-v2-idx-shell__list-header,
html[data-bp~="sm-and-down"] .r-v2-idx-shell :deep(.coll-list-row--compact),
html[data-bp~="sm-and-down"] .r-v2-idx-shell :deep(.plat-list-row) {
margin-inline: calc(-1 * var(--r-row-pad));
}
</style>

View File

@@ -11,16 +11,27 @@
// gallery views (Platform / Collection / Search) share one separator
// regardless of which header sits above it.
import { RTag } from "@v2/lib";
import { computed } from "vue";
import { useAnimatedNumber } from "@/v2/composables/useAnimatedNumber";
defineOptions({ inheritAttrs: false });
withDefaults(
const props = withDefaults(
defineProps<{
title: string;
count?: number | string | null;
}>(),
{ count: null },
);
// A numeric count rolls up to its value; a string one (a range, a label) is
// printed as it comes.
const rolling = useAnimatedNumber(() =>
typeof props.count === "number" ? props.count : null,
);
const countText = computed(() =>
typeof props.count === "number" ? rolling.value : props.count,
);
</script>
<template>
@@ -31,7 +42,7 @@ withDefaults(
{{ title }}
</h1>
<slot name="count">
<RTag v-if="count != null" :text="count" />
<RTag v-if="countText != null" :text="countText" />
</slot>
</div>
<slot />

View File

@@ -2,6 +2,8 @@
// Stat — KPI column: big value on top, small uppercase label below.
// Feature component; InfoPanel and the gallery hero cards reuse it, but
// it's not general enough to be a design-system primitive.
import { computed } from "vue";
import { useAnimatedNumber } from "@/v2/composables/useAnimatedNumber";
defineOptions({ inheritAttrs: false });
@@ -10,16 +12,25 @@ interface Props {
label?: string;
}
withDefaults(defineProps<Props>(), {
const props = withDefaults(defineProps<Props>(), {
value: undefined,
label: undefined,
});
// A count rolls up to its value; anything already formatted (a size, a date)
// is printed as it comes.
const rolling = useAnimatedNumber(() =>
typeof props.value === "number" ? props.value : null,
);
const text = computed(() =>
typeof props.value === "number" ? rolling.value : props.value,
);
</script>
<template>
<div class="stat">
<div class="stat__value">
<slot>{{ value }}</slot>
<slot>{{ text }}</slot>
</div>
<div class="stat__label">
<slot name="label">{{ label }}</slot>

View File

@@ -0,0 +1,63 @@
import { describe, expect, it, vi } from "vitest";
import { computed, effectScope, ref } from "vue";
import { useAnimatedNumber } from "./index";
// Reduced motion lands on the value in one step, which is what makes the
// state machine readable without chasing frames.
const reduced = ref(true);
vi.mock("@/v2/composables/useReducedMotion", () => ({
useReducedMotion: () => ({ enabled: computed(() => reduced.value) }),
}));
describe("useAnimatedNumber", () => {
it("shows the value it is given", () => {
const source = ref<number | null>(42);
const display = useAnimatedNumber(() => source.value);
expect(display.value).toBe(42);
});
it("lands exactly on each new value", async () => {
const source = ref<number | null>(3);
const display = useAnimatedNumber(() => source.value);
source.value = 88;
await Promise.resolve();
expect(display.value).toBe(88);
});
it("paints a missing value as nothing to roll to", async () => {
const source = ref<number | null>(7);
const display = useAnimatedNumber(() => source.value);
source.value = null;
await Promise.resolve();
expect(display.value).toBeNull();
});
it("rolls through the numbers on the way when motion is allowed", async () => {
reduced.value = false;
const source = ref<number | null>(0);
const scope = effectScope();
const seen: (number | null)[] = [];
let display!: ReturnType<typeof useAnimatedNumber>;
scope.run(() => {
display = useAnimatedNumber(() => source.value, { duration: 60 });
});
source.value = 100;
await new Promise((resolve) => setTimeout(resolve, 20));
seen.push(display.value);
await new Promise((resolve) => setTimeout(resolve, 80));
// Caught mid-roll it sits between the two, and it finishes on the target.
expect(seen[0]).toBeGreaterThan(0);
expect(seen[0]).toBeLessThan(100);
expect(display.value).toBe(100);
scope.stop();
reduced.value = true;
});
});

View File

@@ -0,0 +1,77 @@
// useAnimatedNumber — a count that rolls up to its new value instead of
// snapping to it, so a number that changed is a number you noticed.
//
// Ported from the same composable in Berserk (itself from Turtletrips), with
// two changes for this codebase: the duration comes from the motion tokens,
// and reduced motion is read through `useReducedMotion`, which also honours
// the in-app setting — the global CSS guard can't reach a ref driven by
// requestAnimationFrame.
import { onScopeDispose, ref, watch, type Ref } from "vue";
import { useReducedMotion } from "@/v2/composables/useReducedMotion";
import { motion } from "@/v2/tokens";
interface Options {
/** Roll duration in ms. Defaults to the `slow` motion token. */
duration?: number;
/** Decimals kept on the in-between frames (the final value lands exact). */
decimals?: number;
}
export function useAnimatedNumber(
source: () => number | null | undefined,
options: Options = {},
): Ref<number | null> {
const { enabled: reducedMotion } = useReducedMotion();
const duration = options.duration ?? parseInt(motion.slow, 10);
const decimals = options.decimals ?? 0;
const display = ref<number | null>(null);
let frame: number | null = null;
function stop() {
if (frame !== null) cancelAnimationFrame(frame);
frame = null;
}
function animate(from: number, to: number) {
if (duration <= 0 || reducedMotion.value) {
display.value = to;
return;
}
const start = performance.now();
const step = (now: number) => {
const t = Math.min(1, (now - start) / duration);
const eased = 1 - (1 - t) ** 3;
// Rounding is cosmetic, for the frames in between: a raw tween value
// like 1567.4972637 would paint in full and widen the layout mid-roll.
display.value =
t < 1 ? Number((from + (to - from) * eased).toFixed(decimals)) : to;
frame = t < 1 ? requestAnimationFrame(step) : null;
};
frame = requestAnimationFrame(step);
}
watch(
source,
(target) => {
stop();
// A missing value is a dash at the call site, not a number to roll to.
if (target == null) {
display.value = null;
return;
}
// The first value rolls up from zero, which is the whole point of the
// effect: a count that arrives is a count you watch land.
const from = display.value ?? 0;
if (from === target) {
display.value = target;
return;
}
animate(from, target);
},
{ immediate: true },
);
onScopeDispose(stop);
return display;
}

View File

@@ -0,0 +1,56 @@
import { describe, expect, it } from "vitest";
import { computed, ref } from "vue";
import {
LIST_ROW_DETAIL_HEIGHT_PX,
LIST_ROW_HEIGHT_PX,
} from "@/v2/components/Gallery/listColumns";
import { useGalleryVirtualItems, type GalleryItem } from "./index";
/** Row heights for a three-row list, with `open` px of panel on row 1. */
function rowHeights(open: number): number[] {
const { virtualItems, getItemHeight } = useGalleryVirtualItems({
layout: ref("list"),
groupBy: ref("none"),
total: ref(3),
charIndex: ref({ a: 0 }),
columns: ref(1),
loadingInitial: computed(() => false),
emptyMessage: ref(""),
listDetailHeight: (position) => (position === 1 ? open : 0),
});
return virtualItems.value
.filter(
(i): i is Extract<GalleryItem, { kind: "list-row" }> =>
i.kind === "list-row",
)
.map((row) => getItemHeight(row));
}
describe("useGalleryVirtualItems — list row with a detail panel", () => {
it("keeps every row at the base height while none is open", () => {
expect(rowHeights(0)).toEqual([
LIST_ROW_HEIGHT_PX,
LIST_ROW_HEIGHT_PX,
LIST_ROW_HEIGHT_PX,
]);
});
it("grows the open row with its panel", () => {
expect(rowHeights(LIST_ROW_DETAIL_HEIGHT_PX)).toEqual([
LIST_ROW_HEIGHT_PX,
LIST_ROW_HEIGHT_PX + LIST_ROW_DETAIL_HEIGHT_PX,
LIST_ROW_HEIGHT_PX,
]);
});
it("follows the panel mid-roll, so the rows below track it", () => {
// Half open: the virtualiser has to reserve exactly what is showing.
const half = Math.round(LIST_ROW_DETAIL_HEIGHT_PX / 2);
expect(rowHeights(half)).toEqual([
LIST_ROW_HEIGHT_PX,
LIST_ROW_HEIGHT_PX + half,
LIST_ROW_HEIGHT_PX,
]);
});
});

View File

@@ -38,7 +38,10 @@ import {
type MaybeRefOrGetter,
type Ref,
} from "vue";
import { LIST_ROW_HEIGHT_PX } from "@/v2/components/Gallery/listColumns";
import {
LIST_ROW_HEIGHT_PX,
listRowHeight,
} from "@/v2/components/Gallery/listColumns";
import type { GroupByMode, LayoutMode } from "../useGalleryMode";
import type { GalleryItem } from "./types";
@@ -152,6 +155,9 @@ interface Options {
fallbackRatio?: MaybeRefOrGetter<number>;
/** Bump to force a re-pack when measured ratios change (Vue tracks it). */
ratioVersion?: Ref<number> | ComputedRef<number>;
/** Px of detail panel showing on the list row at `position` (0 for the
* rest), so the rows below an opening one sit clear of it. */
listDetailHeight?: (position: number) => number;
}
const ALPHABET = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ@".split("");
@@ -250,9 +256,11 @@ export function useGalleryVirtualItems(opts: Options) {
// `unknown` matches RVirtualScroller's generic prop. Row / skeleton-row
// share the uniform height; every other kind is fixed.
function getItemHeight(item: unknown): number {
const { kind } = item as GalleryItem;
const entry = item as GalleryItem;
const { kind } = entry;
if (kind === "row" || kind === "skeleton-row") return rowHeightPx.value;
return FIXED_HEIGHT_BY_KIND[kind] ?? 0;
if (kind !== "list-row") return FIXED_HEIGHT_BY_KIND[kind] ?? 0;
return listRowHeight(opts.listDetailHeight?.(entry.position) ?? 0);
}
// ── Structural sharing across re-packs ────────────────────────────────

View File

@@ -0,0 +1,67 @@
import { describe, expect, it, vi } from "vitest";
import { computed } from "vue";
import {
LIST_ROW_DETAIL_HEIGHT_PX,
LIST_ROW_HEIGHT_PX,
} from "@/v2/components/Gallery/listColumns";
import { useListExpansion } from "./index";
// Reduced motion skips the roll, so the panel lands on its final height in
// one step and the state machine can be read without chasing frames.
vi.mock("@/v2/composables/useReducedMotion", () => ({
useReducedMotion: () => ({ enabled: computed(() => true) }),
}));
const OPEN_HEIGHT = LIST_ROW_HEIGHT_PX + LIST_ROW_DETAIL_HEIGHT_PX;
describe("useListExpansion", () => {
it("opens a row's panel and gives it the room", () => {
const list = useListExpansion();
list.toggle(3);
expect(list.isExpanded(3)).toBe(true);
expect(list.detailHeight(3)).toBe(LIST_ROW_DETAIL_HEIGHT_PX);
expect(list.rowHeight(3)).toBe(OPEN_HEIGHT);
});
it("leaves every other row alone", () => {
const list = useListExpansion();
list.toggle(3);
expect(list.detailHeight(4)).toBe(0);
expect(list.rowHeight(4)).toBe(LIST_ROW_HEIGHT_PX);
});
it("opens one row at a time", () => {
const list = useListExpansion();
list.toggle(3);
list.toggle(7);
expect(list.isExpanded(3)).toBe(false);
expect(list.rowHeight(3)).toBe(LIST_ROW_HEIGHT_PX);
expect(list.rowHeight(7)).toBe(OPEN_HEIGHT);
});
it("gives the row its height back when it closes", () => {
const list = useListExpansion();
list.toggle(3);
list.toggle(3);
expect(list.isExpanded(3)).toBe(false);
expect(list.rowHeight(3)).toBe(LIST_ROW_HEIGHT_PX);
});
it("drops everything when the list underneath changes", () => {
const list = useListExpansion();
list.toggle(3);
list.collapse();
expect(list.isExpanded(3)).toBe(false);
expect(list.rowHeight(3)).toBe(LIST_ROW_HEIGHT_PX);
});
});

View File

@@ -0,0 +1,100 @@
// useListExpansion — one open detail panel at a time in a list-mode table.
//
// Every surface that renders `GameListRow` (the gallery shell, Settings →
// Missing games) needs the same two things: which row is open, and the height
// that row now takes, since the virtualiser reserves each row's slot up front.
// Keeping both here is what makes the two tables behave identically.
//
// The panel rolls open and shut like a blind, which only reads right if the
// reserved slot grows and shrinks with it — a panel animating inside a slot
// that already jumped to its full height just fades. So the height is animated
// here, and both the row's panel and the virtualiser read the same number.
import { ref } from "vue";
import {
LIST_ROW_DETAIL_HEIGHT_PX,
listRowHeight,
} from "@/v2/components/Gallery/listColumns";
import { useReducedMotion } from "@/v2/composables/useReducedMotion";
/** Matches `--r-motion-med`, the duration the rest of v2 opens things at. */
const DURATION_MS = 220;
function easeOut(t: number): number {
return 1 - (1 - t) ** 3;
}
export function useListExpansion() {
const { enabled: reducedMotion } = useReducedMotion();
/** The row painting a panel — set while it rolls shut, too. */
const expandedPosition = ref<number | null>(null);
/** How much of the panel is currently showing, in px. */
const openHeight = ref(0);
let frame: number | null = null;
function stopAnimation() {
if (frame !== null) cancelAnimationFrame(frame);
frame = null;
}
function animateTo(target: number, onDone?: () => void) {
stopAnimation();
if (reducedMotion.value) {
openHeight.value = target;
onDone?.();
return;
}
const from = openHeight.value;
const start = performance.now();
const step = (now: number) => {
const t = Math.min(1, (now - start) / DURATION_MS);
openHeight.value = from + (target - from) * easeOut(t);
if (t < 1) {
frame = requestAnimationFrame(step);
return;
}
frame = null;
onDone?.();
};
frame = requestAnimationFrame(step);
}
function isExpanded(position: number | null | undefined): boolean {
return position != null && expandedPosition.value === position;
}
/** Panel height for the row at `position` — 0 for every other row. */
function detailHeight(position: number | null | undefined): number {
return isExpanded(position) ? openHeight.value : 0;
}
function toggle(position: number) {
if (isExpanded(position)) {
animateTo(0, () => (expandedPosition.value = null));
return;
}
expandedPosition.value = position;
openHeight.value = 0;
animateTo(LIST_ROW_DETAIL_HEIGHT_PX);
}
function collapse() {
stopAnimation();
expandedPosition.value = null;
openHeight.value = 0;
}
/** Height of the row at `position`, however much panel is showing. */
function rowHeight(position: number | null | undefined): number {
return listRowHeight(detailHeight(position));
}
return {
expandedPosition,
isExpanded,
detailHeight,
toggle,
collapse,
rowHeight,
};
}

View File

@@ -430,6 +430,27 @@ const hasLabel = computed(
0 0 16px color-mix(in srgb, var(--r-cb-fill) 40%, transparent);
}
/* The inset top highlight reads as a sheen across a flat edge, but on a
circle it follows the curve and lands as a white arc over the fill. The
round variant keeps the glow and drops the highlight. */
.r-checkbox--shape-circle.r-checkbox--checked .r-checkbox__box,
.r-checkbox--shape-circle.r-checkbox--indeterminate .r-checkbox__box,
.r-checkbox--shape-circle.r-checkbox--multi-active .r-checkbox__box {
box-shadow: 0 0 12px color-mix(in srgb, var(--r-cb-fill) 32%, transparent);
}
.r-checkbox--shape-circle.r-checkbox--checked:not(.r-checkbox--disabled):hover
.r-checkbox__box,
.r-checkbox--shape-circle.r-checkbox--indeterminate:not(
.r-checkbox--disabled
):hover
.r-checkbox__box,
.r-checkbox--shape-circle.r-checkbox--multi-active:not(
.r-checkbox--disabled
):hover
.r-checkbox__box {
box-shadow: 0 0 16px color-mix(in srgb, var(--r-cb-fill) 40%, transparent);
}
/* ── Glyph (check / minus) — drawn-in stroke ──────────────────── */
/* SVG icon — sized to the per-size --r-cb-icon var, color inherits
white from the box. Always mounted (so the path animations have a

View File

@@ -292,7 +292,7 @@ function scrollToIndex(index: number, options: ScrollToIndexOptions = {}) {
}
}
defineExpose({ scrollToIndex, containerEl, scrollTop });
defineExpose({ scrollToIndex, containerEl, scrollTop, innerOffsetTop });
const minContentWidthCss = computed(() => {
const w = props.minContentWidth;

View File

@@ -42,6 +42,8 @@ html[data-bp~="sm-and-down"].r-v2 {
}
html[data-bp~="xs"].r-v2 {
--r-row-pad: 14px;
/* List mode: a tighter tick column, so the table spends its width on data. */
--r-list-select-w: 24px;
}
/* The nav chrome unmounts while a player stage owns the viewport, so its
@@ -313,8 +315,9 @@ html.r-v2-reduced-motion *::after {
color: var(--r-color-fg-muted);
}
/* Top-bar glass, shared with the toolbars that pin under it. Reduced motion
swaps the blur (costly, murky over its solid background) for a flat bg. */
/* Top-bar glass, shared with the toolbars and list column headers that pin
under it. Reduced motion swaps the blur (costly, murky over its solid
background) for a flat bg. */
.r-v2 {
--r-glass-bar-bg: color-mix(in srgb, var(--r-color-bg) 78%, transparent);
--r-glass-bar-filter: blur(20px);
@@ -346,6 +349,22 @@ html.r-v2-reduced-motion {
opacity: 1;
}
/* List column header once pinned: the same glass, edge to edge, with its
border moved onto it. Goes on the sticky element, which anchors the glass. */
.r-pinned-list-header {
--r-list-header-border: 0;
}
.r-pinned-list-header::before {
content: "";
position: absolute;
inset: 0 calc(-1 * var(--r-row-pad));
z-index: -1;
background: var(--r-glass-bar-bg);
backdrop-filter: var(--r-glass-bar-filter);
border-bottom: 1px solid var(--r-color-border);
pointer-events: none;
}
/* Column both gallery Settings tabs (platform, collection) render in, so they
share one width. */
.r-settings-column {

View File

@@ -156,9 +156,9 @@
--r-coll-cover-w-xs: 150px;
--r-coll-cover-h-xs: 202px;
--r-alpha-strip-w: 24px;
--r-alpha-strip-w-xs: 30px;
--r-list-row-h: 80px;
--r-list-header-h: 40px;
--r-list-row-detail-h: 226px;
--r-z-drawer: 2300;
--r-z-dialog: 2400;
--r-z-menu: 2500;
@@ -212,6 +212,7 @@ html[data-input="pad"] .r-v2 {
--r-color-fg-secondary: rgba(17, 17, 23, 0.82);
--r-color-fg-muted: rgba(17, 17, 23, 0.74);
--r-color-fg-faint: rgba(17, 17, 23, 0.58);
--r-color-fg-faint-hard: rgba(17, 17, 23, 0.2);
--r-color-border: rgba(0, 0, 0, 0.1);
--r-color-border-strong: rgba(0, 0, 0, 0.22);
--r-color-focus: rgba(0, 0, 0, 0.45);

View File

@@ -182,6 +182,7 @@ export const colorLight = {
fgSecondary: "rgba(17, 17, 23, 0.82)",
fgMuted: "rgba(17, 17, 23, 0.74)",
fgFaint: "rgba(17, 17, 23, 0.58)",
fgFaintHard: "rgba(17, 17, 23, 0.2)",
border: "rgba(0, 0, 0, 0.1)",
borderStrong: "rgba(0, 0, 0, 0.22)",
focus: "rgba(0, 0, 0, 0.45)",
@@ -451,10 +452,8 @@ export const layout = {
collectionCoverHeight: "188px",
collectionCoverWidthXs: "150px",
collectionCoverHeightXs: "202px",
// AlphaStrip A-Z jump column (gallery). Wider on phones for bigger, more
// tappable letters.
// AlphaStrip A-Z jump column (gallery).
alphaStripWidth: "24px",
alphaStripWidthXs: "30px",
// List-mode (table) gallery geometry. `GameListRow`, `GameListHeader`
// and `GameListSkeletonRow` all derive their pixel sizing from these,
// and `useGalleryVirtualItems` reads `listRowHeight` so the virtualiser's
@@ -463,6 +462,10 @@ export const layout = {
// `<GameCard size="xs" />` — no dedicated list-cover token.)
listRowHeight: "80px",
listHeaderHeight: "40px",
// Height of a list row's expanded detail panel on phones and tablets,
// where the row collapses to two lines and the columns move in here.
// Fixed so the virtualiser can offset the rows below it exactly.
listRowDetailHeight: "226px",
} as const;
export const tokens = {

View File

@@ -0,0 +1,7 @@
/** A KPI column in a gallery header: `Stat` renders one per entry. Shared by
* the header component and the views that compose the rows. */
export interface StatRow {
label: string;
/** A number rolls up on screen; a string (a size, a date) is printed. */
value: string | number;
}

View File

@@ -41,6 +41,7 @@ import { useIsAlive } from "@/v2/composables/useIsAlive";
import { usePageTitle } from "@/v2/composables/usePageTitle";
import { useSnackbar } from "@/v2/composables/useSnackbar";
import storeGalleryRoms from "@/v2/stores/galleryRoms";
import type { StatRow } from "@/v2/types/stats";
const { t } = useI18n();
const route = useRoute();
@@ -162,14 +163,13 @@ const tags = computed<string[]>(() => {
return out;
});
type StatRow = { label: string; value: string };
const platformStats = computed<StatRow[]>(() => {
const p = currentPlatform.value;
if (!p) return [];
const rows: StatRow[] = [
{
label: t("platform.in-library"),
value: String(p.rom_count ?? total.value),
value: p.rom_count ?? total.value,
},
{ label: t("platform.on-disk"), value: formatBytes(p.fs_size_bytes ?? 0) },
];
@@ -178,7 +178,7 @@ const platformStats = computed<StatRow[]>(() => {
if (usableFirmware.length) {
rows.push({
label: t("common.firmware"),
value: String(usableFirmware.length),
value: usableFirmware.length,
});
}
return rows;