Class: GovukComponent::WarningTextComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/govuk_component/warning_text_component.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Methods inherited from Base

#brand, #class_prefix

Constructor Details

#initialize(text: nil, icon_fallback_text: config.default_warning_text_icon_fallback_text, icon: config.default_warning_text_icon, classes: [], html_attributes: {}) ⇒ WarningTextComponent

Returns a new instance of WarningTextComponent.



4
5
6
7
8
9
10
# File 'app/components/govuk_component/warning_text_component.rb', line 4

def initialize(text: nil, icon_fallback_text: config.default_warning_text_icon_fallback_text, icon: config.default_warning_text_icon, classes: [], html_attributes: {})
  @text = text
  @icon = icon
  @icon_fallback_text = icon_fallback_text

  super(classes:, html_attributes:)
end

Instance Attribute Details

#iconObject (readonly)

Returns the value of attribute icon.



2
3
4
# File 'app/components/govuk_component/warning_text_component.rb', line 2

def icon
  @icon
end

#icon_fallback_textObject (readonly)

Returns the value of attribute icon_fallback_text.



2
3
4
# File 'app/components/govuk_component/warning_text_component.rb', line 2

def icon_fallback_text
  @icon_fallback_text
end

#textObject (readonly)

Returns the value of attribute text.



2
3
4
# File 'app/components/govuk_component/warning_text_component.rb', line 2

def text
  @text
end

Instance Method Details

#callObject



12
13
14
15
16
# File 'app/components/govuk_component/warning_text_component.rb', line 12

def call
  tag.div(**html_attributes) do
    safe_join([icon_element, warning_text])
  end
end