diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-08-16 10:02:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-16 10:02:41 -0700 |
commit | 79a68197697bfbeb2b942c6733d83a17dfc3e09b (patch) | |
tree | 056ab448015178c4eb248bceb6d8f2b9c3ead9fe | |
parent | 884e5c92944a4d53c7e0d2847eabd576b080b4ae (diff) | |
download | voidsky-79a68197697bfbeb2b942c6733d83a17dfc3e09b.tar.zst |
Tune up the link card to look nicer, show more info, and layout horizontally on web to user space more nicely (#1190)
-rw-r--r-- | src/lib/strings/url-helpers.ts | 2 | ||||
-rw-r--r-- | src/view/com/util/post-embeds/ExternalLinkEmbed.tsx | 51 |
2 files changed, 36 insertions, 17 deletions
diff --git a/src/lib/strings/url-helpers.ts b/src/lib/strings/url-helpers.ts index 105c631bf..1406e2af0 100644 --- a/src/lib/strings/url-helpers.ts +++ b/src/lib/strings/url-helpers.ts @@ -30,7 +30,7 @@ export function toNiceDomain(url: string): string { if (`https://${urlp.host}` === PROD_SERVICE) { return 'Bluesky Social' } - return urlp.host + return urlp.host ? urlp.host : url } catch (e) { return url } diff --git a/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx b/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx index d371cbfc8..6dd93c19d 100644 --- a/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx +++ b/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx @@ -4,6 +4,8 @@ import {Text} from '../text/Text' import {StyleSheet, View} from 'react-native' import {usePalette} from 'lib/hooks/usePalette' import {AppBskyEmbedExternal} from '@atproto/api' +import {isDesktopWeb} from 'platform/detection' +import {toNiceDomain} from 'lib/strings/url-helpers' export const ExternalLinkEmbed = ({ link, @@ -14,7 +16,7 @@ export const ExternalLinkEmbed = ({ }) => { const pal = usePalette('default') return ( - <> + <View style={styles.extContainer}> {link.thumb ? ( <View style={styles.extImageContainer}> <Image @@ -26,39 +28,56 @@ export const ExternalLinkEmbed = ({ </View> ) : undefined} <View style={styles.extInner}> - <Text type="md-bold" numberOfLines={2} style={[pal.text]}> - {link.title || link.uri} - </Text> <Text type="sm" numberOfLines={1} style={[pal.textLight, styles.extUri]}> - {link.uri} + {toNiceDomain(link.uri)} + </Text> + <Text + type={isDesktopWeb ? 'xl-bold' : 'lg-bold'} + numberOfLines={isDesktopWeb ? 2 : 4} + style={[pal.text]}> + {link.title || link.uri} </Text> {link.description ? ( <Text - type="sm" - numberOfLines={2} + type={isDesktopWeb ? 'lg' : 'md'} + numberOfLines={isDesktopWeb ? 2 : 4} style={[pal.text, styles.extDescription]}> {link.description} </Text> ) : undefined} </View> - </> + </View> ) } const styles = StyleSheet.create({ - extInner: { - padding: 10, + extContainer: { + flexDirection: isDesktopWeb ? 'row' : 'column', }, - extImageContainer: { - borderTopLeftRadius: 6, - borderTopRightRadius: 6, - width: '100%', - height: 200, - overflow: 'hidden', + extInner: { + paddingHorizontal: isDesktopWeb ? 14 : 10, + paddingTop: 8, + paddingBottom: 10, + flex: isDesktopWeb ? 1 : undefined, }, + extImageContainer: isDesktopWeb + ? { + borderTopLeftRadius: 6, + borderBottomLeftRadius: 6, + width: 120, + aspectRatio: 1, + overflow: 'hidden', + } + : { + borderTopLeftRadius: 6, + borderTopRightRadius: 6, + width: '100%', + height: 200, + overflow: 'hidden', + }, extImage: { width: '100%', height: 200, |