-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emojis larger in other contexts than just single character messages #40692
Merged
roryabraham
merged 42 commits into
Expensify:main
from
kbieganowski:feat/enlarge-emojis-font-size
Jul 27, 2024
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
2fcb0c4
rebase wip
kbieganowski 7dcb710
wip: updated emojis size in settings input and LHP username
kbieganowski 1ded82a
wip: emojis font size - CR changes
kbieganowski ee38c51
rebase wip
kbieganowski 0208efe
rebase wip
kbieganowski d10aeb2
CR fixes
kbieganowski 2278d7e
wip: CR fixes
kbieganowski bfea051
wip: CR fixes
kbieganowski 8a31012
CR fixes
kbieganowski 4172e9c
Merge branch 'main' into feat/enlarge-emojis-font-size
VickyStash 472d746
Minor improvement
VickyStash 0812b3a
Merge branch 'main' into feat/enlarge-emojis-font-size
VickyStash d06253b
Merge branch 'main' into feat/enlarge-emojis-font-size
VickyStash 71a1bf4
Composer display fixes
VickyStash f7948b7
Lint fix
VickyStash cd2211b
Merge branch 'main' into feat/enlarge-emojis-font-size
VickyStash 012d799
Merge branch 'main' into feat/enlarge-emojis-font-size
VickyStash 536e1d9
Fix composer scroll while only emojis there
VickyStash 3a3ff16
Fix cursor alignment
VickyStash 74eeede
Fix gap between actor name and emoji
VickyStash c21134b
Merge branch 'main' into feat/enlarge-emojis-font-size
VickyStash 83dd616
Fix date alignment
VickyStash bc45dad
Merge branch 'main' into feat/enlarge-emojis-font-size
VickyStash 733dfa4
Merge branch 'main' into feat/enlarge-emojis-font-size
VickyStash 8fba153
Fix emojis are cut off
VickyStash 98cd390
Merge branch 'main' into feat/enlarge-emojis-font-size
VickyStash a055312
Merge branch 'main' into feat/enlarge-emojis-font-size
VickyStash e1a6828
Remove unnecessary param
VickyStash d28b3a7
Minor improvements
VickyStash a481e54
Merge branch 'refs/heads/main' into feat/enlarge-emojis-font-size
VickyStash 2902135
Merge branch 'refs/heads/main' into feat/enlarge-emojis-font-size
VickyStash 326dc0d
Merge branch 'refs/heads/main' into feat/enlarge-emojis-font-size
VickyStash 7799a13
Apply recommended updates on InitialSettingsPage
VickyStash 876a5ec
Add isMarkdownEnabled to name input, update boolean values naming
VickyStash 6a31133
Update TextWithEmojiFragment component
VickyStash bea55ee
Create ReportActionItemMessageHeaderSender component
VickyStash 8049e44
Minor improvement
VickyStash 959fac5
Rename boolean variable
VickyStash a5dc739
Minor improvement
VickyStash ce32c11
Merge branch 'refs/heads/main' into feat/enlarge-emojis-font-size
VickyStash 46a71dd
Minor update after merging main
VickyStash 08e72ff
Add ReportActionItemMessageHeaderSender display name
VickyStash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; | ||
roryabraham marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that we have been doing this a lot in the code. Is there a way to reduce the duplicates? For example, create a new regex with g flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While working on implementation of splitting logic, @fabioh8010 noticed that
g
flag in regex maintain state betweentest()
calls that resulted in different outcomes even if input was the same. We decided that it would be a better/safer option to removeg
flag and add it when function is called (other functions that are using this regex were updated as well) so we can avoid random bugsedit: also discussed here