Class: UI::FieldSeparator

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

Overview

Separator - Phlex implementation

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

Examples:

Basic separator (line only)

render UI::Separator.new

With label

render UI::Separator.new { "OR" }

Instance Method Summary collapse

Methods included from FieldSeparatorBehavior

#field_separator_classes, #field_separator_html_attributes, #has_content?

Constructor Details

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

Returns a new instance of FieldSeparator.

Parameters:

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



18
19
20
21
22
# File 'app/components/ui/field_separator.rb', line 18

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

Instance Method Details

#view_template(&block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'app/components/ui/field_separator.rb', line 24

def view_template(&block)
  @block_given = block_given?

  div(**field_separator_html_attributes) do
    if @block_given
      render_with_label(&block)
    else
      render_line_only
    end
  end
end