Add tooltip to HistoryIcon

pull/1874/head
LASER-Yi 2 years ago
parent 98937a0378
commit 23022f5282

@ -9,6 +9,7 @@ import {
faUser,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Tooltip } from "@mantine/core";
import { FunctionComponent } from "react";
enum HistoryAction {
@ -26,35 +27,52 @@ const HistoryIcon: FunctionComponent<{
title?: string;
}> = ({ action, title }) => {
let icon = null;
let label = "Unknown";
switch (action) {
case HistoryAction.Delete:
icon = faTrash;
label = "Delete";
break;
case HistoryAction.Download:
icon = faDownload;
label = "Download";
break;
case HistoryAction.Manual:
icon = faUser;
label = "Manual";
break;
case HistoryAction.Sync:
icon = faClock;
label = "Sync";
break;
case HistoryAction.Upgrade:
icon = faRecycle;
label = "Upgrade";
break;
case HistoryAction.Upload:
icon = faCloudUploadAlt;
label = "Upload";
break;
case HistoryAction.Translated:
icon = faLanguage;
label = "Translated";
break;
default:
icon = faClosedCaptioning;
label = "Unknown";
break;
}
if (icon) {
return <FontAwesomeIcon title={title} icon={icon}></FontAwesomeIcon>;
return (
<Tooltip label={label} openDelay={500} position="right">
<FontAwesomeIcon
aria-label={label}
title={title}
icon={icon}
></FontAwesomeIcon>
</Tooltip>
);
} else {
return null;
}

Loading…
Cancel
Save