From d06784958d73159b5e4abafe5114804662114ed7 Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Thu, 9 Jul 2026 22:15:53 -0400 Subject: move ubersicht modules in tree --- .../simple-bar-source/lib/components/error.jsx | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 users/ryan/modules/simple-bar/simple-bar-source/lib/components/error.jsx (limited to 'users/ryan/modules/simple-bar/simple-bar-source/lib/components/error.jsx') 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 @@ +import * as Settings from "./settings/settings.jsx"; +import * as Utils from "../utils"; + +// Error messages for different types of errors +const message = { + error: "Something went wrong…", + yabaiError: "yabai is not running", + aerospaceError: "AeroSpace is either not running or outdated", + noOutput: "Loading…", + noData: "JSON error…", +}; + +/** + * Component to display error messages based on the type of error. + * @param {Object} props - The properties object. + * @param {string} props.type - The type of error. + * @param {string} props.classes - Additional CSS classes. + * @returns {JSX.Element} The error component. + */ +export function Component({ type, classes }) { + // Combine base class with additional classes and conditional loading class + const errorClasses = Utils.classNames("simple-bar--empty", classes, { + "simple-bar--loading": type === "noOutput", + }); + + // Refresh the component after 2 seconds for general errors and JSON errors + if (type === "error" || type === "noData") { + setTimeout(Utils.softRefresh, 2000); + } + + // Refresh the component after 15 seconds for yabai and aerospace errors + if (type === "yabaiError" || type === "aerospaceError") { + setTimeout(Utils.softRefresh, 15000); + } + + return ( +
+ simple-bar-index.jsx: {message[type]} + +
+ ); +} -- cgit v1.3