1
0
Fork 0
forked from mirrors/ntfy
ntfy/web/src/components/AttachmentIcon.js

39 lines
1 KiB
JavaScript
Raw Normal View History

2022-03-29 19:22:26 +00:00
import * as React from "react";
import Box from "@mui/material/Box";
import fileDocument from "../img/file-document.svg";
import fileImage from "../img/file-image.svg";
import fileVideo from "../img/file-video.svg";
import fileAudio from "../img/file-audio.svg";
import fileApp from "../img/file-app.svg";
2022-04-04 12:40:54 +00:00
const AttachmentIcon = (props) => {
2022-03-29 19:22:26 +00:00
const type = props.type;
let imageFile;
if (!type) {
imageFile = fileDocument;
} else if (type.startsWith('image/')) {
imageFile = fileImage;
} else if (type.startsWith('video/')) {
imageFile = fileVideo;
} else if (type.startsWith('audio/')) {
imageFile = fileAudio;
} else if (type === "application/vnd.android.package-archive") {
imageFile = fileApp;
} else {
imageFile = fileDocument;
}
return (
<Box
component="img"
src={imageFile}
loading="lazy"
sx={{
width: '28px',
height: '28px'
}}
/>
);
}
2022-04-04 12:40:54 +00:00
export default AttachmentIcon;