Sha256: 9ae2496f942c933fcd234b05b7f3a0537fd9063d624a6c279671ddaa2078b169

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

<%
  add_gem_component_stylesheet("warning-text")

  id ||= "warning-text-#{SecureRandom.hex(4)}"
  text_assistive ||= 'Warning'
  text_icon ||= '!'
  large_font ||= false
  highlight_text ||= false
  heading_level ||= 0

  shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)

  text_classes = %w(govuk-warning-text__text)
  text_classes << "gem-c-warning-text__text--no-indent" if text_icon.empty?
  text_classes << "gem-c-warning-text__text--large" if large_font
  text_classes << "gem-c-warning-text__text--highlight" if highlight_text

  component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
  component_helper.set_id(id)
  component_helper.add_class("gem-c-warning-text govuk-warning-text")
%>

<%= tag.div(**component_helper.all_attributes) do %>
  <% unless text_icon.empty? %>
    <%= tag.span text_icon, class: "govuk-warning-text__icon", "aria-hidden": "true" %>
  <% end %>
  <% inner_text = capture do %>
    <%= tag.span text_assistive, class: "govuk-visually-hidden" %>
    <%= text %>
  <% end %>
  <% if heading_level > 0 %>
    <%= content_tag(shared_helper.get_heading_level, class: text_classes) do %>
      <%= inner_text %>
    <% end %>
  <% else %>
    <%= tag.strong class: text_classes do %>
      <%= inner_text %>
    <% end %>
  <% end %>
<% end %>

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 app/views/govuk_publishing_components/components/_warning_text.html.erb
govuk_publishing_components-51.0.0 app/views/govuk_publishing_components/components/_warning_text.html.erb
govuk_publishing_components-50.0.1 app/views/govuk_publishing_components/components/_warning_text.html.erb
govuk_publishing_components-50.0.0 app/views/govuk_publishing_components/components/_warning_text.html.erb
govuk_publishing_components-49.1.0 app/views/govuk_publishing_components/components/_warning_text.html.erb
govuk_publishing_components-49.0.0 app/views/govuk_publishing_components/components/_warning_text.html.erb
govuk_publishing_components-48.0.0 app/views/govuk_publishing_components/components/_warning_text.html.erb