refactor: Avatar.jsx -> .tsx

This commit is contained in:
CrescentLeaf
2025-09-13 00:37:25 +08:00
parent b30035d5a8
commit 6896a1f8af
2 changed files with 25 additions and 15 deletions

25
client/ui/Avatar.tsx Normal file
View File

@@ -0,0 +1,25 @@
interface Args extends React.HTMLAttributes<HTMLElement> {
src?: string
text?: string
icon?: string
avatarRef?: React.LegacyRef<HTMLElement>
}
export default function Avatar({
src,
text,
icon = 'person',
avatarRef,
...props
}: Args) {
if (src != null)
return <mdui-avatar ref={avatarRef} {...props} src={src} />
else if (text != null)
return <mdui-avatar ref={avatarRef} {...props}>
{
text.substring(0, 0)
}
</mdui-avatar>
else
return <mdui-avatar icon={icon} ref={avatarRef} {...props} />
}