govuk-components 5.0.0 → 5.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48254d17c646e2b01105ded5e6e439027fc60ff451c1e33f01c03f9922f58975
4
- data.tar.gz: e9502d4077f983dd0f4ca33fec2cf101c34a7f1973943c9b77f5f43eb2af3656
3
+ metadata.gz: 8ea92186b060054ebbab68352b115d86c1a051ac637fa6cb2baf16299a0e1c9e
4
+ data.tar.gz: 4e230e506c271f6c905ae11f1b9703449d9cff10385b9722643865b55e135377
5
5
  SHA512:
6
- metadata.gz: 44e7aa296d43612ca4f31437239ce4445fc6ff4559a024e196b571cc3e4fb27db37ef785a3da3ba578b230caf6b3c4e859d0a654e71dce79fc344b5c95b07341
7
- data.tar.gz: bdfb0aa85989f7453f71f956a9c27998d40a217cd3180d51263f69bd13d3feb5cdae1d64443779388d34088bc0d54b4da55c0a6c4cca7a14e24c1efd6d864b9a
6
+ metadata.gz: ad1b1774616a6345aacda5a61d92d7a11f4074d72eb00a86f055db0ad1d77f98485b843892d1f482fa231513f9a163b01bbb54e07b5be44e58e0c8884a6cf8a3
7
+ data.tar.gz: 773ab4a3aa83dc5eff40e946ceea1a9fda5d414cbabcaf8bd3838140cc0525ea97b151b3d7b98bca6e638be820ee7b133cd8a9089c8b7dce2485a9319866bcac
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Gem](https://img.shields.io/gem/dt/govuk-components?logo=rubygems)](https://rubygems.org/gems/govuk-components)
7
7
  [![Test coverage](https://api.codeclimate.com/v1/badges/cbcbc140f300b920d833/test_coverage)](https://codeclimate.com/github/x-govuk/govuk-components/test_coverage)
8
8
  [![Licence](https://img.shields.io/github/license/x-govuk/govuk-components)](https://github.com/x-govuk/govuk-components/blob/main/LICENSE.txt)
9
- [![GOV.UK Design System version](https://img.shields.io/badge/GOV.UK%20Design%20System-4.7.0-brightgreen)](https://design-system.service.gov.uk)
9
+ [![GOV.UK Design System version](https://img.shields.io/badge/GOV.UK%20Design%20System-5.0.0-brightgreen)](https://design-system.service.gov.uk)
10
10
  [![ViewComponent](https://img.shields.io/badge/ViewComponent-3.3.0-brightgreen)](https://viewcomponent.org/)
11
11
  [![Rails](https://img.shields.io/badge/Rails-7.0.8%20%E2%95%B1%207.1.0-E16D6D)](https://weblog.rubyonrails.org/releases/)
12
12
  [![Ruby](https://img.shields.io/badge/Ruby-3.0.6%20%20%E2%95%B1%203.1.4%20%20%E2%95%B1%203.2.2-E16D6D)](https://www.ruby-lang.org/en/downloads/)
@@ -3,7 +3,7 @@ class GovukComponent::AccordionComponent < GovukComponent::Base
3
3
  GovukComponent::AccordionComponent::SectionComponent.new(
4
4
  classes: classes,
5
5
  expanded: expanded,
6
- heading_level: heading_level, # set once at parent level, passed to all children
6
+ heading_level: heading_level, # set once at parent level, passed to all children
7
7
  html_attributes: html_attributes,
8
8
  summary_text: summary_text,
9
9
  heading_text: heading_text,
@@ -1,7 +1,7 @@
1
1
  class GovukComponent::SummaryListComponent::ActionComponent < GovukComponent::Base
2
- attr_reader :href, :text, :visually_hidden_text, :attributes, :classes
2
+ attr_reader :href, :text, :visually_hidden_text, :visually_hidden_action_suffix, :attributes, :classes
3
3
 
4
- def initialize(href: nil, text: 'Change', visually_hidden_text: false, classes: [], html_attributes: {})
4
+ def initialize(href: nil, text: 'Change', visually_hidden_text: false, visually_hidden_action_suffix: nil, classes: [], html_attributes: {})
5
5
  @visually_hidden_text = visually_hidden_text
6
6
 
7
7
  if config.require_summary_list_action_visually_hidden_text && visually_hidden_text == false
@@ -9,9 +9,9 @@ class GovukComponent::SummaryListComponent::ActionComponent < GovukComponent::Ba
9
9
  end
10
10
 
11
11
  super(classes: classes, html_attributes: html_attributes)
12
-
13
12
  @href = href
14
13
  @text = text
14
+ @visually_hidden_action_suffix = visually_hidden_action_suffix
15
15
  end
16
16
 
17
17
  def render?
@@ -36,7 +36,13 @@ private
36
36
  content || text || fail(ArgumentError, "no text or content")
37
37
  end
38
38
 
39
+ def visually_hidden_content
40
+ return "#{visually_hidden_text} (#{visually_hidden_action_suffix})" if visually_hidden_action_suffix
41
+
42
+ visually_hidden_text
43
+ end
44
+
39
45
  def visually_hidden_span
40
- tag.span(%( #{visually_hidden_text}), class: "#{brand}-visually-hidden") if visually_hidden_text.present?
46
+ tag.span(%( #{visually_hidden_content}), class: "#{brand}-visually-hidden") if visually_hidden_text.present?
41
47
  end
42
48
  end
@@ -5,7 +5,7 @@
5
5
  <% if actions.any? %>
6
6
  <ul class="<%= brand %>-summary-card__actions">
7
7
  <% actions.each do |action| %>
8
- <%= tag.li(action, class: "#{brand}-summary-card__action") %>
8
+ <%= tag.li(action_text(action), class: "#{brand}-summary-card__action") %>
9
9
  <% end %>
10
10
  </ul>
11
11
  <% end %>
@@ -16,4 +16,8 @@ private
16
16
  def default_attributes
17
17
  { class: "#{brand}-summary-card" }
18
18
  end
19
+
20
+ def action_text(action)
21
+ safe_join([action, tag.span(" (" + title + ")", class: "#{brand}-visually-hidden")])
22
+ end
19
23
  end
@@ -1,12 +1,23 @@
1
1
  class GovukComponent::SummaryListComponent::RowComponent < GovukComponent::Base
2
- attr_reader :href, :visually_hidden_text, :show_actions_column
2
+ attr_reader :href, :visually_hidden_text, :show_actions_column, :visually_hidden_action_suffix
3
3
 
4
4
  renders_one :key, GovukComponent::SummaryListComponent::KeyComponent
5
5
  renders_one :value, GovukComponent::SummaryListComponent::ValueComponent
6
- renders_many :actions, GovukComponent::SummaryListComponent::ActionComponent
6
+ renders_many :actions, ->(href: nil, text: 'Change', visually_hidden_text: false, classes: [], html_attributes: {}, &block) do
7
+ GovukComponent::SummaryListComponent::ActionComponent.new(
8
+ href: href,
9
+ text: text,
10
+ visually_hidden_text: visually_hidden_text,
11
+ visually_hidden_action_suffix: visually_hidden_action_suffix,
12
+ classes: classes,
13
+ html_attributes: html_attributes,
14
+ &block
15
+ )
16
+ end
7
17
 
8
- def initialize(show_actions_column: nil, classes: [], html_attributes: {})
18
+ def initialize(show_actions_column: nil, visually_hidden_action_suffix: nil, classes: [], html_attributes: {})
9
19
  @show_actions_column = show_actions_column
20
+ @visually_hidden_action_suffix = visually_hidden_action_suffix
10
21
 
11
22
  super(classes: classes, html_attributes: html_attributes)
12
23
  end
@@ -1,20 +1,22 @@
1
1
  module GovukComponent
2
2
  class SummaryListComponent < GovukComponent::Base
3
- attr_reader :borders, :actions, :card
3
+ attr_reader :borders, :actions, :card, :visually_hidden_action_suffix
4
4
 
5
5
  renders_many :rows, ->(classes: [], html_attributes: {}, &block) do
6
6
  GovukComponent::SummaryListComponent::RowComponent.new(
7
7
  show_actions_column: @show_actions_column,
8
+ visually_hidden_action_suffix: visually_hidden_action_suffix || card&.title,
8
9
  classes: classes,
9
10
  html_attributes: html_attributes,
10
11
  &block
11
12
  )
12
13
  end
13
14
 
14
- def initialize(rows: nil, actions: true, borders: config.default_summary_list_borders, card: nil, classes: [], html_attributes: {})
15
- @borders = borders
16
- @show_actions_column = actions
17
- @card = card
15
+ def initialize(rows: nil, actions: true, borders: config.default_summary_list_borders, card: {}, visually_hidden_action_suffix: nil, classes: [], html_attributes: {})
16
+ @borders = borders
17
+ @show_actions_column = actions
18
+ @card = GovukComponent::SummaryListComponent::CardComponent.new(**card) if card.present?
19
+ @visually_hidden_action_suffix = visually_hidden_action_suffix
18
20
 
19
21
  super(classes: classes, html_attributes: html_attributes)
20
22
 
@@ -26,16 +28,20 @@ module GovukComponent
26
28
  def call
27
29
  summary_list = tag.dl(**html_attributes) { safe_join(rows) }
28
30
 
29
- (card.nil?) ? summary_list : card_with(summary_list)
31
+ (card?) ? card_with(summary_list) : summary_list
30
32
  end
31
33
 
32
34
  private
33
35
 
36
+ def card?
37
+ @card.present?
38
+ end
39
+
34
40
  # we're not using `renders_one` here because we always want the card to render
35
41
  # outside of the summary list. when manually building use
36
42
  # govuk_summary_list_card { govuk_summary_list }
37
43
  def card_with(summary_list)
38
- render(GovukComponent::SummaryListComponent::CardComponent.new(**card)) { summary_list }
44
+ render(@card) { summary_list }
39
45
  end
40
46
 
41
47
  def borders_class
@@ -23,7 +23,7 @@ private
23
23
 
24
24
  def initialize(label:, text: nil, classes: [], html_attributes: {})
25
25
  @label = label
26
- @text = text
26
+ @text = h(text)
27
27
 
28
28
  super(classes: classes, html_attributes: html_attributes)
29
29
  end
@@ -1,10 +1,11 @@
1
1
  module GovukComponent
2
2
  class TaskListComponent::ItemComponent < GovukComponent::Base
3
- renders_one :status, ->(text: nil, classes: [], html_attributes: {}, &block) do
3
+ renders_one :status, ->(text: nil, cannot_start_yet: false, classes: [], html_attributes: {}, &block) do
4
4
  GovukComponent::TaskListComponent::StatusComponent.new(
5
5
  id_prefix: @id_prefix,
6
6
  count: @count,
7
7
  text: text,
8
+ cannot_start_yet: cannot_start_yet,
8
9
  classes: classes,
9
10
  html_attributes: html_attributes,
10
11
  &block
@@ -39,6 +40,10 @@ module GovukComponent
39
40
  end
40
41
 
41
42
  def call
43
+ if href.presence && status_content.cannot_start_yet
44
+ fail(ArgumentError, "item cannot have a href with status where cannot_start_yet: true")
45
+ end
46
+
42
47
  adjusted_html_attributes = if href.present? || title&.href.present?
43
48
  html_attributes_with_link_class
44
49
  else
@@ -1,11 +1,12 @@
1
1
  module GovukComponent
2
2
  class TaskListComponent::StatusComponent < GovukComponent::Base
3
- attr_reader :id_prefix, :text, :count
3
+ attr_reader :id_prefix, :text, :cannot_start_yet, :count
4
4
 
5
- def initialize(text: nil, id_prefix: nil, count: nil, classes: [], html_attributes: {})
6
- @text = text
7
- @count = count
8
- @id_prefix = id_prefix
5
+ def initialize(text: nil, id_prefix: nil, count: nil, cannot_start_yet: false, classes: [], html_attributes: {})
6
+ @text = text
7
+ @count = count
8
+ @id_prefix = id_prefix
9
+ @cannot_start_yet = cannot_start_yet
9
10
 
10
11
  super(classes: classes, html_attributes: html_attributes)
11
12
  end
@@ -21,7 +22,13 @@ module GovukComponent
21
22
  private
22
23
 
23
24
  def default_attributes
24
- { class: %w(govuk-task-list__status), id: [id_prefix, count, "status"].compact.join("-") }
25
+ {
26
+ class: class_names(
27
+ "govuk-task-list__status",
28
+ "govuk-task-list__status--cannot-start-yet" => cannot_start_yet,
29
+ ),
30
+ id: [id_prefix, count, "status"].compact.join("-"),
31
+ }
25
32
  end
26
33
 
27
34
  def status_text
@@ -44,7 +44,7 @@ module GovukLinkHelper
44
44
  end
45
45
 
46
46
  def govuk_breadcrumb_link_to(name, href = nil, **kwargs, &block)
47
- link_args = { class: "#{brand}-breadcrumbs--link" }.deep_merge_html_attributes(kwargs)
47
+ link_args = { class: "#{brand}-breadcrumbs__link" }.deep_merge_html_attributes(kwargs)
48
48
 
49
49
  link_to(name, href, **link_args, &block)
50
50
  end
@@ -88,12 +88,18 @@ private
88
88
  end
89
89
 
90
90
  def extract_link_args(new_tab: false, inverse: false, muted: false, no_underline: false, no_visited_state: false, text_colour: false, **kwargs)
91
+ Rails.logger.warn(actions_warning_message(kwargs.fetch(:action))) if kwargs.key?(:action)
92
+ Rails.logger.warn(controller_warning_message(kwargs.fetch(:controller))) if kwargs.key?(:controller)
93
+
91
94
  link_classes = extract_link_classes(inverse: inverse, muted: muted, no_underline: no_underline, no_visited_state: no_visited_state, text_colour: text_colour)
92
95
 
93
96
  { **link_classes, **new_tab_args(new_tab) }.deep_merge_html_attributes(kwargs)
94
97
  end
95
98
 
96
99
  def extract_button_link_args(new_tab: false, disabled: false, inverse: false, secondary: false, warning: false, **kwargs)
100
+ Rails.logger.warn(actions_warning_message(kwargs.fetch(:action))) if kwargs.key?(:action)
101
+ Rails.logger.warn(controller_warning_message(kwargs.fetch(:controller))) if kwargs.key?(:controller)
102
+
97
103
  button_classes = extract_button_classes(inverse: inverse, secondary: secondary, warning: warning)
98
104
 
99
105
  { **button_classes, **button_attributes(disabled), **new_tab_args(new_tab) }.deep_merge_html_attributes(kwargs)
@@ -139,6 +145,14 @@ private
139
145
 
140
146
  safe_join([govuk_visually_hidden(prefix), text, govuk_visually_hidden(suffix)].compact)
141
147
  end
148
+
149
+ def actions_warning_message(value)
150
+ "action: '#{value}' parameter detected Support for old style controller/action links has been removed. See https://github.com/x-govuk/govuk-components/releases/tag/v5.0.0"
151
+ end
152
+
153
+ def controller_warning_message(value)
154
+ "controller: '#{value}' parameter detected. Support for old style controller/action links has been removed. See https://github.com/x-govuk/govuk-components/releases/tag/v5.0.0"
155
+ end
142
156
  end
143
157
 
144
158
  ActiveSupport.on_load(:action_view) { include GovukLinkHelper }
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '5.0.0'.freeze
3
+ VERSION = '5.0.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - DfE developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-08 00:00:00.000000000 Z
11
+ date: 2024-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-attributes-utils
@@ -50,20 +50,20 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '3.3'
53
+ version: '3.9'
54
54
  - - "<"
55
55
  - !ruby/object:Gem::Version
56
- version: '3.8'
56
+ version: '3.10'
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: '3.3'
63
+ version: '3.9'
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
- version: '3.8'
66
+ version: '3.10'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: deep_merge
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -126,14 +126,14 @@ dependencies:
126
126
  requirements:
127
127
  - - '='
128
128
  - !ruby/object:Gem::Version
129
- version: 4.12.0
129
+ version: 4.13.0
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - '='
135
135
  - !ruby/object:Gem::Version
136
- version: 4.12.0
136
+ version: 4.13.0
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: sassc-rails
139
139
  requirement: !ruby/object:Gem::Requirement
@@ -280,14 +280,14 @@ dependencies:
280
280
  requirements:
281
281
  - - "~>"
282
282
  - !ruby/object:Gem::Version
283
- version: 5.1.0
283
+ version: 5.2.0
284
284
  type: :development
285
285
  prerelease: false
286
286
  version_requirements: !ruby/object:Gem::Requirement
287
287
  requirements:
288
288
  - - "~>"
289
289
  - !ruby/object:Gem::Version
290
- version: 5.1.0
290
+ version: 5.2.0
291
291
  - !ruby/object:Gem::Dependency
292
292
  name: slim_lint
293
293
  requirement: !ruby/object:Gem::Requirement