Class: UI::FieldLegendComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
FieldLegendBehavior
Defined in:
app/view_components/ui/field_legend_component.rb

Overview

FieldLegendComponent - ViewComponent implementation

Legend element for FieldSet with variant support. Uses FieldLegendBehavior concern for shared styling logic.

Examples:

With block

<%= render UI::FieldLegendComponent.new do %>
  Personal Information
<% end %>

With variant

<%= render UI::FieldLegendComponent.new(variant: "label") do %>
  Settings
<% end %>

Instance Method Summary collapse

Methods included from FieldLegendBehavior

#field_legend_classes, #field_legend_html_attributes

Constructor Details

#initialize(variant: "legend", classes: "", **attributes) ⇒ FieldLegendComponent

Returns a new instance of FieldLegendComponent.

Parameters:

  • variant (String) (defaults to: "legend")

    Style variant: “legend” or “label”

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



23
24
25
26
27
# File 'app/view_components/ui/field_legend_component.rb', line 23

def initialize(variant: "legend", classes: "", **attributes)
  @variant = variant
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



29
30
31
32
33
# File 'app/view_components/ui/field_legend_component.rb', line 29

def call
   :legend, **field_legend_html_attributes do
    content
  end
end