Class: UI::SidebarHeader

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

Overview

Header - Phlex implementation

Fixed header section at the top of the sidebar.

Examples:

Basic usage

render UI::Header.new do
  # Header content (logo, brand, etc.)
end

Instance Method Summary collapse

Methods included from SidebarHeaderBehavior

#sidebar_header_classes, #sidebar_header_data_attributes, #sidebar_header_html_attributes

Constructor Details

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

Returns a new instance of SidebarHeader.

Parameters:

  • classes (String) (defaults to: "")

    Additional CSS classes

  • attributes (Hash)

    Additional HTML attributes



16
17
18
19
# File 'app/components/ui/sidebar_header.rb', line 16

def initialize(classes: "", **attributes)
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/components/ui/sidebar_header.rb', line 21

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