mirror of
https://github.com/tuxdotrs/tpanel.git
synced 2025-10-10 21:01:54 +05:30
feat: add notifications widget
This commit is contained in:
29
widgets/notifications/index.tsx
Normal file
29
widgets/notifications/index.tsx
Normal 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>
|
||||
);
|
||||
};
|
Reference in New Issue
Block a user