mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-27 10:32:58 +02:00
25 lines
855 B
TypeScript
25 lines
855 B
TypeScript
import { FolderIcon, FolderIconType } from '@joplin/lib/services/database/types';
|
|
import EmojiBox from './EmojiBox';
|
|
|
|
interface Props {
|
|
folderIcon: FolderIcon;
|
|
opacity?: number;
|
|
}
|
|
|
|
export default function(props: Props) {
|
|
const folderIcon = props.folderIcon;
|
|
const opacity = 'opacity' in props ? props.opacity : 1;
|
|
const width = 20;
|
|
const height = 20;
|
|
|
|
if (folderIcon.type === FolderIconType.Emoji) {
|
|
return <EmojiBox width={width} height={height} emoji={folderIcon.emoji}/>;
|
|
} else if (folderIcon.type === FolderIconType.DataUrl) {
|
|
return <img style={{ width, height, opacity }} src={folderIcon.dataUrl} />;
|
|
} else if (folderIcon.type === FolderIconType.FontAwesome) {
|
|
return <i style={{ fontSize: 18, width, opacity }} className={folderIcon.name}></i>;
|
|
} else {
|
|
throw new Error(`Unsupported folder icon type: ${folderIcon.type}`);
|
|
}
|
|
}
|