Mercurial > urweb
annotate demo/more/expandable.ur @ 1298:e665527fce1c
Support empty datatypes, which can now be generated via 'variant []'
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 09 Sep 2010 12:42:25 -0400 |
parents | 7facf72aaf0a |
children |
rev | line source |
---|---|
adamc@1025 | 1 con t ctx = source bool * xml ctx [] [] |
adamc@1025 | 2 |
adamc@1025 | 3 fun create [ctx] (x : xml ctx [] []) = |
adamc@1025 | 4 s <- source False; |
adamc@1025 | 5 return (s, x) |
adamc@1025 | 6 |
adamc@1025 | 7 fun expand [ctx] (t : t ctx) = |
adamc@1025 | 8 set t.1 True |
adamc@1025 | 9 |
adamc@1025 | 10 fun collapse [ctx] (t : t ctx) = |
adamc@1025 | 11 set t.1 False |
adamc@1025 | 12 |
adamc@1025 | 13 fun render [ctx] [[Body] ~ ctx] (t : t ([Body] ++ ctx)) = |
adamc@1025 | 14 <xml><dyn signal={b <- signal t.1; |
adamc@1025 | 15 return (if b then |
adamc@1025 | 16 <xml> |
adamc@1025 | 17 <button value="-" onclick={collapse t}/><br/> |
adamc@1025 | 18 {t.2} |
adamc@1025 | 19 </xml> |
adamc@1025 | 20 else |
adamc@1025 | 21 <xml> |
adamc@1025 | 22 <button value="+" onclick={expand t}/><br/> |
adamc@1025 | 23 </xml>)}/></xml> |