Created
January 11, 2015 03:46
-
-
Save ncammarata/bce98e0e770f44419c15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| placeholder = "What needs to be done?" | |
| type Filter = All | Active | Complete | |
| filterFn = case Filter of | |
| All: constant True | |
| Complete: (eq .complete) | |
| Active: (not << eq) .complete | |
| App { | |
| state: { filter: All, newText: "", tasks: [] } | |
| action: | |
| add: | |
| @tasks = @tasks :: { done: False, editing: false, text: @newText } | |
| @newText = "" | |
| remove task: | |
| @tasks = filter (eq task) @tasks | |
| clearDone: | |
| @tasks = filter (eq .done) @tasks | |
| template: | |
| textbox(sync: @newText, enter: :add, placeholder: placeholder) | |
| button.activate-all(click: @tasks = map (.done = True) @tasks) | |
| .item( | |
| repeat<task>: filter (filterFn @filter) @tasks | |
| dblClick: .editing = True | |
| class<done>: .done | |
| ) | |
| textbox(sync: .text, if: .editing) | |
| .text(if: not .editing) {.text} | |
| button.remove(click: :remove task) x | |
| button.done(click: .done = true) done | |
| button.clear-done(click: :clearDone) | |
| .items-left {length <| filter (not << eq <| .done) @tasks} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment