mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-28 04:12:41 +03:00
Time to embrace prefers-reduced-motion with picture
This commit is contained in:
parent
fb798ce895
commit
58c6b6349c
2 changed files with 15 additions and 11 deletions
|
@ -9,10 +9,13 @@ function EmojiText({ text, emojis }) {
|
|||
const elements = text.split(regex).map((word) => {
|
||||
const emoji = emojis.find((e) => e.shortcode === word);
|
||||
if (emoji) {
|
||||
const { url, staticUrl } = emoji;
|
||||
return (
|
||||
<picture>
|
||||
<source srcset={staticUrl} media="(prefers-reduced-motion: reduce)" />
|
||||
<img
|
||||
key={word}
|
||||
src={emoji.url}
|
||||
src={url}
|
||||
alt={word}
|
||||
class="shortcode-emoji emoji"
|
||||
width="12"
|
||||
|
@ -20,6 +23,7 @@ function EmojiText({ text, emojis }) {
|
|||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</picture>
|
||||
);
|
||||
}
|
||||
return word;
|
||||
|
|
|
@ -8,7 +8,7 @@ function emojifyText(text, emojis = []) {
|
|||
const { shortcode, staticUrl, url } = emoji;
|
||||
text = text.replace(
|
||||
new RegExp(`:${shortcode}:`, 'g'),
|
||||
`<img class="shortcode-emoji emoji" src="${url}" alt=":${shortcode}:" width="12" height="12" loading="lazy" decoding="async" />`,
|
||||
`<picture><source srcset="${staticUrl}" media="(prefers-reduced-motion: reduce)"></source><img class="shortcode-emoji emoji" src="${url}" alt=":${shortcode}:" width="12" height="12" loading="lazy" decoding="async" /></picture>`,
|
||||
);
|
||||
});
|
||||
// console.log(text, emojis);
|
||||
|
|
Loading…
Reference in a new issue