Class: FoxTail::PopoverComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- Base
- BaseComponent
- FoxTail::PopoverComponent
- Includes:
- Concerns::HasStimulusController
- Defined in:
- app/components/fox_tail/popover_component.rb
Defined Under Namespace
Classes: StimulusController
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Attributes inherited from BaseComponent
Instance Method Summary collapse
- #before_render ⇒ Object
- #call ⇒ Object
-
#initialize(id, html_attributes = {}) ⇒ PopoverComponent
constructor
A new instance of PopoverComponent.
- #stimulus_controller_options ⇒ Object
- #trigger_id ⇒ Object
Methods inherited from BaseComponent
classname_merger, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class
Methods inherited from Base
Constructor Details
#initialize(id, html_attributes = {}) ⇒ PopoverComponent
Returns a new instance of PopoverComponent.
30 31 32 33 |
# File 'app/components/fox_tail/popover_component.rb', line 30 def initialize(id, html_attributes = {}) super(html_attributes) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'app/components/fox_tail/popover_component.rb', line 6 def id @id end |
Instance Method Details
#before_render ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'app/components/fox_tail/popover_component.rb', line 39 def before_render super html_attributes[:id] = id html_attributes[:role] ||= :tooltip html_attributes[:class] = classnames theme.apply(:root, self), theme.apply("root/hidden", self), html_class stimulus_controller.merge! html_attributes, if use_stimulus? end |
#call ⇒ Object
48 49 50 51 52 53 |
# File 'app/components/fox_tail/popover_component.rb', line 48 def call capture do concat trigger if trigger? concat render_popover end end |
#stimulus_controller_options ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/components/fox_tail/popover_component.rb', line 55 def { trigger_id: trigger_id, placement: placement, offset: offset, shift: shift, inline: inline?, delay: delay, trigger_type: trigger_type, visible_classes: theme.apply("root/visible", self), hidden_classes: theme.apply("root/hidden", self) } end |
#trigger_id ⇒ Object
35 36 37 |
# File 'app/components/fox_tail/popover_component.rb', line 35 def trigger_id [:trigger_id] ||= :"#{id}_trigger" end |