From 01b350175ecb9e522e3dde3b7f7ce8048c6988ae Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 2 Nov 2024 15:08:11 +0000 Subject: [PATCH] Round avatars on mobile web --- src/view/com/lightbox/Lightbox.web.tsx | 142 +++++++++++++++---------- 1 file changed, 87 insertions(+), 55 deletions(-) diff --git a/src/view/com/lightbox/Lightbox.web.tsx b/src/view/com/lightbox/Lightbox.web.tsx index 2ba7d06cc5..f9b147b297 100644 --- a/src/view/com/lightbox/Lightbox.web.tsx +++ b/src/view/com/lightbox/Lightbox.web.tsx @@ -21,13 +21,9 @@ import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {colors, s} from '#/lib/styles' import {useLightbox, useLightboxControls} from '#/state/lightbox' import {Text} from '../util/text/Text' +import {ImageSource} from './ImageViewing/@types' import ImageDefaultHeader from './ImageViewing/components/ImageDefaultHeader' -interface Img { - uri: string - alt?: string -} - export function Lightbox() { const {activeLightbox} = useLightbox() const {closeLightbox} = useLightboxControls() @@ -54,7 +50,7 @@ function LightboxInner({ initialIndex = 0, onClose, }: { - imgs: Img[] + imgs: ImageSource[] initialIndex: number onClose: () => void }) { @@ -101,6 +97,8 @@ function LightboxInner({ return isTabletOrDesktop ? 32 : 24 }, [isTabletOrDesktop]) + const img = imgs[index] + const isAvi = img.type === 'circle-avi' || img.type === 'rect-avi' return ( - - - {canGoLeft && ( - - - - )} - {canGoRight && ( - - - - )} - + {isAvi ? ( + + {img.alt} + + ) : ( + + + {canGoLeft && ( + + + + )} + {canGoRight && ( + + + + )} + + )} - {imgs[index].alt ? ( + {img.alt ? ( - {imgs[index].alt} + {img.alt} @@ -203,6 +222,19 @@ const styles = StyleSheet.create({ height: '100%', resizeMode: 'contain', }, + aviCenterer: { + flex: 1, + alignItems: 'center', + justifyContent: 'center', + }, + avi: { + // @ts-ignore web-only + maxWidth: `calc(min(400px, 100vw))`, + // @ts-ignore web-only + maxHeight: `calc(min(400px, 100vh))`, + padding: 16, + boxSizing: 'border-box', + }, icon: { color: colors.white, },