Skip to content

Commit a0b0fe3

Browse files
authored
Merge pull request cinnyapp#222 from 7w1/url-preview-card-styles
adjust styling for smaller standard image previews
2 parents e7c385b + 5fd09cc commit a0b0fe3

1 file changed

Lines changed: 45 additions & 13 deletions

File tree

src/app/components/url-preview/UrlPreviewCard.tsx

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,16 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: s
5252
);
5353

5454
return (
55-
<Box grow="Yes" direction="ColumnReverse" gap="0">
55+
<Box
56+
grow="Yes"
57+
direction={prev['og:video'] ? 'ColumnReverse' : 'Row'}
58+
style={{
59+
display: 'flex',
60+
alignItems: 'center',
61+
overflow: 'hidden',
62+
width: '100%',
63+
}}
64+
>
5665
{(prev['og:video'] && (
5766
<VideoContent
5867
style={{
@@ -69,19 +78,34 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: s
6978
/>
7079
)) ||
7180
(prev['og:image'] && (
72-
<ImageContent
73-
style={{
74-
aspectRatio: (prev['og:image:width'] ?? 1) / (prev['og:image:height'] ?? 1),
75-
}}
76-
autoPlay
77-
body={prev['og:title']}
78-
url={prev['og:image']}
79-
renderViewer={(p) => <ImageViewer {...p} />}
80-
renderImage={(p) => <Image style={{ objectFit: 'contain' }} {...p} />}
81-
/>
81+
<Box style={{ flexShrink: 0, height: '100px' }}>
82+
{' '}
83+
<ImageContent
84+
style={{
85+
height: '100%',
86+
aspectRatio: (prev['og:image:width'] ?? 1) / (prev['og:image:height'] ?? 1),
87+
position: 'relative',
88+
width: 'auto',
89+
}}
90+
autoPlay
91+
body={prev['og:title']}
92+
url={prev['og:image']}
93+
renderViewer={(p) => <ImageViewer {...p} />}
94+
renderImage={(p) => (
95+
<Image
96+
{...p}
97+
style={{
98+
height: '100%',
99+
width: 'auto',
100+
objectFit: 'contain',
101+
}}
102+
/>
103+
)}
104+
/>
105+
</Box>
82106
)) ||
83107
(prev['og:audio'] && (
84-
<Box className={css.UrlPreviewAudio}>
108+
<Box className={css.UrlPreviewAudio} style={{ flexShrink: 0 }}>
85109
<AudioContent
86110
url={(prev['og:audio'] as string) ?? ''}
87111
mimeType={(prev['og:audio:type'] as string) ?? ''}
@@ -90,7 +114,15 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: s
90114
/>
91115
</Box>
92116
))}
93-
<UrlPreviewContent>
117+
<UrlPreviewContent
118+
style={{
119+
flex: 1,
120+
minWidth: 0,
121+
display: 'flex',
122+
flexDirection: 'column',
123+
justifyContent: 'center',
124+
}}
125+
>
94126
<Text
95127
style={linkStyles}
96128
truncate

0 commit comments

Comments
 (0)