Module: GovukDesignSystem::WarningTextHelper

Defined in:
app/helpers/govuk_design_system/warning_text_helper.rb

Instance Method Summary collapse

Instance Method Details

#govukWarningText(iconFallbackText:, text: nil, html: nil, classes: "", attributes: {}) ⇒ Object

Use the [warning text component](design-system.service.gov.uk/components/warning-text/) when you need to warn users about something important, such as legal consequences of an action, or lack of action, that they might take.

Implementation based on github.com/alphagov/govuk-frontend/tree/master/src/govuk/components/warning-text



8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/govuk_design_system/warning_text_helper.rb', line 8

def govukWarningText(iconFallbackText:, text: nil, html: nil, classes: "", attributes: {})
  attributes[:class] = "govuk-warning-text #{classes}"

  ("div", attributes) do
    ("span", "!", class: "govuk-warning-text__icon", "aria-hidden" => "true") +
      ("strong", class: "govuk-warning-text__text") do
        ("span", iconFallbackText, class: "govuk-warning-text__assistive") +
          (html || text)
      end
  end
end