diff --git a/frontend/src/components/GameDetails/ArtworkSubtab.vue b/frontend/src/components/GameDetails/ArtworkSubtab.vue index 3c49dfd59..947fa193e 100644 --- a/frontend/src/components/GameDetails/ArtworkSubtab.vue +++ b/frontend/src/components/GameDetails/ArtworkSubtab.vue @@ -9,7 +9,7 @@ import { REmptyState } from "@/lib"; import type { DetailedRom } from "@/stores/roms"; import { resolveRomArtwork } from "@/utils/romArtwork"; -const props = defineProps<{ rom: DetailedRom }>(); +const props = defineProps<{ rom: DetailedRom; suspended?: boolean }>(); const { t } = useI18n(); const { isPinned, togglePin } = usePinnedMedia(() => props.rom); @@ -29,6 +29,7 @@ const artwork = computed(() => resolveRomArtwork(props.rom)); v-else :items="artwork" captions + :suspended="suspended" :is-pinned="isPinned" @toggle-pin="togglePin" /> diff --git a/frontend/src/components/GameDetails/MediaShelf.test.ts b/frontend/src/components/GameDetails/MediaShelf.test.ts index d5a5d0252..40fbf8d8a 100644 --- a/frontend/src/components/GameDetails/MediaShelf.test.ts +++ b/frontend/src/components/GameDetails/MediaShelf.test.ts @@ -34,6 +34,24 @@ function stubLoad() { } describe("MediaShelf", () => { + it("renders a YouTube item as an embed, kept out of the lightbox", () => { + const wrapper = mount(MediaShelf, { + props: { + items: [{ key: "yt", label: "YouTube", url: "", youtubeId: "abc123" }], + suspended: true, + }, + global: { stubs: { RCarousel: true, RIcon: true, YoutubeEmbed: true } }, + }); + const embed = wrapper.getComponent({ name: "YoutubeEmbed" }); + + expect(embed.props()).toMatchObject({ + videoId: "abc123", + title: "YouTube", + suspended: true, + }); + expect(wrapper.find("button.r-media-shelf__btn").exists()).toBe(false); + }); + it("does not start loading a clip until it is played", () => { const wrapper = mountShelf([clip]); diff --git a/frontend/src/components/GameDetails/MediaShelf.vue b/frontend/src/components/GameDetails/MediaShelf.vue index f67e02fbc..58e2563f9 100644 --- a/frontend/src/components/GameDetails/MediaShelf.vue +++ b/frontend/src/components/GameDetails/MediaShelf.vue @@ -4,6 +4,7 @@ import { computed, reactive, ref, type VNode } from "vue"; import { useI18n } from "vue-i18n"; import MediaPinButton from "@/components/GameDetails/MediaPinButton.vue"; +import YoutubeEmbed from "@/components/GameDetails/YoutubeEmbed.vue"; import { RCarousel, RIcon } from "@/lib"; import { claimMedia, releaseMedia } from "@/utils/releaseMedia"; @@ -14,6 +15,8 @@ export type MediaShelfItem = { isVideo?: boolean; /** Still shown in a clip's box until it plays. */ poster?: string; + /** Renders a YouTube embed instead of an image or clip; `url` is unused. */ + youtubeId?: string; }; defineOptions({ inheritAttrs: false }); @@ -23,12 +26,16 @@ const props = defineProps<{ captions?: boolean; compact?: boolean; isPinned?: ((key: string) => boolean) | undefined; + /** The shelf sits in a hidden panel, so embeds pause. */ + suspended?: boolean; }>(); const emit = defineEmits<{ "toggle-pin": [key: string] }>(); const { t } = useI18n(); -const images = computed(() => props.items.filter((item) => !item.isVideo)); +const images = computed(() => + props.items.filter((item) => !item.isVideo && !item.youtubeId), +); // Lightbox indexes into the image-only list, so map a clicked card to its // position there (videos are skipped). @@ -83,10 +90,16 @@ function onClipPlay(event: Event, key: string) { >