summaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-01-16 23:17:31 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-01-16 23:17:31 +1100
commit828da2ce9e88c6a0cc0c33f22f764c4283a1f651 (patch)
tree0d558f99f2615c87dd69c40f0cebdc4cfe73750a /src/widgets
parentbar: unread -> notif count (diff)
downloadcaelestia-shell-828da2ce9e88c6a0cc0c33f22f764c4283a1f651.tar.gz
caelestia-shell-828da2ce9e88c6a0cc0c33f22f764c4283a1f651.tar.bz2
caelestia-shell-828da2ce9e88c6a0cc0c33f22f764c4283a1f651.zip
base popdown window
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/popdownwindow.tsx44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/widgets/popdownwindow.tsx b/src/widgets/popdownwindow.tsx
new file mode 100644
index 0000000..8710a59
--- /dev/null
+++ b/src/widgets/popdownwindow.tsx
@@ -0,0 +1,44 @@
+import type { Binding } from "astal";
+import { Gtk } from "astal/gtk3";
+import PopupWindow from "./popupwindow";
+
+export default ({
+ name,
+ count,
+ headerButtons,
+ emptyIcon,
+ emptyLabel,
+ list,
+}: {
+ name: string;
+ count: Binding<number>;
+ headerButtons: { label: string; onClicked: () => void; className?: Binding<string> }[];
+ emptyIcon: string;
+ emptyLabel: string;
+ list: JSX.Element;
+}) => (
+ <PopupWindow name={name}>
+ <box vertical className={name}>
+ <box className="header">
+ <label label={count.as(c => `${c} ${name.slice(0, -1)}${c === 1 ? "" : "s"}`)} />
+ <box hexpand />
+ {headerButtons.map(({ label, onClicked, className }) => (
+ <button cursor="pointer" onClicked={onClicked} label={label} className={className} />
+ ))}
+ </box>
+ <stack
+ transitionType={Gtk.StackTransitionType.CROSSFADE}
+ transitionDuration={150}
+ shown={count.as(c => (c > 0 ? "list" : "empty"))}
+ >
+ <box vertical valign={Gtk.Align.CENTER} name="empty">
+ <label className="icon" label={emptyIcon} />
+ <label label={emptyLabel} />
+ </box>
+ <scrollable expand hscroll={Gtk.PolicyType.NEVER} name="list">
+ {list}
+ </scrollable>
+ </stack>
+ </box>
+ </PopupWindow>
+);