Module: UI::FieldContentBehavior

Included in:
FieldContent, FieldContentComponent
Defined in:
app/behaviors/ui/field_content_behavior.rb

Overview

FieldContentBehavior

Shared behavior for FieldContent component across ERB, ViewComponent, and Phlex implementations. FieldContent is a flex column that groups control and descriptions.

Instance Method Summary collapse

Instance Method Details

#field_content_classesObject

Returns combined CSS classes for the field content



18
19
20
21
22
23
# File 'app/behaviors/ui/field_content_behavior.rb', line 18

def field_content_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  base = "group/field-content flex flex-1 flex-col gap-1.5 leading-snug"

  TailwindMerge::Merger.new.merge([base, classes_value].compact.join(" "))
end

#field_content_html_attributesObject

Returns HTML attributes for the field content wrapper element



9
10
11
12
13
14
15
# File 'app/behaviors/ui/field_content_behavior.rb', line 9

def field_content_html_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  {
    "data-slot": "field-content",
    class: field_content_classes
  }.merge(attributes_value).compact
end