Module: UI::FieldDescriptionBehavior
- Included in:
- FieldDescription, FieldDescriptionComponent
- Defined in:
- app/behaviors/ui/field_description_behavior.rb
Overview
FieldDescriptionBehavior
Shared behavior for FieldDescription component across ERB, ViewComponent, and Phlex implementations. FieldDescription provides helper text for form fields.
Instance Method Summary collapse
-
#field_description_classes ⇒ Object
Returns combined CSS classes for the field description.
-
#field_description_html_attributes ⇒ Object
Returns HTML attributes for the field description element.
Instance Method Details
#field_description_classes ⇒ Object
Returns combined CSS classes for the field description
18 19 20 21 22 23 |
# File 'app/behaviors/ui/field_description_behavior.rb', line 18 def field_description_classes classes_value = respond_to?(:classes, true) ? classes : @classes base = "text-muted-foreground text-sm leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5 [&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4" TailwindMerge::Merger.new.merge([base, classes_value].compact.join(" ")) end |
#field_description_html_attributes ⇒ Object
Returns HTML attributes for the field description element
9 10 11 12 13 14 15 |
# File 'app/behaviors/ui/field_description_behavior.rb', line 9 def field_description_html_attributes attributes_value = respond_to?(:attributes, true) ? attributes : @attributes { "data-slot": "field-description", class: field_description_classes }.merge(attributes_value).compact end |