Class: SdrViewComponents::Forms::HelpTextComponent

Inherits:
BaseComponent
  • Object
show all
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

Instance Method Summary collapse

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

#argsObject (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

#idObject (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

#textObject (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

#classesObject



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

Returns:

  • (Boolean)


20
21
22
# File 'app/components/sdr_view_components/forms/help_text_component.rb', line 20

def render?
  text.present? || content.present?
end