users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/opened-apps.jsx
cd1edb8102b069072cafb8b7e399ab252472b995
· 1.8 KB · 55 lines
raw
| 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 | } |