Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AndyObtiva/5e55425ac014d7943693ee8c0fb93ebd to your computer and use it in GitHub Desktop.
Save AndyObtiva/5e55425ac014d7943693ee8c0fb93ebd to your computer and use it in GitHub Desktop.
Glimmer DSL for Web - Regular Sample - Todo MVC - Views - NewTodoInput
# Source: https://github.com/AndyObtiva/glimmer-dsl-web/blob/master/lib/glimmer-dsl-web/samples/regular/todo_mvc/views/new_todo_input.rb
require_relative 'todo_input'
class NewTodoInput < TodoInput
option :presenter
markup {
input(class: todo_input_class, placeholder: "What needs to be done?", autofocus: "") {
# Data-bind `input` `value` property bidirectionally to `presenter.new_todo` `task` attribute
# meaning make any changes to the new todo task automatically update the input value
# and any changes to the input value by the user automatically update the new todo task value
value <=> [presenter.new_todo, :task]
onkeyup do |event|
presenter.create_todo if event.key == 'Enter' || event.keyCode == "\r"
end
style {
todo_input_styles
}
}
}
def todo_input_class
'new-todo'
end
def todo_input_styles
super
rule(".#{todo_input_class}") {
padding '16px 16px 16px 60px'
height '65px'
border 'none'
background 'rgba(0, 0, 0, 0.003)'
box_shadow 'inset 0 -2px 1px rgba(0,0,0,0.03)'
}
rule(".#{todo_input_class}::placeholder") {
font_style 'italic'
font_weight '400'
color 'rgba(0, 0, 0, 0.4)'
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment