Sha256: 90ee7ff2684f59c5a37f102e1e546f09bfd2849098d91149ea10a6eb9126455d

Contents?: true

Size: 951 Bytes

Versions: 3

Compression:

Stored size: 951 Bytes

Contents

module GovukDesignSystem
  module WarningTextHelper
    # Use the [warning text component](https://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 https://github.com/alphagov/govuk-frontend/tree/master/src/govuk/components/warning-text
    def govukWarningText(iconFallbackText:, text: nil, html: nil, classes: "", attributes: {})
      attributes[:class] = "govuk-warning-text #{classes}"

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
govuk-design-system-rails-0.10.3 app/helpers/govuk_design_system/warning_text_helper.rb
govuk-design-system-rails-0.10.2 app/helpers/govuk_design_system/warning_text_helper.rb
govuk-design-system-rails-0.10.1 app/helpers/govuk_design_system/warning_text_helper.rb