-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix address copy crash (and floating emojis animation) (#6392)
- Loading branch information
1 parent
73c782d
commit 91af6c1
Showing
9 changed files
with
150 additions
and
122 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
22 changes: 19 additions & 3 deletions
22
...nts/floating-emojis/CopyFloatingEmojis.js → ...ts/floating-emojis/CopyFloatingEmojis.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
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 was deleted.
Oops, something went wrong.
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,54 @@ | ||
import { isString } from 'lodash'; | ||
import React, { ReactNode } from 'react'; | ||
import Text from './Text'; | ||
import { emojis } from '@/references'; | ||
import { fonts } from '@/styles'; | ||
|
||
const emojiData = Object.entries(emojis).map(([emojiChar, { name }]) => { | ||
return [name, emojiChar]; | ||
}) as [string, string][]; | ||
|
||
export const emoji = new Map<string, string>(emojiData); | ||
|
||
function normalizeName(name: string): string { | ||
if (/:.+:/.test(name)) { | ||
name = name.slice(1, -1); | ||
} | ||
return name; | ||
} | ||
|
||
function getEmoji(name: unknown): string | null { | ||
if (!isString(name)) return null; | ||
const result = emoji.get(normalizeName(name)); | ||
return result ?? null; | ||
} | ||
|
||
export interface TextProps { | ||
isEmoji?: boolean; | ||
letterSpacing?: string; | ||
lineHeight?: string; | ||
size?: keyof typeof fonts.size; | ||
[key: string]: unknown; | ||
} | ||
|
||
export interface EmojiProps extends Omit<TextProps, 'isEmoji' | 'lineHeight' | 'letterSpacing' | 'children'> { | ||
children?: ReactNode; | ||
letterSpacing?: string; | ||
lineHeight?: string; | ||
name?: string; | ||
} | ||
|
||
export default function Emoji({ | ||
children = undefined, | ||
letterSpacing = 'zero', | ||
lineHeight = 'none', | ||
name, | ||
size = 'h4', | ||
...props | ||
}: EmojiProps) { | ||
return ( | ||
<Text {...props} isEmoji letterSpacing={letterSpacing} lineHeight={lineHeight} size={size}> | ||
{children || getEmoji(name)} | ||
</Text> | ||
); | ||
} |
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