make standardsiteembed peekable

This commit is contained in:
Samuel Newman
2026-06-11 14:17:57 +03:00
parent 0187a49534
commit 21b49a301e
3 changed files with 125 additions and 98 deletions
-3
View File
@@ -976,9 +976,6 @@
} }
}, },
"src/lib/hooks/useOpenLink.ts": { "src/lib/hooks/useOpenLink.ts": {
"@typescript-eslint/no-floating-promises": {
"count": 2
},
"@typescript-eslint/require-await": { "@typescript-eslint/require-await": {
"count": 1 "count": 1
} }
@@ -127,7 +127,6 @@ export const StandardSiteEmbed = ({
style={[ style={[
a.flex_col, a.flex_col,
a.rounded_lg, a.rounded_lg,
a.overflow_hidden,
a.w_full, a.w_full,
a.border, a.border,
t.atoms.bg, t.atoms.bg,
@@ -135,28 +134,44 @@ export const StandardSiteEmbed = ({
preview && a.pointer_events_none, preview && a.pointer_events_none,
style, style,
]}> ]}>
{/*
* The article is an in-flow `Link` wrapping the content so the iOS peek
* menu has something to lift. The publication footer below lives outside
* it - it has its own link (to the publication) and Subscribe button, so
* it can't be nested inside the article's peek.
*/}
<Link <Link
peek
shouldProxy shouldProxy
to={view.uri} to={view.uri}
label={view.title || l`Open link to ${niceUrl}`} label={view.title || l`Open link to ${niceUrl}`}
onPress={onPress} onPress={onPress}
onLongPress={onLongPress} onLongPress={onLongPress}
style={[a.absolute, a.inset_0, a.z_10]} style={[a.rounded_lg]}
{...web({ {...web({
onMouseEnter: onInteract, onMouseEnter: onInteract,
onMouseLeave: onInteractOut, onMouseLeave: onInteractOut,
})} })}
onFocus={onInteract} onFocus={onInteract}
onBlur={onInteractOut}> onBlur={onInteractOut}>
<></> {() => (
</Link>
<View <View
style={[ style={[
a.w_full, a.w_full,
a.z_10, a.overflow_hidden,
a.pointer_events_none, // The container can't clip (overflow_hidden there breaks the peek
interacted && [t.atoms.bg_contrast_25], // lift animation), so each half rounds its own outer corners to
// match the container border. The article rounds the top, plus the
// bottom when there's no footer beneath it.
{
borderTopLeftRadius: a.rounded_lg.borderRadius,
borderTopRightRadius: a.rounded_lg.borderRadius,
},
!view.source && {
borderBottomLeftRadius: a.rounded_lg.borderRadius,
borderBottomRightRadius: a.rounded_lg.borderRadius,
},
interacted ? t.atoms.bg_contrast_25 : t.atoms.bg,
]}> ]}>
{imageUri ? ( {imageUri ? (
<Image <Image
@@ -208,7 +223,12 @@ export const StandardSiteEmbed = ({
{isStandard && (view.createdAt || view.readingTime) && ( {isStandard && (view.createdAt || view.readingTime) && (
<View <View
style={[a.flex_row, a.align_center, a.gap_md, {paddingTop: 2}]}> style={[
a.flex_row,
a.align_center,
a.gap_md,
{paddingTop: 2},
]}>
{view.createdAt && ( {view.createdAt && (
<Text <Text
style={[ style={[
@@ -252,9 +272,11 @@ export const StandardSiteEmbed = ({
</View> </View>
)} )}
</View> </View>
)}
</Link>
{view.source && ( {view.source && (
<View style={[a.z_20]}> <View>
<Divider /> <Divider />
<PublicationFooter <PublicationFooter
preview={preview} preview={preview}
@@ -629,6 +651,14 @@ export function PublicationFooter({
a.justify_between, a.justify_between,
a.p_md, a.p_md,
a.gap_md, a.gap_md,
a.overflow_hidden,
// Rounds the bottom corners to match the container border, since the
// container itself can't clip (overflow_hidden there breaks the peek
// lift animation on the article above).
{
borderBottomLeftRadius: a.rounded_lg.borderRadius,
borderBottomRightRadius: a.rounded_lg.borderRadius,
},
gtPhone && [a.flex_row, a.gap_sm], gtPhone && [a.flex_row, a.gap_sm],
interactedOuter && t.atoms.bg_contrast_25, interactedOuter && t.atoms.bg_contrast_25,
preview && a.pointer_events_none, preview && a.pointer_events_none,
+2 -2
View File
@@ -66,12 +66,12 @@ export function useOpenLink() {
}).catch(err => { }).catch(err => {
if (__DEV__) if (__DEV__)
logger.error('Could not open web browser', {message: err}) logger.error('Could not open web browser', {message: err})
Linking.openURL(url) void Linking.openURL(url)
}) })
return return
} }
} }
Linking.openURL(url) void Linking.openURL(url)
}, },
[ax, enabled, inAppBrowserConsentControl, t, dialogContext], [ax, enabled, inAppBrowserConsentControl, t, dialogContext],
) )