Class: PhlexKit::FieldLegend

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/field/field_legend.rb

Overview

of a FieldSet, ported from shadcn/ui's FieldLegend. variant: :legend (text-base, default) or :label (text-sm — matches FieldLabel when the set sits among plain fields). See field.rb.

Constant Summary collapse

VARIANTS =
{ legend: "legend", label: "label" }.freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(variant: :legend, **attrs) ⇒ FieldLegend

Returns a new instance of FieldLegend.



8
9
10
11
# File 'app/components/phlex_kit/field/field_legend.rb', line 8

def initialize(variant: :legend, **attrs)
  @variant = variant.to_sym
  @attrs = attrs
end

Instance Method Details

#view_templateObject



13
14
15
# File 'app/components/phlex_kit/field/field_legend.rb', line 13

def view_template(&)
  legend(**mix({ class: "pk-field-legend #{fetch_option(VARIANTS, @variant, :variant)}" }, @attrs), &)
end