#lang planet dyoo/whalesong (require (planet dyoo/whalesong/web-world) (planet dyoo/whalesong/resource)) (define-resource view.html) ;; The world is the set of dwarfs. ;; make-item: string -> view (define (make-item name) (view-bind (->view `(li ,name)) "click" hide-on-click)) ;; When a dwarf clicks, it hides! (define (hide-on-click w v) (remove (view-id v) w)) (define dwarf-names '("Doc" "Grumpy" "Happy" "Sleepy" "Bashful" "Sneezy" "Dopey")) ;; Update the view so it shows the next dwarf on the scene, ;; until we're all done. (define (draw w dom-view) (foldl (lambda (name view) (cond [(view-focus? view name) (define focused (view-focus view name)) (cond [(member name w) view] [else (view-remove focused)])] [else view])) dom-view dwarf-names)) ;; The first view consists of view.html. We attach event handlers ;; to each name here. (define my-view (foldl (lambda (name view) (view-bind (view-focus view name) "click" hide-on-click)) (->view view.html) dwarf-names)) (big-bang dwarf-names (initial-view my-view) (to-draw draw))