-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cross-platform emoji compatibility
Signed-off-by: Adam Setch <adam.setch@outlook.com>
- Loading branch information
Showing
11 changed files
with
254 additions
and
44 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
68 changes: 48 additions & 20 deletions
68
src/components/__snapshots__/AccountNotifications.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,12 @@ | ||
import { render } from '@testing-library/react'; | ||
import { Emoji, type IEmoji } from './Emoji'; | ||
|
||
describe('components/icons/Emoji.tsx', () => { | ||
it('should render', () => { | ||
const props: IEmoji = { | ||
emoji: '🍺', | ||
}; | ||
const tree = render(<Emoji {...props} />); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
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,17 @@ | ||
import twemoji from '@twemoji/api'; | ||
import type { FC } from 'react'; | ||
|
||
export interface IEmoji { | ||
emoji: string; | ||
} | ||
|
||
export const Emoji: FC<IEmoji> = (props: IEmoji) => { | ||
// Generate the HTML for the emoji using twemoji | ||
const emojiHtml = twemoji.parse(props.emoji, { | ||
folder: 'svg', | ||
ext: '.svg', | ||
}); | ||
|
||
// biome-ignore lint/security/noDangerouslySetInnerHtml: used for cross-platform emoji compatibility | ||
return <span dangerouslySetInnerHTML={{ __html: emojiHtml }} />; | ||
}; |
Oops, something went wrong.