users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/opened-apps.jsx

cd1edb8102b069072cafb8b7e399ab252472b995 · 1016 B · 33 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 icons of opened applications.
10 * @param {Object} props - The component props.
11 * @param {Array} props.apps - The list of opened applications.
12 * @returns {JSX.Element|null} The rendered component or null if no apps are opened.
13 */
14 export default function OpenedApps({ apps }) {
15 if (!apps.length) return null;
16
17 return apps.map((app, i) => {
18 const { focused } = app;
19 const appName = Utils.normalizeAppName(app["app-name"]);
20 const Icon = AppIcons.apps[appName] || AppIcons.apps.Default;
21
22 // Generate class names for the app icon
23 const classes = Utils.classNames("space__icon", {
24 "space__icon--focused": focused,
25 });
26
27 return (
28 <SuspenseIcon key={i}>
29 <Icon className={classes} />
30 </SuspenseIcon>
31 );
32 });
33 }