feat: add notifications widget

This commit is contained in:
tux
2025-06-13 23:12:11 +05:30
parent e042268846
commit e93f98d154
8 changed files with 219 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
import { Astal, Gdk } from "astal/gtk4";
import Notifd from "gi://AstalNotifd";
import { bind } from "astal";
import { NotificationWidget } from "./notification";
export const WINDOW_NAME = "notifications";
export const Notifications = (gdkmonitor: Gdk.Monitor) => {
const notifd = Notifd.get_default();
const { TOP, RIGHT } = Astal.WindowAnchor;
return (
<window
name={WINDOW_NAME}
cssClasses={["notifications"]}
gdkmonitor={gdkmonitor}
anchor={TOP | RIGHT}
visible={bind(notifd, "notifications").as(
(notifications) => notifications.length > 0,
)}
>
<box vertical={true} spacing={10}>
{bind(notifd, "notifications").as((notifications) =>
notifications.map((n) => <NotificationWidget n={n} />),
)}
</box>
</window>
);
};