Class: FoxTail::TooltipComponent
- Inherits:
-
BaseComponent
show all
- Includes:
- Concerns::HasStimulusController, Concerns::Identifiable
- Defined in:
- app/components/fox_tail/tooltip_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 = {}) ⇒ TooltipComponent
Returns a new instance of TooltipComponent.
20
21
22
23
24
25
26
27
28
29
|
# File 'app/components/fox_tail/tooltip_component.rb', line 20
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
35
36
37
38
39
40
41
|
# File 'app/components/fox_tail/tooltip_component.rb', line 35
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
end
|
#call ⇒ Object
43
44
45
46
47
48
|
# File 'app/components/fox_tail/tooltip_component.rb', line 43
def call
capture do
concat trigger if trigger?
concat render_tooltip
end
end
|
#stimulus_controller_options ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/components/fox_tail/tooltip_component.rb', line 50
def stimulus_controller_options
{
trigger_id: trigger_id,
placement: placement,
offset: offset,
shift: shift,
inline: inline?,
visible_classes: theme.apply("root/visible", self),
hidden_classes: theme.apply("root/hidden", self)
}
end
|
#trigger_id ⇒ Object
31
32
33
|
# File 'app/components/fox_tail/tooltip_component.rb', line 31
def trigger_id
options[:trigger_id] ||= :"#{id}_trigger"
end
|