Last active
March 26, 2019 03:53
-
-
Save catmando/c2dda4eec48f0036179a0932c2163170 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
class TodoIndex < HyperComponent | |
def create_new_todo_item | |
Todo.create(title: @title) | |
@title = nil | |
end | |
render(DIV, class: 'ToDo') do | |
IMG(class: 'Logo', src: 'assets/logo.png', alt: 'Hyperstack Logo') | |
H1(class: 'ToDo-Header') { 'Hyperstack To Do' } | |
DIV(class: 'ToDo-Container') do | |
DIV(class: 'ToDo-Content') do | |
Todo.each do |item| | |
TodoItem(key: item, item: item.title) | |
.on(:delete_item) { item.destroy } | |
end | |
end | |
DIV do | |
INPUT(type: :text, value: @title) | |
.on(:change) { |e| mutate @title = e.target.value } | |
.on(:enter) { create_new_todo_item } | |
BUTTON(class: 'ToDo-Add') { '+' } | |
.on(:click) { create_new_todo_item } | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment