Class: UI::DropdownMenu
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::DropdownMenu
- Includes:
- DropdownMenuBehavior, SharedAsChildBehavior
- Defined in:
- app/components/ui/dropdown_menu.rb
Overview
DropdownMenu - Phlex implementation
Container for dropdown menus with Stimulus controller for interactivity. Uses DropdownMenuBehavior concern for shared styling logic.
Supports asChild pattern for composition without wrapper elements.
Instance Method Summary collapse
-
#initialize(as_child: false, placement: "bottom-start", offset: 4, flip: true, classes: "", **attributes) ⇒ DropdownMenu
constructor
A new instance of DropdownMenu.
- #view_template(&block) ⇒ Object
Methods included from SharedAsChildBehavior
Methods included from DropdownMenuBehavior
#dropdown_menu_classes, #dropdown_menu_data_attributes, #dropdown_menu_html_attributes
Constructor Details
#initialize(as_child: false, placement: "bottom-start", offset: 4, flip: true, classes: "", **attributes) ⇒ DropdownMenu
Returns a new instance of DropdownMenu.
34 35 36 37 38 39 40 41 |
# File 'app/components/ui/dropdown_menu.rb', line 34 def initialize(as_child: false, placement: "bottom-start", offset: 4, flip: true, classes: "", **attributes) @as_child = as_child @placement = placement @offset = offset @flip = flip @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/components/ui/dropdown_menu.rb', line 43 def view_template(&block) dropdown_attrs = .deep_merge(@attributes) if @as_child # Yield data attributes to block - child receives controller setup yield(dropdown_attrs) if block_given? else # Default: render wrapper div with controller div(**dropdown_attrs) do yield if block_given? end end end |