Module: UI::FieldSeparatorBehavior
- Included in:
- FieldSeparator, FieldSeparatorComponent
- Defined in:
- app/behaviors/ui/field_separator_behavior.rb
Overview
FieldSeparatorBehavior
Shared behavior for FieldSeparator component across ERB, ViewComponent, and Phlex implementations. FieldSeparator provides visual divider to separate sections inside FieldGroup.
Instance Method Summary collapse
-
#field_separator_classes ⇒ Object
Returns combined CSS classes for the field separator.
-
#field_separator_html_attributes ⇒ Object
Returns HTML attributes for the field separator element.
-
#has_content? ⇒ Boolean
Returns true if separator has content (text/label).
Instance Method Details
#field_separator_classes ⇒ Object
Returns combined CSS classes for the field separator
20 21 22 23 24 25 |
# File 'app/behaviors/ui/field_separator_behavior.rb', line 20 def field_separator_classes classes_value = respond_to?(:classes, true) ? classes : @classes base = "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2" TailwindMerge::Merger.new.merge([base, classes_value].compact.join(" ")) end |
#field_separator_html_attributes ⇒ Object
Returns HTML attributes for the field separator element
9 10 11 12 13 14 15 16 17 |
# File 'app/behaviors/ui/field_separator_behavior.rb', line 9 def field_separator_html_attributes attributes_value = respond_to?(:attributes, true) ? attributes : @attributes has_content = has_content? { "data-slot": "field-separator", "data-content": has_content ? "true" : nil, class: field_separator_classes }.merge(attributes_value).compact end |
#has_content? ⇒ Boolean
Returns true if separator has content (text/label)
28 29 30 |
# File 'app/behaviors/ui/field_separator_behavior.rb', line 28 def has_content? @content.present? || (@block_given if defined?(@block_given)) end |