Class: UI::SidebarGroupAction
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::SidebarGroupAction
- Includes:
- SidebarGroupActionBehavior
- Defined in:
- app/components/ui/sidebar_group_action.rb
Overview
GroupAction - Phlex implementation
Action button within a sidebar group header. Typically used for actions like “Add” or contextual menus.
Instance Method Summary collapse
-
#initialize(as_child: false, classes: "", **attributes) ⇒ SidebarGroupAction
constructor
A new instance of SidebarGroupAction.
- #view_template(&block) ⇒ Object
Methods included from SidebarGroupActionBehavior
#sidebar_group_action_classes, #sidebar_group_action_data_attributes, #sidebar_group_action_html_attributes
Constructor Details
#initialize(as_child: false, classes: "", **attributes) ⇒ SidebarGroupAction
Returns a new instance of SidebarGroupAction.
22 23 24 25 26 |
# File 'app/components/ui/sidebar_group_action.rb', line 22 def initialize(as_child: false, classes: "", **attributes) @as_child = as_child @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/components/ui/sidebar_group_action.rb', line 28 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 |