Class: FoxTail::PopoverComponent
- Inherits:
-
BaseComponent
show all
- Includes:
- Concerns::HasStimulusController, Concerns::Identifiable
- Defined in:
- app/components/fox_tail/popover_component.rb
Defined Under Namespace
Classes: StimulusController
Instance Attribute Summary
#html_attributes
Instance Method Summary
collapse
classname_merger, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class
Methods inherited from Base
fox_tail_config
Constructor Details
#initialize(id_or_attributes = {}, html_attributes = {}) ⇒ PopoverComponent
Returns a new instance of PopoverComponent.
30
31
32
33
34
35
36
37
38
39
|
# File 'app/components/fox_tail/popover_component.rb', line 30
def initialize(id_or_attributes = {}, html_attributes = {})
if id_or_attributes.is_a? Hash
html_attributes = id_or_attributes
else
__id_argument_deprecated_warning
html_attributes[:id] = id_or_attributes
end
super(html_attributes)
end
|
Instance Method Details
#before_render ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'app/components/fox_tail/popover_component.rb', line 45
def before_render
super
generate_unique_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, stimulus_controller_options if use_stimulus?
end
|
#call ⇒ Object
54
55
56
57
58
59
|
# File 'app/components/fox_tail/popover_component.rb', line 54
def call
capture do
concat trigger if trigger?
concat render_popover
end
end
|
#stimulus_controller_options ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'app/components/fox_tail/popover_component.rb', line 61
def stimulus_controller_options
{
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
41
42
43
|
# File 'app/components/fox_tail/popover_component.rb', line 41
def trigger_id
options[:trigger_id] ||= :"#{id}_trigger"
end
|