@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
53 lines (50 loc) • 1.42 kB
JavaScript
'use client';
import { useCdnFn } from "../ConfigProvider/index.mjs";
import Center_default from "../Flex/Center.mjs";
import Img_default from "../Img/index.mjs";
import { styles } from "./style.mjs";
import { genEmojiUrl } from "./utils.mjs";
import { useMemo, useState } from "react";
import { jsx } from "react/jsx-runtime";
import { cx } from "antd-style";
//#region src/FluentEmoji/FluentEmoji.tsx
const FluentEmoji = ({ emoji, className, style, type = "3d", size = 40, unoptimized, ref, ...rest }) => {
const [loadingFail, setLoadingFail] = useState(false);
const genCdnUrl = useCdnFn();
const emojiUrl = useMemo(() => genEmojiUrl(emoji, type), [type, emoji]);
if (type === "raw" || !emojiUrl || loadingFail) return /* @__PURE__ */ jsx(Center_default, {
className: cx(styles.container, className),
flex: "none",
height: size,
ref,
role: "img",
style: {
fontSize: size * .9,
...style
},
width: size,
...rest,
children: emoji
});
return /* @__PURE__ */ jsx(Img_default, {
alt: emoji,
className,
height: size,
loading: "lazy",
onError: () => setLoadingFail(true),
ref,
src: genCdnUrl(emojiUrl),
style: {
flex: "none",
...style
},
unoptimized,
width: size,
...rest
});
};
FluentEmoji.displayName = "FluentEmoji";
var FluentEmoji_default = FluentEmoji;
//#endregion
export { FluentEmoji_default as default };
//# sourceMappingURL=FluentEmoji.mjs.map