Class: FoxTail::PopoverComponent::StimulusController

Inherits:
StimulusController show all
Defined in:
app/components/fox_tail/popover_component.rb

Constant Summary collapse

TRIGGER_TYPES =
{
  hover: {
    hoverShow: :mouseenter,
    hoverHide: :mouseleave
  }
}.freeze

Instance Attribute Summary

Attributes inherited from StimulusController

#identifier

Instance Method Summary collapse

Methods inherited from StimulusController

#action, #action_param_key, #build_actions, #classes_key, #config, #event, #initialize, #merge, #merge!, #outlet_key, #target_key, #to_s, #to_sym, #value_key

Constructor Details

This class inherits a constructor from FoxTail::StimulusController

Instance Method Details

#attributes(options = {}) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'app/components/fox_tail/popover_component.rb', line 101

def attributes(options = {})
  trigger_type = options[:trigger_type]&.to_sym
  attributes = super
  attributes[:data][value_key(:placement)] = options[:placement]
  attributes[:data][value_key(:offset)] = options[:offset]
  attributes[:data][value_key(:shift)] = options[:shift]
  attributes[:data][value_key(:inline)] = options[:inline]
  attributes[:data][value_key(:delay)] = options[:delay]
  attributes[:data][outlet_key(trigger_identifier)] = "##{options[:trigger_id]}"
  attributes[:data][classes_key(:hidden)] = options[:hidden_classes]
  attributes[:data][classes_key(:visible)] = options[:visible_classes]
  attributes[:data][:action] = build_actions TRIGGER_TYPES[trigger_type]
  attributes
end

#trigger_identifierObject



97
98
99
# File 'app/components/fox_tail/popover_component.rb', line 97

def trigger_identifier
  FoxTail::PopoverTriggerComponent.stimulus_controller_identifier
end