diff --git a/src/components/Post/Translated/index.tsx b/src/components/Post/Translated/index.tsx index fb05fd9d3a..c6402978a2 100644 --- a/src/components/Post/Translated/index.tsx +++ b/src/components/Post/Translated/index.tsx @@ -1,5 +1,5 @@ import {useCallback, useMemo} from 'react' -import {Platform, View} from 'react-native' +import {Platform, type StyleProp, type TextStyle, View} from 'react-native' import {type AppBskyFeedDefs} from '@atproto/api' import {Trans, useLingui} from '@lingui/react/macro' @@ -14,7 +14,7 @@ import { } from '#/locale/helpers' import {LANGUAGES} from '#/locale/languages' import {useLanguagePrefs} from '#/state/preferences' -import {atoms as a, native, useTheme, web} from '#/alf' +import {atoms as a, flatten, native, useTheme, web} from '#/alf' import {Button} from '#/components/Button' import {ArrowRight_Stroke2_Corner0_Rounded as ArrowRightIcon} from '#/components/icons/Arrow' import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Times' @@ -26,14 +26,18 @@ import {Text} from '#/components/Typography' import {useAnalytics} from '#/analytics' import {IS_WEB} from '#/env' +const X_ICON_OFFSET = 16 + export function TranslatedPost({ hideTranslateLink = false, post, postText, + postTextStyle = a.text_md, }: { hideTranslateLink?: boolean post: AppBskyFeedDefs.PostView postText: string + postTextStyle?: StyleProp }) { const langPrefs = useLanguagePrefs() const {clearTranslation, translate, translationState} = useTranslate({ @@ -54,6 +58,7 @@ export function TranslatedPost({ clearTranslation={clearTranslation} translate={translate} postText={postText} + postTextStyle={postTextStyle} sourceLanguage={ translationState.sourceLanguage ?? null // Fallback primarily for iOS } @@ -86,12 +91,12 @@ function TranslationLoading() { const t = useTheme() return ( - + - - Translating… + Translating + ) @@ -127,7 +132,7 @@ function TranslationLink({ - - - - - {message} - - - - - + + + + {message} + + + + style={[ + a.text_xs, + a.font_medium, + a.leading_snug, + {color: t.palette.primary_500}, + ]}> Try Google Translate @@ -224,12 +245,14 @@ function TranslationResult({ clearTranslation, translate, postText, + postTextStyle, sourceLanguage, translatedText, }: { clearTranslation: () => void translate: TranslationFunction postText: string + postTextStyle?: StyleProp sourceLanguage: string | null translatedText: string }) { @@ -241,39 +264,47 @@ function TranslationResult({ ? codeToLanguageName(sourceLanguage, i18n.locale) : undefined + const flattenedStyle = flatten(postTextStyle) ?? {} + const fontSize = flattenedStyle.fontSize + return ( - + {langName ? ( - + <> {langName}{' '} - - - + {' '} @@ -282,15 +313,10 @@ function TranslationResult({ langPrefs.appLanguage, )} - + ) : ( + style={[a.text_xs, a.leading_snug, t.atoms.text_contrast_medium]}> Translated )} @@ -300,6 +326,7 @@ function TranslationResult({ style={[ a.text_xs, a.font_medium, + a.leading_snug, t.atoms.text_contrast_medium, ]}> {' '} @@ -312,18 +339,19 @@ function TranslationResult({ /> )} + + - + {translatedText} - ) @@ -393,7 +421,12 @@ function TranslationLanguageSelect({ hitSlop={HITSLOP_30} hoverStyle={native({opacity: 0.5})}> + style={[ + a.text_xs, + a.font_medium, + a.leading_snug, + t.atoms.text_contrast_high, + ]}> Change diff --git a/src/screens/PostThread/components/ThreadItemAnchor.tsx b/src/screens/PostThread/components/ThreadItemAnchor.tsx index 1531784aee..9133a313cd 100644 --- a/src/screens/PostThread/components/ThreadItemAnchor.tsx +++ b/src/screens/PostThread/components/ThreadItemAnchor.tsx @@ -407,7 +407,11 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({ shouldProxyLinks={true} /> ) : undefined} - + {post.embed && (