Class: UI::DropdownMenuTrigger
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::DropdownMenuTrigger
- Includes:
- DropdownMenuTriggerBehavior, SharedAsChildBehavior
- Defined in:
- app/components/ui/dropdown_menu_trigger.rb
Overview
Trigger - Phlex implementation
Wrapper that adds toggle action to child element. Uses DropdownMenuTriggerBehavior concern for shared styling logic.
Supports asChild pattern for composition without wrapper elements.
Instance Method Summary collapse
-
#initialize(as_child: false, classes: "", **attributes) ⇒ DropdownMenuTrigger
constructor
A new instance of DropdownMenuTrigger.
- #view_template(&block) ⇒ Object
Methods included from SharedAsChildBehavior
Methods included from DropdownMenuTriggerBehavior
#dropdown_menu_trigger_base_classes, #dropdown_menu_trigger_classes, #dropdown_menu_trigger_data_attributes, #dropdown_menu_trigger_html_attributes
Constructor Details
#initialize(as_child: false, classes: "", **attributes) ⇒ DropdownMenuTrigger
Returns a new instance of DropdownMenuTrigger.
24 25 26 27 28 |
# File 'app/components/ui/dropdown_menu_trigger.rb', line 24 def initialize(as_child: false, classes: "", **attributes) @as_child = as_child @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/components/ui/dropdown_menu_trigger.rb', line 30 def view_template(&block) trigger_attrs = .deep_merge(@attributes) if @as_child # When as_child is true, only pass functional attributes (data, aria, tabindex, role) # The child component handles its own styling (following shadcn pattern) yield(trigger_attrs.except(:class)) if block_given? else # Default: render wrapper div with trigger behavior div(**trigger_attrs) do yield if block_given? end end end |