From b51640fbc099a1e9df1430b5a05bf913495008b7 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 31 May 2024 22:57:42 +0300 Subject: [🐴] add emoji multiplier prop to RichText and bump it up for DMs (#4229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add emoji multiplier prop to RichText and bump it up for DMs * remove background if only emoji * Handle more emoji * Adjust emoji regex and length * Fix bad merge conflict res * Fix logic * Revert to emoji specific regex --------- Co-authored-by: Eric Bailey --- src/components/RichText.tsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/components/RichText.tsx') diff --git a/src/components/RichText.tsx b/src/components/RichText.tsx index ed69c199a..9ba44eabe 100644 --- a/src/components/RichText.tsx +++ b/src/components/RichText.tsx @@ -28,6 +28,7 @@ export function RichText({ authorHandle, onLinkPress, interactiveStyle, + emojiMultiplier = 1.85, }: TextStyleProp & Pick & { value: RichTextAPI | string @@ -38,6 +39,7 @@ export function RichText({ authorHandle?: string onLinkPress?: LinkProps['onPress'] interactiveStyle?: TextStyle + emojiMultiplier?: number }) { const richText = React.useMemo( () => @@ -57,17 +59,14 @@ export function RichText({ const {text, facets} = richText if (!facets?.length) { - if (text.length <= 5 && /^\p{Extended_Pictographic}+$/u.test(text)) { + if (isOnlyEmoji(text)) { + const fontSize = + (flattenedStyle.fontSize ?? a.text_sm.fontSize) * emojiMultiplier return ( {text} @@ -247,3 +246,10 @@ function RichTextTag({ ) } + +export function isOnlyEmoji(text: string) { + return ( + text.length <= 15 && + /^[\p{Emoji_Presentation}\p{Extended_Pictographic}]+$/u.test(text) + ) +} -- cgit 1.4.1