Sha256: 08d1c018959a3582fa6bac8045b02a550f2f69330560afd41a7000c113d5187d

Contents?: true

Size: 1.89 KB

Versions: 77

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

77 entries across 77 versions & 1 rubygems

Version Path
govuk_publishing_components-34.12.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.11.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.10.1 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.10.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.9.1 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.9.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.8.1 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.8.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.7.1 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.7.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.6.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.5.1 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.5.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.4.2 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.4.1 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.4.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.3.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.2.0 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.1.3 app/views/govuk_publishing_components/components/_notice.html.erb
govuk_publishing_components-34.1.2 app/views/govuk_publishing_components/components/_notice.html.erb