Class: UI::SidebarGroupContent

Inherits:
Phlex::HTML
  • Object
show all
Includes:
SidebarGroupContentBehavior
Defined in:
app/components/ui/sidebar_group_content.rb

Overview

GroupContent - Phlex implementation

Container for content within a sidebar group. Typically wraps a SidebarMenu.

Examples:

Basic usage

render UI::GroupContent.new do
  render UI::Menu.new { ... }
end

Inside a collapsible group

render UI::CollapsibleContent.new do
  render UI::GroupContent.new do
    render UI::Menu.new { ... }
  end
end

Instance Method Summary collapse

Methods included from SidebarGroupContentBehavior

#sidebar_group_content_classes, #sidebar_group_content_data_attributes, #sidebar_group_content_html_attributes

Constructor Details

#initialize(classes: "", **attributes) ⇒ SidebarGroupContent

Returns a new instance of SidebarGroupContent.



22
23
24
25
# File 'app/components/ui/sidebar_group_content.rb', line 22

def initialize(classes: "", **attributes)
  @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
# File 'app/components/ui/sidebar_group_content.rb', line 27

def view_template(&block)
  all_attributes = sidebar_group_content_html_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