Class: FoxTail::ButtonComponent

Inherits:
ButtonBaseComponent show all
Defined in:
app/components/fox_tail/button_component.rb

Instance Attribute Summary

Attributes inherited from BaseComponent

#html_attributes

Instance Method Summary collapse

Methods inherited from ClickableComponent

#link?, #root_tag_name, stimulus_controller_name, #stimulus_controller_options, #use_stimulus?

Methods inherited from BaseComponent

classname_merger, #initialize, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class

Methods inherited from Base

fox_tail_config

Constructor Details

This class inherits a constructor from FoxTail::BaseComponent

Instance Method Details

#before_renderObject



50
51
52
53
54
# File 'app/components/fox_tail/button_component.rb', line 50

def before_render
  super

  with_loading_icon if !loading_icon? && loadable?
end

#callObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'app/components/fox_tail/button_component.rb', line 56

def call
  super do
    concat indicator if indicator?
    concat loading_icon if loading_icon?
    concat left_visual if left_visual?

    if loadable? && loading_label?
      if controlled?
        concat(
          (
            :span,
            loading_label,
            class: !loading? && theme.classname("hidden"),
            data: {stimulus_controller.target_key => "loading"}
          )
        )
        concat(
          (
            :span,
            content,
            class: loading? && theme.classname("hidden"),
            data: {stimulus_controller.target_key => "active"}
          )
        )
      else
        concat loading_label
      end
    else
      concat retrieve_content
    end

    concat right_visual if right_visual?
  end
end

#loadable?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/components/fox_tail/button_component.rb', line 42

def loadable?
  loading? || super
end

#visuals?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/components/fox_tail/button_component.rb', line 46

def visuals?
  loadable? || left_visual? || right_visual?
end