mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 10:01:00 +01:00
The redesign wrote the same compact sort control into three headers, the same compact row anatomy into four components, and a second rAF tween beside the one it had just added. - Extract ListSortMenu, which also settles the three different answers the headers gave when no column carries the current sort. - Move the compact row's flex/stack/facts rules to global.css, beside the list chrome already there. - Share one `tween` helper between the two animating composables. - Let useAnimatedNumber take an already-formatted value, so Stat and PageHeader stop repeating the same number-or-string branch. - Make the tick column a layout token instead of a constant, a CSS variable declared only for phones, and three literal fallbacks. - Read the expansion duration from the motion token it documents. - Drop the `compact` aliases that only renamed `smAndDown`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016bZ7R3xC73MZu1vTNuatPK
310 lines
8.7 KiB
Vue
310 lines
8.7 KiB
Vue
<script setup lang="ts">
|
|
// CollectionListRow — single row of the Collections list-mode index.
|
|
//
|
|
// Anatomy mirrors GameListRow: cover mosaic + name on the left, kind
|
|
// chip in the middle, game count on the right. Click navigates with
|
|
// the same shared-element morph as CollectionTile so grid ↔ list ↔
|
|
// detail-page transitions land on the same animation anchor. Morph
|
|
// name includes the kind so regular/virtual/smart with overlapping
|
|
// numeric ids never collide.
|
|
import { RIcon, RTooltip } from "@v2/lib";
|
|
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,
|
|
} from "@/v2/composables/useViewTransition";
|
|
import { COLLECTION_LIST_GRID_TEMPLATE } from "./collectionListColumns";
|
|
|
|
defineOptions({ inheritAttrs: false });
|
|
|
|
type Kind = "regular" | "virtual" | "smart";
|
|
|
|
interface Props {
|
|
id: number | string;
|
|
name: string;
|
|
romCount?: number;
|
|
covers?: (string | null | undefined)[];
|
|
to: string;
|
|
kind?: Kind;
|
|
/** Owner-set visibility. Drives the private-lock marker. Only
|
|
* meaningful for regular/smart collections — virtual collections are
|
|
* autogenerated and never carry a public/private state. */
|
|
isPublic?: boolean;
|
|
}
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
romCount: 0,
|
|
covers: () => [],
|
|
kind: "regular",
|
|
isPublic: undefined,
|
|
});
|
|
|
|
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 router = useRouter();
|
|
const coverEl = ref<HTMLElement | null>(null);
|
|
const { morphTransition } = useViewTransition();
|
|
|
|
const morphName = computed(() => `coll-cover-${props.kind}-${props.id}`);
|
|
|
|
const morphStyle = computed(() =>
|
|
pendingMorphName.value === morphName.value
|
|
? { viewTransitionName: morphName.value }
|
|
: undefined,
|
|
);
|
|
|
|
// Kind cell — icon + label for every kind (the list view can afford the
|
|
// text). Icons match the grid cards.
|
|
const kindBadge = computed<{ icon: string; label: string }>(() => {
|
|
if (props.kind === "smart") {
|
|
return { icon: "mdi-flash", label: t("collection.kind-smart") };
|
|
}
|
|
if (props.kind === "virtual") {
|
|
return { icon: "mdi-bookmark-box", label: t("collection.kind-virtual") };
|
|
}
|
|
return { icon: "mdi-bookmark-outline", label: t("collection.kind-standard") };
|
|
});
|
|
|
|
// Visibility cell — public/private for owner-managed kinds. Virtual
|
|
// collections are autogenerated and have no visibility state (→ "—").
|
|
const visibility = computed<{ icon: string; label: string } | null>(() => {
|
|
if (props.kind === "virtual") return null;
|
|
return props.isPublic
|
|
? { icon: "mdi-earth", label: t("collection.public") }
|
|
: { icon: "mdi-lock", label: t("collection.private") };
|
|
});
|
|
|
|
const gridStyle = { gridTemplateColumns: COLLECTION_LIST_GRID_TEMPLATE };
|
|
|
|
function onRowClick(e: MouseEvent) {
|
|
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) {
|
|
return;
|
|
}
|
|
if (!coverEl.value) return;
|
|
e.preventDefault();
|
|
morphTransition({ el: coverEl.value, name: morphName.value }, async () => {
|
|
await router.push(props.to);
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<a
|
|
v-if="smAndDown"
|
|
class="coll-list-row coll-list-row--compact r-list-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="r-list-compact__stack">
|
|
<div class="coll-list-row__name">{{ name }}</div>
|
|
<div class="r-list-compact__facts">
|
|
<RIcon :icon="kindBadge.icon" size="13" />
|
|
<span>{{ kindBadge.label }}</span>
|
|
<span class="r-list-compact__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"
|
|
:aria-label="t('rom.open-game', { name })"
|
|
@click="onRowClick"
|
|
>
|
|
<div class="coll-list-row__cell coll-list-row__title">
|
|
<div ref="coverEl" class="coll-list-row__thumb" :style="morphStyle">
|
|
<CollectionMosaic :covers="covers" />
|
|
</div>
|
|
<div class="coll-list-row__meta">
|
|
<div class="coll-list-row__name">{{ name }}</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="coll-list-row__cell">
|
|
<RTooltip :text="kindBadge.label" location="top">
|
|
<template #activator="{ props: tip }">
|
|
<span
|
|
v-bind="tip"
|
|
class="coll-list-row__kind"
|
|
:class="[`coll-list-row__kind--${kind}`]"
|
|
>
|
|
<RIcon
|
|
:icon="kindBadge.icon"
|
|
size="16"
|
|
class="coll-list-row__kind-icon"
|
|
/>
|
|
<span class="coll-list-row__kind-text">{{ kindBadge.label }}</span>
|
|
</span>
|
|
</template>
|
|
</RTooltip>
|
|
</div>
|
|
|
|
<div class="coll-list-row__cell">
|
|
<span
|
|
v-if="visibility"
|
|
class="coll-list-row__vis"
|
|
:class="{ 'coll-list-row__vis--public': isPublic }"
|
|
>
|
|
<RIcon :icon="visibility.icon" size="16" />
|
|
<span class="coll-list-row__vis-text">{{ visibility.label }}</span>
|
|
</span>
|
|
<span v-else class="coll-list-row__vis">—</span>
|
|
</div>
|
|
|
|
<div class="coll-list-row__cell coll-list-row__cell--end">
|
|
{{ t("collection.games-count", romCount, { named: { n: romCount } }) }}
|
|
</div>
|
|
</a>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.coll-list-row {
|
|
display: grid;
|
|
align-items: center;
|
|
gap: 0 var(--r-space-3);
|
|
padding: 0 var(--r-space-3);
|
|
height: var(--r-list-row-h);
|
|
border-bottom: 1px solid var(--r-color-border);
|
|
font-size: var(--r-font-size-md);
|
|
color: var(--r-color-fg-secondary);
|
|
text-decoration: none;
|
|
cursor: pointer;
|
|
transition: background var(--r-motion-fast) var(--r-motion-ease-out);
|
|
}
|
|
|
|
.coll-list-row:hover {
|
|
background: var(--r-color-bg-elevated);
|
|
}
|
|
|
|
/* Compact (phones / tablets): cover + name, and the columns collapse into
|
|
one line of facts. */
|
|
/* 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:focus-visible {
|
|
outline: none;
|
|
background: var(--r-color-bg-elevated);
|
|
box-shadow: inset 0 0 0 2px var(--r-color-brand-primary);
|
|
}
|
|
|
|
.coll-list-row__cell {
|
|
min-width: 0;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.coll-list-row__cell--end {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.coll-list-row__title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--r-space-3);
|
|
min-width: 0;
|
|
}
|
|
|
|
.coll-list-row__thumb {
|
|
width: var(--r-card-art-w-xs);
|
|
height: var(--r-card-art-h-xs);
|
|
flex-shrink: 0;
|
|
border-radius: var(--r-radius-sm);
|
|
overflow: hidden;
|
|
background: var(--r-color-surface);
|
|
}
|
|
|
|
.coll-list-row__thumb :deep(.coll-mosaic) {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.coll-list-row__meta {
|
|
min-width: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
}
|
|
|
|
.coll-list-row__name {
|
|
font-size: var(--r-font-size-md);
|
|
font-weight: var(--r-font-weight-medium);
|
|
color: var(--r-color-fg);
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
/* Kind + visibility share an icon-plus-label anatomy: the icon holds its
|
|
size, the label shrinks and ellipsises within the column. */
|
|
.coll-list-row__kind,
|
|
.coll-list-row__vis {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: var(--r-space-1);
|
|
max-width: 100%;
|
|
min-width: 0;
|
|
font-size: var(--r-font-size-xs);
|
|
font-weight: var(--r-font-weight-bold);
|
|
letter-spacing: 0.05em;
|
|
text-transform: uppercase;
|
|
color: var(--r-color-fg-muted);
|
|
}
|
|
|
|
.coll-list-row__kind-icon {
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.coll-list-row__kind-text,
|
|
.coll-list-row__vis-text {
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
/* Smart = accent (warm), virtual = brand (cool) — so the two computed
|
|
kinds read apart at a glance. */
|
|
.coll-list-row__kind--smart {
|
|
color: var(--r-color-brand-accent);
|
|
}
|
|
|
|
.coll-list-row__kind--virtual {
|
|
color: var(--r-color-brand-primary);
|
|
}
|
|
|
|
/* Public reads as the highlighted "live" state (brand), matching the
|
|
smart/virtual kind accent; private + the virtual placeholder stay
|
|
muted (inherited from the shared base above). */
|
|
.coll-list-row__vis--public {
|
|
color: var(--r-color-brand-primary);
|
|
}
|
|
</style>
|