Last active
June 20, 2017 15:39
-
-
Save askucher/736dd3381723dc7fe2119e65f288559e to your computer and use it in GitHub Desktop.
Example of reactify-ls
This file contains 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
require! { | |
\mobx-react : { observer } | |
\mobx : { observable } | |
\react-dom : { render } | |
\react | |
} | |
btn = ({click, text})-> | |
style = | |
color: \red | |
padding-left: \5px | |
a.pug.btn(target='blank' on-click=click style=style) #{text} | |
input = ({store})-> | |
handle-enter-click = (event) -> | |
return if event.key-code isnt 13 | |
store.todos.push text: event.target.value | |
event.target.value = '' | |
input.pug(on-key-down=handle-enter-click) | |
Main = observer ({store})-> | |
remove = (todo, _)--> | |
index = store.todos.index-of todo | |
return if index < 0 | |
store.todos.splice 1, index | |
.pug | |
h3.pug Tasks | |
for todo in store.todos | |
.pug | |
span.pug #{todo.text} | |
span.pug | |
btn {text: 'Remove', click: remove todo} | |
input { store } | |
window.onload = -> | |
store = observable do | |
todos: | |
* text: 'Do dishes' | |
... | |
render do | |
Main.pug(store=store) | |
document.body.append-child document.create-element \app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment