1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/components/common/DefaultIconText.tsx
2024-09-18 15:31:15 -04:00

42 lines
1.1 KiB
TypeScript

import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind';
import React, { type FC } from 'react';
import Icon from '@mui/material/Icon';
import { getItemTypeIcon, getLibraryIcon } from 'utils/image';
import DefaultName from './DefaultName';
import type { ItemDto } from 'types/base/models/item-dto';
interface DefaultIconTextProps {
item: ItemDto;
defaultCardImageIcon?: string;
}
const DefaultIconText: FC<DefaultIconTextProps> = ({
item,
defaultCardImageIcon
}) => {
let icon;
if (item.Type === BaseItemKind.CollectionFolder || item.CollectionType) {
icon = getLibraryIcon(item.CollectionType);
}
if (!icon) {
icon = getItemTypeIcon(item.Type, defaultCardImageIcon);
}
if (icon) {
return (
<Icon
className='cardImageIcon'
sx={{ color: 'inherit', fontSize: '5em' }}
aria-hidden='true'
>
{icon}
</Icon>
);
}
return <DefaultName item={item} />;
};
export default DefaultIconText;