Class: GovukComponent::WarningTextComponent
- Defined in:
- app/components/govuk_component/warning_text_component.rb
Constant Summary collapse
- ICON =
'!'.freeze
Instance Attribute Summary collapse
-
#icon_fallback_text ⇒ Object
readonly
Returns the value of attribute icon_fallback_text.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Base
Attributes included from Traits::CustomHtmlAttributes
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text:, icon_fallback_text: 'Warning', classes: [], html_attributes: {}) ⇒ WarningTextComponent
constructor
A new instance of WarningTextComponent.
Methods included from Traits::CustomClasses
Methods included from Govuk::Components::Helpers::CssUtilities
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_text ⇒ Object (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 |
#text ⇒ Object (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
#call ⇒ Object
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 |