-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Handle emoji tooltip #35838
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
Merged
Merged
Handle emoji tooltip #35838
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
b930ed4
implement tooltip for emoji
dukenv0307 7385bf2
Merge branch 'main' into fix/34307
dukenv0307 925d6c3
implement tooltip for emoji
dukenv0307 ff81b72
write new file in typescript
dukenv0307 b6ecd0f
merge main
dukenv0307 21d6337
Merge branch 'main' into fix/34307
dukenv0307 d5f99a0
Merge branch 'main' into fix/34307
dukenv0307 ab0f57b
fix edge case
dukenv0307 54a21ae
write new page on ts
dukenv0307 046522e
revert local change
dukenv0307 47e78b6
disable tooltip for native
dukenv0307 a0f72ef
Merge branch 'main' into fix/34307
dukenv0307 4a9f29e
bump version of expensify-common
dukenv0307 2b5ec33
Merge branch 'main' into fix/34307
dukenv0307 1de60ab
Update src/styles/index.ts
dukenv0307 5a6a291
Merge branch 'main' into fix/34307
dukenv0307 2755f34
merge main
dukenv0307 a9bd9b4
fix ts error
dukenv0307 a0e43e0
merge main
dukenv0307 05c9b28
Merge branch 'main' into fix/34307
dukenv0307 0501a41
merge main
dukenv0307 439e629
fix the case emoji that is made up by some different emojis
dukenv0307 cf36e9b
Merge branch 'main' into fix/34307
dukenv0307 d622078
update version expesify-common
dukenv0307 7a65924
Merge branch 'main' into fix/34307
dukenv0307 db43ff1
Merge branch 'main' into fix/34307
dukenv0307 7eedaf3
add new attribute for emoji tag if contain only emoji
dukenv0307 5382c13
Merge branch 'main' into fix/34307
dukenv0307 62d558d
add check shouldRenderAsText for seprate platform
dukenv0307 1a34f6b
merge main
dukenv0307 a37188a
fix case delete emoji
dukenv0307 4cad935
merge main
dukenv0307 2a292da
Merge branch 'main' into fix/34307
dukenv0307 5f599ae
fix test
dukenv0307 bcb3510
fix lint
dukenv0307 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 |
---|---|---|
|
@@ -101,7 +101,7 @@ | |
"date-fns-tz": "^2.0.0", | ||
"dom-serializer": "^0.2.2", | ||
"domhandler": "^4.3.0", | ||
"expensify-common": "git+ssh://[email protected]/Expensify/expensify-common.git#a8ed0f8e1be3a1e09016e07a74cfd13c85bbc167", | ||
"expensify-common": "git+ssh://[email protected]/Expensify/expensify-common.git#45d3b61bb38b4f9a19ddf573ce1e212369b242db", | ||
"expo": "^50.0.3", | ||
"expo-av": "~13.10.4", | ||
"expo-image": "1.10.1", | ||
|
This file contains hidden or 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,10 @@ | ||
import Text from '@components/Text'; | ||
import type EmojiWithTooltipProps from './types'; | ||
|
||
function EmojiWithTooltip({emojiCode, style = {}}: EmojiWithTooltipProps) { | ||
return <Text style={style}>{emojiCode}</Text>; | ||
} | ||
|
||
EmojiWithTooltip.displayName = 'EmojiWithTooltip'; | ||
|
||
export default EmojiWithTooltip; |
This file contains hidden or 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,40 @@ | ||
import React, {useCallback} from 'react'; | ||
import {View} from 'react-native'; | ||
import Text from '@components/Text'; | ||
import Tooltip from '@components/Tooltip'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as EmojiUtils from '@libs/EmojiUtils'; | ||
import type EmojiWithTooltipProps from './types'; | ||
|
||
function EmojiWithTooltip({emojiCode, style = {}}: EmojiWithTooltipProps) { | ||
const styles = useThemeStyles(); | ||
const emoji = EmojiUtils.findEmojiByCode(emojiCode); | ||
const emojiName = EmojiUtils.getEmojiName(emoji); | ||
|
||
const emojiTooltipContent = useCallback( | ||
() => ( | ||
<View style={[styles.alignItemsCenter, styles.ph2]}> | ||
<View style={[styles.flexRow, styles.emojiTooltipWrapper]}> | ||
<Text | ||
key={emojiCode} | ||
style={styles.onlyEmojisText} | ||
> | ||
{emojiCode} | ||
</Text> | ||
</View> | ||
<Text style={[styles.textMicro, styles.fontColorReactionLabel]}>{`:${emojiName}:`}</Text> | ||
</View> | ||
), | ||
[emojiCode, emojiName, styles.alignItemsCenter, styles.ph2, styles.flexRow, styles.emojiTooltipWrapper, styles.fontColorReactionLabel, styles.onlyEmojisText, styles.textMicro], | ||
); | ||
|
||
return ( | ||
<Tooltip renderTooltipContent={emojiTooltipContent}> | ||
<Text style={[style, styles.cursorDefault]}>{emojiCode}</Text> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
EmojiWithTooltip.displayName = 'EmojiWithTooltip'; | ||
|
||
export default EmojiWithTooltip; |
This file contains hidden or 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,8 @@ | ||
import type {StyleProp, TextStyle} from 'react-native'; | ||
|
||
type EmojiWithTooltipProps = { | ||
emojiCode: string; | ||
style?: StyleProp<TextStyle>; | ||
}; | ||
|
||
export default EmojiWithTooltipProps; |
This file contains hidden or 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
19 changes: 19 additions & 0 deletions
19
src/components/HTMLEngineProvider/HTMLRenderers/EmojiRenderer.tsx
This file contains hidden or 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,19 @@ | ||
import React from 'react'; | ||
import type {CustomRendererProps, TPhrasing, TText} from 'react-native-render-html'; | ||
import EmojiWithTooltip from '@components/EmojiWithTooltip'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
|
||
function EmojiRenderer({tnode}: CustomRendererProps<TText | TPhrasing>) { | ||
const styles = useThemeStyles(); | ||
const style = 'islarge' in tnode.attributes ? styles.onlyEmojisText : {}; | ||
return ( | ||
<EmojiWithTooltip | ||
style={[style, styles.cursorDefault]} | ||
emojiCode={'data' in tnode ? tnode.data : ''} | ||
/> | ||
); | ||
} | ||
|
||
EmojiRenderer.displayName = 'EmojiRenderer'; | ||
|
||
export default EmojiRenderer; |
This file contains hidden or 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 hidden or 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 hidden or 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
12 changes: 12 additions & 0 deletions
12
src/pages/home/report/comment/shouldRenderAsText/index.native.ts
This file contains hidden or 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,12 @@ | ||
import Str from 'expensify-common/lib/str'; | ||
|
||
/** | ||
* Whether to render the report action as text | ||
*/ | ||
export default function shouldRenderAsText(html: string, text: string): boolean { | ||
// On native, we render emoji as text to prevent the large emoji is cut off when the action is edited. | ||
// More info: https://github.com/Expensify/App/pull/35838#issuecomment-1964839350 | ||
const htmlWithoutLineBreak = Str.replaceAll(html, '<br />', '\n'); | ||
const htmlWithoutEmojiOpenTag = Str.replaceAll(htmlWithoutLineBreak, '<emoji>', ''); | ||
return Str.replaceAll(htmlWithoutEmojiOpenTag, '</emoji>', '') === text; | ||
} |
This file contains hidden or 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,8 @@ | ||
import Str from 'expensify-common/lib/str'; | ||
|
||
/** | ||
* Whether to render the report action as text | ||
*/ | ||
export default function shouldRenderAsText(html: string, text: string): boolean { | ||
return Str.replaceAll(html, '<br />', '\n') === text; | ||
} |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.