From 6fa4c9a75e9cd38c8fbbc23ca238d19d70d75f74 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 14 Apr 2026 16:46:29 -0500 Subject: [PATCH] Add crop badges --- src/components/images/Gallery/index.tsx | 68 ++++++++++++++++++------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/src/components/images/Gallery/index.tsx b/src/components/images/Gallery/index.tsx index bcd81bcae0..0c0a1842cd 100644 --- a/src/components/images/Gallery/index.tsx +++ b/src/components/images/Gallery/index.tsx @@ -24,6 +24,7 @@ import {useA11y} from '#/state/a11y' import {useLargeAltBadgeEnabled} from '#/state/preferences/large-alt-badge' import {BlockDrawerGesture} from '#/view/shell/BlockDrawerGesture' import {atoms as a, useBreakpoints, useTheme} from '#/alf' +import {ArrowsDiagonalOut_Stroke2_Corner0_Rounded as Fullscreen} from '#/components/icons/ArrowsDiagonal' import {AutoSizedImage} from '#/components/images/AutoSizedImage' import { ITEM_GAP, @@ -331,12 +332,10 @@ function computeDims({ * Clamp between MIN_ASPECT_RATIO (portrait) and MAX_ASPECT_RATIO * (landscape) so items stay a reasonable size in the carousel. */ - const clamped = Math.max( - MIN_ASPECT_RATIO, - Math.min(aspectRatio ?? 1, MAX_ASPECT_RATIO), - ) + const raw = aspectRatio ?? 1 + const clamped = Math.max(MIN_ASPECT_RATIO, Math.min(raw, MAX_ASPECT_RATIO)) const width = Math.floor(height * clamped) - return {width, height, aspectRatio: clamped} + return {width, height, aspectRatio: clamped, isCropped: raw !== clamped} } function GalleryImage({ @@ -370,7 +369,8 @@ function GalleryImage({ const [aspectRatio, setAspectRatio] = useState(() => getAspectRatio(image.aspectRatio), ) - const dims = computeDims({height, aspectRatio}) + const {isCropped, ...dims} = computeDims({height, aspectRatio}) + const hasAlt = !!image.alt useEffect(() => { onWidthChange(index, dims.width) @@ -415,31 +415,63 @@ function GalleryImage({ }} /> - {image.alt && !hideBadges ? ( + {(hasAlt || isCropped) && !hideBadges ? ( - - ALT - + {isCropped && ( + + + + )} + {hasAlt && ( + + + ALT + + + )} ) : null}