Class: UI::SidebarMenuSubButton
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::SidebarMenuSubButton
- Includes:
- SidebarMenuSubButtonBehavior
- Defined in:
- app/components/ui/sidebar_menu_sub_button.rb
Overview
MenuSubButton - Phlex implementation
Interactive button within a sidebar submenu item. Smaller than MenuButton, designed for nested navigation.
Constant Summary
Constants included from SidebarMenuSubButtonBehavior
UI::SidebarMenuSubButtonBehavior::SIZES
Instance Method Summary collapse
-
#initialize(size: :md, active: false, as_child: false, classes: "", **attributes) ⇒ SidebarMenuSubButton
constructor
A new instance of SidebarMenuSubButton.
- #view_template(&block) ⇒ Object
Methods included from SidebarMenuSubButtonBehavior
#sidebar_menu_sub_button_classes, #sidebar_menu_sub_button_data_attributes, #sidebar_menu_sub_button_html_attributes
Constructor Details
#initialize(size: :md, active: false, as_child: false, classes: "", **attributes) ⇒ SidebarMenuSubButton
Returns a new instance of SidebarMenuSubButton.
21 22 23 24 25 26 27 |
# File 'app/components/ui/sidebar_menu_sub_button.rb', line 21 def initialize(size: :md, active: false, as_child: false, classes: "", **attributes) @size = size.to_sym @active = active @as_child = as_child @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/components/ui/sidebar_menu_sub_button.rb', line 29 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)) a(**all_attributes, &block) end end |