diff options
Diffstat (limited to 'users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/opened-apps.jsx')
| -rwxr-xr-x | users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/opened-apps.jsx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/opened-apps.jsx b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/opened-apps.jsx new file mode 100755 index 0000000..744867e --- /dev/null +++ b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/opened-apps.jsx | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | import * as Uebersicht from "uebersicht"; | ||
| 2 | import * as AppIcons from "../../app-icons.js"; | ||
| 3 | import { SuspenseIcon } from "../icons/icon.jsx"; | ||
| 4 | import * as Utils from "../../utils.js"; | ||
| 5 | |||
| 6 | const { React } = Uebersicht; | ||
| 7 | |||
| 8 | /** | ||
| 9 | * OpenedApps component to display a list of opened applications. | ||
| 10 | * @param {Object} props - Component properties. | ||
| 11 | * @param {Array} props.apps - The list of opened applications. | ||
| 12 | * @returns {JSX.Element|null} The rendered component or null if no applications are present. | ||
| 13 | */ | ||
| 14 | export default function OpenedApps({ apps }) { | ||
| 15 | // Return null if no applications are present | ||
| 16 | if (!apps.length) return null; | ||
| 17 | |||
| 18 | // Sort and map the applications to JSX elements | ||
| 19 | return Utils.sortWindows(apps).map((app, i) => { | ||
| 20 | const { | ||
| 21 | "is-minimized": isMinimized, | ||
| 22 | minimized: __legacyIsMinimized, | ||
| 23 | "has-focus": hasFocus, | ||
| 24 | focused: __legacyHasFocus, | ||
| 25 | "has-parent-zoom": hasParentZoom, | ||
| 26 | "zoom-parent": __legacyHasParentZoom, | ||
| 27 | "has-fullscreen-zoom": hasFullscreenZoom, | ||
| 28 | "zoom-fullscreen": __legacyHasFullscreenZoom, | ||
| 29 | "is-topmost": isTopmost, | ||
| 30 | } = app; | ||
| 31 | const appName = Utils.normalizeAppName(app.app); | ||
| 32 | |||
| 33 | // Skip minimized applications | ||
| 34 | if (isMinimized ?? __legacyIsMinimized) return null; | ||
| 35 | |||
| 36 | // Get the application icon or default icon | ||
| 37 | const Icon = AppIcons.apps[appName] || AppIcons.apps.Default; | ||
| 38 | |||
| 39 | // Determine the CSS classes for the icon | ||
| 40 | const classes = Utils.classNames("space__icon", { | ||
| 41 | "space__icon--focused": hasFocus ?? __legacyHasFocus, | ||
| 42 | "space__icon--fullscreen": | ||
| 43 | (hasParentZoom ?? __legacyHasParentZoom) || | ||
| 44 | (hasFullscreenZoom ?? __legacyHasFullscreenZoom), | ||
| 45 | "space__icon--topmost": isTopmost, | ||
| 46 | }); | ||
| 47 | |||
| 48 | // Render the application icon | ||
| 49 | return ( | ||
| 50 | <SuspenseIcon key={i}> | ||
| 51 | <Icon className={classes} /> | ||
| 52 | </SuspenseIcon> | ||
| 53 | ); | ||
| 54 | }); | ||
| 55 | } | ||
