-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathNamespaceIcon.tsx
More file actions
33 lines (30 loc) · 1.21 KB
/
NamespaceIcon.tsx
File metadata and controls
33 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Avatar, theme } from 'antd';
import { Brain } from 'lucide-react';
import { useResolvedAvatarSrc } from '@/hooks/useResolvedAvatarSrc';
import type { AvatarType } from '@/stores/userProfileStore';
import type { MemoryNamespace } from '@/types';
interface NamespaceIconProps {
ns: MemoryNamespace;
size?: number;
}
export function NamespaceIcon({ ns, size = 16 }: NamespaceIconProps) {
const resolvedSrc = useResolvedAvatarSrc((ns.iconType as AvatarType) ?? 'icon', ns.iconValue ?? '');
const { token } = theme.useToken();
if (ns.iconType === 'emoji' && ns.iconValue) {
return (
<span style={{
width: size, height: size, borderRadius: '50%',
backgroundColor: token.colorFillSecondary,
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
fontSize: size * 0.7, lineHeight: 1, flexShrink: 0,
}}>
{ns.iconValue}
</span>
);
}
if ((ns.iconType === 'url' || ns.iconType === 'file') && ns.iconValue) {
const src = ns.iconType === 'file' ? resolvedSrc : ns.iconValue;
return <Avatar size={size} src={src} style={{ flexShrink: 0 }} />;
}
return <Brain size={size} style={{ flexShrink: 0, color: token.colorTextSecondary }} />;
}