Sha256: a2e7b48942970bf581430183385a68f543756774801a411e432a455940b97965
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
require_relative 'todo_input' class EditTodoInput < TodoInput option :presenter option :todo markup { # evaluated against instance as a smart default convention input { |edit_input| style <= [ todo, :editing, on_read: ->(editing) { editing ? '' : 'display: none;' }, after_read: -> { edit_input.focus if todo.editing? } ] value <=> [todo, :task] onkeyup do |event| if event.key == 'Enter' || event.keyCode == "\r" todo.save_editing presenter.destroy(todo) if todo.task.strip.empty? elsif event.key == 'Escape' || event.keyCode == 27 todo.cancel_editing end end onblur do |event| todo.save_editing end } } style { # evaluated against class as a smart default convention (common to all instances) todo_input_styles rule("*:has(> .#{component_element_class})") { position 'relative' } rule(".#{component_element_class}") { position 'absolute' display 'block' width 'calc(100% - 43px)' padding '12px 16px' margin '0 0 0 43px' top '0' } } end
Version data entries
3 entries across 3 versions & 1 rubygems