Class: SdrViewComponents::Forms::HelpTextComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Forms::HelpTextComponent
- Defined in:
- app/components/sdr_view_components/forms/help_text_component.rb
Overview
Component for rendering help text for form fields.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(id:, text: nil, classes: [], **args) ⇒ HelpTextComponent
constructor
this component can take plain text via ‘help_text’ or a block (which can contain html) it will render the help_text if provided, else it will render the block content.
- #render? ⇒ Boolean
Methods inherited from BaseComponent
#args_for, #merge_actions, #merge_classes
Constructor Details
#initialize(id:, text: nil, classes: [], **args) ⇒ HelpTextComponent
this component can take plain text via ‘help_text’ or a block (which can contain html) it will render the help_text if provided, else it will render the block content
10 11 12 13 14 15 16 |
# File 'app/components/sdr_view_components/forms/help_text_component.rb', line 10 def initialize(id:, text: nil, classes: [], **args) @text = text @id = id @classes = classes @args = args super() end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
18 19 20 |
# File 'app/components/sdr_view_components/forms/help_text_component.rb', line 18 def args @args end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
18 19 20 |
# File 'app/components/sdr_view_components/forms/help_text_component.rb', line 18 def id @id end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
18 19 20 |
# File 'app/components/sdr_view_components/forms/help_text_component.rb', line 18 def text @text end |
Instance Method Details
#classes ⇒ Object
24 25 26 |
# File 'app/components/sdr_view_components/forms/help_text_component.rb', line 24 def classes merge_classes('form-text', @classes) end |
#render? ⇒ Boolean
20 21 22 |
# File 'app/components/sdr_view_components/forms/help_text_component.rb', line 20 def render? text.present? || content.present? end |