diff --git a/frontend/src/v2/components/shared/RecommendationReason.vue b/frontend/src/v2/components/shared/RecommendationReason.vue
index fd94c6f7e..f63c64078 100644
--- a/frontend/src/v2/components/shared/RecommendationReason.vue
+++ b/frontend/src/v2/components/shared/RecommendationReason.vue
@@ -7,31 +7,44 @@ import { useI18n } from "vue-i18n";
import type { SimilarityReasonSchema } from "@/__generated__";
import { reasonIcon, reasonLabel } from "@/v2/utils/similarityReasons";
+const SEED_ICON = "mdi-play";
+
const props = defineProps<{
reasons: SimilarityReasonSchema[];
- // Takes the place of the facet chip where the feed knows the seed game,
- // e.g. "Because you played Super Metroid".
- label?: string | null;
+ // Captions the card with the game the recommendation came from, in place
+ // of the first facet.
+ seedRomName?: string | null;
}>();
const { t } = useI18n();
const reason = computed(() =>
- props.label ? null : (props.reasons[0] ?? null),
+ props.seedRomName ? null : (props.reasons[0] ?? null),
+);
+
+const icon = computed(() => {
+ if (props.seedRomName) return SEED_ICON;
+ return reason.value ? reasonIcon(reason.value) : null;
+});
+
+const text = computed(() => {
+ if (props.seedRomName) return props.seedRomName;
+ return reason.value ? reasonLabel(reason.value, t) : null;
+});
+
+// The seed name alone fits the card where the full sentence never did, so
+// the sentence lives here.
+const title = computed(() =>
+ props.seedRomName
+ ? t("recommendations.because-you-played", [props.seedRomName])
+ : t("recommendations.why"),
);
-
- {{ label }}
-
-
- {{ reasonLabel(reason, t) }}
-
+
+
+ {{ text }}
@@ -43,11 +56,28 @@ const reason = computed(() =>
/* Clip to the card it captions rather than widening the row's scroll
track; the token tracks the per-breakpoint card width. */
max-width: var(--r-card-art-w);
+ /* Centres the caption under the card's centred title. Auto margins, not
+ `justify-content`, so an over-long caption still truncates from one end. */
+ margin-inline: auto;
overflow: hidden;
font-size: 10.5px;
font-weight: var(--r-font-weight-medium);
color: var(--r-color-fg-faint);
white-space: nowrap;
+}
+
+/* The caption is a flex container, so the ellipsis has to live on a real
+ child: an anonymous text run never truncates, it just gets cut off. */
+.rec-reason__text {
+ min-width: 0;
+ overflow: hidden;
text-overflow: ellipsis;
}
+
+.rec-reason__icon {
+ /* MDI glyphs centre on the em box, which the text's descender space drops
+ ~2px below its optical centre. Transform, not margin: centring absorbs
+ half of a margin, and a whole pixel stays crisp at 1x. */
+ transform: translateY(-1px);
+}
diff --git a/frontend/src/v2/views/Home.test.ts b/frontend/src/v2/views/Home.test.ts
index c9402de9a..39d8113e7 100644
--- a/frontend/src/v2/views/Home.test.ts
+++ b/frontend/src/v2/views/Home.test.ts
@@ -243,7 +243,11 @@ describe("Home", () => {
await flushPromises();
expect(getRecommendedRoms).toHaveBeenCalledTimes(1);
- expect(wrapper.text()).toContain("recommendations.because-you-played");
+ const caption = wrapper.find(".rec-reason");
+ expect(caption.text()).toBe("Super Metroid");
+ expect(caption.attributes("title")).toContain(
+ "recommendations.because-you-played",
+ );
});
it("hides the recommendations row when the feed comes back empty", async () => {
diff --git a/frontend/src/v2/views/Home.vue b/frontend/src/v2/views/Home.vue
index 3cb460c15..62ece3b69 100644
--- a/frontend/src/v2/views/Home.vue
+++ b/frontend/src/v2/views/Home.vue
@@ -436,13 +436,7 @@ function collectionCovers(c: {
/>