From 0518ec4214583bcc26f5b052f02fd93b12a00a77 Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Fri, 17 Jan 2025 00:16:40 +1100
Subject: bluetoothdevices: make popup window

---
 src/widgets/popdownwindow.tsx | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

(limited to 'src/widgets/popdownwindow.tsx')

diff --git a/src/widgets/popdownwindow.tsx b/src/widgets/popdownwindow.tsx
index 8710a59..18e9ae9 100644
--- a/src/widgets/popdownwindow.tsx
+++ b/src/widgets/popdownwindow.tsx
@@ -5,6 +5,7 @@ import PopupWindow from "./popupwindow";
 export default ({
     name,
     count,
+    countLabel = count.as(c => `${c} ${name.slice(0, -1)}${c === 1 ? "" : "s"}`),
     headerButtons,
     emptyIcon,
     emptyLabel,
@@ -12,7 +13,8 @@ export default ({
 }: {
     name: string;
     count: Binding<number>;
-    headerButtons: { label: string; onClicked: () => void; className?: Binding<string> }[];
+    countLabel?: Binding<string>;
+    headerButtons: { label: string | Binding<string>; onClicked: () => void; enabled?: Binding<boolean> }[];
     emptyIcon: string;
     emptyLabel: string;
     list: JSX.Element;
@@ -20,10 +22,15 @@ export default ({
     <PopupWindow name={name}>
         <box vertical className={name}>
             <box className="header">
-                <label label={count.as(c => `${c} ${name.slice(0, -1)}${c === 1 ? "" : "s"}`)} />
+                <label label={countLabel} />
                 <box hexpand />
-                {headerButtons.map(({ label, onClicked, className }) => (
-                    <button cursor="pointer" onClicked={onClicked} label={label} className={className} />
+                {headerButtons.map(({ label, onClicked, enabled }) => (
+                    <button
+                        cursor="pointer"
+                        onClicked={onClicked}
+                        label={label}
+                        className={enabled?.as(d => (d ? "enabled" : ""))}
+                    />
                 ))}
             </box>
             <stack
-- 
cgit v1.2.3-freya

