Class: Tramway::TooltipComponent
Overview
Constant Summary
collapse
- EVENTS =
%i[hover onclick].freeze
Helpers::ViewsHelper::FORM_SIZES
Instance Method Summary
collapse
#tramway_back_button, #tramway_badge, #tramway_button, #tramway_cell, #tramway_chat, #tramway_container, #tramway_flash, #tramway_form_for, #tramway_header, #tramway_main_container, #tramway_row, #tramway_table, #tramway_title, #tramway_tooltip
#component
#tramway_decorate
Instance Method Details
#normalized_event ⇒ Object
53
54
55
|
# File 'app/components/tramway/tooltip_component.rb', line 53
def normalized_event
event.to_sym
end
|
49
50
51
|
# File 'app/components/tramway/tooltip_component.rb', line 49
def tooltip_classes
(base_tooltip_classes + event_tooltip_classes).join(' ')
end
|
43
44
45
46
47
|
# File 'app/components/tramway/tooltip_component.rb', line 43
def tooltip_data
return {} unless normalized_event == :onclick
{ 'tramway-tooltip-target': 'panel' }
end
|
#trigger_classes ⇒ Object
17
18
19
20
21
22
|
# File 'app/components/tramway/tooltip_component.rb', line 17
def trigger_classes
{
hover: %w[peer inline-flex w-fit],
onclick: %w[inline-flex w-fit cursor-pointer]
}[normalized_event].join(' ')
end
|
#trigger_data ⇒ Object
37
38
39
40
41
|
# File 'app/components/tramway/tooltip_component.rb', line 37
def trigger_data
return {} unless normalized_event == :onclick
{ action: 'click->tramway-tooltip#toggle' }
end
|
#wrapper_classes ⇒ Object
13
14
15
|
# File 'app/components/tramway/tooltip_component.rb', line 13
def wrapper_classes
(base_wrapper_classes + options[:class].to_s.split).compact.join(' ')
end
|
#wrapper_data ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'app/components/tramway/tooltip_component.rb', line 24
def wrapper_data
return options[:data] || {} unless normalized_event == :onclick
(options[:data] || {}).merge(
controller: merged_controller,
action: merged_action
)
end
|
#wrapper_options ⇒ Object
33
34
35
|
# File 'app/components/tramway/tooltip_component.rb', line 33
def wrapper_options
options.except(:class, :data).merge(data: wrapper_data)
end
|