diff demo/more/expandable.ur @ 1025:7facf72aaf0a

Initial form for paper assignment
author Adam Chlipala <adamc@hcoop.net>
date Sun, 01 Nov 2009 14:26:20 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demo/more/expandable.ur	Sun Nov 01 14:26:20 2009 -0500
@@ -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>