govuk-components 4.0.0 → 4.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 +22 -22
- data/app/components/govuk_component/accordion_component/section_component.html.erb +5 -5
- data/app/components/govuk_component/accordion_component/section_component.rb +1 -1
- data/app/components/govuk_component/accordion_component.rb +1 -1
- data/app/components/govuk_component/back_link_component.rb +9 -3
- data/app/components/govuk_component/base.rb +4 -0
- data/app/components/govuk_component/breadcrumbs_component.html.erb +1 -1
- data/app/components/govuk_component/breadcrumbs_component.rb +9 -6
- data/app/components/govuk_component/cookie_banner_component/message_component.rb +7 -7
- data/app/components/govuk_component/cookie_banner_component.rb +1 -1
- data/app/components/govuk_component/details_component.rb +5 -5
- data/app/components/govuk_component/exit_this_page_component.rb +56 -0
- data/app/components/govuk_component/footer_component.html.erb +11 -11
- data/app/components/govuk_component/footer_component.rb +7 -7
- data/app/components/govuk_component/header_component.html.erb +10 -10
- data/app/components/govuk_component/header_component.rb +8 -8
- data/app/components/govuk_component/inset_text_component.rb +1 -1
- data/app/components/govuk_component/notification_banner_component.html.erb +3 -3
- data/app/components/govuk_component/notification_banner_component.rb +5 -5
- data/app/components/govuk_component/pagination_component/adjacent_page.rb +6 -6
- data/app/components/govuk_component/pagination_component/item.rb +4 -4
- data/app/components/govuk_component/pagination_component/next_page.rb +1 -1
- data/app/components/govuk_component/pagination_component/previous_page.rb +1 -1
- data/app/components/govuk_component/pagination_component.rb +4 -4
- data/app/components/govuk_component/panel_component.rb +3 -3
- data/app/components/govuk_component/phase_banner_component.html.erb +2 -2
- data/app/components/govuk_component/phase_banner_component.rb +2 -2
- data/app/components/govuk_component/section_break_component.rb +3 -3
- data/app/components/govuk_component/start_button_component.rb +8 -10
- data/app/components/govuk_component/summary_list_component/action_component.rb +1 -1
- data/app/components/govuk_component/summary_list_component/card_component.html.erb +5 -5
- data/app/components/govuk_component/summary_list_component/card_component.rb +1 -1
- data/app/components/govuk_component/summary_list_component/key_component.rb +1 -1
- data/app/components/govuk_component/summary_list_component/row_component.rb +5 -5
- data/app/components/govuk_component/summary_list_component/value_component.rb +1 -1
- data/app/components/govuk_component/summary_list_component.rb +2 -2
- data/app/components/govuk_component/tab_component.html.erb +2 -2
- data/app/components/govuk_component/tab_component.rb +5 -5
- data/app/components/govuk_component/table_component/body_component.rb +1 -1
- data/app/components/govuk_component/table_component/caption_component.rb +2 -2
- data/app/components/govuk_component/table_component/cell_component.rb +12 -10
- data/app/components/govuk_component/table_component/foot_component.rb +1 -1
- data/app/components/govuk_component/table_component/head_component.rb +1 -1
- data/app/components/govuk_component/table_component/row_component.rb +1 -1
- data/app/components/govuk_component/table_component.rb +1 -1
- data/app/components/govuk_component/tag_component.rb +2 -2
- data/app/components/govuk_component/warning_text_component.rb +4 -4
- data/app/helpers/govuk_back_to_top_link_helper.rb +7 -1
- data/app/helpers/govuk_components_helper.rb +1 -0
- data/app/helpers/govuk_exit_this_page_link_helper.rb +23 -0
- data/app/helpers/govuk_link_helper.rb +38 -26
- data/app/helpers/govuk_skip_link_helper.rb +2 -2
- data/app/helpers/title_with_error_prefix_helper.rb +7 -0
- data/lib/govuk/components/engine.rb +16 -2
- data/lib/govuk/components/version.rb +1 -1
- metadata +21 -12
@@ -3,34 +3,20 @@ require "html_attributes_utils"
|
|
3
3
|
module GovukLinkHelper
|
4
4
|
using HTMLAttributesUtils
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
no_underline: "govuk-link--no-underline",
|
10
|
-
no_visited_state: "govuk-link--no-visited-state",
|
11
|
-
text_colour: "govuk-link--text-colour",
|
12
|
-
}.freeze
|
13
|
-
|
14
|
-
BUTTON_STYLES = {
|
15
|
-
disabled: "govuk-button--disabled",
|
16
|
-
secondary: "govuk-button--secondary",
|
17
|
-
warning: "govuk-button--warning",
|
18
|
-
}.freeze
|
19
|
-
|
20
|
-
def govuk_link_classes(*styles, default_class: 'govuk-link')
|
21
|
-
if (invalid_styles = (styles - LINK_STYLES.keys)) && invalid_styles.any?
|
22
|
-
fail(ArgumentError, "invalid styles #{invalid_styles.to_sentence}. Valid styles are #{LINK_STYLES.keys.to_sentence}")
|
6
|
+
def govuk_link_classes(*styles, default_class: "#{brand}-link")
|
7
|
+
if (invalid_styles = (styles - link_styles.keys)) && invalid_styles.any?
|
8
|
+
fail(ArgumentError, "invalid styles #{invalid_styles.to_sentence}. Valid styles are #{link_styles.keys.to_sentence}")
|
23
9
|
end
|
24
10
|
|
25
|
-
[default_class] +
|
11
|
+
[default_class] + link_styles.values_at(*styles).compact
|
26
12
|
end
|
27
13
|
|
28
|
-
def govuk_button_classes(*styles, default_class:
|
29
|
-
if (invalid_styles = (styles -
|
30
|
-
fail(ArgumentError, "invalid styles #{invalid_styles.to_sentence}. Valid styles are #{
|
14
|
+
def govuk_button_classes(*styles, default_class: "#{brand}-button")
|
15
|
+
if (invalid_styles = (styles - button_styles.keys)) && invalid_styles.any?
|
16
|
+
fail(ArgumentError, "invalid styles #{invalid_styles.to_sentence}. Valid styles are #{button_styles.keys.to_sentence}")
|
31
17
|
end
|
32
18
|
|
33
|
-
[default_class] +
|
19
|
+
[default_class] + button_styles.values_at(*styles).compact
|
34
20
|
end
|
35
21
|
|
36
22
|
def govuk_link_to(name = nil, options = nil, extra_options = {}, &block)
|
@@ -68,8 +54,11 @@ module GovukLinkHelper
|
|
68
54
|
|
69
55
|
def govuk_button_link_to(name = nil, options = nil, extra_options = {}, &block)
|
70
56
|
extra_options = options if block_given?
|
71
|
-
html_options =
|
72
|
-
|
57
|
+
html_options = {
|
58
|
+
data: { module: "#{brand}-button" },
|
59
|
+
draggable: 'false',
|
60
|
+
role: 'button',
|
61
|
+
}.merge build_html_options(extra_options, style: :button)
|
73
62
|
|
74
63
|
if block_given?
|
75
64
|
link_to(name, html_options, &block)
|
@@ -91,8 +80,31 @@ module GovukLinkHelper
|
|
91
80
|
|
92
81
|
private
|
93
82
|
|
83
|
+
def brand
|
84
|
+
Govuk::Components.brand
|
85
|
+
end
|
86
|
+
|
87
|
+
def link_styles
|
88
|
+
{
|
89
|
+
inverse: "#{brand}-link--inverse",
|
90
|
+
muted: "#{brand}-link--muted",
|
91
|
+
no_underline: "#{brand}-link--no-underline",
|
92
|
+
no_visited_state: "#{brand}-link--no-visited-state",
|
93
|
+
text_colour: "#{brand}-link--text-colour",
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
def button_styles
|
98
|
+
{
|
99
|
+
disabled: "#{brand}-button--disabled",
|
100
|
+
secondary: "#{brand}-button--secondary",
|
101
|
+
warning: "#{brand}-button--warning",
|
102
|
+
inverse: "#{brand}-button--inverse",
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
94
106
|
def build_html_options(provided_options, style: :link)
|
95
|
-
element_styles = { link:
|
107
|
+
element_styles = { link: link_styles, button: button_styles }.fetch(style, {})
|
96
108
|
|
97
109
|
# we need to take a couple of extra steps here because we don't want the style
|
98
110
|
# params (inverse, muted, etc) to end up as extra attributes on the link.
|
@@ -110,7 +122,7 @@ private
|
|
110
122
|
case style
|
111
123
|
when :link then govuk_link_classes(*keys)
|
112
124
|
when :button then govuk_button_classes(*keys)
|
113
|
-
when :breadcrumb then
|
125
|
+
when :breadcrumb then "#{brand}-breadcrumbs__link"
|
114
126
|
end
|
115
127
|
end
|
116
128
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module GovukSkipLinkHelper
|
2
2
|
def govuk_skip_link(text: 'Skip to main content', href: '#main-content', classes: [], **html_attributes, &block)
|
3
|
-
link_classes = Array.wrap(classes).append(
|
3
|
+
link_classes = Array.wrap(classes).append("#{brand}-skip-link")
|
4
4
|
|
5
|
-
html_attributes_with_data_module = { data: { module: "
|
5
|
+
html_attributes_with_data_module = { data: { module: "#{brand}-skip-link" } }.deep_merge(html_attributes)
|
6
6
|
|
7
7
|
return link_to(href, class: link_classes, **html_attributes_with_data_module, &block) if block_given?
|
8
8
|
|
@@ -32,11 +32,19 @@ module Govuk
|
|
32
32
|
#
|
33
33
|
# Default components configuration
|
34
34
|
#
|
35
|
+
# +:brand+ sets the value used to prefix all classes, used to allow the components to be branded for alternative (similar) design systems
|
35
36
|
# +:default_back_link_text+ Default text for the back link, defaults to +Back+
|
36
37
|
# +:default_breadcrumbs_collapse_on_mobile+ false
|
37
38
|
# +:default_breadcrumbs_hide_in_print+ false
|
38
39
|
# +:default_cookie_banner_aria_label+ "Cookie banner"
|
39
40
|
# +:default_cookie_banner_hide_in_print+ true
|
41
|
+
# +:default_error_prefix+ Text to use at the start of the page title tag when there is an error on the page. Default is 'Error: '
|
42
|
+
# +: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
|
43
|
+
# +:default_exit_this_page_text+ The default text that forms the link. Defaults to 'Exit this page'
|
44
|
+
# +: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.
|
45
|
+
# +: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.
|
46
|
+
# +: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.
|
47
|
+
# +: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
48
|
# +:default_header_navigation_label+ 'Navigation menu'
|
41
49
|
# +:default_header_menu_button_label+ 'Show or hide navigation menu'
|
42
50
|
# +:default_header_logotype+ 'GOV.UK'
|
@@ -66,11 +74,19 @@ module Govuk
|
|
66
74
|
# +:require_summary_list_action_visually_hidden_text+ when true forces visually hidden text to be set for every action. It can still be explicitly skipped by passing in +nil+. Defaults to +false+
|
67
75
|
# +:enable_auto_table_scopes+ automatically adds a scope of 'col' to th elements in thead and 'row' to th elements in tbody.
|
68
76
|
DEFAULTS = {
|
77
|
+
brand: 'govuk',
|
69
78
|
default_back_link_text: 'Back',
|
70
79
|
default_breadcrumbs_collapse_on_mobile: false,
|
71
80
|
default_breadcrumbs_hide_in_print: false,
|
72
81
|
default_cookie_banner_aria_label: "Cookie banner",
|
73
82
|
default_cookie_banner_hide_in_print: true,
|
83
|
+
default_error_prefix: "Error: ",
|
84
|
+
default_exit_this_page_redirect_url: "https://www.bbc.co.uk/weather",
|
85
|
+
default_exit_this_page_text: "Exit this page",
|
86
|
+
default_exit_this_page_activated_text: nil,
|
87
|
+
default_exit_this_page_timed_out_text: nil,
|
88
|
+
default_exit_this_page_press_two_more_times_text: nil,
|
89
|
+
default_exit_this_page_press_one_more_time_text: nil,
|
74
90
|
default_header_navigation_label: 'Navigation menu',
|
75
91
|
default_header_menu_button_label: 'Show or hide navigation menu',
|
76
92
|
default_header_logotype: 'GOV.UK',
|
@@ -96,9 +112,7 @@ module Govuk
|
|
96
112
|
default_notification_title_success: false,
|
97
113
|
default_warning_text_icon_fallback_text: "Warning",
|
98
114
|
default_warning_text_icon: "!",
|
99
|
-
|
100
115
|
default_link_new_tab_text: "(opens in new tab)",
|
101
|
-
|
102
116
|
require_summary_list_action_visually_hidden_text: false,
|
103
117
|
enable_auto_table_scopes: true,
|
104
118
|
}.freeze
|
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.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: 2023-
|
11
|
+
date: 2023-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-attributes-utils
|
@@ -48,16 +48,22 @@ dependencies:
|
|
48
48
|
name: view_component
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.3'
|
54
|
+
- - "<"
|
52
55
|
- !ruby/object:Gem::Version
|
53
|
-
version: 3.
|
56
|
+
version: '3.6'
|
54
57
|
type: :runtime
|
55
58
|
prerelease: false
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
57
60
|
requirements:
|
58
|
-
- - "
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '3.3'
|
64
|
+
- - "<"
|
59
65
|
- !ruby/object:Gem::Version
|
60
|
-
version: 3.
|
66
|
+
version: '3.6'
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: deep_merge
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,14 +126,14 @@ dependencies:
|
|
120
126
|
requirements:
|
121
127
|
- - '='
|
122
128
|
- !ruby/object:Gem::Version
|
123
|
-
version: 4.
|
129
|
+
version: 4.12.0
|
124
130
|
type: :development
|
125
131
|
prerelease: false
|
126
132
|
version_requirements: !ruby/object:Gem::Requirement
|
127
133
|
requirements:
|
128
134
|
- - '='
|
129
135
|
- !ruby/object:Gem::Version
|
130
|
-
version: 4.
|
136
|
+
version: 4.12.0
|
131
137
|
- !ruby/object:Gem::Dependency
|
132
138
|
name: sassc-rails
|
133
139
|
requirement: !ruby/object:Gem::Requirement
|
@@ -310,8 +316,8 @@ dependencies:
|
|
310
316
|
- - "~>"
|
311
317
|
- !ruby/object:Gem::Version
|
312
318
|
version: 1.8.1
|
313
|
-
description:
|
314
|
-
|
319
|
+
description: This library provides view components for the GOV.UK Design System. It
|
320
|
+
makes creating services more familiar for Ruby on Rails developers.
|
315
321
|
email:
|
316
322
|
- peter.yates@digital.education.gov.uk
|
317
323
|
executables: []
|
@@ -332,6 +338,7 @@ files:
|
|
332
338
|
- app/components/govuk_component/cookie_banner_component.rb
|
333
339
|
- app/components/govuk_component/cookie_banner_component/message_component.rb
|
334
340
|
- app/components/govuk_component/details_component.rb
|
341
|
+
- app/components/govuk_component/exit_this_page_component.rb
|
335
342
|
- app/components/govuk_component/footer_component.html.erb
|
336
343
|
- app/components/govuk_component/footer_component.rb
|
337
344
|
- app/components/govuk_component/header_component.html.erb
|
@@ -372,15 +379,17 @@ files:
|
|
372
379
|
- app/components/govuk_component/warning_text_component.rb
|
373
380
|
- app/helpers/govuk_back_to_top_link_helper.rb
|
374
381
|
- app/helpers/govuk_components_helper.rb
|
382
|
+
- app/helpers/govuk_exit_this_page_link_helper.rb
|
375
383
|
- app/helpers/govuk_link_helper.rb
|
376
384
|
- app/helpers/govuk_skip_link_helper.rb
|
385
|
+
- app/helpers/title_with_error_prefix_helper.rb
|
377
386
|
- config/routes.rb
|
378
387
|
- lib/govuk/components.rb
|
379
388
|
- lib/govuk/components/engine.rb
|
380
389
|
- lib/govuk/components/helpers/css_utilities.rb
|
381
390
|
- lib/govuk/components/version.rb
|
382
391
|
- lib/tasks/govuk/components_tasks.rake
|
383
|
-
homepage: https://github.com/
|
392
|
+
homepage: https://github.com/x-govuk/govuk-components
|
384
393
|
licenses:
|
385
394
|
- MIT
|
386
395
|
metadata: {}
|
@@ -402,5 +411,5 @@ requirements: []
|
|
402
411
|
rubygems_version: 3.2.33
|
403
412
|
signing_key:
|
404
413
|
specification_version: 4
|
405
|
-
summary:
|
414
|
+
summary: GOV.UK Components for Ruby on Rails
|
406
415
|
test_files: []
|