Module: UI::FieldLegendBehavior

Included in:
FieldLegend, FieldLegendComponent
Defined in:
app/behaviors/ui/field_legend_behavior.rb

Overview

UI::FieldLegendBehavior

Instance Method Summary collapse

Instance Method Details

#field_legend_classesObject

Returns combined CSS classes for the field legend



26
27
28
29
30
31
# File 'app/behaviors/ui/field_legend_behavior.rb', line 26

def field_legend_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  base = "mb-3 font-medium data-[variant=legend]:text-base data-[variant=label]:text-sm"

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

#field_legend_html_attributesObject

Returns HTML attributes for the field legend element



15
16
17
18
19
20
21
22
23
# File 'app/behaviors/ui/field_legend_behavior.rb', line 15

def field_legend_html_attributes
  attributes_value = respond_to?(:attributes, true) ? attributes : @attributes
  variant_value = @variant.to_s.presence || "legend"
  {
    "data-slot": "field-legend",
    "data-variant": variant_value,
    class: field_legend_classes
  }.merge(attributes_value).compact
end