Sha256: 9272401c1e3e837bf4dafafea340353d899ee6e342a9be538c6083d661086e6a

Contents?: true

Size: 1.89 KB

Versions: 50

Compression:

Stored size: 1.89 KB

Contents

<%
  title ||= false
  description_text ||= false
  description_govspeak ||= false
  description ||= yield || false
  aria_live ||= false
  lang = local_assigns[:lang].presence
  local_assigns[:margin_bottom] ||= 8
  local_assigns[:margin_bottom] = 8 if local_assigns[:margin_bottom] > 9

  banner_title ||= t("components.notice.banner_title")
  banner_title_id ||= "govuk-notification-banner-title-#{SecureRandom.hex(4)}"
  show_banner_title ||= false
  heading_level = show_banner_title ? "h3" : "h2"

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

  css_classes = %w[govuk-notification-banner gem-c-notice]
  css_classes << (shared_helper.get_margin_bottom)

  aria_attributes = {label: 'Notice'}
  aria_attributes[:live] = 'polite' if aria_live
  aria_attributes[:labelledby] = banner_title_id if show_banner_title

  description_present = description.present? || description_text.present? || description_govspeak.present?
%>
<% if title || description_present %>
  <%= tag.section class: css_classes, aria: aria_attributes, lang: lang, role: "region" do %>
    <%= tag.div class: "govuk-notification-banner__header" do %>
      <%= tag.h2 banner_title, class: "govuk-notification-banner__title", id: banner_title_id %>
    <% end if show_banner_title %>
    <%= tag.div class: "govuk-notification-banner__content" do %>
      <%= content_tag(heading_level, title, class: "gem-c-notice__title govuk-notification-banner__heading") if description_present && title %>
      <%= tag.span title, class: "gem-c-notice__title govuk-notification-banner__heading" if !description_present && title %>
      <%= tag.p description_text, class: "gem-c-notice__description" if description_text %>

      <%= description if description %>

      <%= render 'govuk_publishing_components/components/govspeak', content: description_govspeak if description_govspeak %>
    <% end %>
  <% end %>
<% end %>

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
govuk_publishing_components-28.4.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-28.3.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-28.2.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-28.1.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-28.0.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.20.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.19.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.18.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.17.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.16.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.15.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.14.2 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.14.1 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.14.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.13.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.12.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.11.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.10.5 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.10.4 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-27.10.3 app/views/govuk_publishing_components/components/_notice.html.erb