govuk-components 4.0.0 → 4.1.0
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 +22 -22
- data/app/components/govuk_component/back_link_component.rb +9 -3
- data/app/components/govuk_component/breadcrumbs_component.rb +5 -2
- data/app/components/govuk_component/exit_this_page_component.rb +56 -0
- data/app/helpers/govuk_components_helper.rb +1 -0
- data/app/helpers/govuk_exit_this_page_link_helper.rb +17 -0
- data/app/helpers/govuk_link_helper.rb +1 -0
- data/lib/govuk/components/engine.rb +12 -0
- data/lib/govuk/components/version.rb +1 -1
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c998783ff4cc73621f04a651a6f3ef2f0a19813e5477a99d2676f50d0f5578b
|
4
|
+
data.tar.gz: 412f8a090cb71ea740c0844721568228a8efaa9cf33c064ef5062848ed326e05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b169ef4f3972c621d3ea3bd3ff84b7e7c93b232fb53336a896e0b8a3d2f52a04132e4142e7d6e3cf1f32629936e6abace87766b648174c93c1238254ba6bcebf
|
7
|
+
data.tar.gz: 27354029f86a306d806a763a9a466f247139664261591575c93fab124f2578c7b3ad4d3760b0e51c51f58320ff0bc31d4f997ab1b73d35b8abc82047ed8ecf6c
|
data/README.md
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
# GOV.UK Components
|
1
|
+
# GOV.UK Components for Ruby on Rails
|
2
2
|
|
3
|
-
[](https://codeclimate.com/github/
|
5
|
-
[](https://github.com/x-govuk/govuk-components/actions?query=workflow%3ATests)
|
4
|
+
[](https://codeclimate.com/github/x-govuk/govuk-components/maintainability)
|
5
|
+
[](https://badge.fury.io/rb/govuk-components)
|
6
6
|
[](https://rubygems.org/gems/govuk-components)
|
7
|
-
[](https://codeclimate.com/github/x-govuk/govuk-components/test_coverage)
|
8
|
+
[](https://github.com/x-govuk/govuk-components/blob/main/LICENSE.txt)
|
9
|
+
[](https://design-system.service.gov.uk)
|
10
|
+
[](https://viewcomponent.org/)
|
11
|
+
[](https://weblog.rubyonrails.org/releases/)
|
12
|
+
[](https://www.ruby-lang.org/en/downloads/)
|
12
13
|
|
13
14
|
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.
|
14
15
|
|
@@ -16,10 +17,7 @@ It aims to implement the functionality from the original Nunjucks macros in a wa
|
|
16
17
|
|
17
18
|
## Documentation
|
18
19
|
|
19
|
-
The gem comes with [a full guide](https://govuk-components.netlify.app/) that
|
20
|
-
covers most aspects of day-to-day use, along with code and output examples. The
|
21
|
-
examples in the guide (and the guide itself) are built using the components,
|
22
|
-
so it will always be up to date.
|
20
|
+
The gem comes with [a full guide](https://govuk-components.netlify.app/) that covers most aspects of day-to-day use, along with code and output examples. The examples in the guide (and the guide itself) are built using the components, so it will always be up to date.
|
23
21
|
|
24
22
|
[](https://app.netlify.com/sites/govuk-components/deploys)
|
25
23
|
|
@@ -34,6 +32,7 @@ The provided components are:
|
|
34
32
|
* [Breadcrumbs](https://govuk-components.netlify.app/components/breadcrumbs)
|
35
33
|
* [Cookie banner](https://govuk-components.netlify.app/components/cookie-banner)
|
36
34
|
* [Details](https://govuk-components.netlify.app/components/details)
|
35
|
+
* [Exit this page](https://govuk-components.netlify.app/components/exit-this-page)
|
37
36
|
* [Footer](https://govuk-components.netlify.app/components/footer)
|
38
37
|
* [Header](https://govuk-components.netlify.app/components/header)
|
39
38
|
* [Inset text](https://govuk-components.netlify.app/components/inset-text)
|
@@ -81,15 +80,15 @@ This library allows components to be rendered with Rails’ `render` method or v
|
|
81
80
|
|
82
81
|
```erb
|
83
82
|
<%= govuk_tabs(title: 'Days of the week') do |component| %>
|
84
|
-
<% component.
|
83
|
+
<% component.with_tab(label: 'Monday') do %>
|
85
84
|
<p>Monday’s child is fair of face</p>
|
86
85
|
<% end %>
|
87
86
|
|
88
|
-
<% component.
|
87
|
+
<% component.with_tab(label: 'Tuesday') do %>
|
89
88
|
<p>Tuesday’s child is full of grace</p>
|
90
89
|
<% end %>
|
91
90
|
|
92
|
-
<% component.
|
91
|
+
<% component.with_tab(label: 'Wednesday') do %>
|
93
92
|
<p>Wednesday’s child is full of woe</p>
|
94
93
|
<% end %>
|
95
94
|
<% end %>
|
@@ -118,6 +117,10 @@ require "govuk/components"
|
|
118
117
|
* [Register trainee teachers](https://github.com/DFE-Digital/register-trainee-teachers)
|
119
118
|
* [Teaching Vacancies](https://github.com/DFE-Digital/teaching-vacancies)
|
120
119
|
|
120
|
+
## Forks
|
121
|
+
|
122
|
+
* [Betagouv Système de Design de l'État view components](https://betagouv.github.io/dsfr-view-components/)
|
123
|
+
|
121
124
|
## Installation
|
122
125
|
|
123
126
|
Add this line to your application’s Gemfile:
|
@@ -140,12 +143,9 @@ gem install govuk-components
|
|
140
143
|
|
141
144
|
## Contributing
|
142
145
|
|
143
|
-
Bug reports and feature requests are most welcome, please raise an issue or
|
144
|
-
submit a pull request.
|
146
|
+
Bug reports and feature requests are most welcome, please raise an issue or submit a pull request.
|
145
147
|
|
146
|
-
Currently we're using [GOVUK Lint](https://github.com/alphagov/govuk-lint) to
|
147
|
-
ensure code meets the GOV.UK guidelines. Please ensure that any PRs also adhere
|
148
|
-
to this standard.
|
148
|
+
Currently we're using [GOVUK Lint](https://github.com/alphagov/govuk-lint) to ensure code meets the GOV.UK guidelines. Please ensure that any PRs also adhere to this standard.
|
149
149
|
|
150
150
|
To help keep the logs clean and tidy, please configure git to use your full name:
|
151
151
|
|
@@ -153,6 +153,6 @@ To help keep the logs clean and tidy, please configure git to use your full name
|
|
153
153
|
git config --global user.name "Julius Hibbert"
|
154
154
|
```
|
155
155
|
|
156
|
-
##
|
156
|
+
## Licence
|
157
157
|
|
158
158
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class GovukComponent::BackLinkComponent < GovukComponent::Base
|
2
|
-
attr_reader :text, :href
|
2
|
+
attr_reader :text, :href, :inverse
|
3
3
|
|
4
|
-
def initialize(href:, text: config.default_back_link_text, classes: [], html_attributes: {})
|
4
|
+
def initialize(href:, inverse: false, text: config.default_back_link_text, classes: [], html_attributes: {})
|
5
5
|
@text = text
|
6
6
|
@href = href
|
7
|
+
@inverse = inverse
|
7
8
|
|
8
9
|
super(classes: classes, html_attributes: html_attributes)
|
9
10
|
end
|
@@ -19,6 +20,11 @@ private
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def default_attributes
|
22
|
-
{
|
23
|
+
{
|
24
|
+
class: class_names(
|
25
|
+
"govuk-back-link",
|
26
|
+
"govuk-back-link--inverse" => inverse
|
27
|
+
).split
|
28
|
+
}
|
23
29
|
end
|
24
30
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
class GovukComponent::BreadcrumbsComponent < GovukComponent::Base
|
2
|
-
attr_reader :breadcrumbs, :hide_in_print, :collapse_on_mobile
|
2
|
+
attr_reader :breadcrumbs, :hide_in_print, :collapse_on_mobile, :inverse
|
3
3
|
|
4
4
|
def initialize(breadcrumbs:,
|
5
5
|
hide_in_print: config.default_breadcrumbs_hide_in_print,
|
6
6
|
collapse_on_mobile: config.default_breadcrumbs_collapse_on_mobile,
|
7
|
+
inverse: false,
|
7
8
|
classes: [],
|
8
9
|
html_attributes: {})
|
9
10
|
|
10
11
|
@breadcrumbs = build_list(breadcrumbs)
|
11
12
|
@hide_in_print = hide_in_print
|
12
13
|
@collapse_on_mobile = collapse_on_mobile
|
14
|
+
@inverse = inverse
|
13
15
|
|
14
16
|
super(classes: classes, html_attributes: html_attributes)
|
15
17
|
end
|
@@ -21,7 +23,8 @@ private
|
|
21
23
|
class: class_names(
|
22
24
|
"govuk-breadcrumbs",
|
23
25
|
"govuk-!-display-none-print" => hide_in_print,
|
24
|
-
"govuk-breadcrumbs--collapse-on-mobile" => collapse_on_mobile
|
26
|
+
"govuk-breadcrumbs--collapse-on-mobile" => collapse_on_mobile,
|
27
|
+
"govuk-breadcrumbs--inverse" => inverse
|
25
28
|
).split
|
26
29
|
}
|
27
30
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class GovukComponent::ExitThisPageComponent < GovukComponent::Base
|
2
|
+
attr_reader :text, :redirect_url, :activated_text, :timed_out_text, :press_two_more_times_text, :press_one_more_time_text
|
3
|
+
|
4
|
+
def initialize(
|
5
|
+
redirect_url: nil,
|
6
|
+
href: nil,
|
7
|
+
text: config.default_exit_this_page_text,
|
8
|
+
activated_text: config.default_exit_this_page_activated_text,
|
9
|
+
timed_out_text: config.default_exit_this_page_timed_out_text,
|
10
|
+
press_two_more_times_text: config.default_exit_this_page_press_two_more_times_text,
|
11
|
+
press_one_more_time_text: config.default_exit_this_page_press_one_more_time_text,
|
12
|
+
classes: [],
|
13
|
+
html_attributes: {}
|
14
|
+
)
|
15
|
+
fail(ArgumentError, "provide either redirect_url or href, not both") if redirect_url.present? && href.present?
|
16
|
+
|
17
|
+
@text = text
|
18
|
+
@redirect_url = href || redirect_url || config.default_exit_this_page_redirect_url || fail(ArgumentError, "no redirect_url provided")
|
19
|
+
@activated_text = activated_text
|
20
|
+
@timed_out_text = timed_out_text
|
21
|
+
@press_two_more_times_text = press_two_more_times_text
|
22
|
+
@press_one_more_time_text = press_one_more_time_text
|
23
|
+
|
24
|
+
super(classes: classes, html_attributes: html_attributes)
|
25
|
+
end
|
26
|
+
|
27
|
+
def call
|
28
|
+
tag.div(exit_this_page_content, **html_attributes)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def exit_this_page_content
|
34
|
+
govuk_button_link_to((content.presence || text), redirect_url, **link_attributes)
|
35
|
+
end
|
36
|
+
|
37
|
+
def default_attributes
|
38
|
+
{
|
39
|
+
class: "govuk-exit-this-page",
|
40
|
+
data: {
|
41
|
+
module: "govuk-exit-this-page",
|
42
|
+
"i18n.activated" => activated_text,
|
43
|
+
"i18n.timed-out" => timed_out_text,
|
44
|
+
"i18n.press-two-more-times" => press_two_more_times_text,
|
45
|
+
"i18n.press-one-more-time" => press_one_more_time_text,
|
46
|
+
}.compact
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def link_attributes
|
51
|
+
{
|
52
|
+
warning: true,
|
53
|
+
class: %w(govuk-exit-this-page__button govuk-js-exit-this-page-button)
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
@@ -5,6 +5,7 @@ module GovukComponentsHelper
|
|
5
5
|
govuk_breadcrumbs: 'GovukComponent::BreadcrumbsComponent',
|
6
6
|
govuk_cookie_banner: 'GovukComponent::CookieBannerComponent',
|
7
7
|
govuk_details: 'GovukComponent::DetailsComponent',
|
8
|
+
govuk_exit_this_page: 'GovukComponent::ExitThisPageComponent',
|
8
9
|
govuk_footer: 'GovukComponent::FooterComponent',
|
9
10
|
govuk_header: 'GovukComponent::HeaderComponent',
|
10
11
|
govuk_inset_text: 'GovukComponent::InsetTextComponent',
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module GovukExitThisPageLinkHelper
|
2
|
+
def govuk_exit_this_page_link(
|
3
|
+
text: Govuk::Components.config.default_exit_this_page_text,
|
4
|
+
href: Govuk::Components.config.default_exit_this_page_redirect_url,
|
5
|
+
classes: [],
|
6
|
+
**html_attributes,
|
7
|
+
&block
|
8
|
+
)
|
9
|
+
link_classes = Array.wrap(classes).append(%w(govuk-skip-link govuk-js-exit-this-page-skiplink))
|
10
|
+
|
11
|
+
html_attributes_with_data_module = { data: { module: "govuk-skip-link" } }.deep_merge(html_attributes)
|
12
|
+
|
13
|
+
link_to(text, href, class: link_classes, **html_attributes_with_data_module, &block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
ActiveSupport.on_load(:action_view) { include GovukExitThisPageLinkHelper }
|
@@ -37,6 +37,12 @@ module Govuk
|
|
37
37
|
# +:default_breadcrumbs_hide_in_print+ false
|
38
38
|
# +:default_cookie_banner_aria_label+ "Cookie banner"
|
39
39
|
# +:default_cookie_banner_hide_in_print+ true
|
40
|
+
# +:default_exit_this_page_redirect_url+ The URL that the exit this page component links to by default. Defaults to https://www.bbc.co.uk/weather
|
41
|
+
# +:default_exit_this_page_text+ The default text that forms the link. Defaults to 'Exit this page'
|
42
|
+
# +:default_exit_this_page_activated_text+ Text announced by screen readers when Exit this Page has been activated via the keyboard shortcut. Default in govuk-frontend is 'Exiting page.' Defaults to nil so govuk-frontend value is used unless overridden.
|
43
|
+
# +:default_exit_this_page_timed_out_text+ Text announced by screen readers when the keyboard shortcut has timed out without successful activation. Default in govuk-frontend is 'Exit this page expired.' Defaults to nil so govuk-frontend value is used unless overridden.
|
44
|
+
# +:default_exit_this_page_press_two_more_times_text+ Text announced by screen readers when the user must press *Shift* two more times to activate the button. Default in govuk-frontend is 'Shift, press 2 more times to exit.' Defaults to nil so govuk-frontend value is used unless overridden.
|
45
|
+
# +:default_exit_this_page_press_one_more_time_text+ Text announced by screen readers when the user must press *Shift* one more time to activate the button. Default in govuk-frontend is 'Shift, press 1 more time to exit.' Defaults to nil so govuk-frontend value is used unless overridden.
|
40
46
|
# +:default_header_navigation_label+ 'Navigation menu'
|
41
47
|
# +:default_header_menu_button_label+ 'Show or hide navigation menu'
|
42
48
|
# +:default_header_logotype+ 'GOV.UK'
|
@@ -71,6 +77,12 @@ module Govuk
|
|
71
77
|
default_breadcrumbs_hide_in_print: false,
|
72
78
|
default_cookie_banner_aria_label: "Cookie banner",
|
73
79
|
default_cookie_banner_hide_in_print: true,
|
80
|
+
default_exit_this_page_redirect_url: "https://www.bbc.co.uk/weather",
|
81
|
+
default_exit_this_page_text: "Exit this page",
|
82
|
+
default_exit_this_page_activated_text: nil,
|
83
|
+
default_exit_this_page_timed_out_text: nil,
|
84
|
+
default_exit_this_page_press_two_more_times_text: nil,
|
85
|
+
default_exit_this_page_press_one_more_time_text: nil,
|
74
86
|
default_header_navigation_label: 'Navigation menu',
|
75
87
|
default_header_menu_button_label: 'Show or hide navigation menu',
|
76
88
|
default_header_logotype: 'GOV.UK',
|
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.
|
4
|
+
version: 4.1.0
|
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
|
+
date: 2023-07-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.
|
53
|
+
version: 3.3.0
|
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.
|
60
|
+
version: 3.3.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: deep_merge
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,14 +120,14 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - '='
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 4.
|
123
|
+
version: 4.11.0
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - '='
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 4.
|
130
|
+
version: 4.11.0
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: sassc-rails
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -310,8 +310,8 @@ dependencies:
|
|
310
310
|
- - "~>"
|
311
311
|
- !ruby/object:Gem::Version
|
312
312
|
version: 1.8.1
|
313
|
-
description:
|
314
|
-
|
313
|
+
description: This library provides view components for the GOV.UK Design System. It
|
314
|
+
makes creating services more familiar for Ruby on Rails developers.
|
315
315
|
email:
|
316
316
|
- peter.yates@digital.education.gov.uk
|
317
317
|
executables: []
|
@@ -332,6 +332,7 @@ files:
|
|
332
332
|
- app/components/govuk_component/cookie_banner_component.rb
|
333
333
|
- app/components/govuk_component/cookie_banner_component/message_component.rb
|
334
334
|
- app/components/govuk_component/details_component.rb
|
335
|
+
- app/components/govuk_component/exit_this_page_component.rb
|
335
336
|
- app/components/govuk_component/footer_component.html.erb
|
336
337
|
- app/components/govuk_component/footer_component.rb
|
337
338
|
- app/components/govuk_component/header_component.html.erb
|
@@ -372,6 +373,7 @@ files:
|
|
372
373
|
- app/components/govuk_component/warning_text_component.rb
|
373
374
|
- app/helpers/govuk_back_to_top_link_helper.rb
|
374
375
|
- app/helpers/govuk_components_helper.rb
|
376
|
+
- app/helpers/govuk_exit_this_page_link_helper.rb
|
375
377
|
- app/helpers/govuk_link_helper.rb
|
376
378
|
- app/helpers/govuk_skip_link_helper.rb
|
377
379
|
- config/routes.rb
|
@@ -380,7 +382,7 @@ files:
|
|
380
382
|
- lib/govuk/components/helpers/css_utilities.rb
|
381
383
|
- lib/govuk/components/version.rb
|
382
384
|
- lib/tasks/govuk/components_tasks.rake
|
383
|
-
homepage: https://github.com/
|
385
|
+
homepage: https://github.com/x-govuk/govuk-components
|
384
386
|
licenses:
|
385
387
|
- MIT
|
386
388
|
metadata: {}
|
@@ -402,5 +404,5 @@ requirements: []
|
|
402
404
|
rubygems_version: 3.2.33
|
403
405
|
signing_key:
|
404
406
|
specification_version: 4
|
405
|
-
summary:
|
407
|
+
summary: GOV.UK Components for Ruby on Rails
|
406
408
|
test_files: []
|