summaryrefslogtreecommitdiff
path: root/demo/more/expandable.ur
diff options
context:
space:
mode:
Diffstat (limited to 'demo/more/expandable.ur')
-rw-r--r--demo/more/expandable.ur23
1 files changed, 23 insertions, 0 deletions
diff --git a/demo/more/expandable.ur b/demo/more/expandable.ur
new file mode 100644
index 00000000..92d8743c
--- /dev/null
+++ b/demo/more/expandable.ur
@@ -0,0 +1,23 @@
+con t ctx = source bool * xml ctx [] []
+
+fun create [ctx] (x : xml ctx [] []) =
+ s <- source False;
+ return (s, x)
+
+fun expand [ctx] (t : t ctx) =
+ set t.1 True
+
+fun collapse [ctx] (t : t ctx) =
+ set t.1 False
+
+fun render [ctx] [[Body] ~ ctx] (t : t ([Body] ++ ctx)) =
+ <xml><dyn signal={b <- signal t.1;
+ return (if b then
+ <xml>
+ <button value="-" onclick={collapse t}/><br/>
+ {t.2}
+ </xml>
+ else
+ <xml>
+ <button value="+" onclick={expand t}/><br/>
+ </xml>)}/></xml>