From 7f729d18d9d85f914b6cb1f4df81207caeee4b61 Mon Sep 17 00:00:00 2001
From: Jasper Ras <jras@hostnet.nl>
Date: Thu, 28 Nov 2024 10:03:42 +0100
Subject: init

---
 widget/Button.tsx | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 widget/Button.tsx

(limited to 'widget/Button.tsx')

diff --git a/widget/Button.tsx b/widget/Button.tsx
new file mode 100644
index 0000000..abc24ca
--- /dev/null
+++ b/widget/Button.tsx
@@ -0,0 +1,34 @@
+import { Variable, bind } from "astal"
+
+type Props = {
+  p: string
+  child?: JSX.Element
+  children?: Array<JSX.Element>
+}
+
+export default function MyButton({p, child, children}: Props) {
+  const count = Variable(0)
+  const labels = [p +"1", p +"2"]
+
+  if (child) {
+    console.log(child.label)
+  }
+
+  function increment() {
+    count.set(count.get() + 1)
+  }
+
+  function handleClick(self, ...args) {
+    console.log(self, "was clicked")
+  }
+  return <box>
+    {labels.map(label => (
+      <button onClick={handleClick}>
+        <label label={label}></label>
+      </button>
+    ))}
+    <button onClick={increment}>
+      <label label={bind(count).as(num => num.toString())}></label>
+    </button>
+  </box>
+}
-- 
cgit v1.2.3

