Class: UI::FieldSeparatorComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
FieldSeparatorBehavior
Defined in:
app/view_components/ui/field_separator_component.rb

Overview

FieldSeparatorComponent - ViewComponent implementation

Visual divider to separate sections inside FieldGroup. Uses FieldSeparatorBehavior concern for shared styling logic.

Examples:

Basic separator (line only)

<%= render UI::FieldSeparatorComponent.new %>

With block

<%= render UI::FieldSeparatorComponent.new do %>
  OR
<% end %>

Instance Method Summary collapse

Methods included from FieldSeparatorBehavior

#field_separator_classes, #field_separator_html_attributes, #has_content?

Constructor Details

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

Returns a new instance of FieldSeparatorComponent.

Parameters:

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



20
21
22
23
# File 'app/view_components/ui/field_separator_component.rb', line 20

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

Instance Method Details

#callObject



25
26
27
28
29
30
31
32
33
# File 'app/view_components/ui/field_separator_component.rb', line 25

def call
   :div, **field_separator_html_attributes do
    if content?
      render_with_label
    else
      render_line_only
    end
  end
end