Class: FoxTail::IconButtonComponent

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

Direct Known Subclasses

FAB::ItemComponent

Instance Attribute Summary

Attributes inherited from BaseComponent

#html_attributes

Instance Method Summary collapse

Methods inherited from ButtonBaseComponent

#before_render

Methods inherited from ClickableComponent

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

Methods inherited from BaseComponent

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

Methods inherited from Base

fox_tail_config

Constructor Details

#initialize(icon_or_attributes = {}, html_attributes = {}) ⇒ IconButtonComponent

Returns a new instance of IconButtonComponent.



9
10
11
12
13
14
15
16
17
18
# File 'app/components/fox_tail/icon_button_component.rb', line 9

def initialize(icon_or_attributes = {}, html_attributes = {})
  if icon_or_attributes.is_a? Hash
    html_attributes = icon_or_attributes
    icon_or_attributes = nil
  end

  super(html_attributes)

  with_icon icon_or_attributes if icon_or_attributes.present?
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
29
# File 'app/components/fox_tail/icon_button_component.rb', line 20

def call
  super do
    icons.each { |icon| concat icon }
    concat indicator if indicator?

    if content? || i18n_content.present?
      concat (:span, retrieve_content, class: theme.apply(:content, self))
    end
  end
end