aboutsummaryrefslogtreecommitdiff
path: root/users/ryan/modules/simple-bar/simple-bar-source/lib/components/error.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'users/ryan/modules/simple-bar/simple-bar-source/lib/components/error.jsx')
-rwxr-xr-xusers/ryan/modules/simple-bar/simple-bar-source/lib/components/error.jsx42
1 files changed, 42 insertions, 0 deletions
diff --git a/users/ryan/modules/simple-bar/simple-bar-source/lib/components/error.jsx b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/error.jsx
new file mode 100755
index 0000000..135cb29
--- /dev/null
+++ b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/error.jsx
@@ -0,0 +1,42 @@
1import * as Settings from "./settings/settings.jsx";
2import * as Utils from "../utils";
3
4// Error messages for different types of errors
5const message = {
6 error: "Something went wrong…",
7 yabaiError: "yabai is not running",
8 aerospaceError: "AeroSpace is either not running or outdated",
9 noOutput: "Loading…",
10 noData: "JSON error…",
11};
12
13/**
14 * Component to display error messages based on the type of error.
15 * @param {Object} props - The properties object.
16 * @param {string} props.type - The type of error.
17 * @param {string} props.classes - Additional CSS classes.
18 * @returns {JSX.Element} The error component.
19 */
20export function Component({ type, classes }) {
21 // Combine base class with additional classes and conditional loading class
22 const errorClasses = Utils.classNames("simple-bar--empty", classes, {
23 "simple-bar--loading": type === "noOutput",
24 });
25
26 // Refresh the component after 2 seconds for general errors and JSON errors
27 if (type === "error" || type === "noData") {
28 setTimeout(Utils.softRefresh, 2000);
29 }
30
31 // Refresh the component after 15 seconds for yabai and aerospace errors
32 if (type === "yabaiError" || type === "aerospaceError") {
33 setTimeout(Utils.softRefresh, 15000);
34 }
35
36 return (
37 <div className={errorClasses}>
38 <span>simple-bar-index.jsx: {message[type]}</span>
39 <Settings.Wrapper />
40 </div>
41 );
42}