Files
ragflow/web/src/components/icon-font.tsx
chanx b79fef1ca8 fix: Modify icon file, knowledge base display style (#10104)
### What problem does this PR solve?

fix: Modify icon file, knowledge base display style #9869

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
2025-09-16 10:37:08 +08:00

48 lines
1.0 KiB
TypeScript

import { FileIconMap } from '@/constants/file';
import { cn } from '@/lib/utils';
import { getExtension } from '@/utils/document-util';
type IconFontType = {
name: string;
className?: string;
};
export const IconFont = ({ name, className }: IconFontType) => (
<svg className={cn('size-4', className)}>
<use xlinkHref={`#icon-${name}`} />
</svg>
);
export function IconFontFill({
name,
className,
isFill = true,
}: IconFontType & { isFill?: boolean }) {
return (
<span className={cn('size-4', className)}>
<svg
className={cn('size-4', className)}
style={{ fill: isFill ? 'currentColor' : '' }}
>
<use xlinkHref={`#icon-${name}`} />
</svg>
</span>
);
}
export function FileIcon({
name,
className,
type,
}: IconFontType & { type?: string }) {
const isFolder = type === 'folder';
return (
<span className={cn('size-4', className)}>
<IconFont
name={isFolder ? 'file-sub' : FileIconMap[getExtension(name)]}
></IconFont>
</span>
);
}