govuk-components 1.1.7 → 2.0.0b2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -1
  3. data/app/components/govuk_component/{accordion.html.erb → accordion_component.html.erb} +2 -2
  4. data/app/components/govuk_component/{accordion.rb → accordion_component.rb} +7 -6
  5. data/app/components/govuk_component/{back_link.rb → back_link_component.rb} +5 -1
  6. data/app/components/govuk_component/base.rb +9 -7
  7. data/app/components/govuk_component/{breadcrumbs.html.erb → breadcrumbs_component.html.erb} +3 -6
  8. data/app/components/govuk_component/{breadcrumbs.rb → breadcrumbs_component.rb} +1 -1
  9. data/app/components/govuk_component/{cookie_banner.html.erb → cookie_banner_component.html.erb} +2 -6
  10. data/app/components/govuk_component/{cookie_banner.rb → cookie_banner_component.rb} +3 -2
  11. data/app/components/govuk_component/details_component.rb +34 -0
  12. data/app/components/govuk_component/{footer.html.erb → footer_component.html.erb} +3 -5
  13. data/app/components/govuk_component/{footer.rb → footer_component.rb} +3 -8
  14. data/app/components/govuk_component/header_component.html.erb +49 -0
  15. data/app/components/govuk_component/header_component.rb +110 -0
  16. data/app/components/govuk_component/{inset_text.rb → inset_text_component.rb} +3 -3
  17. data/app/components/govuk_component/notification_banner_component.html.erb +14 -0
  18. data/app/components/govuk_component/{notification_banner.rb → notification_banner_component.rb} +28 -14
  19. data/app/components/govuk_component/panel_component.rb +46 -0
  20. data/app/components/govuk_component/phase_banner_component.html.erb +6 -0
  21. data/app/components/govuk_component/phase_banner_component.rb +20 -0
  22. data/app/components/govuk_component/start_button_component.rb +47 -0
  23. data/app/components/govuk_component/summary_list_component.html.erb +11 -0
  24. data/app/components/govuk_component/summary_list_component.rb +61 -0
  25. data/app/components/govuk_component/tab_component.html.erb +11 -0
  26. data/app/components/govuk_component/{tabs.rb → tab_component.rb} +23 -12
  27. data/app/components/govuk_component/{tag.rb → tag_component.rb} +21 -3
  28. data/app/components/govuk_component/warning_text_component.rb +38 -0
  29. data/app/helpers/govuk_components_helper.rb +16 -16
  30. data/lib/govuk/components.rb +1 -0
  31. data/lib/govuk/components/helpers/css_utilities.rb +22 -0
  32. data/lib/govuk/components/version.rb +1 -1
  33. metadata +52 -42
  34. data/app/components/govuk_component/back_link.html.erb +0 -1
  35. data/app/components/govuk_component/details.html.erb +0 -10
  36. data/app/components/govuk_component/details.rb +0 -16
  37. data/app/components/govuk_component/header.html.erb +0 -47
  38. data/app/components/govuk_component/header.rb +0 -53
  39. data/app/components/govuk_component/notification_banner.html.erb +0 -23
  40. data/app/components/govuk_component/panel.html.erb +0 -13
  41. data/app/components/govuk_component/panel.rb +0 -28
  42. data/app/components/govuk_component/phase_banner.html.erb +0 -8
  43. data/app/components/govuk_component/phase_banner.rb +0 -16
  44. data/app/components/govuk_component/start_now_button.html.erb +0 -6
  45. data/app/components/govuk_component/start_now_button.rb +0 -16
  46. data/app/components/govuk_component/summary_list.html.erb +0 -19
  47. data/app/components/govuk_component/summary_list.rb +0 -34
  48. data/app/components/govuk_component/tabs.html.erb +0 -19
  49. data/app/components/govuk_component/warning.html.erb +0 -7
  50. data/app/components/govuk_component/warning.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fa9844129aad4b89c9845af6db1fbd942d0bde94823f891f65164163b935295
4
- data.tar.gz: 962375a05bc998a2b5caf5e3eeccb2a7f12a8dd120e8054857e79128287d3b8f
3
+ metadata.gz: d78b72089a8fad902b686ad63ecb7b101a7353a5e59bbd70369d929eb3f9b8ab
4
+ data.tar.gz: f72eff8f23f2a8a808f21ea5cb14be0574a61ba6688e8e137fec6387ea6f44d7
5
5
  SHA512:
6
- metadata.gz: '048424bb98e6ed1ba126dfa971310ffa8b61629aea7394c1da291eeaa0c9bf31b1d1d547d190bcf8e31ce17f13b8b9d501bb8e9ccd01e2ba5c3a2f9444b6693d'
7
- data.tar.gz: 4c30a89b2f53b0cdcc869ae766182249f7d0c34b2c81c507c8ae6835344cc2b734b065ada162643a1ad15cb701d5af2445abec5173a400470c5cf458f28146ba
6
+ metadata.gz: bb0b5e3653d68b5e53a8931204ce9a973d6cc8f5e778ea3d8950cd8c9499eafe6c2080b7a973ca53284d9e7de9dc0fa31bda6df3c1aa908d2477b06d4f964f7c
7
+ data.tar.gz: b7d8992142ec9627c957f63082b66dbacbee454e2a837209f3dd86d4fe018c929c2f113942a11d368afeb3569f210fc7ce1ed3e5c22bb211141c9ef915588912
data/README.md CHANGED
@@ -99,7 +99,11 @@ To setup the dummy app:
99
99
  `bin/rails db:migrate`
100
100
  `bin/rails s`
101
101
 
102
- After adding a new component update the examples page by cd-ing into the dummy app `cd spec/dummy` and running the rake task `bin/rake generate_examples_page`.
102
+ After changing a component or adding a new one:
103
+
104
+ * add or update the corresponding specs, and check they pass by running `bundle exec rspec`.
105
+
106
+ * update the examples page by cd-ing into the dummy app `cd spec/dummy` and running the rake task `bin/rake generate_examples_page`.
103
107
 
104
108
  ## License
105
109
 
@@ -3,13 +3,13 @@
3
3
  <%= tag.div(id: section.id(suffix: 'section'), class: section.classes, **section.html_attributes) do %>
4
4
  <div class="govuk-accordion__section-header">
5
5
  <h2 class="govuk-accordion__section-heading">
6
- <%= tag.span(section.title, id: section.id, class: "govuk-accordion__section-button", aria: { expanded: section.expanded? }) %>
6
+ <%= tag.span(section.title, id: section.id, class: "govuk-accordion__section-button", aria: { expanded: section.expanded?, controls: section.id(suffix: 'content') }) %>
7
7
  </h2>
8
8
  <% if section.summary.present? %>
9
9
  <%= tag.div(section.summary, id: section.id(suffix: 'summary'), class: %w(govuk-accordion__section-summary govuk-body)) %>
10
10
  <% end %>
11
11
  </div>
12
- <%= tag.div(section.content, id: section.id(suffix: 'content'), class: %w(govuk-accordion__section-content), aria: { labelledby: section.id }) %>
12
+ <%= section %>
13
13
  <% end %>
14
14
  <% end %>
15
15
  <% end %>
@@ -1,8 +1,5 @@
1
- class GovukComponent::Accordion < GovukComponent::Base
2
- include ViewComponent::Slotable
3
-
4
- with_slot :section, collection: true, class_name: 'Section'
5
- wrap_slot :section
1
+ class GovukComponent::AccordionComponent < GovukComponent::Base
2
+ renders_many :sections, "Section"
6
3
 
7
4
  attr_accessor :id
8
5
 
@@ -18,7 +15,7 @@ private
18
15
  %w(govuk-accordion)
19
16
  end
20
17
 
21
- class Section < GovukComponent::Slot
18
+ class Section < GovukComponent::Base
22
19
  attr_accessor :title, :summary, :expanded
23
20
 
24
21
  alias_method :expanded?, :expanded
@@ -39,6 +36,10 @@ private
39
36
  super + (expanded? ? %w(govuk-accordion__section--expanded) : [])
40
37
  end
41
38
 
39
+ def call
40
+ tag.div(content, id: id(suffix: 'content'), class: %w(govuk-accordion__section-content), aria: { labelledby: id })
41
+ end
42
+
42
43
  private
43
44
 
44
45
  def default_classes
@@ -1,4 +1,4 @@
1
- class GovukComponent::BackLink < GovukComponent::Base
1
+ class GovukComponent::BackLinkComponent < GovukComponent::Base
2
2
  attr_accessor :text, :href, :options
3
3
 
4
4
  def initialize(text:, href:, classes: nil, html_attributes: {})
@@ -8,6 +8,10 @@ class GovukComponent::BackLink < GovukComponent::Base
8
8
  @href = href
9
9
  end
10
10
 
11
+ def call
12
+ link_to(@text, @href, class: classes, **html_attributes)
13
+ end
14
+
11
15
  private
12
16
 
13
17
  def default_classes
@@ -1,17 +1,19 @@
1
1
  class GovukComponent::Base < ViewComponent::Base
2
+ include Govuk::Components::Helpers::CssUtilities
3
+
2
4
  include GovukComponent::Traits::CustomClasses
3
5
  include GovukComponent::Traits::CustomHtmlAttributes
4
6
 
5
- def initialize(classes: [], html_attributes: {})
7
+ attr_reader :html_attributes
8
+
9
+ def initialize(classes:, html_attributes:)
6
10
  @classes = parse_classes(classes)
7
11
  @html_attributes = html_attributes
12
+
13
+ super
8
14
  end
9
15
 
10
- # Redirect #add_name to #slot(:name) to make building components
11
- # with slots feel more DSL-like
12
- def self.wrap_slot(name)
13
- define_method(%(add_#{name})) do |*args, **kwargs, &block|
14
- slot(name, *args, **kwargs, &block)
15
- end
16
+ def default_classes
17
+ []
16
18
  end
17
19
  end
@@ -1,17 +1,14 @@
1
1
  <%= tag.div(class: classes, **html_attributes) do %>
2
2
  <ol class="govuk-breadcrumbs__list">
3
- <%- @breadcrumbs.each do |text, link| %>
3
+ <% @breadcrumbs.each do |text, link| %>
4
4
 
5
- <%- if link.present? -%>
5
+ <% if link.present? %>
6
6
  <li class="govuk-breadcrumbs__list-item">
7
7
  <%= link_to(text, link, class: "govuk-breadcrumbs__link") %>
8
8
  </li>
9
9
  <% else %>
10
- <li class="govuk-breadcrumbs__list-item" aria-current="page">
11
- <%= text %>
12
- </li>
10
+ <%= tag.li(text, class: "govuk-breadcrumbs__list-item", aria: { current: "page" }) %>
13
11
  <% end %>
14
-
15
12
  <% end %>
16
13
  </ol>
17
14
  <% end %>
@@ -1,4 +1,4 @@
1
- class GovukComponent::Breadcrumbs < GovukComponent::Base
1
+ class GovukComponent::BreadcrumbsComponent < GovukComponent::Base
2
2
  attr_accessor :breadcrumbs
3
3
 
4
4
  def initialize(breadcrumbs:, hide_in_print: false, collapse_on_mobile: false, classes: [], html_attributes: {})
@@ -3,14 +3,10 @@
3
3
  <div class="govuk-grid-row">
4
4
  <div class="govuk-grid-column-two-thirds">
5
5
  <% if title.present? %>
6
- <h2 class="govuk-cookie-banner__heading govuk-heading-m">
7
- <%= title %>
8
- </h2>
6
+ <%= tag.h2(title, class: %w(govuk-cookie-banner__heading govuk-heading-m)) %>
9
7
  <% end %>
10
8
 
11
- <div class="govuk-cookie-banner__content">
12
- <%= body %>
13
- </div>
9
+ <%= tag.div(body, class: "govuk-cookie-banner__content") %>
14
10
  </div>
15
11
  </div>
16
12
 
@@ -1,5 +1,6 @@
1
- class GovukComponent::CookieBanner < GovukComponent::Base
2
- with_content_areas :body, :actions
1
+ class GovukComponent::CookieBannerComponent < GovukComponent::Base
2
+ renders_one :body
3
+ renders_one :actions
3
4
 
4
5
  attr_accessor :title, :aria_label
5
6
 
@@ -0,0 +1,34 @@
1
+ class GovukComponent::DetailsComponent < GovukComponent::Base
2
+ attr_accessor :summary_text, :text
3
+
4
+ def initialize(summary_text:, text: nil, classes: [], html_attributes: {})
5
+ super(classes: classes, html_attributes: html_attributes)
6
+
7
+ @summary_text = summary_text
8
+ @text = text
9
+ end
10
+
11
+ def call
12
+ tag.details(class: classes, data: { module: "govuk-details" }, **html_attributes) do
13
+ safe_join([summary, description])
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def summary
20
+ tag.summary(class: "govuk-details__summary") do
21
+ tag.span(summary_text, class: "govuk-details__summary-text")
22
+ end
23
+ end
24
+
25
+ def description
26
+ tag.div(class: "govuk-details__text") do
27
+ content.presence || text
28
+ end
29
+ end
30
+
31
+ def default_classes
32
+ %w(govuk-details)
33
+ end
34
+ end
@@ -2,7 +2,7 @@
2
2
  <div class="govuk-width-container ">
3
3
  <div class="govuk-footer__meta">
4
4
  <% if meta.present? %>
5
- <%= meta.content %>
5
+ <%= meta %>
6
6
  <% else %>
7
7
  <div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
8
8
  <% if meta_items.any? %>
@@ -28,13 +28,11 @@
28
28
  <% end %>
29
29
 
30
30
  <% if meta_content.present? %>
31
- <%= meta_content.content %>
31
+ <%= meta_content %>
32
32
  <% end %>
33
33
  </div>
34
34
  <div class="govuk-footer__meta">
35
- <div class="govuk-footer__meta-item">
36
- <%= copyright %>
37
- </div>
35
+ <%= tag.div(copyright, class: "govuk-footer__meta-item") %>
38
36
  </div>
39
37
  <% end %>
40
38
  </div>
@@ -1,11 +1,6 @@
1
- class GovukComponent::Footer < GovukComponent::Base
2
- include ViewComponent::Slotable
3
-
4
- with_slot :meta_content
5
- wrap_slot :meta_content
6
-
7
- with_slot :meta
8
- wrap_slot :meta
1
+ class GovukComponent::FooterComponent < GovukComponent::Base
2
+ renders_one :meta_content
3
+ renders_one :meta
9
4
 
10
5
  attr_accessor :meta_items, :meta_items_title, :meta_licence, :copyright
11
6
 
@@ -0,0 +1,49 @@
1
+ <%= tag.header(class: classes, role: 'banner', data: { module: 'govuk-header' }, **html_attributes) do %>
2
+ <%= tag.div(class: container_classes) do %>
3
+ <div class="govuk-header__logo">
4
+ <%= link_to(@homepage_url, class: %w(govuk-header__link govuk-header__link--homepage)) do %>
5
+ <span class="govuk-header__logotype">
6
+ <% if custom_logo.present? %>
7
+ <%= custom_logo %>
8
+ <% else %>
9
+ <% if crown %>
10
+ <svg aria-hidden="true" focusable="false" class="govuk-header__logotype-crown" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 132 97" height="30" width="36">
11
+ <path fill="currentColor" fill-rule="evenodd" d="M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.6-1.5-7.6.3-9.1 3.8-1.3 3.6.4 7.7 3.9 9.1zm64.4-5.6c-3.6 1.5-7.8-.2-9.1-3.7-1.5-3.6.2-7.8 3.8-9.2 3.6-1.4 7.7.3 9.2 3.9 1.3 3.5-.4 7.5-3.9 9zm15.9 9.3c-3.6 1.5-7.7-.2-9.1-3.7-1.5-3.6.2-7.8 3.7-9.1 3.6-1.5 7.7.2 9.2 3.8 1.5 3.5-.3 7.5-3.8 9zm4.7 17.7c-3.6 1.5-7.8-.2-9.2-3.8-1.5-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.3 3.5-.4 7.6-3.9 9.1zM89.3 35.8c-3.6 1.5-7.8-.2-9.2-3.8-1.4-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.4 3.6-.3 7.7-3.9 9.1zM69.7 17.7l8.9 4.7V9.3l-8.9 2.8c-.2-.3-.5-.6-.9-.9L72.4 0H59.6l3.5 11.2c-.3.3-.6.5-.9.9l-8.8-2.8v13.1l8.8-4.7c.3.3.6.7.9.9l-5 15.4v.1c-.2.8-.4 1.6-.4 2.4 0 4.1 3.1 7.5 7 8.1h.2c.3 0 .7.1 1 .1.4 0 .7 0 1-.1h.2c4-.6 7.1-4.1 7.1-8.1 0-.8-.1-1.7-.4-2.4V34l-5.1-15.4c.4-.2.7-.6 1-.9zM66 92.8c16.9 0 32.8 1.1 47.1 3.2 4-16.9 8.9-26.7 14-33.5l-9.6-3.4c1 4.9 1.1 7.2 0 10.2-1.5-1.4-3-4.3-4.2-8.7L108.6 76c2.8-2 5-3.2 7.5-3.3-4.4 9.4-10 11.9-13.6 11.2-4.3-.8-6.3-4.6-5.6-7.9 1-4.7 5.7-5.9 8-.5 4.3-8.7-3-11.4-7.6-8.8 7.1-7.2 7.9-13.5 2.1-21.1-8 6.1-8.1 12.3-4.5 20.8-4.7-5.4-12.1-2.5-9.5 6.2 3.4-5.2 7.9-2 7.2 3.1-.6 4.3-6.4 7.8-13.5 7.2-10.3-.9-10.9-8-11.2-13.8 2.5-.5 7.1 1.8 11 7.3L80.2 60c-4.1 4.4-8 5.3-12.3 5.4 1.4-4.4 8-11.6 8-11.6H55.5s6.4 7.2 7.9 11.6c-4.2-.1-8-1-12.3-5.4l1.4 16.4c3.9-5.5 8.5-7.7 10.9-7.3-.3 5.8-.9 12.8-11.1 13.8-7.2.6-12.9-2.9-13.5-7.2-.7-5 3.8-8.3 7.1-3.1 2.7-8.7-4.6-11.6-9.4-6.2 3.7-8.5 3.6-14.7-4.6-20.8-5.8 7.6-5 13.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z"></path>
12
+ <image src="/assets/images/govuk-logotype-crown.png" xlink:href="" class="govuk-header__logotype-crown-fallback-image" width="36" height="32"></image>
13
+ </svg>
14
+ <% end %>
15
+ <%= tag.span(logotype, class: "govuk-header__logotype-text") %>
16
+ <% end %>
17
+ </span>
18
+ <% if product_name.present? %>
19
+ <%= product_name %>
20
+ <% end %>
21
+ <% end %>
22
+ </div>
23
+
24
+ <% if @service_name.present? || @items.present? %>
25
+ <div class="govuk-header__content">
26
+ <% if @service_name.present? %>
27
+ <%= link_to(@service_name, @service_url, class: %w(govuk-header__link govuk-header__link--service-name)) %>
28
+ <% end %>
29
+
30
+ <% if items.any? %>
31
+ <%= tag.button("Menu", type: "button", class: %w(govuk-header__menu-button govuk-js-header-toggle), aria: { controls: "navigation", label: menu_button_label }) %>
32
+ <nav>
33
+ <%= tag.ul(class: navigation_classes, id: "navigation", aria: { label: navigation_label }) do %>
34
+ <% items.each do |item| %>
35
+ <%= tag.li(class: item.classes.append(item.active_class), **item.html_attributes) do %>
36
+ <% if item.link? %>
37
+ <%= link_to(item.title, item.href, class: "govuk-header__link") %>
38
+ <% else %>
39
+ <%= item.title %>
40
+ <% end %>
41
+ <% end %>
42
+ <% end %>
43
+ <% end %>
44
+ </nav>
45
+ <% end %>
46
+ </div>
47
+ <% end %>
48
+ <% end %>
49
+ <% end %>
@@ -0,0 +1,110 @@
1
+ class GovukComponent::HeaderComponent < GovukComponent::Base
2
+ renders_many :items, "Item"
3
+ renders_one :custom_logo
4
+ renders_one :product_name, "ProductName"
5
+
6
+ attr_accessor :logotype,
7
+ :crown,
8
+ :homepage_url,
9
+ :service_name,
10
+ :service_url,
11
+ :menu_button_label,
12
+ :navigation_label
13
+
14
+ def initialize(classes: [],
15
+ html_attributes: {},
16
+ logotype: 'GOV.UK',
17
+ crown: true,
18
+ homepage_url: '/',
19
+ menu_button_label: 'Show or hide navigation menu',
20
+ navigation_classes: [],
21
+ navigation_label: 'Navigation menu',
22
+ service_name: nil,
23
+ service_url: '/',
24
+ container_classes: nil)
25
+
26
+ super(classes: classes, html_attributes: html_attributes)
27
+
28
+ @logotype = logotype
29
+ @crown = crown
30
+ @homepage_url = homepage_url
31
+ @service_name = service_name
32
+ @service_url = service_url
33
+ @menu_button_label = menu_button_label
34
+ @navigation_classes = navigation_classes
35
+ @navigation_label = navigation_label
36
+ @container_classes = container_classes
37
+ end
38
+
39
+ private
40
+
41
+ def default_classes
42
+ %w(govuk-header)
43
+ end
44
+
45
+ def navigation_classes
46
+ combine_classes(%w(govuk-header__navigation), @navigation_classes)
47
+ end
48
+
49
+ def container_classes
50
+ combine_classes(%w(govuk-header__container govuk-width-container), @container_classes)
51
+ end
52
+
53
+ class Item < GovukComponent::Base
54
+ attr_accessor :title, :href, :active
55
+
56
+ def initialize(title:, href: nil, active: false, classes: [], html_attributes: {})
57
+ super(classes: classes, html_attributes: html_attributes)
58
+
59
+ self.title = title
60
+ self.href = href
61
+ self.active = active
62
+ end
63
+
64
+ def active?
65
+ active
66
+ end
67
+
68
+ def active_class
69
+ %w(govuk-header__navigation-item--active) if active?
70
+ end
71
+
72
+ def link?
73
+ href.present?
74
+ end
75
+
76
+ private
77
+
78
+ def default_classes
79
+ %w(govuk-header__navigation-item)
80
+ end
81
+ end
82
+
83
+ class ProductName < GovukComponent::Base
84
+ attr_accessor :name
85
+
86
+ def initialize(name: nil, html_attributes: {}, classes: [])
87
+ super(classes: classes, html_attributes: html_attributes)
88
+
89
+ @name = name
90
+ end
91
+
92
+ def render?
93
+ @name.present? || content.present?
94
+ end
95
+
96
+ def call
97
+ if content.present?
98
+ tag.div(content, class: classes)
99
+ else
100
+ tag.span(@name, class: classes)
101
+ end
102
+ end
103
+
104
+ private
105
+
106
+ def default_classes
107
+ %w(govuk-header__product-name)
108
+ end
109
+ end
110
+ end
@@ -1,4 +1,4 @@
1
- class GovukComponent::InsetText < GovukComponent::Base
1
+ class GovukComponent::InsetTextComponent < GovukComponent::Base
2
2
  attr_accessor :text
3
3
 
4
4
  def initialize(text: nil, classes: [], html_attributes: {})
@@ -8,11 +8,11 @@ class GovukComponent::InsetText < GovukComponent::Base
8
8
  end
9
9
 
10
10
  def call
11
- tag.div(class: classes, **html_attributes) { content.presence || @text }
11
+ tag.div(class: classes, **html_attributes) { content.presence || text }
12
12
  end
13
13
 
14
14
  def render?
15
- @text.present? || content.present?
15
+ text.present? || content.present?
16
16
  end
17
17
 
18
18
  private
@@ -0,0 +1,14 @@
1
+ <%= tag.div(class: classes, role: "region", aria: { labelledby: title_id }, data: data_params, **html_attributes) do %>
2
+ <div class="govuk-notification-banner__header">
3
+ <%= content_tag(title_tag, class: "govuk-notification-banner__title", id: title_id) do %>
4
+ <%= title %>
5
+ <% end %>
6
+ </div>
7
+ <div class="govuk-notification-banner__content">
8
+ <% headings.each do |heading| %>
9
+ <%= heading %>
10
+ <% end %>
11
+
12
+ <%= content %>
13
+ </div>
14
+ <% end %>