govuk-components 1.1.0 → 1.1.5

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: d6f8009727bd1da1e578c97b2b2dfe48b6e86a97f0e7854e16edbb3bf7991154
4
- data.tar.gz: a0442f769f7fb611a083b34707210fa11a499708d64c9b9aab0081218262e7f2
3
+ metadata.gz: 7bdf0839ecbe0f5046c63a0cca80caa808aa3b0d4f8d5f5280253523742d28d0
4
+ data.tar.gz: d4d694316d383bdbfe93f0f1974d0ca14daedbe24e7d48371636b75384ddebaf
5
5
  SHA512:
6
- metadata.gz: d4cacf374531c0c9cd3f41750cc1e640f543fd4eb21b587690fa653fb683a6a29c515acd1938b24ceeee62b32b772a5becc6fb856102260608ead6f31f5a482c
7
- data.tar.gz: 18846eb057b53d9ed93ef5bffe9c3d676a46c9522997d316ac6054fb7348adef0e064a86210a8f9755942a7a5eeeb6556db4263b2aea01b53caeae5d75c864a9
6
+ metadata.gz: b3aec4489d49df3becca14855f389a4479f82393a6aa231e220f7553202252a8c51a0dab7fd4dfa514e879db12b9c12beacf0db0be0694f412510a81e5c2d486
7
+ data.tar.gz: 6429c8416c30dbd25c4afe381f0991f1b505e20faf74e99ad1fe32784345209da388d86ec980dda52c1d1aa3fd3b0f9a2e09d965cadf929e9fb2d6a65ec3c140
data/README.md CHANGED
@@ -16,6 +16,7 @@ This gem provides a suite of reusable components for the [GOV.UK Design System](
16
16
  | [Accordion](app/components/govuk_component/accordion.rb) | `govuk_accordion` |
17
17
  | [Back link](app/components/govuk_component/back_link.rb) | `govuk_back_link` |
18
18
  | [Breadcrumbs](app/components/govuk_component/breadcrumbs.rb) | `govuk_breadcrumbs` |
19
+ | [Cookie banner](app/components/govuk_component/cookie_banner.rb) | `govuk_cookie_banner` |
19
20
  | [Details](app/components/govuk_component/details.rb) | `govuk_details` |
20
21
  | [Footer](app/components/govuk_component/footer.rb) | `govuk_footer` |
21
22
  | [Header](app/components/govuk_component/header.rb) | `govuk_header` |
@@ -3,7 +3,7 @@
3
3
  <%= tag.div(id: section.id(suffix: 'section'), class: section.classes, **section.html_attributes) do %>
4
4
  <div class="govuk-accordion__section-header">
5
5
  <h2 class="govuk-accordion__section-heading">
6
- <%= tag.span(section.title, id: section.id, class: "govuk-accordion__section-button") %>
6
+ <%= tag.span(section.title, id: section.id, class: "govuk-accordion__section-button", aria: { expanded: section.expanded? }) %>
7
7
  </h2>
8
8
  <% if section.summary.present? %>
9
9
  <%= tag.div(section.summary, id: section.id(suffix: 'summary'), class: %w(govuk-accordion__section-summary govuk-body)) %>
@@ -19,19 +19,26 @@ private
19
19
  end
20
20
 
21
21
  class Section < GovukComponent::Slot
22
- attr_accessor :title, :summary
22
+ attr_accessor :title, :summary, :expanded
23
23
 
24
- def initialize(title:, summary: nil, classes: [], html_attributes: {})
24
+ alias_method :expanded?, :expanded
25
+
26
+ def initialize(title:, summary: nil, expanded: false, classes: [], html_attributes: {})
25
27
  super(classes: classes, html_attributes: html_attributes)
26
28
 
27
29
  self.title = title
28
30
  self.summary = summary
31
+ self.expanded = expanded
29
32
  end
30
33
 
31
34
  def id(suffix: nil)
32
35
  [title.parameterize, suffix].compact.join('-')
33
36
  end
34
37
 
38
+ def classes
39
+ super + (expanded? ? %w(govuk-accordion__section--expanded) : [])
40
+ end
41
+
35
42
  private
36
43
 
37
44
  def default_classes
@@ -0,0 +1,21 @@
1
+ <%= tag.div(class: classes, role: "region", aria: { label: aria_label }, **html_attributes) do %>
2
+ <div class="govuk-cookie-banner__message govuk-width-container">
3
+ <div class="govuk-grid-row">
4
+ <div class="govuk-grid-column-two-thirds">
5
+ <% if title.present? %>
6
+ <h2 class="govuk-cookie-banner__heading govuk-heading-m">
7
+ <%= title %>
8
+ </h2>
9
+ <% end %>
10
+
11
+ <div class="govuk-cookie-banner__content">
12
+ <%= body %>
13
+ </div>
14
+ </div>
15
+ </div>
16
+
17
+ <div class="govuk-button-group">
18
+ <%= actions %>
19
+ </div>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,18 @@
1
+ class GovukComponent::CookieBanner < GovukComponent::Base
2
+ with_content_areas :body, :actions
3
+
4
+ attr_accessor :title, :aria_label
5
+
6
+ def initialize(title: nil, aria_label: "Cookie banner", classes: [], html_attributes: {})
7
+ super(classes: classes, html_attributes: html_attributes)
8
+
9
+ @title = title
10
+ @aria_label = aria_label
11
+ end
12
+
13
+ private
14
+
15
+ def default_classes
16
+ %w(govuk-cookie-banner)
17
+ end
18
+ end
@@ -1,4 +1,4 @@
1
- <%= tag.div(class: classes.append(success_class).compact, **html_attributes, role: "region", aria: { labelledby: title_id }, data: data_params) do %>
1
+ <%= tag.div(class: classes.append(success_class).compact, role: "region", aria: { labelledby: title_id }, data: data_params, **html_attributes) do %>
2
2
  <div class="govuk-notification-banner__header">
3
3
  <%= content_tag(title_tag, class: "govuk-notification-banner__title", id: title_id) do %>
4
4
  <%= title %>
@@ -24,7 +24,7 @@ class GovukComponent::NotificationBanner < GovukComponent::Base
24
24
  end
25
25
 
26
26
  def render?
27
- headings.any?
27
+ headings.any? || content.present?
28
28
  end
29
29
 
30
30
  def title_tag
@@ -3,6 +3,7 @@ module GovukComponentsHelper
3
3
  govuk_accordion: 'GovukComponent::Accordion',
4
4
  govuk_back_link: 'GovukComponent::BackLink',
5
5
  govuk_breadcrumbs: 'GovukComponent::Breadcrumbs',
6
+ govuk_cookie_banner: 'GovukComponent::CookieBanner',
6
7
  govuk_details: 'GovukComponent::Details',
7
8
  govuk_footer: 'GovukComponent::Footer',
8
9
  govuk_header: 'GovukComponent::Header',
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '1.1.0'.freeze
3
+ VERSION = '1.1.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.5
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-01-23 00:00:00.000000000 Z
11
+ date: 2021-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,25 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: view_component
28
+ name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.22.1
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: 2.25.0
33
+ version: '6.0'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
- version: 2.22.1
44
- - - "<"
40
+ version: '6.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: view_component
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.20'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
45
53
  - !ruby/object:Gem::Version
46
- version: 2.25.0
54
+ version: '2.20'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: capybara
49
57
  requirement: !ruby/object:Gem::Requirement
@@ -160,6 +168,8 @@ files:
160
168
  - app/components/govuk_component/base.rb
161
169
  - app/components/govuk_component/breadcrumbs.html.erb
162
170
  - app/components/govuk_component/breadcrumbs.rb
171
+ - app/components/govuk_component/cookie_banner.html.erb
172
+ - app/components/govuk_component/cookie_banner.rb
163
173
  - app/components/govuk_component/details.html.erb
164
174
  - app/components/govuk_component/details.rb
165
175
  - app/components/govuk_component/footer.html.erb
@@ -213,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
223
  - !ruby/object:Gem::Version
214
224
  version: '0'
215
225
  requirements: []
216
- rubygems_version: 3.1.2
226
+ rubygems_version: 3.1.4
217
227
  signing_key:
218
228
  specification_version: 4
219
229
  summary: Lightweight set of reusable GOV.UK Design System components