Multiple improvements to link cards and quote posts (#2398)
* fix canvas * fix external link embed styles * Use the same link-card style on web and mobile and give a little more height on desktop to the card images * Use dark border on link embeds to match quote post style * Fix the highlighting behavior on linkcards and quoteposts --------- Co-authored-by: Hailey <me@haileyok.com>zio/stable
parent
2c31e2a042
commit
df277e5977
|
@ -117,9 +117,6 @@ function createResizedImage(
|
||||||
return reject(new Error('Failed to resize image'))
|
return reject(new Error('Failed to resize image'))
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.width = width
|
|
||||||
canvas.height = height
|
|
||||||
|
|
||||||
let scale = 1
|
let scale = 1
|
||||||
if (mode === 'cover') {
|
if (mode === 'cover') {
|
||||||
scale = img.width < img.height ? width / img.width : height / img.height
|
scale = img.width < img.height ? width / img.width : height / img.height
|
||||||
|
@ -128,10 +125,11 @@ function createResizedImage(
|
||||||
}
|
}
|
||||||
let w = img.width * scale
|
let w = img.width * scale
|
||||||
let h = img.height * scale
|
let h = img.height * scale
|
||||||
let x = (width - w) / 2
|
|
||||||
let y = (height - h) / 2
|
|
||||||
|
|
||||||
ctx.drawImage(img, x, y, w, h)
|
canvas.width = w
|
||||||
|
canvas.height = h
|
||||||
|
|
||||||
|
ctx.drawImage(img, 0, 0, w, h)
|
||||||
resolve(canvas.toDataURL('image/jpeg', quality))
|
resolve(canvas.toDataURL('image/jpeg', quality))
|
||||||
})
|
})
|
||||||
img.src = dataUri
|
img.src = dataUri
|
||||||
|
|
|
@ -25,6 +25,7 @@ export const defaultTheme: Theme = {
|
||||||
postCtrl: '#71768A',
|
postCtrl: '#71768A',
|
||||||
brandText: '#0066FF',
|
brandText: '#0066FF',
|
||||||
emptyStateIcon: '#B6B6C9',
|
emptyStateIcon: '#B6B6C9',
|
||||||
|
borderLinkHover: '#cac1c1',
|
||||||
},
|
},
|
||||||
primary: {
|
primary: {
|
||||||
background: colors.blue3,
|
background: colors.blue3,
|
||||||
|
@ -310,6 +311,7 @@ export const darkTheme: Theme = {
|
||||||
postCtrl: '#707489',
|
postCtrl: '#707489',
|
||||||
brandText: '#0085ff',
|
brandText: '#0085ff',
|
||||||
emptyStateIcon: colors.gray4,
|
emptyStateIcon: colors.gray4,
|
||||||
|
borderLinkHover: colors.gray5,
|
||||||
},
|
},
|
||||||
primary: {
|
primary: {
|
||||||
...defaultTheme.palette.primary,
|
...defaultTheme.palette.primary,
|
||||||
|
|
|
@ -23,29 +23,16 @@ export const ExternalLinkEmbed = ({
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View style={{flexDirection: 'column'}}>
|
||||||
style={{
|
|
||||||
flexDirection: !isMobile && !embedPlayerParams ? 'row' : 'column',
|
|
||||||
}}>
|
|
||||||
{link.thumb && !embedPlayerParams ? (
|
{link.thumb && !embedPlayerParams ? (
|
||||||
<View
|
<View
|
||||||
style={
|
style={{
|
||||||
!isMobile
|
borderTopLeftRadius: 6,
|
||||||
? {
|
borderTopRightRadius: 6,
|
||||||
borderTopLeftRadius: 6,
|
width: '100%',
|
||||||
borderBottomLeftRadius: 6,
|
height: isMobile ? 200 : 300,
|
||||||
width: 120,
|
overflow: 'hidden',
|
||||||
aspectRatio: 1,
|
}}>
|
||||||
overflow: 'hidden',
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
borderTopLeftRadius: 6,
|
|
||||||
borderTopRightRadius: 6,
|
|
||||||
width: '100%',
|
|
||||||
height: 200,
|
|
||||||
overflow: 'hidden',
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
<Image
|
<Image
|
||||||
style={styles.extImage}
|
style={styles.extImage}
|
||||||
source={{uri: link.thumb}}
|
source={{uri: link.thumb}}
|
||||||
|
@ -61,7 +48,6 @@ export const ExternalLinkEmbed = ({
|
||||||
paddingHorizontal: isMobile ? 10 : 14,
|
paddingHorizontal: isMobile ? 10 : 14,
|
||||||
paddingTop: 8,
|
paddingTop: 8,
|
||||||
paddingBottom: 10,
|
paddingBottom: 10,
|
||||||
flex: !isMobile ? 1 : undefined,
|
|
||||||
}}>
|
}}>
|
||||||
<Text
|
<Text
|
||||||
type="sm"
|
type="sm"
|
||||||
|
@ -69,16 +55,13 @@ export const ExternalLinkEmbed = ({
|
||||||
style={[pal.textLight, styles.extUri]}>
|
style={[pal.textLight, styles.extUri]}>
|
||||||
{toNiceDomain(link.uri)}
|
{toNiceDomain(link.uri)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text type="lg-bold" numberOfLines={4} style={[pal.text]}>
|
||||||
type="lg-bold"
|
|
||||||
numberOfLines={isMobile ? 4 : 2}
|
|
||||||
style={[pal.text]}>
|
|
||||||
{link.title || link.uri}
|
{link.title || link.uri}
|
||||||
</Text>
|
</Text>
|
||||||
{link.description ? (
|
{link.description ? (
|
||||||
<Text
|
<Text
|
||||||
type="md"
|
type="md"
|
||||||
numberOfLines={isMobile ? 4 : 2}
|
numberOfLines={4}
|
||||||
style={[pal.text, styles.extDescription]}>
|
style={[pal.text, styles.extDescription]}>
|
||||||
{link.description}
|
{link.description}
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -90,8 +73,7 @@ export const ExternalLinkEmbed = ({
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
extImage: {
|
extImage: {
|
||||||
width: '100%',
|
flex: 1,
|
||||||
height: 200,
|
|
||||||
},
|
},
|
||||||
extUri: {
|
extUri: {
|
||||||
marginTop: 2,
|
marginTop: 2,
|
||||||
|
|
|
@ -98,6 +98,7 @@ export function QuoteEmbed({
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
style={[styles.container, pal.borderDark, style]}
|
style={[styles.container, pal.borderDark, style]}
|
||||||
|
hoverStyle={{borderColor: pal.colors.borderLinkHover}}
|
||||||
href={itemHref}
|
href={itemHref}
|
||||||
title={itemTitle}>
|
title={itemTitle}>
|
||||||
<PostMeta
|
<PostMeta
|
||||||
|
|
|
@ -63,7 +63,7 @@ export function PostEmbeds({
|
||||||
const mediaModeration = isModOnQuote ? {} : moderation
|
const mediaModeration = isModOnQuote ? {} : moderation
|
||||||
const quoteModeration = isModOnQuote ? moderation : {}
|
const quoteModeration = isModOnQuote ? moderation : {}
|
||||||
return (
|
return (
|
||||||
<View style={[styles.stackContainer, style]}>
|
<View style={style}>
|
||||||
<PostEmbeds embed={embed.media} moderation={mediaModeration} />
|
<PostEmbeds embed={embed.media} moderation={mediaModeration} />
|
||||||
<ContentHider moderation={quoteModeration}>
|
<ContentHider moderation={quoteModeration}>
|
||||||
<MaybeQuoteEmbed embed={embed.record} moderation={quoteModeration} />
|
<MaybeQuoteEmbed embed={embed.record} moderation={quoteModeration} />
|
||||||
|
@ -168,11 +168,14 @@ export function PostEmbeds({
|
||||||
const link = embed.external
|
const link = embed.external
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[styles.extOuter, pal.view, pal.border, style]}>
|
<Link
|
||||||
<Link asAnchor href={link.uri}>
|
asAnchor
|
||||||
<ExternalLinkEmbed link={link} />
|
anchorNoUnderline
|
||||||
</Link>
|
href={link.uri}
|
||||||
</View>
|
style={[styles.extOuter, pal.view, pal.borderDark, style]}
|
||||||
|
hoverStyle={{borderColor: pal.colors.borderLinkHover}}>
|
||||||
|
<ExternalLinkEmbed link={link} />
|
||||||
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,9 +183,6 @@ export function PostEmbeds({
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
stackContainer: {
|
|
||||||
gap: 6,
|
|
||||||
},
|
|
||||||
imagesContainer: {
|
imagesContainer: {
|
||||||
marginTop: 8,
|
marginTop: 8,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue