Class: UI::SidebarGroupLabel
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::SidebarGroupLabel
- Includes:
- SidebarGroupLabelBehavior
- Defined in:
- app/components/ui/sidebar_group_label.rb
Overview
GroupLabel - Phlex implementation
Label/header for a sidebar group. Can be used with UI::CollapsibleTrigger for collapsible groups.
Instance Method Summary collapse
-
#initialize(as_child: false, classes: "", **attributes) ⇒ SidebarGroupLabel
constructor
A new instance of SidebarGroupLabel.
- #view_template(&block) ⇒ Object
Methods included from SidebarGroupLabelBehavior
#sidebar_group_label_classes, #sidebar_group_label_data_attributes, #sidebar_group_label_html_attributes
Constructor Details
#initialize(as_child: false, classes: "", **attributes) ⇒ SidebarGroupLabel
Returns a new instance of SidebarGroupLabel.
21 22 23 24 25 |
# File 'app/components/ui/sidebar_group_label.rb', line 21 def initialize(as_child: false, classes: "", **attributes) @as_child = as_child @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/ui/sidebar_group_label.rb', line 27 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)) div(**all_attributes, &block) end end |