[🐴] add emoji multiplier prop to RichText and bump it up for DMs (#4229)
* 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 <git@esb.lol>
This commit is contained in:
parent
5cda807d9d
commit
b51640fbc0
2 changed files with 36 additions and 28 deletions
|
|
@ -28,6 +28,7 @@ export function RichText({
|
|||
authorHandle,
|
||||
onLinkPress,
|
||||
interactiveStyle,
|
||||
emojiMultiplier = 1.85,
|
||||
}: TextStyleProp &
|
||||
Pick<TextProps, 'selectable'> & {
|
||||
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
|
||||
selectable={selectable}
|
||||
testID={testID}
|
||||
style={[
|
||||
{
|
||||
fontSize: 26,
|
||||
lineHeight: 30,
|
||||
},
|
||||
]}
|
||||
style={[plainStyles, {fontSize}]}
|
||||
// @ts-ignore web only -prf
|
||||
dataSet={WORD_WRAP}>
|
||||
{text}
|
||||
|
|
@ -247,3 +246,10 @@ function RichTextTag({
|
|||
</React.Fragment>
|
||||
)
|
||||
}
|
||||
|
||||
export function isOnlyEmoji(text: string) {
|
||||
return (
|
||||
text.length <= 15 &&
|
||||
/^[\p{Emoji_Presentation}\p{Extended_Pictographic}]+$/u.test(text)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue