Class: UI::NavigationMenuTriggerComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
NavigationMenuTriggerBehavior
Defined in:
app/view_components/ui/navigation_menu_trigger_component.rb

Overview

TriggerComponent - ViewComponent implementation

Button that toggles the navigation menu content. Includes an animated chevron icon.

Instance Method Summary collapse

Methods included from NavigationMenuTriggerBehavior

#navigation_menu_trigger_chevron_classes, #navigation_menu_trigger_classes, #navigation_menu_trigger_data_attributes, #navigation_menu_trigger_html_attributes

Constructor Details

#initialize(first: false, classes: "", **attributes) ⇒ NavigationMenuTriggerComponent

Returns a new instance of NavigationMenuTriggerComponent.

Parameters:

  • first (Boolean) (defaults to: false)

    Whether this is the first trigger (gets tabindex=0)

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



13
14
15
16
17
# File 'app/view_components/ui/navigation_menu_trigger_component.rb', line 13

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

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
# File 'app/view_components/ui/navigation_menu_trigger_component.rb', line 19

def call
   :button, **navigation_menu_trigger_html_attributes.deep_merge(@attributes) do
    safe_join([
      content,
      chevron_icon
    ])
  end
end