Files
Tom Moor fb9f4bb991 feat: Allow replacing custom emoji image (#11998)
* feat: Allow replacing custom emoji image
2026-04-10 18:51:59 -04:00

33 lines
683 B
TypeScript

import useShare from "@shared/hooks/useShare";
type Props = React.ImgHTMLAttributes<HTMLImageElement> & {
value: string;
size?: number | string;
/** Optional cache-busting key, e.g. updatedAt timestamp. */
cacheKey?: string;
};
export const CustomEmoji = ({
value,
size = 16,
cacheKey,
...props
}: Props) => {
const { shareId } = useShare();
let src = `/api/emojis.redirect?id=${value}`;
if (shareId) {
src += `&shareId=${shareId}`;
}
if (cacheKey) {
src += `&v=${encodeURIComponent(cacheKey)}`;
}
return (
<img
alt=""
src={src}
style={{ width: size, height: size, objectFit: "contain" }}
{...props}
/>
);
};