Class: UI::SidebarMenuBadge
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::SidebarMenuBadge
- Includes:
- SidebarMenuBadgeBehavior
- Defined in:
- app/components/ui/sidebar_menu_badge.rb
Overview
MenuBadge - Phlex implementation
Badge that appears at the end of a menu button. Used to display counts or status indicators.
Instance Method Summary collapse
-
#initialize(classes: "", **attributes) ⇒ SidebarMenuBadge
constructor
A new instance of SidebarMenuBadge.
- #view_template(&block) ⇒ Object
Methods included from SidebarMenuBadgeBehavior
#sidebar_menu_badge_classes, #sidebar_menu_badge_data_attributes, #sidebar_menu_badge_html_attributes
Constructor Details
#initialize(classes: "", **attributes) ⇒ SidebarMenuBadge
Returns a new instance of SidebarMenuBadge.
19 20 21 22 |
# File 'app/components/ui/sidebar_menu_badge.rb', line 19 def initialize(classes: "", **attributes) @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/components/ui/sidebar_menu_badge.rb', line 24 def view_template(&block) 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)) div(**all_attributes, &block) end |