Sha256: 46d98e9f9ea75d842e3fe9bfe30c7d42db94f9ff629e2825ec8e1e7d38bb25e4

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

<%
  banner_type = local_assigns[:type]&.to_s
  if banner_type ==  "success"
    success_banner = true
    type_class = "govuk-notification-banner--#{banner_type}"
  end

  role = if local_assigns[:role]
           local_assigns[:role]
         elsif success_banner
           "alert"
         else
           "region"
         end

  title = if local_assigns[:titleHtml]
            local_assigns[:titleHtml]
          elsif local_assigns[:titleText]
            local_assigns[:titleText]
          elsif success_banner
            "Success"
          else
            "Important"
          end

  banner_classes = class_names(
    "govuk-notification-banner",
    type_class,
    local_assigns[:classes]
  )

  labelled_by = local_assigns[:titleId] || "govuk-notification-banner-title"

  attributes = {
    role: role,
    "aria-labelledby" => labelled_by,
    "data-module" => "govuk-notification-banner",
    class: banner_classes
  }.merge(local_assigns[:attributes] || {})

  attributes["data-disable-auto-focus"] = true if local_assigns[:disableAutoFocus]

  title_heading_level = local_assigns[:title_heading_level] ? "h#{local_assigns[:title_heading_level]}" : "h2"

  header_attributes = {
    class: "govuk-notification-banner__title",
    id: labelled_by
  }
%>

<%= tag.div(**attributes) do %>
  <div class="govuk-notification-banner__header">
    <%= tag.send(title_heading_level, **header_attributes) do %>
      <%= title %>
    <% end %>
  </div>
  <div class="govuk-notification-banner__content">
    <% if local_assigns[:block] %>
      <%= capture(&block) %>
    <% elsif local_assigns[:html] %>
      <%= local_assigns[:html] %>
    <% elsif local_assigns[:text] %>
      <p class="govuk-notification-banner__heading">
        <%= local_assigns[:text] %>
      </p>
    <% end %>
  </div>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
govuk-design-system-rails-0.10.3 app/views/components/_govuk_notification_banner.html.erb
govuk-design-system-rails-0.10.2 app/views/components/_govuk_notification_banner.html.erb