From 79a2f8d5280230a125b42c60bbb5b9e4be4f9109 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 20 Sep 2024 20:47:28 +0100 Subject: [PATCH] Increase rounding for all embeds (#5421) * tweak image styles * fix reply image preview and covert to atoms * increase rounding on media inset border * decrease gap on desktop * fix inset styles * increase rounding on embeds to `md` * Couple edge cases --------- Co-authored-by: Eric Bailey --- src/components/MediaInsetBorder.tsx | 2 +- src/view/com/composer/ComposerReplyTo.tsx | 157 ++++++++---------- src/view/com/util/images/AutoSizedImage.tsx | 4 +- src/view/com/util/images/Gallery.tsx | 19 ++- src/view/com/util/images/ImageLayoutGrid.tsx | 130 ++++++++++++--- .../com/util/post-embeds/ExternalGifEmbed.tsx | 2 +- .../util/post-embeds/ExternalLinkEmbed.tsx | 12 +- .../util/post-embeds/ExternalPlayerEmbed.tsx | 14 +- src/view/com/util/post-embeds/GifEmbed.tsx | 8 +- src/view/com/util/post-embeds/QuoteEmbed.tsx | 16 +- src/view/com/util/post-embeds/VideoEmbed.tsx | 4 +- .../com/util/post-embeds/VideoEmbed.web.tsx | 4 +- .../VideoEmbedInner/VideoEmbedInnerWeb.tsx | 2 +- src/view/com/util/post-embeds/index.tsx | 9 +- 14 files changed, 223 insertions(+), 160 deletions(-) diff --git a/src/components/MediaInsetBorder.tsx b/src/components/MediaInsetBorder.tsx index ef8b00e2e0..ed89880f40 100644 --- a/src/components/MediaInsetBorder.tsx +++ b/src/components/MediaInsetBorder.tsx @@ -24,7 +24,7 @@ export function MediaInsetBorder({ return ( - - {(images.length === 1 && ( - + + {(images.length === 1 && ( + + )) || + (images.length === 2 && ( + + + + )) || - (images.length === 2 && ( - + (images.length === 3 && ( + + + - )) || - (images.length === 3 && ( - + + )) || + (images.length === 4 && ( + + + - - - - - )) || - (images.length === 4 && ( - - - - - - - - - + + + - ))} - + + ))} ) } @@ -240,23 +233,7 @@ const styles = StyleSheet.create({ borderRadius: 6, overflow: 'hidden', marginTop: 2, - }, - imagesInner: { - gap: 2, - }, - imagesRow: { - flexDirection: 'row', - }, - singleImage: { - width: 65, - height: 65, - }, - doubleImageTall: { - width: 32.5, - height: 65, - }, - doubleImage: { - width: 32.5, - height: 32.5, + height: 64, + width: 64, }, }) diff --git a/src/view/com/util/images/AutoSizedImage.tsx b/src/view/com/util/images/AutoSizedImage.tsx index 9abbe2875f..a9bfc1c966 100644 --- a/src/view/com/util/images/AutoSizedImage.tsx +++ b/src/view/com/util/images/AutoSizedImage.tsx @@ -88,7 +88,7 @@ export function ConstrainedImage({ void -interface GalleryItemProps { +interface Props { images: AppBskyEmbedImages.ViewImage[] index: number onPress?: EventFunction onLongPress?: EventFunction onPressIn?: EventFunction - imageStyle?: ComponentProps['style'] + imageStyle?: StyleProp viewContext?: PostEmbedViewContext + insetBorderStyle?: StyleProp } -export const GalleryItem: FC = ({ +export function GalleryItem({ images, index, imageStyle, @@ -31,7 +32,8 @@ export const GalleryItem: FC = ({ onPressIn, onLongPress, viewContext, -}) => { + insetBorderStyle, +}: Props) { const t = useTheme() const {_} = useLingui() const largeAltBadge = useLargeAltBadgeEnabled() @@ -47,7 +49,6 @@ export const GalleryItem: FC = ({ onLongPress={onLongPress ? () => onLongPress(index) : undefined} style={[ a.flex_1, - a.rounded_sm, a.overflow_hidden, t.atoms.bg_contrast_25, imageStyle, @@ -63,7 +64,7 @@ export const GalleryItem: FC = ({ accessibilityHint="" accessibilityIgnoresInvertColors /> - + {hasAlt && !hideBadges ? ( - + @@ -54,10 +63,18 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) { return ( - + - + ) @@ -65,15 +82,35 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) { case 3: return ( - - + + - - + + - - + + @@ -83,19 +120,51 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) { return ( <> - - + + - - + + - - + + - - + + @@ -105,3 +174,22 @@ function ImageLayoutGridInner(props: ImageLayoutGridInnerProps) { return null } } + +function noCorners( + corners: ('topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight')[], +) { + const styles: StyleProp[] = [] + if (corners.includes('topLeft')) { + styles.push({borderTopLeftRadius: 0}) + } + if (corners.includes('topRight')) { + styles.push({borderTopRightRadius: 0}) + } + if (corners.includes('bottomLeft')) { + styles.push({borderBottomLeftRadius: 0}) + } + if (corners.includes('bottomRight')) { + styles.push({borderBottomRightRadius: 0}) + } + return StyleSheet.flatten(styles) +} diff --git a/src/view/com/util/post-embeds/ExternalGifEmbed.tsx b/src/view/com/util/post-embeds/ExternalGifEmbed.tsx index 1f966d7107..6f1c88dcdf 100644 --- a/src/view/com/util/post-embeds/ExternalGifEmbed.tsx +++ b/src/view/com/util/post-embeds/ExternalGifEmbed.tsx @@ -117,7 +117,7 @@ export function ExternalGifEmbed({ style={[ {height: imageDims.height}, styles.gifContainer, - a.rounded_sm, + a.rounded_md, a.overflow_hidden, { borderBottomLeftRadius: 0, diff --git a/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx b/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx index 2fc53a4df9..54e1eb4d55 100644 --- a/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx +++ b/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx @@ -59,15 +59,15 @@ export const ExternalLinkEmbed = ({ } return ( - + {imageUri && !embedPlayerParams ? ( + @@ -132,7 +132,7 @@ export function GifEmbed({ diff --git a/src/view/com/util/post-embeds/VideoEmbed.web.tsx b/src/view/com/util/post-embeds/VideoEmbed.web.tsx index 908c06e221..3180dd99eb 100644 --- a/src/view/com/util/post-embeds/VideoEmbed.web.tsx +++ b/src/view/com/util/post-embeds/VideoEmbed.web.tsx @@ -66,8 +66,8 @@ export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) { {aspectRatio}, {backgroundColor: 'black'}, a.relative, - a.rounded_sm, - a.my_xs, + a.rounded_md, + a.mt_xs, ]}>
+