Class: FoxTail::FAB::ItemComponent
- Inherits:
-
IconButtonComponent
- Object
- IconButtonComponent
- FoxTail::FAB::ItemComponent
- Defined in:
- app/components/fox_tail/f_a_b/item_component.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{color: :light, variant: :solid}.freeze
Instance Method Summary collapse
- #before_render ⇒ Object
- #call ⇒ Object
-
#initialize(icon_or_attributes = {}, html_attributes = {}) ⇒ ItemComponent
constructor
A new instance of ItemComponent.
- #size ⇒ Object
- #tag_id ⇒ Object
- #tooltip_id ⇒ Object
Constructor Details
#initialize(icon_or_attributes = {}, html_attributes = {}) ⇒ ItemComponent
Returns a new instance of ItemComponent.
10 11 12 13 14 15 16 17 18 |
# File 'app/components/fox_tail/f_a_b/item_component.rb', line 10 def initialize(icon_or_attributes = {}, html_attributes = {}) if icon_or_attributes.is_a? Hash icon_or_attributes.reverse_merge! DEFAULT_OPTIONS else html_attributes.reverse_merge! DEFAULT_OPTIONS end super end |
Instance Method Details
#before_render ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/components/fox_tail/f_a_b/item_component.rb', line 20 def before_render super html_attributes[:class] = classnames theme.apply(:root, self), html_class if label_style == :tooltip && self.class.use_stimulus? trigger_component = FoxTail::TooltipTriggerComponent.new tag_id, "##{tooltip_id}", trigger_type: :hover = trigger_component. attributes = FoxTail::TooltipTriggerComponent.stimulus_controller.attributes stimulus_merger.merge_attributes! html_attributes, attributes end end |
#call ⇒ Object
48 49 50 51 52 53 |
# File 'app/components/fox_tail/f_a_b/item_component.rb', line 48 def call capture do concat concat render_tooltip if label_style == :tooltip end end |
#size ⇒ Object
41 42 43 |
# File 'app/components/fox_tail/f_a_b/item_component.rb', line 41 def size :fab end |
#tag_id ⇒ Object
33 34 35 |
# File 'app/components/fox_tail/f_a_b/item_component.rb', line 33 def tag_id html_attributes[:id] ||= :"fab_item_#{SecureRandom.hex(4)}" end |
#tooltip_id ⇒ Object
37 38 39 |
# File 'app/components/fox_tail/f_a_b/item_component.rb', line 37 def tooltip_id :"tooltip_#{tag_id}" end |