govuk-components 4.0.0a2 → 4.0.0rc1

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: 4a89715e3ac54c26a25f8711ffcc1bcbae3c7cd697e6dc4993d6581c52fe4885
4
- data.tar.gz: 8c781f15f6e02d50b5c463732770340502a7c3e300b63f633c6ca09b084effab
3
+ metadata.gz: bd7e8066fccea2b88cdf610a3311daf69e72552d2025e740417a8716851866bc
4
+ data.tar.gz: 506bd4f0a292bae9d908038af9597c83adca6e3b2a8cc912adb79566977d238c
5
5
  SHA512:
6
- metadata.gz: 4c89afcba1f59b8b7d02142b891904667a9b6aaeb84db7f1d4c6c373d516b7ee302aa23e6431d21e3144f1ea6bbdc7d78703bc6d3dfe88e5c00c2f987ce8368c
7
- data.tar.gz: 1dc348dde934a1806118c18c75d20b4cee98b03ba2032a1a86a4a0519461662acab039b8a8f65fd41ef3406faf634da95e72db9a2e33456af191375f87477b19
6
+ metadata.gz: f77444b5107f2a0d3ccb9166bb28297b6a8d643a0e4d4ac9310dd33699df7de1e51ab9ccd4ce4fc457267f43b497d5b17b2f5904b79007dac418f987900364ea
7
+ data.tar.gz: fc20ae15eba5a9d0faf7e953a9d28958928ecbed0b9a82c4d23643cac88ca60846e7f5cffa1fe11d38ad38c90ebb9582ef6abf0d3be9c1fa85b3f101e4281d2d
@@ -1,26 +1,29 @@
1
1
  class GovukComponent::AccordionComponent::SectionComponent < GovukComponent::Base
2
- attr_reader :heading_text, :summary_text, :expanded, :heading_level
2
+ attr_reader :heading_text, :summary_text, :expanded, :heading_level, :accordion_id
3
3
 
4
4
  renders_one :heading_html
5
5
  renders_one :summary_html
6
6
 
7
7
  alias_method :expanded?, :expanded
8
8
 
9
- def initialize(heading_text:, summary_text:, expanded:, heading_level:, classes: [], html_attributes: {})
9
+ def initialize(heading_text:, summary_text:, expanded:, heading_level:, accordion_id: nil, classes: [], html_attributes: {})
10
10
  @heading_text = heading_text
11
11
  @summary_text = summary_text
12
12
  @expanded = expanded
13
13
  @heading_level = heading_level
14
+ @accordion_id = accordion_id
14
15
 
15
16
  super(classes: classes, html_attributes: html_attributes)
16
17
  end
17
18
 
18
19
  def id(suffix: nil)
20
+ prefix = @accordion_id
21
+
19
22
  # generate a random number if we don't have heading_text to avoid attempting
20
23
  # to parameterize a potentially-huge chunk of HTML
21
- @prefix ||= heading_text&.parameterize || SecureRandom.hex(4)
24
+ @unique_identifier ||= heading_text&.parameterize || SecureRandom.hex(4)
22
25
 
23
- [@prefix, suffix].compact.join('-')
26
+ [prefix, @unique_identifier, suffix].compact.join('-')
24
27
  end
25
28
 
26
29
  def heading_content
@@ -7,14 +7,16 @@ class GovukComponent::AccordionComponent < GovukComponent::Base
7
7
  html_attributes: html_attributes,
8
8
  summary_text: summary_text,
9
9
  heading_text: heading_text,
10
+ accordion_id: accordion_id,
10
11
  &block
11
12
  )
12
13
  end
13
14
 
14
- attr_reader :id, :heading_level
15
+ attr_reader :accordion_id, :heading_level
15
16
 
16
17
  def initialize(heading_level: 2, classes: [], html_attributes: {})
17
18
  @heading_level = heading_tag(heading_level)
19
+ @accordion_id = html_attributes[:id]
18
20
 
19
21
  super(classes: classes, html_attributes: html_attributes)
20
22
  end
@@ -22,7 +24,7 @@ class GovukComponent::AccordionComponent < GovukComponent::Base
22
24
  private
23
25
 
24
26
  def default_attributes
25
- { class: %w(govuk-accordion), data: { module: 'govuk-accordion' } }
27
+ { class: %w(govuk-accordion), data: { module: 'govuk-accordion' } }.compact
26
28
  end
27
29
 
28
30
  def heading_tag(level)
@@ -125,11 +125,11 @@ private
125
125
  end
126
126
 
127
127
  def render?
128
- name.present? || content.present?
128
+ name.present? || content?
129
129
  end
130
130
 
131
131
  def call
132
- if content.present?
132
+ if content?
133
133
  tag.div(content, **html_attributes)
134
134
  else
135
135
  tag.span(name, **html_attributes)
@@ -27,7 +27,7 @@ class GovukComponent::NotificationBannerComponent < GovukComponent::Base
27
27
  end
28
28
 
29
29
  def render?
30
- headings.any? || text.present? || content.present?
30
+ headings.any? || text.present? || content?
31
31
  end
32
32
 
33
33
  class Heading < GovukComponent::Base
@@ -20,7 +20,7 @@ class GovukComponent::SummaryListComponent::ActionComponent < GovukComponent::Ba
20
20
 
21
21
  def call
22
22
  link_to(href, **html_attributes) do
23
- safe_join([action_text, visually_hidden_span].compact, " ")
23
+ safe_join([action_text, visually_hidden_span].compact)
24
24
  end
25
25
  end
26
26
 
@@ -37,6 +37,6 @@ private
37
37
  end
38
38
 
39
39
  def visually_hidden_span
40
- tag.span(visually_hidden_text, class: "govuk-visually-hidden") if visually_hidden_text.present?
40
+ tag.span(%( #{visually_hidden_text}), class: "govuk-visually-hidden") if visually_hidden_text.present?
41
41
  end
42
42
  end
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '4.0.0a2'.freeze
3
+ VERSION = '4.0.0rc1'.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: 4.0.0a2
4
+ version: 4.0.0rc1
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-02-13 00:00:00.000000000 Z
11
+ date: 2023-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-attributes-utils
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 3.0.0rc1
53
+ version: 3.0.0rc6
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 3.0.0rc1
60
+ version: 3.0.0rc6
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: deep_merge
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -218,14 +218,14 @@ dependencies:
218
218
  requirements:
219
219
  - - "~>"
220
220
  - !ruby/object:Gem::Version
221
- version: 4.0.0
221
+ version: 4.1.0
222
222
  type: :development
223
223
  prerelease: false
224
224
  version_requirements: !ruby/object:Gem::Requirement
225
225
  requirements:
226
226
  - - "~>"
227
227
  - !ruby/object:Gem::Version
228
- version: 4.0.0
228
+ version: 4.1.0
229
229
  - !ruby/object:Gem::Dependency
230
230
  name: rubypants
231
231
  requirement: !ruby/object:Gem::Requirement
@@ -274,14 +274,14 @@ dependencies:
274
274
  requirements:
275
275
  - - "~>"
276
276
  - !ruby/object:Gem::Version
277
- version: 4.1.0
277
+ version: 5.1.0
278
278
  type: :development
279
279
  prerelease: false
280
280
  version_requirements: !ruby/object:Gem::Requirement
281
281
  requirements:
282
282
  - - "~>"
283
283
  - !ruby/object:Gem::Version
284
- version: 4.1.0
284
+ version: 5.1.0
285
285
  - !ruby/object:Gem::Dependency
286
286
  name: slim_lint
287
287
  requirement: !ruby/object:Gem::Requirement