1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-07-22 04:57:30 +02:00
ntfy/web/src/components/AttachmentIcon.jsx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.4 KiB
React
Raw Normal View History

2022-03-29 21:22:26 +02:00
import * as React from "react";
import { Box } from "@mui/material";
2022-05-03 01:30:29 +02:00
import { useTranslation } from "react-i18next";
2022-03-29 21:22:26 +02:00
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 14:40:54 +02:00
const AttachmentIcon = (props) => {
2022-05-03 01:30:29 +02:00
const { t } = useTranslation();
2022-03-29 21:22:26 +02:00
const { type } = props;
2022-05-03 01:30:29 +02:00
let imageFile;
let imageLabel;
2022-03-29 21:22:26 +02:00
if (!type) {
imageFile = fileDocument;
2022-05-03 01:30:29 +02:00
imageLabel = t("notifications_attachment_file_image");
2022-03-29 21:22:26 +02:00
} else if (type.startsWith("image/")) {
imageFile = fileImage;
2022-05-03 01:30:29 +02:00
imageLabel = t("notifications_attachment_file_video");
2022-03-29 21:22:26 +02:00
} else if (type.startsWith("video/")) {
imageFile = fileVideo;
2022-05-03 01:30:29 +02:00
imageLabel = t("notifications_attachment_file_video");
2022-03-29 21:22:26 +02:00
} else if (type.startsWith("audio/")) {
imageFile = fileAudio;
2022-05-03 01:30:29 +02:00
imageLabel = t("notifications_attachment_file_audio");
2022-03-29 21:22:26 +02:00
} else if (type === "application/vnd.android.package-archive") {
imageFile = fileApp;
2022-05-03 01:30:29 +02:00
imageLabel = t("notifications_attachment_file_app");
2022-03-29 21:22:26 +02:00
} else {
imageFile = fileDocument;
2022-05-03 01:30:29 +02:00
imageLabel = t("notifications_attachment_file_document");
2022-03-29 21:22:26 +02:00
}
return (
<Box
component="img"
src={imageFile}
2022-05-03 01:30:29 +02:00
alt={imageLabel}
2022-03-29 21:22:26 +02:00
loading="lazy"
sx={{
width: "28px",
height: "28px",
}}
/>
);
};
2022-04-04 14:40:54 +02:00
export default AttachmentIcon;