From 928ba0ce419bacba113951095278a5138ead34cf Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Sun, 10 Apr 2022 16:04:03 +0800
Subject: ...

---
 .../src/views/timeline/ConnectionStatusBadge.tsx   | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 FrontEnd/src/views/timeline/ConnectionStatusBadge.tsx

(limited to 'FrontEnd/src/views/timeline/ConnectionStatusBadge.tsx')

diff --git a/FrontEnd/src/views/timeline/ConnectionStatusBadge.tsx b/FrontEnd/src/views/timeline/ConnectionStatusBadge.tsx
new file mode 100644
index 00000000..c8478557
--- /dev/null
+++ b/FrontEnd/src/views/timeline/ConnectionStatusBadge.tsx
@@ -0,0 +1,41 @@
+import React from "react";
+import classnames from "classnames";
+import { HubConnectionState } from "@microsoft/signalr";
+import { useTranslation } from "react-i18next";
+
+import "./ConnectionStatusBadge.css";
+
+export interface ConnectionStatusBadgeProps {
+  status: HubConnectionState;
+  className?: string;
+  style?: React.CSSProperties;
+}
+
+const classNameMap: Record<HubConnectionState, string> = {
+  Connected: "success",
+  Connecting: "warning",
+  Disconnected: "danger",
+  Disconnecting: "warning",
+  Reconnecting: "warning",
+};
+
+const ConnectionStatusBadge: React.FC<ConnectionStatusBadgeProps> = (props) => {
+  const { status, className, style } = props;
+
+  const { t } = useTranslation();
+
+  return (
+    <div
+      className={classnames(
+        "connection-status-badge",
+        classNameMap[status],
+        className
+      )}
+      style={style}
+    >
+      {t(`connectionState.${status}`)}
+    </div>
+  );
+};
+
+export default ConnectionStatusBadge;
-- 
cgit v1.2.3

