2022-02-06 18:42:00 +02:00
|
|
|
import { FolderIcon, FolderIconType } from '@joplin/lib/services/database/types';
|
2022-10-23 16:49:28 +02:00
|
|
|
import EmojiBox from './EmojiBox';
|
2022-02-06 18:42:00 +02:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
folderIcon: FolderIcon;
|
2022-09-05 18:26:22 +02:00
|
|
|
opacity?: number;
|
2022-02-06 18:42:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export default function(props: Props) {
|
|
|
|
const folderIcon = props.folderIcon;
|
2022-09-05 18:26:22 +02:00
|
|
|
const opacity = 'opacity' in props ? props.opacity : 1;
|
2022-10-23 16:49:28 +02:00
|
|
|
const width = 20;
|
|
|
|
const height = 20;
|
2022-02-06 18:42:00 +02:00
|
|
|
|
|
|
|
if (folderIcon.type === FolderIconType.Emoji) {
|
2022-10-23 16:49:28 +02:00
|
|
|
return <EmojiBox width={width} height={height} emoji={folderIcon.emoji}/>;
|
2022-02-06 18:42:00 +02:00
|
|
|
} else if (folderIcon.type === FolderIconType.DataUrl) {
|
2022-10-23 16:49:28 +02:00
|
|
|
return <img style={{ width, height, opacity }} src={folderIcon.dataUrl} />;
|
2022-09-05 18:26:22 +02:00
|
|
|
} else if (folderIcon.type === FolderIconType.FontAwesome) {
|
2024-10-15 18:59:51 +02:00
|
|
|
return <i style={{ fontSize: 18, width, opacity }} className={folderIcon.name} role='img'></i>;
|
2022-02-06 18:42:00 +02:00
|
|
|
} else {
|
|
|
|
throw new Error(`Unsupported folder icon type: ${folderIcon.type}`);
|
|
|
|
}
|
|
|
|
}
|