govuk-components 2.1.4 → 3.0.0b3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5a21817c2a776dc4571b5d5dab5a6492d4648672c6ec1603b1955132a811108
4
- data.tar.gz: 00e69dbbf540695dcaa130e21f9a340293d80cc73bbb1b9ee6827e39c063d0e7
3
+ metadata.gz: 07ed020fcee80322b4d5d89f39eab0fc2ee474916f94359a80ca9801a08a24aa
4
+ data.tar.gz: fe4a45acd08735f21c6b465b956d7372c7e3b8843016284a010aac7a080b6619
5
5
  SHA512:
6
- metadata.gz: e2308aa03c1af4efb1aae22af50322cbb7aebdf03b1c8668b12918b8c1edcf53c197217ef66b7ab19d46c218386f60075f78e99957726e898e3492df5e0c7dfa
7
- data.tar.gz: 77bccd1dd23d937d82c1e058fed2803a14e62a99e15acdb4841134249b24bef8992a9347c11920a95a620d28a13f0d7af187f992c1e8f232c45eda5c99bc969e
6
+ metadata.gz: f7892945af9393cac946f328fe0262da01ecd2c0a489f00a002e2599b03d94d48fef1e1c1e5e679270fdd9c15f8448f7a3835858db34487219eb1c671cbd6ca3
7
+ data.tar.gz: 39dee312be4c324de08d94077d53b05af472a33773f0c1187aaa9986e13ccbaa4d33f4ae7665b666e4a35fd680c1224a6c536666f544f9d17dff8cfa1e322552
data/README.md CHANGED
@@ -2,47 +2,52 @@
2
2
 
3
3
  [![Tests](https://github.com/DFE-Digital/govuk-components/workflows/Tests/badge.svg)](https://github.com/DFE-Digital/govuk-components/actions?query=workflow%3ATests)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/cbcbc140f300b920d833/maintainability)](https://codeclimate.com/github/DFE-Digital/govuk-components/maintainability)
5
+ [![Gem Version](https://badge.fury.io/rb/govuk-components.svg)](https://badge.fury.io/rb/govuk-components)
6
+ [![Gem](https://img.shields.io/gem/dt/govuk-components?logo=rubygems)](https://rubygems.org/gems/govuk-components)
5
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/cbcbc140f300b920d833/test_coverage)](https://codeclimate.com/github/DFE-Digital/govuk-components/test_coverage)
6
8
  [![GitHub license](https://img.shields.io/github/license/DFE-Digital/govuk-components)](https://github.com/DFE-Digital/govuk-components/blob/master/LICENSE)
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)
9
+ [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-4.0.0-brightgreen)](https://design-system.service.gov.uk)
10
+ [![Rails](https://img.shields.io/badge/Rails-6.1.4.4%20%E2%95%B1%207.0.0-E16D6D)](https://weblog.rubyonrails.org/releases/)
11
+ [![Ruby](https://img.shields.io/badge/Ruby-2.7.5%20%20%E2%95%B1%203.0.3-E16D6D)](https://www.ruby-lang.org/en/downloads/)
8
12
 
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.
13
+ 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
14
 
11
15
  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
16
 
13
- ## What's included?
17
+ ## Whats included?
14
18
 
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/).
19
+ 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
20
 
17
21
  The provided components are:
18
22
 
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`.
23
+ * [Accordion](https://govuk-components.netlify.app/components/accordion)
24
+ * [Back link](https://govuk-components.netlify.app/components/back-links)
25
+ * [Back to top link](https://govuk-components.netlify.app/components/back-to-top-link)
26
+ * [Breadcrumbs](https://govuk-components.netlify.app/components/breadcrumbs)
27
+ * [Cookie banner](https://govuk-components.netlify.app/components/cookie-banner)
28
+ * [Details](https://govuk-components.netlify.app/components/details)
29
+ * [Footer](https://govuk-components.netlify.app/components/footer)
30
+ * [Header](https://govuk-components.netlify.app/components/header)
31
+ * [Inset text](https://govuk-components.netlify.app/components/inset-text)
32
+ * [Notification banner](https://govuk-components.netlify.app/components/notification-banner)
33
+ * [Panel](https://govuk-components.netlify.app/components/panel)
34
+ * [Phase banner](https://govuk-components.netlify.app/components/phase-banner)
35
+ * [Skip link](https://govuk-components.netlify.app/components/skip-link)
36
+ * [Start button](https://govuk-components.netlify.app/components/start-button)
37
+ * [Summary list](https://govuk-components.netlify.app/components/summary-list)
38
+ * [Tabs](https://govuk-components.netlify.app/components/tabs)
39
+ * [Tables](https://govuk-components.netlify.app/components/table)
40
+ * [Tags](https://govuk-components.netlify.app/components/tags)
41
+ * [Warning text](https://govuk-components.netlify.app/components/warning-text)
42
+
43
+ This library also provides [link](https://govuk-components.netlify.app/helpers/link) and
44
+ [button](https://govuk-components.netlify.app/helpers/button) helpers.
40
45
 
41
46
  ## Alternative syntax
42
47
 
43
48
  All of the components can be rendered in two ways:
44
49
 
45
- * directly using Rails' `#render` method:
50
+ * directly using Rails `#render` method:
46
51
 
47
52
  ```erb
48
53
  <%= render GovukComponent::WarningTextComponent.new do %>
@@ -58,28 +63,26 @@ All of the components can be rendered in two ways:
58
63
  <% end %>
59
64
  ```
60
65
 
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).
66
+ 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
67
 
64
68
  ## Example use
65
69
 
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:
70
+ 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
71
 
68
72
  ```erb
69
73
  <%= govuk_tabs(title: 'Days of the week') do |component| %>
70
74
  <% component.tab(label: 'Monday') do %>
71
- <p>Monday's child is fair of face</p>
75
+ <p>Mondays child is fair of face</p>
72
76
  <% end %>
73
77
 
74
78
  <% component.tab(label: 'Tuesday') do %>
75
- <p>Tuesday's child is full of grace</p>
79
+ <p>Tuesdays child is full of grace</p>
76
80
  <% end %>
77
81
 
78
82
  <% component.tab(label: 'Wednesday') do %>
79
- <p>Wednesday's child is full of woe</p>
83
+ <p>Wednesdays child is full of woe</p>
80
84
  <% end %>
81
85
  <% end %>
82
-
83
86
  ```
84
87
 
85
88
  Here are the rendered tabs:
@@ -107,38 +110,38 @@ require "govuk/components"
107
110
 
108
111
  ## Installation
109
112
 
110
- Add this line to your application's Gemfile:
113
+ Add this line to your applications Gemfile:
111
114
 
112
115
  ```ruby
113
116
  gem 'govuk-components'
114
117
  ```
115
118
 
116
119
  And then execute:
117
- ```bash
118
- $ bundle
120
+
121
+ ```sh
122
+ bundle
119
123
  ```
120
124
 
121
125
  Or install it yourself as:
122
- ```bash
123
- $ gem install govuk-components
126
+
127
+ ```sh
128
+ gem install govuk-components
124
129
  ```
125
130
 
126
131
  ## Contributing
127
132
 
128
- To setup the dummy app:
133
+ Bug reports and feature requests are most welcome, please raise an issue or
134
+ submit a pull request.
129
135
 
130
- `cd spec/dummy`
131
- `yarn install`
132
- `bundle install`
133
- `bin/rails db:create`
134
- `bin/rails db:migrate`
135
- `bin/rails s`
136
+ Currently we're using [GOVUK Lint](https://github.com/alphagov/govuk-lint) to
137
+ ensure code meets the GOV.UK guidelines. Please ensure that any PRs also adhere
138
+ to this standard.
136
139
 
137
- After changing a component or adding a new one:
140
+ To help keep the logs clean and tidy, please configure git to use your full name:
138
141
 
139
- * add or update the corresponding specs, and check they pass by running `bundle exec rspec`.
140
-
141
- * update the examples page by cd-ing into the dummy app `cd spec/dummy` and running the rake task `bin/rake generate_examples_page`.
142
+ ```sh
143
+ git config --global user.name "Julius Hibbert"
144
+ ```
142
145
 
143
146
  ## License
144
147
 
@@ -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
@@ -1,25 +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, :hide_in_print
5
+ attr_accessor :aria_label, :hidden, :hide_in_print
5
6
 
6
- def initialize(aria_label: "Cookie banner", hidden: false, hide_in_print: true, 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
- @hide_in_print = hide_in_print
12
- end
10
+ @aria_label = aria_label
11
+ @hidden = hidden
12
+ @hide_in_print = hide_in_print
13
+ end
13
14
 
14
- def call
15
- tag.div(class: classes, role: "region", aria: { label: aria_label }, hidden: hidden, **html_attributes) do
16
- 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
17
19
  end
18
- end
19
20
 
20
- private
21
+ private
21
22
 
22
- def default_classes
23
- class_names("govuk-cookie-banner", "govuk-!-display-none-print" => hide_in_print).split
23
+ def default_classes
24
+ class_names("govuk-cookie-banner", "govuk-!-display-none-print" => hide_in_print).split
25
+ end
24
26
  end
25
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
@@ -36,7 +36,9 @@
36
36
  <% end %>
37
37
 
38
38
  <% if meta_content.present? %>
39
- <%= meta_content %>
39
+ <div class="govuk-footer__meta-custom">
40
+ <%= meta_content %>
41
+ </div>
40
42
  <% end %>
41
43
  </div>
42
44
 
@@ -77,7 +77,7 @@ private
77
77
  end
78
78
 
79
79
  def default_copright_text
80
- raw(%(&copy Crown copyright))
80
+ raw(%(© Crown copyright))
81
81
  end
82
82
 
83
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
@@ -9,12 +9,11 @@ class GovukComponent::SummaryListComponent::ActionComponent < GovukComponent::Ba
9
9
  @visually_hidden_text = visually_hidden_text
10
10
  end
11
11
 
12
- def call
13
- # when no href is provided return an empty string so the dd container
14
- # will render, it's useful in lists where some rows have actions
15
- # and others don't
16
- return "" if href.blank?
12
+ def render?
13
+ href.present?
14
+ end
17
15
 
16
+ def call
18
17
  link_classes = govuk_link_classes.append(classes).flatten
19
18
 
20
19
  link_to(href, class: link_classes, **html_attributes) do
@@ -1,12 +1,14 @@
1
1
  class GovukComponent::SummaryListComponent::RowComponent < GovukComponent::Base
2
- attr_reader :href, :visually_hidden_text
2
+ attr_reader :href, :visually_hidden_text, :show_actions_column
3
3
 
4
4
  renders_one :key, GovukComponent::SummaryListComponent::KeyComponent
5
5
  renders_one :value, GovukComponent::SummaryListComponent::ValueComponent
6
6
  renders_many :actions, GovukComponent::SummaryListComponent::ActionComponent
7
7
 
8
- def initialize(classes: [], html_attributes: {})
8
+ def initialize(show_actions_column: nil, classes: [], html_attributes: {})
9
9
  super(classes: classes, html_attributes: html_attributes)
10
+
11
+ @show_actions_column = show_actions_column
10
12
  end
11
13
 
12
14
  def call
@@ -18,7 +20,7 @@ class GovukComponent::SummaryListComponent::RowComponent < GovukComponent::Base
18
20
  private
19
21
 
20
22
  def actions_content
21
- return if actions.blank?
23
+ return unless show_actions_column && actions.any?
22
24
 
23
25
  (actions.one?) ? single_action : actions_list
24
26
  end
@@ -36,7 +38,9 @@ private
36
38
  end
37
39
 
38
40
  def default_classes
39
- %w(govuk-summary-list__row)
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
40
44
  end
41
45
 
42
46
  def actions_class
@@ -1,29 +1,35 @@
1
- class GovukComponent::SummaryListComponent < GovukComponent::Base
2
- attr_reader :borders
3
-
4
- renders_many :rows, GovukComponent::SummaryListComponent::RowComponent
5
-
6
- def initialize(borders: true, classes: [], html_attributes: {})
7
- super(classes: classes, html_attributes: html_attributes)
8
-
9
- @borders = borders
10
- end
11
-
12
- def any_row_has_actions?
13
- rows.any? { |row| row.href.present? }
14
- end
15
-
16
- def classes
17
- super.append(borders_class).compact
18
- end
19
-
20
- private
21
-
22
- def borders_class
23
- %(govuk-summary-list--no-border) unless borders
24
- end
25
-
26
- def default_classes
27
- %w(govuk-summary-list)
1
+ module GovukComponent
2
+ class SummaryListComponent < GovukComponent::Base
3
+ attr_reader :borders, :actions
4
+
5
+ renders_many :rows, ->(classes: [], html_attributes: {}, &block) do
6
+ GovukComponent::SummaryListComponent::RowComponent.new(
7
+ show_actions_column: @show_actions_column,
8
+ classes: classes,
9
+ html_attributes: html_attributes,
10
+ &block
11
+ )
12
+ end
13
+
14
+ def initialize(actions: true, borders: true, classes: [], html_attributes: {})
15
+ super(classes: classes, html_attributes: html_attributes)
16
+
17
+ @borders = borders
18
+ @show_actions_column = actions
19
+ end
20
+
21
+ def classes
22
+ super.append(borders_class).compact
23
+ end
24
+
25
+ private
26
+
27
+ def borders_class
28
+ %(govuk-summary-list--no-border) unless borders
29
+ end
30
+
31
+ def default_classes
32
+ %w(govuk-summary-list)
33
+ end
28
34
  end
29
35
  end
@@ -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)
@@ -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: {})
@@ -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,3 +1,5 @@
1
+ require "rails/engine"
2
+
1
3
  module Govuk
2
4
  module Components
3
5
  class Engine < ::Rails::Engine
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '2.1.4'.freeze
3
+ VERSION = '3.0.0b3'.freeze
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
- require "view_component/engine"
1
+ require "rails/engine"
2
+ require "view_component"
2
3
  require "govuk/components/helpers/css_utilities"
3
4
  require "govuk/components/engine"
metadata CHANGED
@@ -1,57 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 3.0.0b3
5
5
  platform: ruby
6
6
  authors:
7
7
  - DfE developers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2022-01-06 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
44
56
  requirements:
45
57
  - - "~>"
46
58
  - !ruby/object:Gem::Version
47
- version: 2.39.0
59
+ version: 2.47.0
48
60
  type: :runtime
49
61
  prerelease: false
50
62
  version_requirements: !ruby/object:Gem::Requirement
51
63
  requirements:
52
64
  - - "~>"
53
65
  - !ruby/object:Gem::Version
54
- version: 2.39.0
66
+ version: 2.47.0
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: pry-byebug
57
69
  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
@@ -220,7 +360,7 @@ homepage: https://github.com/DFE-Digital/govuk-components
220
360
  licenses:
221
361
  - MIT
222
362
  metadata: {}
223
- post_install_message:
363
+ post_install_message:
224
364
  rdoc_options: []
225
365
  require_paths:
226
366
  - lib
@@ -231,12 +371,12 @@ 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.1.6
239
- signing_key:
378
+ rubygems_version: 3.2.32
379
+ signing_key:
240
380
  specification_version: 4
241
381
  summary: Lightweight set of reusable GOV.UK Design System components
242
382
  test_files: []