govuk-components 2.1.3 → 3.0.0b2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +37 -36
  3. data/app/components/govuk_component/accordion_component/section_component.rb +1 -3
  4. data/app/components/govuk_component/back_link_component.rb +2 -2
  5. data/app/components/govuk_component/breadcrumbs_component.rb +5 -4
  6. data/app/components/govuk_component/cookie_banner_component.rb +18 -15
  7. data/app/components/govuk_component/details_component.rb +1 -1
  8. data/app/components/govuk_component/footer_component.html.erb +13 -4
  9. data/app/components/govuk_component/footer_component.rb +2 -1
  10. data/app/components/govuk_component/header_component.html.erb +5 -5
  11. data/app/components/govuk_component/phase_banner_component.rb +1 -1
  12. data/app/components/govuk_component/summary_list_component.rb +21 -19
  13. data/app/components/govuk_component/tab_component.rb +1 -3
  14. data/app/components/govuk_component/table_component/body_component.rb +1 -1
  15. data/app/components/govuk_component/table_component/caption_component.rb +1 -3
  16. data/app/components/govuk_component/table_component/cell_component.rb +9 -15
  17. data/app/components/govuk_component/table_component/head_component.rb +1 -1
  18. data/app/components/govuk_component/table_component/row_component.rb +1 -1
  19. data/app/components/govuk_component/table_component.rb +25 -23
  20. data/app/components/govuk_component/traits.rb +1 -0
  21. data/app/components/govuk_component/warning_text_component.rb +4 -4
  22. data/app/components/govuk_component.rb +1 -0
  23. data/app/helpers/govuk_link_helper.rb +6 -2
  24. data/lib/govuk/components/version.rb +1 -1
  25. metadata +149 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ff2f2871745bc313242de390b143fd475f0983e6ddf03c627512d26e5c52b8c
4
- data.tar.gz: c191fa0f05fea8fa6bc19d9fddf8528802086a05f63217e4b48079329cf25a87
3
+ metadata.gz: ae11984437c0a4e6631d19c4db1211886178b8a70498f3d2592175cb7ba466e9
4
+ data.tar.gz: 6cfbbf6933643393abf51f6dc6c8b6d6c62c36b5a93e62dbfdd955f3ab845fe1
5
5
  SHA512:
6
- metadata.gz: ea255c815feebd10555c8f403b4cd3ebac0d807cd1f4fe9a34442318a2f95d75cbbe309fb0f18aebbfcc0a7c32ee3bc962c971717fe7f9506ab10844eea8cda0
7
- data.tar.gz: 6dada7350b560d7b967fa1bba83231d82173b1f81c90c563d803583fc4d99347a9973e193adda2eb58af86a86183d5e22d3b17d5e7be3aa9fb0ec8066af75c04
6
+ metadata.gz: 82da69e1477bd8e07b7c778aff87da77886eb2008bbe470996635445b73de841b03b3fb91b0000d7067072b98a6998ccaafa204447e2ed284b8411204e1ff435
7
+ data.tar.gz: eb1ce8afdb5562b9de0eeda99bb62122101ac42656ab0a5999f10372ed343c153f8769cc8ab420e06c790c21407e94fb79932c7448c7a36da41a3d02629e62e1
data/README.md CHANGED
@@ -6,43 +6,43 @@
6
6
  [![GitHub license](https://img.shields.io/github/license/DFE-Digital/govuk-components)](https://github.com/DFE-Digital/govuk-components/blob/master/LICENSE)
7
7
  [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-3.13.1-brightgreen)](https://design-system.service.gov.uk)
8
8
 
9
- This gem provides a suite of reusable components for the [GOV.UK Design System](https://design-system.service.gov.uk/). It is intended to provide a lightweight alternative to the [GOV.UK Publishing Components](https://github.com/alphagov/govuk_publishing_components) library and is built with Github's [ViewComponent](https://github.com/github/view_component) framework.
9
+ This gem provides a suite of reusable components for the [GOV.UK Design System](https://design-system.service.gov.uk/). It is intended to provide a lightweight alternative to the [GOV.UK Publishing Components](https://github.com/alphagov/govuk_publishing_components) library and is built with GitHub’s [ViewComponent](https://github.com/github/view_component) framework.
10
10
 
11
11
  It aims to implement the functionality from the original Nunjucks macros in a way that will feel more familiar to Rails developers. Blocks are preferred over strings of HTML, beneath the surface each component is just a Ruby object, everything is inheritable and overrideable.
12
12
 
13
- ## What's included?
13
+ ## Whats included?
14
14
 
15
- All of the non-form components from the GOV.UK Design System are implmented by this library as ViewComponents. Form components are implemented by the [form builder](https://govuk-form-builder.netlify.app/).
15
+ All of the non-form components from the GOV.UK Design System are implemented by this library as ViewComponents. Form components are implemented by the [GOV.UK Form Builder](https://govuk-form-builder.netlify.app/).
16
16
 
17
17
  The provided components are:
18
18
 
19
- * [Accordion](https://dfe-digital.github.io/govuk-components/#accordion)
20
- * [Back link](https://dfe-digital.github.io/govuk-components/#back-links)
21
- * [Back to top link](https://dfe-digital.github.io/govuk-components/#back-to-top-link)
22
- * [Breadcrumbs](https://dfe-digital.github.io/govuk-components/#breadcrumbs)
23
- * [Cookie banner](https://dfe-digital.github.io/govuk-components/#cookie-banner)
24
- * [Details](https://dfe-digital.github.io/govuk-components/#details)
25
- * [Footer](https://dfe-digital.github.io/govuk-components/#footer)
26
- * [Header](https://dfe-digital.github.io/govuk-components/#header)
27
- * [Inset text](https://dfe-digital.github.io/govuk-components/#inset-text)
28
- * [Notification banner](https://dfe-digital.github.io/govuk-components/#notification-banner)
29
- * [Panel](https://dfe-digital.github.io/govuk-components/#panel)
30
- * [Phase banner](https://dfe-digital.github.io/govuk-components/#phase-banner)
31
- * [Skip link](https://dfe-digital.github.io/govuk-components/#skip-link)
32
- * [Start button](https://dfe-digital.github.io/govuk-components/#start-button)
33
- * [Summary list](https://dfe-digital.github.io/govuk-components/#summary-list)
34
- * [Tabs](https://dfe-digital.github.io/govuk-components/#tabs)
35
- * [Tables](https://dfe-digital.github.io/govuk-components/#table)
36
- * [Tags](https://dfe-digital.github.io/govuk-components/#tags)
37
- * [Warning text](https://dfe-digital.github.io/govuk-components/#warning-text)
38
-
39
- This library also provides [several link helpers](https://dfe-digital.github.io/govuk-components/#links-and-buttons) that are commonly used in services, including `#govuk_link_to` and `#govuk_button_to`.
19
+ * [Accordion](https://govuk-components.netlify.app/components/accordion)
20
+ * [Back link](https://govuk-components.netlify.app/components/back-links)
21
+ * [Back to top link](https://govuk-components.netlify.app/components/back-to-top-link)
22
+ * [Breadcrumbs](https://govuk-components.netlify.app/components/breadcrumbs)
23
+ * [Cookie banner](https://govuk-components.netlify.app/components/cookie-banner)
24
+ * [Details](https://govuk-components.netlify.app/components/details)
25
+ * [Footer](https://govuk-components.netlify.app/components/footer)
26
+ * [Header](https://govuk-components.netlify.app/components/header)
27
+ * [Inset text](https://govuk-components.netlify.app/components/inset-text)
28
+ * [Notification banner](https://govuk-components.netlify.app/components/notification-banner)
29
+ * [Panel](https://govuk-components.netlify.app/components/panel)
30
+ * [Phase banner](https://govuk-components.netlify.app/components/phase-banner)
31
+ * [Skip link](https://govuk-components.netlify.app/components/skip-link)
32
+ * [Start button](https://govuk-components.netlify.app/components/start-button)
33
+ * [Summary list](https://govuk-components.netlify.app/components/summary-list)
34
+ * [Tabs](https://govuk-components.netlify.app/components/tabs)
35
+ * [Tables](https://govuk-components.netlify.app/components/table)
36
+ * [Tags](https://govuk-components.netlify.app/components/tags)
37
+ * [Warning text](https://govuk-components.netlify.app/components/warning-text)
38
+
39
+ This library also provides [link](https://govuk-components.netlify.app/helpers/link) and [button](https://govuk-components.netlify.app/helpers/button) helpers.
40
40
 
41
41
  ## Alternative syntax
42
42
 
43
43
  All of the components can be rendered in two ways:
44
44
 
45
- * directly using Rails' `#render` method:
45
+ * directly using Rails `#render` method:
46
46
 
47
47
  ```erb
48
48
  <%= render GovukComponent::WarningTextComponent.new do %>
@@ -58,25 +58,24 @@ All of the components can be rendered in two ways:
58
58
  <% end %>
59
59
  ```
60
60
 
61
- The naming convention for helpers is `govuk_` followed by the component's name in snake case. You can
62
- see the full list in [GovukComponentsHelper](app/helpers/govuk_components_helper.rb).
61
+ The naming convention for helpers is `govuk_` followed by the components name in snake case. You can see the full list in [GovukComponentsHelper](app/helpers/govuk_components_helper.rb).
63
62
 
64
63
  ## Example use
65
64
 
66
- This library allows components to be rendered with Rails' `render` method or via the provided helpers. Here we'll use the `govuk_tabs` to render three tabbed sections:
65
+ This library allows components to be rendered with Rails `render` method or via the provided helpers. Here well use the `govuk_tabs` to render three tabbed sections:
67
66
 
68
67
  ```erb
69
68
  <%= govuk_tabs(title: 'Days of the week') do |component| %>
70
69
  <% component.tab(label: 'Monday') do %>
71
- <p>Monday's child is fair of face</p>
70
+ <p>Mondays child is fair of face</p>
72
71
  <% end %>
73
72
 
74
73
  <% component.tab(label: 'Tuesday') do %>
75
- <p>Tuesday's child is full of grace</p>
74
+ <p>Tuesdays child is full of grace</p>
76
75
  <% end %>
77
76
 
78
77
  <% component.tab(label: 'Wednesday') do %>
79
- <p>Wednesday's child is full of woe</p>
78
+ <p>Wednesdays child is full of woe</p>
80
79
  <% end %>
81
80
  <% end %>
82
81
 
@@ -107,20 +106,22 @@ require "govuk/components"
107
106
 
108
107
  ## Installation
109
108
 
110
- Add this line to your application's Gemfile:
109
+ Add this line to your applications Gemfile:
111
110
 
112
111
  ```ruby
113
112
  gem 'govuk-components'
114
113
  ```
115
114
 
116
115
  And then execute:
117
- ```bash
118
- $ bundle
116
+
117
+ ```sh
118
+ bundle
119
119
  ```
120
120
 
121
121
  Or install it yourself as:
122
- ```bash
123
- $ gem install govuk-components
122
+
123
+ ```sh
124
+ gem install govuk-components
124
125
  ```
125
126
 
126
127
  ## Contributing
@@ -34,8 +34,6 @@ class GovukComponent::AccordionComponent::SectionComponent < GovukComponent::Bas
34
34
  private
35
35
 
36
36
  def default_classes
37
- %w(govuk-accordion__section).tap do |classes|
38
- classes.append("govuk-accordion__section--expanded") if expanded?
39
- end
37
+ class_names("govuk-accordion__section", "govuk-accordion__section--expanded" => expanded?).split
40
38
  end
41
39
  end
@@ -1,7 +1,7 @@
1
1
  class GovukComponent::BackLinkComponent < GovukComponent::Base
2
2
  attr_reader :text, :href
3
3
 
4
- def initialize(href:, text: nil, classes: nil, html_attributes: {})
4
+ def initialize(href:, text: 'Back', classes: nil, html_attributes: {})
5
5
  super(classes: classes, html_attributes: html_attributes)
6
6
 
7
7
  @text = text
@@ -15,7 +15,7 @@ class GovukComponent::BackLinkComponent < GovukComponent::Base
15
15
  private
16
16
 
17
17
  def link_content
18
- text || content || fail(ArgumentError, "no text or content")
18
+ content || text || fail(ArgumentError, "no text or content")
19
19
  end
20
20
 
21
21
  def default_classes
@@ -12,10 +12,11 @@ class GovukComponent::BreadcrumbsComponent < GovukComponent::Base
12
12
  private
13
13
 
14
14
  def default_classes
15
- %w(govuk-breadcrumbs).tap do |classes|
16
- classes << "govuk-!-display-none-print" if hide_in_print
17
- classes << "govuk-breadcrumbs--collapse-on-mobile" if collapse_on_mobile
18
- end
15
+ class_names(
16
+ "govuk-breadcrumbs",
17
+ "govuk-!-display-none-print" => hide_in_print,
18
+ "govuk-breadcrumbs--collapse-on-mobile" => collapse_on_mobile
19
+ ).split
19
20
  end
20
21
 
21
22
  def build_list(breadcrumbs)
@@ -1,24 +1,27 @@
1
- class GovukComponent::CookieBannerComponent < GovukComponent::Base
2
- renders_many :messages, GovukComponent::CookieBannerComponent::MessageComponent
1
+ module GovukComponent
2
+ class CookieBannerComponent < GovukComponent::Base
3
+ renders_many :messages, "GovukComponent::CookieBannerComponent::MessageComponent"
3
4
 
4
- attr_accessor :aria_label, :hidden
5
+ attr_accessor :aria_label, :hidden, :hide_in_print
5
6
 
6
- def initialize(aria_label: "Cookie banner", hidden: false, classes: [], html_attributes: {})
7
- super(classes: classes, html_attributes: html_attributes)
7
+ def initialize(aria_label: "Cookie banner", hidden: false, hide_in_print: true, classes: [], html_attributes: {})
8
+ super(classes: classes, html_attributes: html_attributes)
8
9
 
9
- @aria_label = aria_label
10
- @hidden = hidden
11
- end
10
+ @aria_label = aria_label
11
+ @hidden = hidden
12
+ @hide_in_print = hide_in_print
13
+ end
12
14
 
13
- def call
14
- tag.div(class: classes, role: "region", aria: { label: aria_label }, hidden: hidden, **html_attributes) do
15
- safe_join(messages)
15
+ def call
16
+ tag.div(class: classes, role: "region", aria: { label: aria_label }, data: { nosnippet: true }, hidden: hidden, **html_attributes) do
17
+ safe_join(messages)
18
+ end
16
19
  end
17
- end
18
20
 
19
- private
21
+ private
20
22
 
21
- def default_classes
22
- %w(govuk-cookie-banner)
23
+ def default_classes
24
+ class_names("govuk-cookie-banner", "govuk-!-display-none-print" => hide_in_print).split
25
+ end
23
26
  end
24
27
  end
@@ -3,7 +3,7 @@ class GovukComponent::DetailsComponent < GovukComponent::Base
3
3
 
4
4
  renders_one :summary_html
5
5
 
6
- def initialize(summary_text:, text: nil, classes: [], id: nil, open: nil, html_attributes: {})
6
+ def initialize(summary_text: nil, text: nil, classes: [], id: nil, open: nil, html_attributes: {})
7
7
  super(classes: classes, html_attributes: html_attributes)
8
8
 
9
9
  @summary_text = summary_text
@@ -1,5 +1,13 @@
1
1
  <%= tag.footer(class: classes, role: 'contentinfo', **html_attributes) do %>
2
2
  <%= tag.div(class: container_classes, **container_html_attributes) do %>
3
+ <% if navigation.present? %>
4
+ <div class="govuk-footer__navigation">
5
+ <%= navigation %>
6
+ </div>
7
+
8
+ <hr class="govuk-footer__section-break">
9
+ <% end %>
10
+
3
11
  <%= tag.div(class: meta_classes, **meta_html_attributes) do %>
4
12
  <% if meta.present? %>
5
13
  <%= meta %>
@@ -28,12 +36,13 @@
28
36
  <% end %>
29
37
 
30
38
  <% if meta_content.present? %>
31
- <%= meta_content %>
39
+ <div class="govuk-footer__meta-custom">
40
+ <%= meta_content %>
41
+ </div>
32
42
  <% end %>
33
43
  </div>
34
- <div class="govuk-footer__meta">
35
- <%= tag.div(copyright, class: "govuk-footer__meta-item") %>
36
- </div>
44
+
45
+ <%= tag.div(copyright, class: "govuk-footer__meta-item") %>
37
46
  <% end %>
38
47
  <% end %>
39
48
  <% end %>
@@ -1,6 +1,7 @@
1
1
  class GovukComponent::FooterComponent < GovukComponent::Base
2
2
  renders_one :meta_html
3
3
  renders_one :meta
4
+ renders_one :navigation
4
5
 
5
6
  attr_reader :meta_items, :meta_text, :meta_items_title, :meta_licence, :copyright, :custom_container_classes
6
7
 
@@ -76,7 +77,7 @@ private
76
77
  end
77
78
 
78
79
  def default_copright_text
79
- raw(%(&copy Crown copyright))
80
+ raw(%(© Crown copyright))
80
81
  end
81
82
 
82
83
  def default_copyright_url
@@ -36,14 +36,14 @@
36
36
  <% end %>
37
37
 
38
38
  <% if navigation_items.any? %>
39
- <%= tag.button("Menu", type: "button", class: %w(govuk-header__menu-button govuk-js-header-toggle), aria: { controls: "navigation", label: menu_button_label }) %>
40
- <nav>
41
- <%= tag.ul(class: navigation_classes, id: "navigation", aria: { label: navigation_label }) do %>
39
+ <%= tag.nav(class: navigation_classes, aria: { label: navigation_label }) do %>
40
+ <%= tag.button("Menu", type: "button", class: %w(govuk-header__menu-button govuk-js-header-toggle), aria: { controls: "navigation", label: menu_button_label }) %>
41
+ <ul id="navigation" class="govuk-header__navigation-list">
42
42
  <% navigation_items.each do |item| %>
43
43
  <%= item %>
44
44
  <% end %>
45
- <% end %>
46
- </nav>
45
+ </ul>
46
+ <% end %>
47
47
  <% end %>
48
48
  </div>
49
49
  <% end %>
@@ -9,7 +9,7 @@ class GovukComponent::PhaseBannerComponent < GovukComponent::Base
9
9
  end
10
10
 
11
11
  def phase_tag_component
12
- GovukComponent::TagComponent.new(classes: "govuk-phase-banner__content__tag", **phase_tag)
12
+ GovukComponent::TagComponent.new(**phase_tag.deep_merge(classes: "govuk-phase-banner__content__tag"))
13
13
  end
14
14
 
15
15
  private
@@ -1,29 +1,31 @@
1
- class GovukComponent::SummaryListComponent < GovukComponent::Base
2
- attr_reader :borders
1
+ module GovukComponent
2
+ class SummaryListComponent < GovukComponent::Base
3
+ attr_reader :borders
3
4
 
4
- renders_many :rows, GovukComponent::SummaryListComponent::RowComponent
5
+ renders_many :rows, "GovukComponent::SummaryListComponent::RowComponent"
5
6
 
6
- def initialize(borders: true, classes: [], html_attributes: {})
7
- super(classes: classes, html_attributes: html_attributes)
7
+ def initialize(borders: true, classes: [], html_attributes: {})
8
+ super(classes: classes, html_attributes: html_attributes)
8
9
 
9
- @borders = borders
10
- end
10
+ @borders = borders
11
+ end
11
12
 
12
- def any_row_has_actions?
13
- rows.any? { |row| row.href.present? }
14
- end
13
+ def any_row_has_actions?
14
+ rows.any? { |row| row.href.present? }
15
+ end
15
16
 
16
- def classes
17
- super.append(borders_class).compact
18
- end
17
+ def classes
18
+ super.append(borders_class).compact
19
+ end
19
20
 
20
- private
21
+ private
21
22
 
22
- def borders_class
23
- %(govuk-summary-list--no-border) unless borders
24
- end
23
+ def borders_class
24
+ %(govuk-summary-list--no-border) unless borders
25
+ end
25
26
 
26
- def default_classes
27
- %w(govuk-summary-list)
27
+ def default_classes
28
+ %w(govuk-summary-list)
29
+ end
28
30
  end
29
31
  end
@@ -35,9 +35,7 @@ private
35
35
  end
36
36
 
37
37
  def li_classes(i = nil)
38
- %w(govuk-tabs__list-item).tap do |c|
39
- c.append("govuk-tabs__list-item--selected") if i&.zero?
40
- end
38
+ class_names("govuk-tabs__list-item", "govuk-tabs__list-item--selected" => i&.zero?).split
41
39
  end
42
40
 
43
41
  def li_link
@@ -1,5 +1,5 @@
1
1
  class GovukComponent::TableComponent::BodyComponent < GovukComponent::Base
2
- renders_many :rows, GovukComponent::TableComponent::RowComponent
2
+ renders_many :rows, "GovukComponent::TableComponent::RowComponent"
3
3
 
4
4
  def initialize(rows: nil, first_cell_is_header: false, classes: [], html_attributes: {})
5
5
  super(classes: classes, html_attributes: html_attributes)
@@ -26,9 +26,7 @@ private
26
26
  end
27
27
 
28
28
  def default_classes
29
- %w(govuk-table__caption).tap do |c|
30
- c << caption_size_class if @size
31
- end
29
+ class_names("govuk-table__caption", caption_size_class => size).split
32
30
  end
33
31
 
34
32
  def caption_size_class
@@ -4,12 +4,12 @@ class GovukComponent::TableComponent::CellComponent < GovukComponent::Base
4
4
  alias_method :numeric?, :numeric
5
5
 
6
6
  WIDTHS = {
7
- "full" => "govuk-input govuk-!-width-full",
8
- "three-quarters" => "govuk-input govuk-!-width-three-quarters",
9
- "two-thirds" => "govuk-input govuk-!-width-two-thirds",
10
- "one-half" => "govuk-input govuk-!-width-one-half",
11
- "one-third" => "govuk-input govuk-!-width-one-third",
12
- "one-quarter" => "govuk-input govuk-!-width-one-quarter",
7
+ "full" => "govuk-!-width-full",
8
+ "three-quarters" => "govuk-!-width-three-quarters",
9
+ "two-thirds" => "govuk-!-width-two-thirds",
10
+ "one-half" => "govuk-!-width-one-half",
11
+ "one-third" => "govuk-!-width-one-third",
12
+ "one-quarter" => "govuk-!-width-one-quarter",
13
13
  }.freeze
14
14
 
15
15
  def initialize(header: false, text: nil, numeric: false, width: nil, classes: [], html_attributes: {})
@@ -37,19 +37,13 @@ private
37
37
 
38
38
  def default_classes
39
39
  if header
40
- %w(govuk-table__header).tap do |c|
41
- c << "govuk-table__header--numeric" if numeric?
42
- c << width_class if width?
43
- end
40
+ class_names("govuk-table__header", "govuk-table__header--numeric" => numeric?, width_class => width?).split
44
41
  else
45
- %w(govuk-table__cell).tap do |c|
46
- c << "govuk-table__cell--numeric" if numeric?
47
- c << width_class if width?
48
- end
42
+ class_names("govuk-table__cell", "govuk-table__cell--numeric" => numeric?, width_class => width?).split
49
43
  end
50
44
  end
51
45
 
52
46
  def width_class
53
- WIDTHS.fetch(width)
47
+ WIDTHS.fetch(width, nil)
54
48
  end
55
49
  end
@@ -1,5 +1,5 @@
1
1
  class GovukComponent::TableComponent::HeadComponent < GovukComponent::Base
2
- renders_many :rows, GovukComponent::TableComponent::RowComponent
2
+ renders_many :rows, "GovukComponent::TableComponent::RowComponent"
3
3
 
4
4
  attr_reader :row_data
5
5
 
@@ -1,5 +1,5 @@
1
1
  class GovukComponent::TableComponent::RowComponent < GovukComponent::Base
2
- renders_many :cells, GovukComponent::TableComponent::CellComponent
2
+ renders_many :cells, "GovukComponent::TableComponent::CellComponent"
3
3
 
4
4
  attr_reader :header, :first_cell_is_header
5
5
 
@@ -1,33 +1,35 @@
1
- class GovukComponent::TableComponent < GovukComponent::Base
2
- renders_one :caption, GovukComponent::TableComponent::CaptionComponent
3
- renders_one :head, GovukComponent::TableComponent::HeadComponent
4
- renders_many :bodies, GovukComponent::TableComponent::BodyComponent
1
+ module GovukComponent
2
+ class TableComponent < GovukComponent::Base
3
+ renders_one :caption, "GovukComponent::TableComponent::CaptionComponent"
4
+ renders_one :head, "GovukComponent::TableComponent::HeadComponent"
5
+ renders_many :bodies, "GovukComponent::TableComponent::BodyComponent"
5
6
 
6
- attr_accessor :id, :first_cell_is_header, :caption_text
7
+ attr_accessor :id, :first_cell_is_header, :caption_text
7
8
 
8
- def initialize(id: nil, rows: nil, head: nil, caption: nil, first_cell_is_header: false, classes: [], html_attributes: {})
9
- super(classes: classes, html_attributes: html_attributes)
9
+ def initialize(id: nil, rows: nil, head: nil, caption: nil, first_cell_is_header: false, classes: [], html_attributes: {})
10
+ super(classes: classes, html_attributes: html_attributes)
10
11
 
11
- @id = id
12
- @first_cell_is_header = first_cell_is_header
13
- @caption_text = caption
12
+ @id = id
13
+ @first_cell_is_header = first_cell_is_header
14
+ @caption_text = caption
14
15
 
15
- # when no rows are passed in it's likely we're taking the slot approach
16
- return unless rows.presence
16
+ # when no rows are passed in it's likely we're taking the slot approach
17
+ return unless rows.presence
17
18
 
18
- # if no head is passed in,use the first row for headers
19
- build(*(head ? [head, rows] : [rows[0], rows[1..]]), caption_text)
20
- end
19
+ # if no head is passed in,use the first row for headers
20
+ build(*(head ? [head, rows] : [rows[0], rows[1..]]), caption_text)
21
+ end
21
22
 
22
- private
23
+ private
23
24
 
24
- def build(head_data, body_data, caption_text)
25
- caption(text: caption_text)
26
- head(rows: [head_data])
27
- body(rows: body_data, first_cell_is_header: first_cell_is_header)
28
- end
25
+ def build(head_data, body_data, caption_text)
26
+ caption(text: caption_text)
27
+ head(rows: [head_data])
28
+ body(rows: body_data, first_cell_is_header: first_cell_is_header)
29
+ end
29
30
 
30
- def default_classes
31
- %w(govuk-table)
31
+ def default_classes
32
+ %w(govuk-table)
33
+ end
32
34
  end
33
35
  end
@@ -0,0 +1 @@
1
+ module GovukComponent::Traits; end
@@ -3,7 +3,7 @@ class GovukComponent::WarningTextComponent < GovukComponent::Base
3
3
 
4
4
  ICON = '!'.freeze
5
5
 
6
- def initialize(text:, icon_fallback_text: 'Warning', classes: [], html_attributes: {})
6
+ def initialize(text: nil, icon_fallback_text: 'Warning', classes: [], html_attributes: {})
7
7
  super(classes: classes, html_attributes: html_attributes)
8
8
 
9
9
  @text = text
@@ -12,7 +12,7 @@ class GovukComponent::WarningTextComponent < GovukComponent::Base
12
12
 
13
13
  def call
14
14
  tag.div(class: classes, **html_attributes) do
15
- safe_join([icon, (content || strong)])
15
+ safe_join([icon, warning_text])
16
16
  end
17
17
  end
18
18
 
@@ -22,9 +22,9 @@ private
22
22
  tag.span(ICON, class: 'govuk-warning-text__icon', aria: { hidden: true })
23
23
  end
24
24
 
25
- def strong
25
+ def warning_text
26
26
  tag.strong(class: 'govuk-warning-text__text') do
27
- safe_join([assistive, text])
27
+ safe_join([assistive, (content || text)])
28
28
  end
29
29
  end
30
30
 
@@ -0,0 +1 @@
1
+ module GovukComponent; end
@@ -56,7 +56,11 @@ module GovukLinkHelper
56
56
  html_options = build_html_options(extra_options, style: :button)
57
57
 
58
58
  if block_given?
59
- button_to(name, html_options, &block)
59
+ if Rails.version >= "7.0.0" && name.is_a?(Hash)
60
+ button_to(name.merge(html_options), &block)
61
+ else
62
+ button_to(name, html_options, &block)
63
+ end
60
64
  else
61
65
  button_to(name, options, html_options)
62
66
  end
@@ -114,7 +118,7 @@ private
114
118
  attributes ||= {}
115
119
 
116
120
  attributes.with_indifferent_access.tap do |attrs|
117
- attrs[:class] = Array.wrap(attrs[:class]).prepend(class_name).flatten
121
+ attrs[:class] = Array.wrap(attrs[:class]).prepend(class_name).flatten.join(" ")
118
122
  end
119
123
  end
120
124
  end
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '2.1.3'.freeze
3
+ VERSION = '3.0.0b2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,43 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 3.0.0b2
5
5
  platform: ruby
6
6
  authors:
7
7
  - DfE developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-08 00:00:00.000000000 Z
11
+ date: 2022-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.4.4
17
20
  - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: '6.0'
22
+ version: '6.1'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 6.1.4.4
24
30
  - - ">="
25
31
  - !ruby/object:Gem::Version
26
- version: '6.0'
32
+ version: '6.1'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: railties
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 6.1.4.4
31
40
  - - ">="
32
41
  - !ruby/object:Gem::Version
33
- version: '6.0'
42
+ version: '6.1'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 6.1.4.4
38
50
  - - ">="
39
51
  - !ruby/object:Gem::Version
40
- version: '6.0'
52
+ version: '6.1'
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: view_component
43
55
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +162,132 @@ dependencies:
150
162
  - - ">="
151
163
  - !ruby/object:Gem::Version
152
164
  version: '0'
165
+ - !ruby/object:Gem::Dependency
166
+ name: htmlbeautifier
167
+ requirement: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - "~>"
170
+ - !ruby/object:Gem::Version
171
+ version: 1.4.1
172
+ type: :development
173
+ prerelease: false
174
+ version_requirements: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - "~>"
177
+ - !ruby/object:Gem::Version
178
+ version: 1.4.1
179
+ - !ruby/object:Gem::Dependency
180
+ name: nanoc
181
+ requirement: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - "~>"
184
+ - !ruby/object:Gem::Version
185
+ version: '4.11'
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - "~>"
191
+ - !ruby/object:Gem::Version
192
+ version: '4.11'
193
+ - !ruby/object:Gem::Dependency
194
+ name: rouge
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: 3.27.0
200
+ type: :development
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - "~>"
205
+ - !ruby/object:Gem::Version
206
+ version: 3.27.0
207
+ - !ruby/object:Gem::Dependency
208
+ name: rubypants
209
+ requirement: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - "~>"
212
+ - !ruby/object:Gem::Version
213
+ version: 0.7.0
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - "~>"
219
+ - !ruby/object:Gem::Version
220
+ version: 0.7.0
221
+ - !ruby/object:Gem::Dependency
222
+ name: sass
223
+ requirement: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - ">="
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ type: :development
229
+ prerelease: false
230
+ version_requirements: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - ">="
233
+ - !ruby/object:Gem::Version
234
+ version: '0'
235
+ - !ruby/object:Gem::Dependency
236
+ name: sassc
237
+ requirement: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - "~>"
240
+ - !ruby/object:Gem::Version
241
+ version: 2.4.0
242
+ type: :development
243
+ prerelease: false
244
+ version_requirements: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - "~>"
247
+ - !ruby/object:Gem::Version
248
+ version: 2.4.0
249
+ - !ruby/object:Gem::Dependency
250
+ name: slim
251
+ requirement: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - "~>"
254
+ - !ruby/object:Gem::Version
255
+ version: 4.1.0
256
+ type: :development
257
+ prerelease: false
258
+ version_requirements: !ruby/object:Gem::Requirement
259
+ requirements:
260
+ - - "~>"
261
+ - !ruby/object:Gem::Version
262
+ version: 4.1.0
263
+ - !ruby/object:Gem::Dependency
264
+ name: slim_lint
265
+ requirement: !ruby/object:Gem::Requirement
266
+ requirements:
267
+ - - "~>"
268
+ - !ruby/object:Gem::Version
269
+ version: 0.22.0
270
+ type: :development
271
+ prerelease: false
272
+ version_requirements: !ruby/object:Gem::Requirement
273
+ requirements:
274
+ - - "~>"
275
+ - !ruby/object:Gem::Version
276
+ version: 0.22.0
277
+ - !ruby/object:Gem::Dependency
278
+ name: webrick
279
+ requirement: !ruby/object:Gem::Requirement
280
+ requirements:
281
+ - - "~>"
282
+ - !ruby/object:Gem::Version
283
+ version: 1.7.0
284
+ type: :development
285
+ prerelease: false
286
+ version_requirements: !ruby/object:Gem::Requirement
287
+ requirements:
288
+ - - "~>"
289
+ - !ruby/object:Gem::Version
290
+ version: 1.7.0
153
291
  description: A collection of components intended to ease the building of GOV.UK Design
154
292
  System web applications
155
293
  email:
@@ -161,6 +299,7 @@ files:
161
299
  - MIT-LICENSE
162
300
  - README.md
163
301
  - Rakefile
302
+ - app/components/govuk_component.rb
164
303
  - app/components/govuk_component/accordion_component.html.erb
165
304
  - app/components/govuk_component/accordion_component.rb
166
305
  - app/components/govuk_component/accordion_component/section_component.html.erb
@@ -203,6 +342,7 @@ files:
203
342
  - app/components/govuk_component/table_component/row_component.html.erb
204
343
  - app/components/govuk_component/table_component/row_component.rb
205
344
  - app/components/govuk_component/tag_component.rb
345
+ - app/components/govuk_component/traits.rb
206
346
  - app/components/govuk_component/traits/custom_classes.rb
207
347
  - app/components/govuk_component/traits/custom_html_attributes.rb
208
348
  - app/components/govuk_component/warning_text_component.rb
@@ -231,11 +371,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
231
371
  version: '0'
232
372
  required_rubygems_version: !ruby/object:Gem::Requirement
233
373
  requirements:
234
- - - ">="
374
+ - - ">"
235
375
  - !ruby/object:Gem::Version
236
- version: '0'
376
+ version: 1.3.1
237
377
  requirements: []
238
- rubygems_version: 3.2.22
378
+ rubygems_version: 3.2.32
239
379
  signing_key:
240
380
  specification_version: 4
241
381
  summary: Lightweight set of reusable GOV.UK Design System components