Lazily load better quality jumbomoji

This commit is contained in:
Fedor Indutny 2024-06-21 18:35:56 -04:00 committed by GitHub
parent ac04d02d4f
commit 5e41701516
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 4566 additions and 137 deletions

View file

@ -11,6 +11,8 @@ import { missingCaseError } from '../../util/missingCaseError';
import type { SizeClassType } from '../emoji/lib';
import { emojiToImage } from '../emoji/lib';
const JUMBO_SIZES = new Set<SizeClassType>(['large', 'extra-large', 'max']);
// Some of this logic taken from emoji-js/replacement
// the DOM structure for this getImageTag should match the other emoji implementations:
// ts/components/emoji/Emoji.tsx
@ -32,10 +34,16 @@ function getImageTag({
return match;
}
let srcSet: string | undefined;
if (sizeClass != null && JUMBO_SIZES.has(sizeClass)) {
srcSet = `emoji://jumbo?emoji=${encodeURIComponent(match)}, ${img}`;
}
return (
<img
key={key}
src={img}
srcSet={srcSet}
aria-label={match}
className={classNames(
'emoji',