Lazily load better quality jumbomoji
This commit is contained in:
parent
ac04d02d4f
commit
5e41701516
10 changed files with 4566 additions and 137 deletions
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue