govuk-components 3.0.4 → 3.1.0

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/app/components/govuk_component/accordion_component/section_component.html.erb +1 -1
  4. data/app/components/govuk_component/accordion_component/section_component.rb +4 -4
  5. data/app/components/govuk_component/accordion_component.html.erb +1 -1
  6. data/app/components/govuk_component/accordion_component.rb +5 -6
  7. data/app/components/govuk_component/back_link_component.rb +6 -6
  8. data/app/components/govuk_component/base.rb +17 -10
  9. data/app/components/govuk_component/breadcrumbs_component.html.erb +1 -1
  10. data/app/components/govuk_component/breadcrumbs_component.rb +10 -8
  11. data/app/components/govuk_component/cookie_banner_component/message_component.rb +5 -5
  12. data/app/components/govuk_component/cookie_banner_component.rb +7 -5
  13. data/app/components/govuk_component/details_component.rb +5 -5
  14. data/app/components/govuk_component/footer_component.html.erb +2 -2
  15. data/app/components/govuk_component/footer_component.rb +13 -9
  16. data/app/components/govuk_component/header_component.html.erb +4 -4
  17. data/app/components/govuk_component/header_component.rb +32 -29
  18. data/app/components/govuk_component/inset_text_component.rb +5 -5
  19. data/app/components/govuk_component/notification_banner_component.html.erb +1 -1
  20. data/app/components/govuk_component/notification_banner_component.rb +20 -21
  21. data/app/components/govuk_component/pagination_component/adjacent_page.rb +60 -0
  22. data/app/components/govuk_component/pagination_component/item.rb +77 -0
  23. data/app/components/govuk_component/pagination_component/next_page.rb +32 -0
  24. data/app/components/govuk_component/pagination_component/previous_page.rb +26 -0
  25. data/app/components/govuk_component/pagination_component.rb +121 -0
  26. data/app/components/govuk_component/panel_component.rb +5 -5
  27. data/app/components/govuk_component/phase_banner_component.html.erb +1 -1
  28. data/app/components/govuk_component/phase_banner_component.rb +4 -4
  29. data/app/components/govuk_component/section_break_component.rb +44 -0
  30. data/app/components/govuk_component/start_button_component.rb +16 -17
  31. data/app/components/govuk_component/summary_list_component/action_component.rb +7 -3
  32. data/app/components/govuk_component/summary_list_component/key_component.rb +5 -5
  33. data/app/components/govuk_component/summary_list_component/row_component.rb +15 -7
  34. data/app/components/govuk_component/summary_list_component/value_component.rb +3 -3
  35. data/app/components/govuk_component/summary_list_component.html.erb +1 -1
  36. data/app/components/govuk_component/summary_list_component.rb +4 -8
  37. data/app/components/govuk_component/tab_component.html.erb +2 -2
  38. data/app/components/govuk_component/tab_component.rb +17 -9
  39. data/app/components/govuk_component/table_component/body_component.html.erb +1 -1
  40. data/app/components/govuk_component/table_component/body_component.rb +2 -2
  41. data/app/components/govuk_component/table_component/caption_component.rb +5 -5
  42. data/app/components/govuk_component/table_component/cell_component.rb +10 -2
  43. data/app/components/govuk_component/table_component/head_component.html.erb +1 -1
  44. data/app/components/govuk_component/table_component/head_component.rb +2 -2
  45. data/app/components/govuk_component/table_component/row_component.html.erb +1 -1
  46. data/app/components/govuk_component/table_component/row_component.rb +4 -4
  47. data/app/components/govuk_component/table_component.html.erb +1 -1
  48. data/app/components/govuk_component/table_component.rb +4 -4
  49. data/app/components/govuk_component/tag_component.rb +7 -5
  50. data/app/components/govuk_component/warning_text_component.rb +5 -5
  51. data/app/helpers/govuk_components_helper.rb +2 -0
  52. data/app/helpers/govuk_link_helper.rb +2 -1
  53. data/lib/govuk/components/version.rb +1 -1
  54. data/lib/govuk/components.rb +1 -0
  55. metadata +74 -8
  56. data/app/components/govuk_component/table_component/cell_component.html.erb +0 -1
  57. data/app/components/govuk_component/traits/custom_classes.rb +0 -28
@@ -0,0 +1,60 @@
1
+ class GovukComponent::PaginationComponent::AdjacentPage < GovukComponent::Base
2
+ attr_reader :href, :label_text, :text, :suffix, :block_mode, :visually_hidden_text
3
+ alias_method :block_mode?, :block_mode
4
+
5
+ def initialize(href:, suffix:, visually_hidden_text:, text:, block_mode: true, label_text: nil, classes: [], html_attributes: {})
6
+ @href = href
7
+ @label_text = label_text
8
+ @text = text
9
+ @block_mode = block_mode
10
+ @suffix = suffix
11
+ @visually_hidden_text = visually_hidden_text
12
+
13
+ super(html_attributes: html_attributes, classes: classes)
14
+ end
15
+
16
+ def call
17
+ tag.div(**html_attributes) do
18
+ tag.a(href: href, class: %w(govuk-link govuk-pagination__link), rel: suffix, aria: { label: aria_label }) do
19
+ safe_join([body, divider, label_content])
20
+ end
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def default_attributes
27
+ { class: ["govuk-pagination__#{suffix}"] }
28
+ end
29
+
30
+ def body
31
+ [arrow, title_span]
32
+ end
33
+
34
+ def title_span
35
+ tag.span(text, class: title_classes)
36
+ end
37
+
38
+ def divider
39
+ return if label_text.blank?
40
+
41
+ tag.span(":", class: %w(govuk-visually-hidden))
42
+ end
43
+
44
+ def label_content
45
+ return if label_text.blank?
46
+
47
+ tag.span(label_text, class: label_classes)
48
+ end
49
+
50
+ def title_classes
51
+ class_names(
52
+ %(govuk-pagination__link-title),
53
+ %(govuk-pagination__link-title--decorated) => label_text.blank?
54
+ )
55
+ end
56
+
57
+ def label_classes
58
+ %w(govuk-pagination__link-label)
59
+ end
60
+ end
@@ -0,0 +1,77 @@
1
+ class GovukComponent::PaginationComponent::Item < GovukComponent::Base
2
+ attr_reader :number, :href, :visually_hidden_text, :mode
3
+
4
+ def initialize(number: nil, href: nil, current: false, ellipsis: false, from_pagy: false, visually_hidden_text: nil, classes: [], html_attributes: {})
5
+ @number = number
6
+ @href = href
7
+ @visually_hidden_text = visually_hidden_text
8
+
9
+ # We have three modes for rendering links:
10
+ #
11
+ # * link (a link to another page)
12
+ # * current (a link to the current page)
13
+ # * gap (an ellipsis symbol)
14
+ #
15
+ # Pagy sets these by object type:
16
+ # Integer = link
17
+ # String = current
18
+ # :gap = gap
19
+ #
20
+ # The original Nunjucks component has two boolean settings instead,
21
+ # ellipsis and current. When ellipsis is true all other arguments are
22
+ # ignored
23
+ @mode = from_pagy ? pagy_mode(number) : manual_mode(ellipsis, current)
24
+
25
+ super(classes: classes, html_attributes: html_attributes)
26
+ end
27
+
28
+ def call
29
+ case mode
30
+ when :link
31
+ link(current: false)
32
+ when :current
33
+ link(current: true)
34
+ when :gap
35
+ ellipsis_item
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def pagy_mode(number)
42
+ return :link if number.is_a?(Integer)
43
+ return :current if number.is_a?(String)
44
+
45
+ :gap
46
+ end
47
+
48
+ def manual_mode(ellipsis, current)
49
+ return :gap if ellipsis
50
+ return :current if current
51
+
52
+ :link
53
+ end
54
+
55
+ def link(current: false)
56
+ attributes = html_attributes.tap { |ha| ha[:class] << "govuk-pagination__item--current" if current }
57
+
58
+ tag.li(**attributes) do
59
+ tag.a(href: href, class: %w(govuk-link govuk-pagination__link)) { number.to_s }
60
+ end
61
+ end
62
+
63
+ def ellipsis_item
64
+ tag.li("⋯", class: %w(govuk-pagination__item govuk-pagination__item--ellipses))
65
+ end
66
+
67
+ def default_attributes
68
+ {
69
+ class: %w(govuk-pagination__item),
70
+ aria: { label: aria_label }
71
+ }
72
+ end
73
+
74
+ def aria_label
75
+ visually_hidden_text || "Page #{number}"
76
+ end
77
+ end
@@ -0,0 +1,32 @@
1
+ class GovukComponent::PaginationComponent::NextPage < GovukComponent::PaginationComponent::AdjacentPage
2
+ def initialize(href:, text:, label_text: nil, visually_hidden_text: nil, block_mode: true, classes: [], html_attributes: {})
3
+ super(
4
+ suffix: "next",
5
+ text: text,
6
+ href: href,
7
+ label_text: label_text,
8
+ block_mode: block_mode,
9
+ visually_hidden_text: visually_hidden_text,
10
+ classes: classes,
11
+ html_attributes: html_attributes
12
+ )
13
+ end
14
+
15
+ def body
16
+ return [arrow, title_span] if block_mode?
17
+
18
+ [title_span, arrow]
19
+ end
20
+
21
+ private
22
+
23
+ def aria_label
24
+ @visually_hidden_text || "Next page"
25
+ end
26
+
27
+ def arrow
28
+ tag.svg(class: "govuk-pagination__icon govuk-pagination__icon--next", xmlns: "http://www.w3.org/2000/svg", height: "13", width: "15", focusable: "false", viewBox: "0 0 15 13", aria: { hidden: "true" }) do
29
+ tag.path(d: "m8.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ class GovukComponent::PaginationComponent::PreviousPage < GovukComponent::PaginationComponent::AdjacentPage
2
+ def initialize(href:, text:, label_text: nil, visually_hidden_text: nil, block_mode: true, classes: [], html_attributes: {})
3
+ super(
4
+ suffix: "prev",
5
+ text: text,
6
+ href: href,
7
+ label_text: label_text,
8
+ block_mode: block_mode,
9
+ visually_hidden_text: visually_hidden_text,
10
+ classes: classes,
11
+ html_attributes: html_attributes
12
+ )
13
+ end
14
+
15
+ private
16
+
17
+ def aria_label
18
+ @visually_hidden_text || "Previous page"
19
+ end
20
+
21
+ def arrow
22
+ tag.svg(class: "govuk-pagination__icon govuk-pagination__icon--prev", xmlns: "http://www.w3.org/2000/svg", height: "13", width: "15", focusable: "false", viewBox: "0 0 15 13", aria: { hidden: "true" }) do
23
+ tag.path(d: "m6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z")
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,121 @@
1
+ class GovukComponent::PaginationComponent < GovukComponent::Base
2
+ include Pagy::UrlHelpers
3
+
4
+ attr_reader :pagy,
5
+ :next_text,
6
+ :previous_text,
7
+ :visually_hidden_next_text,
8
+ :visually_hidden_previous_text,
9
+ :page_items,
10
+ :previous_content,
11
+ :next_content,
12
+ :block_mode,
13
+ :landmark_label
14
+
15
+ alias_method :block_mode?, :block_mode
16
+
17
+ renders_many :items, "GovukComponent::PaginationComponent::Item"
18
+
19
+ renders_one :next_page, ->(href:, text: default_next_text, label_text: nil, visually_hidden_text: nil, classes: [], html_attributes: {}) do
20
+ GovukComponent::PaginationComponent::NextPage.new(
21
+ text: text,
22
+ href: href,
23
+ label_text: label_text,
24
+ block_mode: block_mode?,
25
+ visually_hidden_text: visually_hidden_text,
26
+ classes: classes,
27
+ html_attributes: html_attributes
28
+ )
29
+ end
30
+
31
+ renders_one :previous_page, ->(href:, text: default_previous_text, label_text: nil, visually_hidden_text: nil, classes: [], html_attributes: {}) do
32
+ GovukComponent::PaginationComponent::PreviousPage.new(
33
+ text: text,
34
+ href: href,
35
+ label_text: label_text,
36
+ block_mode: block_mode?,
37
+ visually_hidden_text: visually_hidden_text,
38
+ classes: classes,
39
+ html_attributes: html_attributes
40
+ )
41
+ end
42
+
43
+ def initialize(pagy: nil, next_text: nil, previous_text: nil, visually_hidden_next_text: nil, visually_hidden_previous_text: nil, block_mode: false, landmark_label: "results", classes: [], html_attributes: {})
44
+ @pagy = pagy
45
+ @next_text = next_text
46
+ @previous_text = previous_text
47
+ @visually_hidden_next_text = visually_hidden_next_text
48
+ @visually_hidden_previous_text = visually_hidden_previous_text
49
+ @block_mode = block_mode
50
+ @landmark_label = landmark_label
51
+
52
+ build_items if pagy.present?
53
+
54
+ super(classes: classes, html_attributes: html_attributes)
55
+ end
56
+
57
+ def before_render
58
+ @page_items = items || build_items
59
+ @previous_content = previous_page || build_previous
60
+ @next_content = next_page || build_next
61
+ end
62
+
63
+ def call
64
+ attributes = html_attributes.tap { |ha| (ha[:class] << "govuk-pagination--block") if items.empty? }
65
+
66
+ tag.nav(**attributes) do
67
+ safe_join([
68
+ previous_content,
69
+ tag.ul(class: "govuk-pagination__list") { safe_join(page_items) },
70
+ next_content
71
+ ])
72
+ end
73
+ end
74
+
75
+ def render?
76
+ # probably isn't any point rendering if there's only one page
77
+ (pagy.present? && pagy.series.size > 1) || @previous_content.present? || @next_content.present?
78
+ end
79
+
80
+ private
81
+
82
+ def default_attributes
83
+ { role: "navigation", aria: { label: landmark_label }, class: %w(govuk-pagination) }
84
+ end
85
+
86
+ def build_previous
87
+ return unless pagy&.prev
88
+
89
+ kwargs = {
90
+ href: pagy_url_for(pagy, pagy.prev),
91
+ text: @previous_text,
92
+ visually_hidden_text: visually_hidden_previous_text,
93
+ }
94
+
95
+ previous_page(**kwargs.compact)
96
+ end
97
+
98
+ def build_next
99
+ return unless pagy&.next
100
+
101
+ kwargs = {
102
+ href: pagy_url_for(pagy, pagy.next),
103
+ text: @next_text,
104
+ visually_hidden_text: visually_hidden_next_text,
105
+ }
106
+
107
+ next_page(**kwargs.compact)
108
+ end
109
+
110
+ def build_items
111
+ pagy.series.map { |i| item(number: i, href: pagy_url_for(pagy, i), from_pagy: true) }
112
+ end
113
+
114
+ def default_next_text
115
+ safe_join(["Next", tag.span(class: "govuk-visually-hidden") { " page" }])
116
+ end
117
+
118
+ def default_previous_text
119
+ safe_join(["Previous", tag.span(class: "govuk-visually-hidden") { " page" }])
120
+ end
121
+ end
@@ -4,24 +4,24 @@ class GovukComponent::PanelComponent < GovukComponent::Base
4
4
  renders_one :title_html
5
5
 
6
6
  def initialize(title_text: nil, text: nil, heading_level: 1, id: nil, classes: [], html_attributes: {})
7
- super(classes: classes, html_attributes: html_attributes)
8
-
9
7
  @heading_level = heading_level
10
8
  @title_text = title_text
11
9
  @text = text
12
10
  @id = id
11
+
12
+ super(classes: classes, html_attributes: html_attributes)
13
13
  end
14
14
 
15
15
  def call
16
- tag.div(id: id, class: classes, **html_attributes) do
16
+ tag.div(id: id, **html_attributes) do
17
17
  safe_join([panel_title, panel_body].compact)
18
18
  end
19
19
  end
20
20
 
21
21
  private
22
22
 
23
- def default_classes
24
- %w(govuk-panel govuk-panel--confirmation)
23
+ def default_attributes
24
+ { class: %w(govuk-panel govuk-panel--confirmation) }
25
25
  end
26
26
 
27
27
  def heading_tag
@@ -1,4 +1,4 @@
1
- <%= tag.div(class: classes, **html_attributes) do %>
1
+ <%= tag.div(**html_attributes) do %>
2
2
  <p class="govuk-phase-banner__content">
3
3
  <%= render(phase_tag_component) %>
4
4
  <%= tag.span((content.presence || @text), class: "govuk-phase-banner__text") %>
@@ -2,10 +2,10 @@ class GovukComponent::PhaseBannerComponent < GovukComponent::Base
2
2
  attr_reader :text, :phase_tag
3
3
 
4
4
  def initialize(tag: nil, text: nil, classes: [], html_attributes: {})
5
- super(classes: classes, html_attributes: html_attributes)
6
-
7
5
  @phase_tag = tag
8
6
  @text = text
7
+
8
+ super(classes: classes, html_attributes: html_attributes)
9
9
  end
10
10
 
11
11
  def phase_tag_component
@@ -14,7 +14,7 @@ class GovukComponent::PhaseBannerComponent < GovukComponent::Base
14
14
 
15
15
  private
16
16
 
17
- def default_classes
18
- %w(govuk-phase-banner)
17
+ def default_attributes
18
+ { class: %w(govuk-phase-banner) }
19
19
  end
20
20
  end
@@ -0,0 +1,44 @@
1
+ class GovukComponent::SectionBreakComponent < GovukComponent::Base
2
+ SIZES = %w(m l xl).freeze
3
+
4
+ def initialize(visible: false, size: nil, classes: [], html_attributes: {})
5
+ @visible = visible
6
+ @size = size
7
+
8
+ super(classes: classes, html_attributes: html_attributes)
9
+ end
10
+
11
+ def call
12
+ tag.hr(**html_attributes)
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :size, :visible
18
+
19
+ def default_attributes
20
+ { class: default_classes }
21
+ end
22
+
23
+ def default_classes
24
+ class_names(
25
+ "govuk-section-break",
26
+ size_class,
27
+ "govuk-section-break--visible" => visible?
28
+ ).split
29
+ end
30
+
31
+ def size_class
32
+ if size.blank?
33
+ ""
34
+ elsif size.in?(SIZES)
35
+ "govuk-section-break--#{size}"
36
+ else
37
+ raise ArgumentError, "invalid size #{size}, supported sizes are #{SIZES.to_sentence}"
38
+ end
39
+ end
40
+
41
+ def visible?
42
+ visible
43
+ end
44
+ end
@@ -1,15 +1,21 @@
1
1
  class GovukComponent::StartButtonComponent < GovukComponent::Base
2
+ BUTTON_ATTRIBUTES = {
3
+ role: 'button',
4
+ draggable: 'false',
5
+ data: { module: 'govuk-button' }
6
+ }.freeze
7
+
2
8
  attr_reader :text, :href
3
9
 
4
10
  def initialize(text:, href:, classes: [], html_attributes: {})
5
- super(classes: classes, html_attributes: html_attributes)
6
-
7
11
  @text = text
8
12
  @href = href
13
+
14
+ super(classes: classes, html_attributes: html_attributes)
9
15
  end
10
16
 
11
17
  def call
12
- link_to(href, **default_attributes, **html_attributes) do
18
+ link_to(href, **html_attributes) do
13
19
  safe_join([text, icon])
14
20
  end
15
21
  end
@@ -17,20 +23,17 @@ class GovukComponent::StartButtonComponent < GovukComponent::Base
17
23
  private
18
24
 
19
25
  def default_attributes
20
- {
21
- role: 'button',
22
- draggable: 'false',
23
- class: classes,
24
- data: { module: 'govuk-button' }
25
- }
26
+ BUTTON_ATTRIBUTES.merge({ class: %w(govuk-button govuk-button--start) })
26
27
  end
27
28
 
28
- def default_classes
29
- %w(govuk-button govuk-button--start)
29
+ def icon
30
+ tag.svg(**svg_attributes) do
31
+ tag.path(fill: "currentColor", d: "M0 0h13l20 20-20 20H0l20-20z")
32
+ end
30
33
  end
31
34
 
32
- def icon
33
- svg_attributes = {
35
+ def svg_attributes
36
+ {
34
37
  class: "govuk-button__start-icon",
35
38
  xmlns: "http://www.w3.org/2000/svg",
36
39
  width: "17.5",
@@ -39,9 +42,5 @@ private
39
42
  focusable: "false",
40
43
  aria: { hidden: "true" }
41
44
  }
42
-
43
- tag.svg(**svg_attributes) do
44
- tag.path(fill: "currentColor", d: "M0 0h13l20 20-20 20H0l20-20z")
45
- end
46
45
  end
47
46
  end
@@ -14,15 +14,19 @@ class GovukComponent::SummaryListComponent::ActionComponent < GovukComponent::Ba
14
14
  end
15
15
 
16
16
  def call
17
- link_classes = govuk_link_classes.append(classes).flatten
18
-
19
- link_to(href, class: link_classes, **html_attributes) do
17
+ link_to(href, **html_attributes) do
20
18
  safe_join([action_text, visually_hidden_span].compact, " ")
21
19
  end
22
20
  end
23
21
 
24
22
  private
25
23
 
24
+ def default_attributes
25
+ link_classes = govuk_link_classes.append(classes).flatten
26
+
27
+ { class: link_classes }
28
+ end
29
+
26
30
  def action_text
27
31
  content || text || fail(ArgumentError, "no text or content")
28
32
  end
@@ -2,19 +2,19 @@ class GovukComponent::SummaryListComponent::KeyComponent < GovukComponent::Base
2
2
  attr_reader :text
3
3
 
4
4
  def initialize(text: nil, classes: [], html_attributes: {})
5
- super(classes: classes, html_attributes: html_attributes)
6
-
7
5
  @text = text
6
+
7
+ super(classes: classes, html_attributes: html_attributes)
8
8
  end
9
9
 
10
10
  def call
11
- tag.dt(key_content, class: classes, **html_attributes)
11
+ tag.dt(key_content, **html_attributes)
12
12
  end
13
13
 
14
14
  private
15
15
 
16
- def default_classes
17
- %w(govuk-summary-list__key)
16
+ def default_attributes
17
+ { class: %w(govuk-summary-list__key) }
18
18
  end
19
19
 
20
20
  def key_content
@@ -6,17 +6,23 @@ class GovukComponent::SummaryListComponent::RowComponent < GovukComponent::Base
6
6
  renders_many :actions, GovukComponent::SummaryListComponent::ActionComponent
7
7
 
8
8
  def initialize(show_actions_column: nil, classes: [], html_attributes: {})
9
- super(classes: classes, html_attributes: html_attributes)
10
-
11
9
  @show_actions_column = show_actions_column
10
+
11
+ super(classes: classes, html_attributes: html_attributes)
12
12
  end
13
13
 
14
14
  def call
15
- tag.div(class: classes, **html_attributes) do
15
+ tag.div(**html_attributes) do
16
16
  safe_join([key, value, actions_content])
17
17
  end
18
18
  end
19
19
 
20
+ def before_render
21
+ if show_actions_column && actions.none?
22
+ html_attributes[:class] << no_actions_class
23
+ end
24
+ end
25
+
20
26
  private
21
27
 
22
28
  def actions_content
@@ -37,13 +43,15 @@ private
37
43
  end
38
44
  end
39
45
 
40
- def default_classes
41
- %w(govuk-summary-list__row).tap do |c|
42
- c << "govuk-summary-list__row--no-actions" if show_actions_column && actions.none?
43
- end
46
+ def default_attributes
47
+ { class: %w(govuk-summary-list__row) }
44
48
  end
45
49
 
46
50
  def actions_class
47
51
  "govuk-summary-list__actions"
48
52
  end
53
+
54
+ def no_actions_class
55
+ "govuk-summary-list__row--no-actions"
56
+ end
49
57
  end
@@ -8,13 +8,13 @@ class GovukComponent::SummaryListComponent::ValueComponent < GovukComponent::Bas
8
8
  end
9
9
 
10
10
  def call
11
- tag.dd(value_content, class: classes, **html_attributes)
11
+ tag.dd(value_content, **html_attributes)
12
12
  end
13
13
 
14
14
  private
15
15
 
16
- def default_classes
17
- %w(govuk-summary-list__value)
16
+ def default_attributes
17
+ { class: %w(govuk-summary-list__value) }
18
18
  end
19
19
 
20
20
  def value_content
@@ -1,4 +1,4 @@
1
- <%= tag.dl(class: classes, **html_attributes) do %>
1
+ <%= tag.dl(**html_attributes) do %>
2
2
  <% rows.each do |row| %>
3
3
  <%= row %>
4
4
  <% end %>
@@ -12,28 +12,24 @@ module GovukComponent
12
12
  end
13
13
 
14
14
  def initialize(rows: nil, actions: true, borders: true, classes: [], html_attributes: {})
15
- super(classes: classes, html_attributes: html_attributes)
16
-
17
15
  @borders = borders
18
16
  @show_actions_column = actions
19
17
 
18
+ super(classes: classes, html_attributes: html_attributes)
19
+
20
20
  return unless rows.presence
21
21
 
22
22
  build(rows)
23
23
  end
24
24
 
25
- def classes
26
- super.append(borders_class).compact
27
- end
28
-
29
25
  private
30
26
 
31
27
  def borders_class
32
28
  %(govuk-summary-list--no-border) unless borders
33
29
  end
34
30
 
35
- def default_classes
36
- %w(govuk-summary-list)
31
+ def default_attributes
32
+ { class: ["govuk-summary-list", borders_class].compact }
37
33
  end
38
34
 
39
35
  def build(rows)
@@ -1,4 +1,4 @@
1
- <%= tag.div(id: id, class: classes, data: { module: 'govuk-tabs' }, **html_attributes) do %>
1
+ <%= tag.div(**html_attributes) do %>
2
2
  <%= tag.h2(title, class: "govuk-tabs__title") %>
3
3
  <ul class="govuk-tabs__list">
4
4
  <% tabs.each.with_index do |tab, i| %>
@@ -6,6 +6,6 @@
6
6
  <% end %>
7
7
  </ul>
8
8
  <% tabs.each.with_index do |tab, i| %>
9
- <%= tag.div(tab, class: tab.classes.append(tab.hidden_class(i)), id: tab.id, **tab.html_attributes) %>
9
+ <%= tag.div(tab, **tab.combined_attributes(i)) %>
10
10
  <% end %>
11
11
  <% end %>