govuk-components 5.0.0b4 → 5.0.1

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: 9e61252c526732d7919b0fc8c0818af26742357a007b18a0e919448ac8069319
4
- data.tar.gz: 4c1271fc9c6ccfb1c15b33e4716841d86f0bbb5d77b2747a4ec2a6a21163448c
3
+ metadata.gz: 803f46227b24a4b94f6c9a18dba4040b95de1248ec04711fdba577848ed69d9c
4
+ data.tar.gz: 05d27bec17047ccf6dbb45b9e7bd2d7d5986dad4edb8724c3a144139d5e03baa
5
5
  SHA512:
6
- metadata.gz: 22eb5f538044e5047270e2ed6cf8b5a93770a46913cf4df3ad259ccd560c6085ddfe257fe93fafbfbe518e05b25c0dbb471a0dd8c12ee2a35a8be44c4496bbfa
7
- data.tar.gz: 2aa37663c893724c13382561c3120e754cb49ea0bc7cc9c52846d2cda203beb772e06e3c7b1c03b2c69e18bae8c586f2f12efa0dd4901330d53ed12b9f7de3a2
6
+ metadata.gz: 6a3b59c877f5dd616144faca5585a4a8c7750d78f7398f3424de98f4096af2e30c70aaa9fa3b959de294a064bdaeee55560aac2c0a43c135ee76ce6f5b92397e
7
+ data.tar.gz: '00668905d6bb618e00f3c61283b74d093d978c33c55d2e5fd0723bf3ac002d52e8ee6ec2b4a409f02e81ec89f2342afe15fda0cc8245468a06c66a7365e69862'
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/)
@@ -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
@@ -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,6 +1,6 @@
1
1
  require "html_attributes_utils"
2
2
 
3
- module GovukRailsCompatibileLinkHelper
3
+ module GovukRailsCompatibleLinkHelper
4
4
  using HTMLAttributesUtils
5
5
 
6
6
  def govuk_link_classes(*styles, default_class: "#{brand}-link")
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '5.0.0b4'.freeze
3
+ VERSION = '5.0.1'.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.0b4
4
+ version: 5.0.1
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-11-29 00:00:00.000000000 Z
11
+ date: 2023-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-attributes-utils
@@ -53,7 +53,7 @@ dependencies:
53
53
  version: '3.3'
54
54
  - - "<"
55
55
  - !ruby/object:Gem::Version
56
- version: '3.8'
56
+ version: '3.9'
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
@@ -63,7 +63,7 @@ dependencies:
63
63
  version: '3.3'
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
- version: '3.8'
66
+ version: '3.9'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: deep_merge
69
69
  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
@@ -385,7 +385,7 @@ files:
385
385
  - app/helpers/govuk_components_helper.rb
386
386
  - app/helpers/govuk_exit_this_page_link_helper.rb
387
387
  - app/helpers/govuk_link_helper.rb
388
- - app/helpers/govuk_rails_compatibile_link_helper.rb
388
+ - app/helpers/govuk_rails_compatible_link_helper.rb
389
389
  - app/helpers/govuk_skip_link_helper.rb
390
390
  - app/helpers/govuk_visually_hidden_helper.rb
391
391
  - app/helpers/title_with_error_prefix_helper.rb
@@ -410,9 +410,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
410
410
  version: '0'
411
411
  required_rubygems_version: !ruby/object:Gem::Requirement
412
412
  requirements:
413
- - - ">"
413
+ - - ">="
414
414
  - !ruby/object:Gem::Version
415
- version: 1.3.1
415
+ version: '0'
416
416
  requirements: []
417
417
  rubygems_version: 3.2.33
418
418
  signing_key: