forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#40692 from kbieganowski/feat/enlarge-emo…
…jis-font-size Emojis larger in other contexts than just single character messages
- Loading branch information
Showing
21 changed files
with
391 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, {useMemo} from 'react'; | ||
import Text from '@components/Text'; | ||
import * as EmojiUtils from '@libs/EmojiUtils'; | ||
import CONST from '@src/CONST'; | ||
import type TextWithTooltipProps from './types'; | ||
|
||
function TextWithTooltip({text, style, emojiFontSize, numberOfLines = 1}: TextWithTooltipProps) { | ||
const processedTextArray = useMemo(() => { | ||
const emojisRegex = new RegExp(CONST.REGEX.EMOJIS, CONST.REGEX.EMOJIS.flags.concat('g')); | ||
const doesTextContainEmojis = !!(emojiFontSize && emojisRegex.test(text)); | ||
|
||
if (!doesTextContainEmojis) { | ||
return []; | ||
} | ||
|
||
return EmojiUtils.splitTextWithEmojis(text); | ||
}, [emojiFontSize, text]); | ||
|
||
return ( | ||
<Text | ||
style={style} | ||
numberOfLines={numberOfLines} | ||
> | ||
{processedTextArray.length !== 0 ? processedTextArray.map(({text: textItem, isEmoji}) => (isEmoji ? <Text style={{fontSize: emojiFontSize}}>{textItem}</Text> : textItem)) : text} | ||
</Text> | ||
); | ||
} | ||
|
||
TextWithTooltip.displayName = 'TextWithTooltip'; | ||
|
||
export default TextWithTooltip; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/pages/home/report/ReportActionItemMessageHeaderSender.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, {useMemo} from 'react'; | ||
import Text from '@components/Text'; | ||
import UserDetailsTooltip from '@components/UserDetailsTooltip'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as EmojiUtils from '@libs/EmojiUtils'; | ||
import CONST from '@src/CONST'; | ||
import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; | ||
|
||
type ReportActionItemMessageHeaderSenderProps = { | ||
/** Text to display */ | ||
fragmentText: string; | ||
|
||
/** Users accountID */ | ||
accountID: number; | ||
|
||
/** Should this fragment be contained in a single line? */ | ||
isSingleLine?: boolean; | ||
|
||
/** The accountID of the copilot who took this action on behalf of the user */ | ||
delegateAccountID?: number; | ||
|
||
/** Actor icon */ | ||
actorIcon?: OnyxCommon.Icon; | ||
}; | ||
|
||
function ReportActionItemMessageHeaderSender({fragmentText, accountID, delegateAccountID, actorIcon, isSingleLine}: ReportActionItemMessageHeaderSenderProps) { | ||
const styles = useThemeStyles(); | ||
|
||
const processedTextArray = useMemo(() => { | ||
const emojisRegex = new RegExp(CONST.REGEX.EMOJIS, CONST.REGEX.EMOJIS.flags.concat('g')); | ||
const doesTextContainEmojis = emojisRegex.test(fragmentText); | ||
|
||
if (!doesTextContainEmojis) { | ||
return []; | ||
} | ||
|
||
return EmojiUtils.splitTextWithEmojis(fragmentText); | ||
}, [fragmentText]); | ||
|
||
return ( | ||
<UserDetailsTooltip | ||
accountID={accountID} | ||
delegateAccountID={delegateAccountID} | ||
icon={actorIcon} | ||
> | ||
<Text | ||
numberOfLines={isSingleLine ? 1 : undefined} | ||
style={[styles.chatItemMessageHeaderSender, isSingleLine ? styles.pre : styles.preWrap]} | ||
> | ||
{processedTextArray.length !== 0 ? processedTextArray.map(({text, isEmoji}) => (isEmoji ? <Text style={styles.emojisWithinDisplayName}>{text}</Text> : text)) : fragmentText} | ||
</Text> | ||
</UserDetailsTooltip> | ||
); | ||
} | ||
|
||
ReportActionItemMessageHeaderSender.displayName = 'ReportActionItemMessageHeaderSender'; | ||
|
||
export default ReportActionItemMessageHeaderSender; |
Oops, something went wrong.