Class: GovukComponent::WarningTextComponent

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

Constant Summary collapse

ICON =
'!'.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Attributes included from Traits::CustomHtmlAttributes

#html_attributes

Instance Method Summary collapse

Methods included from Traits::CustomClasses

#classes

Methods included from Govuk::Components::Helpers::CssUtilities

#combine_classes

Constructor Details

#initialize(text:, icon_fallback_text: 'Warning', classes: [], html_attributes: {}) ⇒ WarningTextComponent

Returns a new instance of WarningTextComponent.



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

def initialize(text:, icon_fallback_text: 'Warning', classes: [], html_attributes: {})
  super(classes: classes, html_attributes: html_attributes)

  @text = text
  @icon_fallback_text = icon_fallback_text
end

Instance Attribute Details

#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



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

def call
  tag.div(class: classes, **html_attributes) do
    safe_join([icon, (content || strong)])
  end
end