From de8d96a5489fc4a382c8063279070d893a854b39 Mon Sep 17 00:00:00 2001 From: vineyardbovines Date: Thu, 9 Jul 2026 10:23:33 -0400 Subject: [PATCH] hide video pillarboxing on web when card fits --- .../Post/Embed/VideoEmbed/index.web.tsx | 59 +++++++++++++++++-- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/src/components/Post/Embed/VideoEmbed/index.web.tsx b/src/components/Post/Embed/VideoEmbed/index.web.tsx index f37ae0d6647..0bb60bd14e4 100644 --- a/src/components/Post/Embed/VideoEmbed/index.web.tsx +++ b/src/components/Post/Embed/VideoEmbed/index.web.tsx @@ -28,6 +28,13 @@ import * as VideoFallback from './VideoEmbedInner/VideoFallback' const noop = () => {} +/** + * Minimum card width for the overlay controls (play, time, CC, volume, + * fullscreen) to fit without crowding. Narrower cards fall back to the + * full-width pillarbox. + */ +const MIN_CARD_WIDTH = 280 + export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) { const t = useTheme() const ref = useRef(null) @@ -89,6 +96,21 @@ export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) { constrained = Math.max(aspectRatio, ratio) } + const [containerWidth, setContainerWidth] = useState(0) + + /* + * Portrait videos render at their own ratio instead of pillarboxed, but + * only when the resulting card fits the overlay controls. Videos taller + * than 1:2 would still show bars inside a ratio-fit card, and an unknown + * ratio can't be fit, so both keep the full-width pillarbox - a narrow + * card with black slices down the sides looks broken (see #9371). + */ + const cardWidth = containerWidth * Math.min(aspectRatio ?? 1, 1) + const fullBleed = + aspectRatio === undefined || + aspectRatio < 1 / 2 || + cardWidth < MIN_CARD_WIDTH + const contents = (
evt.stopPropagation()}> + {/* blurred backdrop fills the bars when the video is boxed */} + {fullBleed && embed.thumbnail && ( +
+ )} +
+ setContainerWidth(e.nativeEvent.layout.width)}>