mirror of
https://github.com/colanode/colanode.git
synced 2025-12-29 00:25:03 +01:00
Improve default avatar
This commit is contained in:
@@ -40,30 +40,30 @@ export const getAvatarUrl = (accountId: string, avatar: string): string => {
|
||||
return `avatar://${accountId}/${avatar}`;
|
||||
};
|
||||
|
||||
export const getDefaultNodeIcon = (type: IdType): string => {
|
||||
export const getDefaultNodeAvatar = (type: IdType): string => {
|
||||
if (type === IdType.Channel) {
|
||||
return 'discuss-line';
|
||||
return '01h37jbxq11hpcnw1mdfgmm70cem';
|
||||
}
|
||||
|
||||
if (type === IdType.Page) {
|
||||
return 'book-line';
|
||||
return '01h37jbxqc5srhy96v34dxaa2aem';
|
||||
}
|
||||
|
||||
if (type === IdType.Database) {
|
||||
return 'database-2-line';
|
||||
return '01h37jbxqc5srhy96v34dxaa25em';
|
||||
}
|
||||
|
||||
if (type === IdType.Record) {
|
||||
return 'article-line';
|
||||
return '01h37jbxqc5srhy96v34dxaa2dem';
|
||||
}
|
||||
|
||||
if (type === IdType.Folder) {
|
||||
return 'folder-open-line';
|
||||
return '01h37jbxqc5srhy96v34dxaa36em';
|
||||
}
|
||||
|
||||
if (type === IdType.Space) {
|
||||
return 'team-line';
|
||||
return '01h37jbxq7628n8m2bwdandtbxem';
|
||||
}
|
||||
|
||||
return 'file-unknown-line';
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -4,10 +4,9 @@ import {
|
||||
getAvatarSizeClasses,
|
||||
getAvatarUrl,
|
||||
getColorForId,
|
||||
getDefaultNodeIcon,
|
||||
getDefaultNodeAvatar,
|
||||
} from '@/lib/avatars';
|
||||
import { getIdType, IdType } from '@/lib/id';
|
||||
import { Icon } from '@/renderer/components/ui/icon';
|
||||
import { getEmojiUrl } from '@/lib/emojis';
|
||||
import { getIconUrl } from '@/lib/icons';
|
||||
import { useAccount } from '@/renderer/contexts/account';
|
||||
@@ -37,6 +36,20 @@ export const Avatar = (props: AvatarProps) => {
|
||||
};
|
||||
|
||||
const AvatarFallback = ({ id, name, size, className }: AvatarProps) => {
|
||||
const idType = getIdType(id);
|
||||
const defaultAvatar = getDefaultNodeAvatar(idType);
|
||||
if (defaultAvatar) {
|
||||
return (
|
||||
<Avatar
|
||||
id={id}
|
||||
name={name}
|
||||
avatar={defaultAvatar}
|
||||
size={size}
|
||||
className={className}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (name) {
|
||||
const color = getColorForId(id);
|
||||
return (
|
||||
@@ -53,11 +66,7 @@ const AvatarFallback = ({ id, name, size, className }: AvatarProps) => {
|
||||
);
|
||||
}
|
||||
|
||||
const idType = getIdType(id);
|
||||
const icon = getDefaultNodeIcon(idType);
|
||||
return (
|
||||
<Icon name={icon} className={cn(getAvatarSizeClasses(size), className)} />
|
||||
);
|
||||
return null;
|
||||
};
|
||||
|
||||
const EmojiAvatar = ({ avatar, size, className }: AvatarProps) => {
|
||||
|
||||
Reference in New Issue
Block a user