import { getLayeredIcon } from '@sd/assets/util'; import clsx from 'clsx'; import { type ImgHTMLAttributes } from 'react'; import { type ObjectKindKey } from '@sd/client'; interface LayeredFileIconProps extends ImgHTMLAttributes { kind: ObjectKindKey; extension: string | null; } const SUPPORTED_ICONS = ['Document', 'Code', 'Text', 'Config']; const positionConfig: Record = { Text: 'flex h-full w-full items-center justify-center', Code: 'flex h-full w-full items-center justify-center', Config: 'flex h-full w-full items-center justify-center' }; const LayeredFileIcon = ({ kind, extension, ...props }: LayeredFileIconProps) => { const iconImg = ; if (SUPPORTED_ICONS.includes(kind) === false) { return iconImg; } const IconComponent = extension ? getLayeredIcon(kind, extension) : null; const positionClass = positionConfig[kind] || 'flex h-full w-full items-end justify-end pb-4 pr-2'; return IconComponent == null ? ( iconImg ) : (
{iconImg}
); }; export default LayeredFileIcon;