feat: enhance GameListRow and GameListSkeletonRow with provider chips and update platform handling

This commit is contained in:
zurdi
2026-05-27 11:51:47 +00:00
parent 8e68cc52b7
commit d703f437ba
7 changed files with 206 additions and 89 deletions

View File

@@ -23,21 +23,22 @@
import {
RCheckbox,
RChip,
RIcon,
RPlatformIcon,
RSkeletonBlock,
RTooltip,
} from "@v2/lib";
import { computed, onBeforeUnmount, onMounted } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import storePlatforms from "@/stores/platforms";
import { formatBytes, toBrowserLocale } from "@/utils";
import MoreMenu from "@/v2/components/GameActions/MoreMenu.vue";
import GameActionBtn from "@/v2/components/GameActions/GameActionBtn.vue";
import GameCard from "@/v2/components/GameCard/GameCard.vue";
import { useGallerySelectionInput } from "@/v2/composables/useGallerySelectionInput";
import { useViewTransition } from "@/v2/composables/useViewTransition";
import storeGalleryRoms, { type SimpleRom } from "@/v2/stores/galleryRoms";
import storeGallerySelection from "@/v2/stores/gallerySelection";
import { activeProviders } from "@/v2/utils/metadataProviders";
import {
getListColumns,
getListGridTemplate,
@@ -47,6 +48,12 @@ import {
defineOptions({ inheritAttrs: false });
// Cap on how many language/region chips render before the `+N` overflow
// chip kicks in. Tuned so 4-chip lists fit on a single wrapped line
// inside the pills cell; longer lists stack to a second line with the
// `+N` chip pinned at the end. Full list lives in the RTooltip.
const PILLS_VISIBLE = 4;
interface Props {
/** Absolute position in the active gallery (0-indexed). Drives the
* row's per-row fetch + serves as the lookup key into the store's
@@ -78,7 +85,7 @@ const selection = storeGallerySelection();
const selectionInput = useGallerySelectionInput();
const platformsStore = storePlatforms();
const { morphTransition } = useViewTransition();
const { locale, t } = useI18n();
const { locale } = useI18n();
const columns = computed(() => getListColumns(props.showPlatformColumn));
const listSkeletonColumns = columns;
@@ -118,6 +125,11 @@ const platformMeta = computed(() => {
return platformsStore.get(item.platform_id) ?? null;
});
const providers = computed(() => {
const item = rom.value;
return item ? activeProviders(item) : [];
});
function formatDate(value: string | null | undefined): string {
if (!value) return "—";
try {
@@ -280,6 +292,26 @@ onBeforeUnmount(() => {
{{ rom.name ?? rom.fs_name_no_ext }}
</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"
:title="provider.title"
:style="provider.bg ? { background: provider.bg } : undefined"
>
<img
:src="`/assets/scrappers/${provider.logo}`"
:alt="provider.title"
width="14"
height="14"
/>
</span>
</div>
</div>
</div>
@@ -290,7 +322,7 @@ onBeforeUnmount(() => {
<RPlatformIcon
v-if="platformMeta?.slug"
:slug="platformMeta.slug"
:size="18"
:size="24"
/>
<span class="game-list-row__platform-name">
{{ platformMeta?.name ?? "—" }}
@@ -304,45 +336,67 @@ onBeforeUnmount(() => {
<div class="game-list-row__cell">{{ releaseDate(rom) }}</div>
<div class="game-list-row__cell">{{ ratingValue(rom) }}</div>
<div class="game-list-row__cell">
<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, 3) ?? []"
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">
<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, 3) ?? []"
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 game-list-row__cell--end">
<MoreMenu :rom="rom">
<template #activator="{ props: activatorProps }">
<button
v-bind="activatorProps"
type="button"
class="game-list-row__more"
:aria-label="t('rom.more-actions')"
@click.stop
>
<RIcon icon="mdi-dots-vertical" size="18" />
</button>
</template>
</MoreMenu>
<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>
@@ -373,10 +427,10 @@ onBeforeUnmount(() => {
<RSkeletonBlock width="40%" :height="10" />
</div>
</div>
<div v-else-if="col.key === 'platform'" class="game-list-row__cell">
<div v-else-if="col.key === 'platform_id'" class="game-list-row__cell">
<div class="game-list-row__platform">
<RSkeletonBlock :width="18" :height="18" circle />
<RSkeletonBlock :width="64" :height="10" />
<RSkeletonBlock :width="24" :height="24" circle />
<RSkeletonBlock :width="100" :height="10" />
</div>
</div>
<div
@@ -503,11 +557,45 @@ onBeforeUnmount(() => {
text-overflow: ellipsis;
}
.game-list-row__providers {
display: flex;
align-items: center;
gap: 3px;
margin-top: 4px;
overflow: hidden;
}
.game-list-row__provider {
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
border-radius: 4px;
background: var(--r-color-surface);
flex-shrink: 0;
}
.game-list-row__provider img {
display: block;
object-fit: contain;
}
/* Pills cell — chips wrap to multiple lines inside the cell when they
don't fit on a single row, so short language/region lists read as a
single horizontal strip and longer lists stack vertically. The cell
keeps `overflow: hidden` (defense against extreme lists) and the
row's fixed 80px height clips anything past ~3 wrapped lines; the
full list is available via the cell's `title` tooltip. */
.game-list-row__cell--pills {
white-space: normal;
}
.game-list-row__pills {
display: flex;
flex-wrap: nowrap;
flex-wrap: wrap;
align-content: center;
gap: 3px;
overflow: hidden;
max-height: 100%;
}
.game-list-row__platform {
@@ -523,24 +611,9 @@ onBeforeUnmount(() => {
text-overflow: ellipsis;
}
.game-list-row__more {
appearance: none;
background: transparent;
border: 0;
padding: var(--r-space-1);
border-radius: var(--r-radius-sm);
.game-list-row__actions {
display: inline-flex;
align-items: center;
justify-content: center;
color: var(--r-color-fg-muted);
cursor: pointer;
transition:
color var(--r-motion-fast) var(--r-motion-ease-out),
background var(--r-motion-fast) var(--r-motion-ease-out);
}
.game-list-row__more:hover,
.game-list-row__more:focus-visible {
color: var(--r-color-fg);
background: var(--r-color-surface-hover);
gap: 4px;
}
</style>

View File

@@ -57,10 +57,10 @@ const gridStyle = computed(() => ({
</div>
</div>
<div v-else-if="col.key === 'platform'" class="r-glr-skel__cell">
<div v-else-if="col.key === 'platform_id'" class="r-glr-skel__cell">
<div class="r-glr-skel__platform">
<RSkeletonBlock :width="18" :height="18" circle />
<RSkeletonBlock :width="64" :height="10" />
<RSkeletonBlock :width="24" :height="24" circle />
<RSkeletonBlock :width="100" :height="10" />
</div>
</div>

View File

@@ -20,6 +20,7 @@ import { layout } from "@/v2/tokens";
export type ListSortKey = Extract<
GalleryOrderKey,
| "name"
| "platform_id"
| "fs_size_bytes"
| "created_at"
| "first_release_date"
@@ -29,13 +30,7 @@ export type ListSortKey = Extract<
export interface ListColumn {
/** Sort key (matches `galleryRoms.orderBy`). `null` for non-sortable
* display-only columns (icon labels, action menus). */
key:
| ListSortKey
| "select"
| "platform"
| "languages"
| "regions"
| "actions";
key: ListSortKey | "select" | "languages" | "regions" | "actions";
/** Column header label. Empty string renders no text (used for the
* leading select column + trailing actions column). */
label: string;
@@ -60,11 +55,11 @@ export function getListColumns(showPlatform: boolean): readonly ListColumn[] {
];
if (showPlatform) {
cols.push({
key: "platform",
key: "platform_id",
label: "Platform",
sortable: false,
sortable: true,
align: "start",
skeletonWidth: 80,
skeletonWidth: 100,
});
}
cols.push(
@@ -119,8 +114,8 @@ export function getListColumns(showPlatform: boolean): readonly ListColumn[] {
* is inserted between `name` and `fs_size_bytes` when present so column
* order matches the array. */
export function getListGridTemplate(showPlatform: boolean): string {
const platformTrack = showPlatform ? " 110px" : "";
return `36px minmax(0, 1.6fr)${platformTrack} 88px 96px 84px 56px 110px 110px 56px`;
const platformTrack = showPlatform ? " 170px" : "";
return `36px minmax(0, 1.6fr)${platformTrack} 88px 96px 84px 56px 110px 110px 88px`;
}
/** Default exports — the cross-platform variant. Used by the bootstrap-

View File

@@ -28,6 +28,9 @@
// glass → default translucent frosted-glass pill
// surface → translucent grey, page-background friendly (Details)
// emphasized → white-on-dark (used by Play in card + details)
// bare → no background or border, just the icon (list rows /
// inline strips where the row's own surface frames the
// control)
//
// `withLabel` turns the button into a pill with "Play" / "Download" /
// etc. text next to the icon, matching the GameDetails Play CTA.
@@ -69,8 +72,10 @@ interface Props {
* (GameDetails header where the buttons sit on the
* page background, not over a cover).
* `emphasized` — primary white-on-dark CTA (Play).
* `bare` — no chrome; just the icon. For list rows where the row's
* own surface already frames the control.
*/
variant?: "glass" | "surface" | "emphasized";
variant?: "glass" | "surface" | "emphasized" | "bare";
withLabel?: boolean;
/**
* Status-only: when several status states are active, the button
@@ -601,6 +606,22 @@ function onClick(e: MouseEvent) {
color: var(--r-color-fg);
}
/* Bare — no chrome. The active-state colour swap (`--active-favorite`
etc.) still applies because it overrides `color` only. Hover paints a
subtle surface tint so the hit-target reads. */
.r-v2-game-btn--bare {
background: transparent;
border-color: transparent;
color: var(--r-color-fg-muted);
backdrop-filter: none;
-webkit-backdrop-filter: none;
}
.r-v2-game-btn--bare:hover {
background: var(--r-color-surface-hover);
border-color: transparent;
color: var(--r-color-fg);
}
/* Emphasized — the primary-action look (white on dark). Used by Play. */
.r-v2-game-btn--emphasized {
background: var(--r-color-overlay-emphasis-bg) !important;

View File

@@ -11,6 +11,7 @@ import { ROUTES } from "@/plugins/router";
import type { SimpleRom } from "@/stores/roms";
import { getMissingCoverImage, getUnmatchedCoverImage } from "@/utils/covers";
import { useWebpSupport } from "@/v2/composables/useWebpSupport";
import { activeProviders } from "@/v2/utils/metadataProviders";
defineOptions({ inheritAttrs: false });
@@ -21,36 +22,6 @@ const props = defineProps<{
const { t } = useI18n();
const { toWebp } = useWebpSupport();
interface Provider {
key: string;
title: string;
logo: string;
bg?: string;
}
const PROVIDERS: readonly Provider[] = [
{ key: "hasheous_id", title: "Verified with Hasheous", logo: "hasheous.png" },
{ key: "igdb_id", title: "IGDB match", logo: "igdb.png" },
{ key: "ss_id", title: "ScreenScraper match", logo: "ss.png" },
{ key: "moby_id", title: "MobyGames match", logo: "moby.png" },
{
key: "launchbox_id",
title: "LaunchBox match",
logo: "launchbox.png",
bg: "#185a7c",
},
{ key: "ra_id", title: "RetroAchievements match", logo: "ra.png" },
{ key: "flashpoint_id", title: "Flashpoint match", logo: "flashpoint.png" },
{ key: "hltb_id", title: "HowLongToBeat match", logo: "hltb.png" },
{ key: "gamelist_id", title: "ES-DE match", logo: "esde.png" },
{ key: "libretro_id", title: "Libretro match", logo: "libretro.png" },
];
function activeProviders(rom: SimpleRom) {
return PROVIDERS.filter((p) =>
Boolean((rom as Record<string, unknown>)[p.key]),
);
}
function coverFor(rom: SimpleRom): string {
if (rom.path_cover_small) return toWebp(rom.path_cover_small);
// Fallback procedural cover — distinct artwork for identified vs.

View File

@@ -46,6 +46,7 @@ export type SimpleRom = SimpleRomSchema;
export type GalleryOrderKey =
| "name"
| "fs_name"
| "platform_id"
| "fs_size_bytes"
| "created_at"
| "updated_at"

View File

@@ -0,0 +1,56 @@
// Metadata-provider registry — single source of truth for the small
// provider chips that appear next to a ROM (gallery list rows, scan
// rows, future surfaces). One entry per provider gives label + logo
// path + (optional) brand-colour background; consumers iterate and
// filter to the providers whose id field is populated on the ROM.
import type { SimpleRom } from "@/stores/roms";
/** Subset of `SimpleRom` fields that hold a matched provider id. Keying
* the list against this type means a typo or a removed field is a
* compile error, not a silent miss. */
export type ProviderIdKey =
| "hasheous_id"
| "igdb_id"
| "ss_id"
| "moby_id"
| "launchbox_id"
| "ra_id"
| "flashpoint_id"
| "hltb_id"
| "gamelist_id"
| "libretro_id";
export interface MetadataProvider {
/** Field on `SimpleRom` that holds this provider's match id. */
key: ProviderIdKey;
/** Tooltip text — also serves as the chip's `alt`. */
title: string;
/** File under `/assets/scrappers/`. */
logo: string;
/** Brand background tint when the logo needs one to read on the chip
* (LaunchBox ships a white isotype that disappears on a light chip). */
bg?: string;
}
export const METADATA_PROVIDERS: readonly MetadataProvider[] = [
{ key: "hasheous_id", title: "Verified with Hasheous", logo: "hasheous.png" },
{ key: "igdb_id", title: "IGDB match", logo: "igdb.png" },
{ key: "ss_id", title: "ScreenScraper match", logo: "ss.png" },
{ key: "moby_id", title: "MobyGames match", logo: "moby.png" },
{
key: "launchbox_id",
title: "LaunchBox match",
logo: "launchbox.png",
bg: "#185a7c",
},
{ key: "ra_id", title: "RetroAchievements match", logo: "ra.png" },
{ key: "flashpoint_id", title: "Flashpoint match", logo: "flashpoint.png" },
{ key: "hltb_id", title: "HowLongToBeat match", logo: "hltb.png" },
{ key: "gamelist_id", title: "ES-DE match", logo: "esde.png" },
{ key: "libretro_id", title: "Libretro match", logo: "libretro.png" },
];
/** Returns the providers whose id field is populated on the given ROM. */
export function activeProviders(rom: SimpleRom): MetadataProvider[] {
return METADATA_PROVIDERS.filter((p) => Boolean(rom[p.key]));
}