Class: UI::SidebarRail

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

Overview

Rail - Phlex implementation

Invisible rail on the sidebar edge for drag-to-expand interaction.

Examples:

Basic usage

render UI::Sidebar.new do
  render UI::Rail.new
  # other content...
end

Instance Method Summary collapse

Methods included from SidebarRailBehavior

#sidebar_rail_classes, #sidebar_rail_data_attributes, #sidebar_rail_html_attributes

Constructor Details

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

Returns a new instance of SidebarRail.



15
16
17
18
# File 'app/components/ui/sidebar_rail.rb', line 15

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

Instance Method Details

#view_templateObject



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

def view_template
  all_attributes = sidebar_rail_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))

  button(**all_attributes)
end