Files
Kam 43acead06d fix(docs-infra): use a facade for docs-video to fix Firefox embeds
Follow-up to #69205. After switching adev's COEP to `credentialless`, the
cross-origin YouTube iframe in `<docs-video>` loads in Chromium and Safari but
not Firefox, whose `credentialless` policy does not extend to nested frames. The
result was a COEP error screen instead of the player.

Render `<docs-video>` as a lightweight thumbnail facade instead of embedding the
iframe directly. The thumbnail is a cross-origin subresource, so it loads under
`credentialless` in every browser. `DocViewer` then upgrades the facade to the
inline player on hydration in browsers that can load the embed (Chromium,
Safari), preserving the previous behavior there. On Firefox the facade stays a
plain link that opens the video on YouTube (with autoplay), which replaces the
error screen.

The thumbnail uses `maxresdefault` and falls back to `hqdefault` when a video
has no max-resolution image.
2026-06-15 08:58:00 -07:00

57 lines
1.1 KiB
SCSS

@use '../colors' as colors;
@mixin docs-video() {
.docs-video-container {
iframe {
border: 0;
width: 100%;
border-radius: 0.25rem;
overflow: hidden;
aspect-ratio: 16 / 9;
}
.docs-video-facade {
position: relative;
display: block;
width: 100%;
aspect-ratio: 16 / 9;
border-radius: 0.25rem;
overflow: hidden;
cursor: pointer;
}
.docs-video-thumbnail {
width: 100%;
height: 100%;
margin: 0;
object-fit: cover;
display: block;
}
.docs-video-play-button {
position: absolute;
inset: 0;
margin: auto;
width: 68px;
height: 48px;
svg {
width: 100%;
height: 100%;
}
.docs-video-play-button-bg {
fill: colors.$gray-800;
fill-opacity: 0.8;
transition: fill-opacity 0.2s ease;
}
}
.docs-video-facade:hover .docs-video-play-button-bg,
.docs-video-facade:focus-visible .docs-video-play-button-bg {
fill: var(--always-red);
fill-opacity: 1;
}
}
}