govuk-components 1.0.2 → 1.1.4

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: 381764ecf5e843d375020a7fe394acef575c591b08035da10d2d0303ae07925f
4
- data.tar.gz: a40ece8066dda10d5bbef274014350967734290aa3f01240a13cd9bb36b52886
3
+ metadata.gz: 2bb78c96c1c9197b5fb35aaecd9f5d92a642db0ce1918ff3cb582698ae8cd8a2
4
+ data.tar.gz: ff373974b83e3aaf04c79becc91fe25527311f3b9d8a0212fca0acac44e8ce31
5
5
  SHA512:
6
- metadata.gz: 238e795f32101c4f5b91dcc3c4e86b4dc2dce8b39f1ab377f353838afc8cb12e192176575d1b7a816ecc8592e213bbb60f1dc22e9a3ebe3b2f3cbbe0ec156e6e
7
- data.tar.gz: 044ea8db203a2ef93781a066bd9c4559c5d45d11f9cdd76c023c7799d5a6caf4d502687f610e094019f1544a2d56bb6fd990d98a496b7457012a854c6b9406b6
6
+ metadata.gz: 4b6c857eb90195678cb4c2c14c7842d690416e3b95b398d991a72eb5ea81d34670c7cf43a7e0c77005f9f3c33c20224dfe4f9d40741027f7789e294e886dcf5d
7
+ data.tar.gz: 28d99eaea4e9047ceddd7e03f2213c48d1d768a748d22cd438b4c2e02f09dddf3f2782948358dffce554c4e9aea3dfd13f191f82c366c5348ad4852951c2c2a5
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=DFE-Digital/govuk-components)](https://dependabot.com)
8
8
  [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-3.10.2-brightgreen)](https://design-system.service.gov.uk)
9
9
 
10
- 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. ViewComponent will be [supported natively in Rails 6.1](https://edgeguides.rubyonrails.org/layouts_and_rendering.html#rendering-objects).
10
+ 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.
11
11
 
12
12
  ## What's included
13
13
 
@@ -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,30 +1,42 @@
1
1
  <%= tag.footer(class: classes, role: 'contentinfo', **html_attributes) do %>
2
2
  <div class="govuk-width-container ">
3
- <% if content.present? %>
4
- <%= content %>
5
- <% end %>
6
3
  <div class="govuk-footer__meta">
7
- <div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
8
- <% if @meta_links.any? %>
9
- <%= @meta_heading %>
10
- <ul class="govuk-footer__inline-list">
11
- <% @meta_links.each do |meta_link| %>
12
- <li class="govuk-footer__inline-list-item">
13
- <%= meta_link %>
14
- </li>
15
- <% end %>
16
- </ul>
17
- <% end %>
18
- <svg aria-hidden="true" focusable="false" class="govuk-footer__licence-logo" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 483.2 195.7" height="17" width="41">
19
- <path fill="currentColor" d="M421.5 142.8V.1l-50.7 32.3v161.1h112.4v-50.7zm-122.3-9.6A47.12 47.12 0 0 1 221 97.8c0-26 21.1-47.1 47.1-47.1 16.7 0 31.4 8.7 39.7 21.8l42.7-27.2A97.63 97.63 0 0 0 268.1 0c-36.5 0-68.3 20.1-85.1 49.7A98 98 0 0 0 97.8 0C43.9 0 0 43.9 0 97.8s43.9 97.8 97.8 97.8c36.5 0 68.3-20.1 85.1-49.7a97.76 97.76 0 0 0 149.6 25.4l19.4 22.2h3v-87.8h-80l24.3 27.5zM97.8 145c-26 0-47.1-21.1-47.1-47.1s21.1-47.1 47.1-47.1 47.2 21 47.2 47S123.8 145 97.8 145" />
20
- </svg>
21
- <span class="govuk-footer__licence-description">
22
- <%= licence %>
23
- </span>
24
- </div>
25
- <div class="govuk-footer__meta-item">
26
- <%= @copyright %>
27
- </div>
4
+ <% if meta.present? %>
5
+ <%= meta.content %>
6
+ <% else %>
7
+ <div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
8
+ <% if meta_items.any? %>
9
+ <h2 class="govuk-visually-hidden"><%= meta_items_title %></h2>
10
+
11
+ <ul class="govuk-footer__inline-list">
12
+ <% @meta_items.each do |hyperlink| %>
13
+ <li class="govuk-footer__inline-list-item">
14
+ <%= hyperlink %>
15
+ </li>
16
+ <% end %>
17
+ </ul>
18
+ <% end %>
19
+
20
+ <% if meta_licence.nil? %>
21
+ <svg aria-hidden="true" focusable="false" class="govuk-footer__licence-logo" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 483.2 195.7" height="17" width="41">
22
+ <path fill="currentColor" d="M421.5 142.8V.1l-50.7 32.3v161.1h112.4v-50.7zm-122.3-9.6A47.12 47.12 0 0 1 221 97.8c0-26 21.1-47.1 47.1-47.1 16.7 0 31.4 8.7 39.7 21.8l42.7-27.2A97.63 97.63 0 0 0 268.1 0c-36.5 0-68.3 20.1-85.1 49.7A98 98 0 0 0 97.8 0C43.9 0 0 43.9 0 97.8s43.9 97.8 97.8 97.8c36.5 0 68.3-20.1 85.1-49.7a97.76 97.76 0 0 0 149.6 25.4l19.4 22.2h3v-87.8h-80l24.3 27.5zM97.8 145c-26 0-47.1-21.1-47.1-47.1s21.1-47.1 47.1-47.1 47.2 21 47.2 47S123.8 145 97.8 145" />
23
+ </svg>
24
+
25
+ <%= tag.span(default_licence, class: "govuk-footer__licence-description") %>
26
+ <% elsif meta_licence.present? %>
27
+ <%= tag.span(meta_licence, class: "govuk-footer__licence-description") %>
28
+ <% end %>
29
+
30
+ <% if meta_content.present? %>
31
+ <%= meta_content.content %>
32
+ <% end %>
33
+ </div>
34
+ <div class="govuk-footer__meta">
35
+ <div class="govuk-footer__meta-item">
36
+ <%= copyright %>
37
+ </div>
38
+ </div>
39
+ <% end %>
28
40
  </div>
29
41
  </div>
30
42
  <% end %>
@@ -1,13 +1,21 @@
1
1
  class GovukComponent::Footer < GovukComponent::Base
2
- attr_accessor :meta, :licence, :copyright
2
+ include ViewComponent::Slotable
3
3
 
4
- def initialize(meta_links: nil, meta_heading: default_meta_heading, licence: nil, copyright_text: default_copright_text, copyright_url: default_copyright_url, classes: [], html_attributes: {})
4
+ with_slot :meta_content
5
+ wrap_slot :meta_content
6
+
7
+ with_slot :meta
8
+ wrap_slot :meta
9
+
10
+ attr_accessor :meta_items, :meta_items_title, :meta_licence, :copyright
11
+
12
+ def initialize(meta_items: {}, meta_items_title: "Support links", meta_licence: nil, classes: [], html_attributes: {}, copyright_text: default_copright_text, copyright_url: default_copyright_url)
5
13
  super(classes: classes, html_attributes: html_attributes)
6
14
 
7
- @meta_links = build_meta_links(meta_links)
8
- @meta_heading = raw(tag.h2(meta_heading, class: 'govuk-visually-hidden'))
9
- @licence = raw(licence).presence || default_licence
10
- @copyright = build_copyright(copyright_text, copyright_url)
15
+ @meta_items = build_meta_links(meta_items)
16
+ @meta_items_title = meta_items_title
17
+ @meta_licence = meta_licence
18
+ @copyright = build_copyright(copyright_text, copyright_url)
11
19
  end
12
20
 
13
21
  private
@@ -24,10 +32,6 @@ private
24
32
  links.map { |text, href| raw(link_to(text, href, class: %w(govuk-footer__link))) }
25
33
  end
26
34
 
27
- def default_meta_heading
28
- 'Supporting links'
29
- end
30
-
31
35
  def default_licence
32
36
  link = link_to("Open Government Licence v3.0", "https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/", class: %w(govuk-footer__link))
33
37
 
@@ -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.0.2'.freeze
3
+ VERSION = '1.1.4'.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: 1.0.2
4
+ version: 1.1.4
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-08 00:00:00.000000000 Z
11
+ date: 2021-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,22 +28,16 @@ dependencies:
28
28
  name: view_component
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.22.1
34
- - - "<"
31
+ - - "~>"
35
32
  - !ruby/object:Gem::Version
36
- version: 2.25.0
33
+ version: '2.20'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 2.22.1
44
- - - "<"
38
+ - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: 2.25.0
40
+ version: '2.20'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: capybara
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -160,6 +154,8 @@ files:
160
154
  - app/components/govuk_component/base.rb
161
155
  - app/components/govuk_component/breadcrumbs.html.erb
162
156
  - app/components/govuk_component/breadcrumbs.rb
157
+ - app/components/govuk_component/cookie_banner.html.erb
158
+ - app/components/govuk_component/cookie_banner.rb
163
159
  - app/components/govuk_component/details.html.erb
164
160
  - app/components/govuk_component/details.rb
165
161
  - app/components/govuk_component/footer.html.erb
@@ -213,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
209
  - !ruby/object:Gem::Version
214
210
  version: '0'
215
211
  requirements: []
216
- rubygems_version: 3.1.2
212
+ rubygems_version: 3.1.4
217
213
  signing_key:
218
214
  specification_version: 4
219
215
  summary: Lightweight set of reusable GOV.UK Design System components