Class: Anchor::LabelComponent
- Defined in:
- app/components/anchor/label_component.rb
Constant Summary collapse
- LABEL_CLASSES =
%w( font-semibold text-base text-primary ).freeze
Constants included from ViewHelper
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(form_builder:, attribute:, **options) ⇒ LabelComponent
constructor
A new instance of LabelComponent.
- #optional_suffix ⇒ Object
Methods inherited from Component
Methods included from ViewHelper
#anchor_form_with, #anchor_svg, #deep_blank?, #merge_options, #popover_trigger_attributes
Methods included from FetchOrFallbackHelper
Constructor Details
#initialize(form_builder:, attribute:, **options) ⇒ LabelComponent
Returns a new instance of LabelComponent.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/components/anchor/label_component.rb', line 11 def initialize(form_builder:, attribute:, **) @form_builder = form_builder @attribute = attribute = .merge( class: Array(.delete(:class)) + LABEL_CLASSES ) @required = ModelValidators .new(@form_builder.object, ) .attribute_required?(attribute) super() end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'app/components/anchor/label_component.rb', line 9 def end |
Instance Method Details
#optional_suffix ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/components/anchor/label_component.rb', line 24 def optional_suffix if required_attribute? "" else tag.span( t(".optional_suffix"), class: "text-secondary font-normal italic" ) end end |