govuk-components 0.8.0 → 1.1.1
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 +4 -4
- data/README.md +8 -4
- data/app/components/govuk_component/base.rb +1 -1
- data/app/components/govuk_component/cookie_banner.html.erb +21 -0
- data/app/components/govuk_component/cookie_banner.rb +18 -0
- data/app/components/govuk_component/footer.html.erb +36 -24
- data/app/components/govuk_component/footer.rb +14 -10
- data/app/components/govuk_component/notification_banner.html.erb +8 -5
- data/app/components/govuk_component/notification_banner.rb +3 -3
- data/app/components/govuk_component/tag.rb +1 -1
- data/app/components/govuk_component/traits/custom_classes.rb +1 -2
- data/app/helpers/govuk_components_helper.rb +2 -1
- data/lib/govuk/components/engine.rb +1 -1
- data/lib/govuk/components/version.rb +1 -1
- metadata +45 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93a84a3c93600e18249b9cb15f53ef3abc0d04cfc57f47790215af5ed24526c6
|
4
|
+
data.tar.gz: 810056d2494f56058ba9be66d36a952e31780cda1ba4e8a239d80f421dc2cfbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22ce8154eb8c60b69bd34fde51e32fa651cf19e816523115d3b564f2bfed1921a35ae8205781b5c53e943203db2dfd48d64316db9984306e582127f42d9da132
|
7
|
+
data.tar.gz: 75fb99c2da5e8644abd9dcc1d03bdc1b83d902a4271e3b71cde0f8151179abcee6fbf4a49d0f08f4484249966354768c801ecbf75384bfb943dcb58e61eaef8d
|
data/README.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
**This gem is under heavy development and the API is likely to change.**
|
2
|
-
|
3
1
|
# GOV.UK Components
|
4
2
|
|
5
|
-
[](https://github.com/DFE-Digital/govuk-components/actions?query=workflow%3ATests)
|
4
|
+
[](https://codeclimate.com/github/DFE-Digital/govuk-components/maintainability)
|
5
|
+
[](https://codeclimate.com/github/DFE-Digital/govuk-components/test_coverage)
|
6
|
+
[](https://github.com/DFE-Digital/govuk-components/blob/master/LICENSE)
|
7
|
+
[](https://dependabot.com)
|
8
|
+
[](https://design-system.service.gov.uk)
|
6
9
|
|
7
|
-
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.
|
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.
|
8
11
|
|
9
12
|
## What's included
|
10
13
|
|
@@ -13,6 +16,7 @@ This gem provides a suite of reusable components for the [GOV.UK Design System](
|
|
13
16
|
| [Accordion](app/components/govuk_component/accordion.rb) | `govuk_accordion` |
|
14
17
|
| [Back link](app/components/govuk_component/back_link.rb) | `govuk_back_link` |
|
15
18
|
| [Breadcrumbs](app/components/govuk_component/breadcrumbs.rb) | `govuk_breadcrumbs` |
|
19
|
+
| [Cookie banner](app/components/govuk_component/cookie_banner.rb) | `govuk_cookie_banner` |
|
16
20
|
| [Details](app/components/govuk_component/details.rb) | `govuk_details` |
|
17
21
|
| [Footer](app/components/govuk_component/footer.rb) | `govuk_footer` |
|
18
22
|
| [Header](app/components/govuk_component/header.rb) | `govuk_header` |
|
@@ -11,7 +11,7 @@ class GovukComponent::Base < ViewComponent::Base
|
|
11
11
|
# with slots feel more DSL-like
|
12
12
|
def self.wrap_slot(name)
|
13
13
|
define_method(%(add_#{name})) do |*args, **kwargs, &block|
|
14
|
-
|
14
|
+
slot(name, *args, **kwargs, &block)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
2
|
+
include ViewComponent::Slotable
|
3
3
|
|
4
|
-
|
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
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@copyright
|
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,
|
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 %>
|
@@ -7,10 +7,13 @@
|
|
7
7
|
<div class="govuk-notification-banner__content">
|
8
8
|
<% headings.each do |heading| %>
|
9
9
|
<p class="govuk-notification-banner__heading">
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
<% if heading.text.present? %>
|
11
|
+
<%= heading.text %>
|
12
|
+
<% if heading.link_target && heading.link_text %>
|
13
|
+
<%= link_to(heading.link_text, heading.link_target, class: "govuk-notification-banner__link") %>.
|
14
|
+
<% end %>
|
15
|
+
<% else %>
|
16
|
+
<%= heading.content %>
|
14
17
|
<% end %>
|
15
18
|
</p>
|
16
19
|
<% end %>
|
@@ -36,9 +36,9 @@ class GovukComponent::NotificationBanner < GovukComponent::Base
|
|
36
36
|
class Heading < ViewComponent::Slot
|
37
37
|
attr_accessor :text, :link_target, :link_text
|
38
38
|
|
39
|
-
def initialize(text
|
40
|
-
@text
|
41
|
-
@link_text
|
39
|
+
def initialize(text: nil, link_text: nil, link_target: nil)
|
40
|
+
@text = text
|
41
|
+
@link_text = link_text
|
42
42
|
@link_target = link_target
|
43
43
|
end
|
44
44
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module GovukComponent
|
2
2
|
module Traits
|
3
3
|
module CustomClasses
|
4
|
-
|
5
4
|
def classes
|
6
5
|
default_classes.concat(Array.wrap(@classes))
|
7
6
|
end
|
@@ -15,7 +14,7 @@ module GovukComponent
|
|
15
14
|
private
|
16
15
|
|
17
16
|
def parse_classes(classes)
|
18
|
-
return []
|
17
|
+
return [] if classes.blank?
|
19
18
|
|
20
19
|
case classes
|
21
20
|
when Array
|
@@ -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',
|
@@ -19,7 +20,7 @@ module GovukComponentsHelper
|
|
19
20
|
define_method(name) do |*args, **kwargs, &block|
|
20
21
|
capture do
|
21
22
|
render(klass.constantize.new(*args, **kwargs)) do |com|
|
22
|
-
block.call(com)
|
23
|
+
block.call(com) if block.present?
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
metadata
CHANGED
@@ -1,51 +1,51 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.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:
|
11
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 6.0.3
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: 6.0
|
19
|
+
version: '6.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 6.0.3
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: 6.0
|
26
|
+
version: '6.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: view_component
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- - "
|
31
|
+
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
33
|
version: 2.22.1
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.26.0
|
40
37
|
type: :runtime
|
41
38
|
prerelease: false
|
42
39
|
version_requirements: !ruby/object:Gem::Requirement
|
43
40
|
requirements:
|
44
|
-
- - "
|
41
|
+
- - ">="
|
45
42
|
- !ruby/object:Gem::Version
|
46
43
|
version: 2.22.1
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.26.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: capybara
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: pry-byebug
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
90
|
+
name: rubocop-govuk
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - ">="
|
@@ -114,6 +114,34 @@ dependencies:
|
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: simplecov
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0.20'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0.20'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: sqlite3
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
117
145
|
description: A collection of components intended to ease the building of GOV.UK Design
|
118
146
|
System web applications
|
119
147
|
email:
|
@@ -132,6 +160,8 @@ files:
|
|
132
160
|
- app/components/govuk_component/base.rb
|
133
161
|
- app/components/govuk_component/breadcrumbs.html.erb
|
134
162
|
- app/components/govuk_component/breadcrumbs.rb
|
163
|
+
- app/components/govuk_component/cookie_banner.html.erb
|
164
|
+
- app/components/govuk_component/cookie_banner.rb
|
135
165
|
- app/components/govuk_component/details.html.erb
|
136
166
|
- app/components/govuk_component/details.rb
|
137
167
|
- app/components/govuk_component/footer.html.erb
|