Class: Matestack::Ui::Bootstrap::Components::Button

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/matestack/ui/bootstrap/components/button.rb

Instance Method Summary collapse

Instance Method Details

#button_response(&block) ⇒ Object



34
35
36
37
38
# File 'lib/matestack/ui/bootstrap/components/button.rb', line 34

def button_response(&block)
  button button_attributes do
    inner_response(&block)
  end
end

#inner_response(&block) ⇒ Object



40
41
42
43
# File 'lib/matestack/ui/bootstrap/components/button.rb', line 40

def inner_response(&block)
  plain context.text if context.text
  yield if block_given?
end

#response(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/matestack/ui/bootstrap/components/button.rb', line 12

def response(&block)
  if context.transition.present? && context.transition.is_a?(Hash)
    transition button_attributes.merge(context.transition.merge({role: "button"})) do
      inner_response(&block)
    end
  elsif context.action.present? && context.action.is_a?(Hash)
    action button_attributes.merge(context.action.merge({role: "button"})) do
      inner_response(&block)
    end
  elsif context.onclick.present? && context.onclick.is_a?(Hash)
    onclick button_attributes.merge(context.onclick.merge({role: "button"})) do
      inner_response(&block)
    end
  elsif context.link.present? && context.link.is_a?(Hash)
    a button_attributes.merge(context.link.merge({role: "button"})) do
      inner_response(&block)
    end
  else
    button_response(&block)
  end
end