Class: UI::CollapsibleTrigger

Inherits:
Phlex::HTML
  • Object
show all
Includes:
CollapsibleTriggerBehavior
Defined in:
app/components/ui/collapsible_trigger.rb

Constant Summary

Constants included from CollapsibleTriggerBehavior

UI::CollapsibleTriggerBehavior::TRIGGER_BASE_CLASSES

Instance Method Summary collapse

Methods included from CollapsibleTriggerBehavior

#collapsible_trigger_classes, #collapsible_trigger_data_attributes, #collapsible_trigger_html_attributes

Constructor Details

#initialize(as_child: false, classes: "", **attributes) ⇒ CollapsibleTrigger

Returns a new instance of CollapsibleTrigger.



6
7
8
9
10
# File 'app/components/ui/collapsible_trigger.rb', line 6

def initialize(as_child: false, classes: "", **attributes)
  @as_child = as_child
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'app/components/ui/collapsible_trigger.rb', line 12

def view_template(&block)
  trigger_attrs = collapsible_trigger_html_attributes.deep_merge(@attributes)

  if @as_child
    yield(trigger_attrs) if block_given?
  else
    button(**trigger_attrs, type: "button", &block)
  end
end