Class: UI::SidebarMenuAction
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::SidebarMenuAction
- Includes:
- SidebarMenuActionBehavior
- Defined in:
- app/components/ui/sidebar_menu_action.rb
Overview
MenuAction - Phlex implementation
Action button within a sidebar menu item, appears on hover/focus. Typically used for dropdown menus or quick actions.
Instance Method Summary collapse
-
#initialize(show_on_hover: false, as_child: false, classes: "", **attributes) ⇒ SidebarMenuAction
constructor
A new instance of SidebarMenuAction.
- #view_template(&block) ⇒ Object
Methods included from SidebarMenuActionBehavior
#sidebar_menu_action_classes, #sidebar_menu_action_data_attributes, #sidebar_menu_action_html_attributes
Constructor Details
#initialize(show_on_hover: false, as_child: false, classes: "", **attributes) ⇒ SidebarMenuAction
Returns a new instance of SidebarMenuAction.
34 35 36 37 38 39 |
# File 'app/components/ui/sidebar_menu_action.rb', line 34 def initialize(show_on_hover: false, as_child: false, classes: "", **attributes) @show_on_hover = show_on_hover @as_child = as_child @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/components/ui/sidebar_menu_action.rb', line 41 def view_template(&block) if @as_child yield .deep_merge(@attributes) else all_attributes = if @attributes.key?(:class) merged_class = TailwindMerge::Merger.new.merge([ all_attributes[:class], @attributes[:class] ].compact.join(" ")) all_attributes = all_attributes.merge(class: merged_class) end all_attributes = all_attributes.deep_merge(@attributes.except(:class)) (**all_attributes, &block) end end |