govuk_publishing_components 25.0.0 → 25.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +34 -5
- data/app/assets/javascripts/govuk_publishing_components/modules.js +11 -17
- data/app/assets/stylesheets/govuk_publishing_components/components/_notice.scss +2 -17
- data/app/views/govuk_publishing_components/components/_fieldset.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_input.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_label.html.erb +6 -4
- data/app/views/govuk_publishing_components/components/_notice.html.erb +19 -13
- data/app/views/govuk_publishing_components/components/_radio.html.erb +4 -4
- data/app/views/govuk_publishing_components/components/_search.html.erb +11 -3
- data/app/views/govuk_publishing_components/components/_select.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_summary_list.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_title.html.erb +14 -4
- data/app/views/govuk_publishing_components/components/docs/notice.yml +15 -0
- data/app/views/govuk_publishing_components/components/docs/search.yml +5 -0
- data/app/views/govuk_publishing_components/components/docs/title.yml +7 -0
- data/config/locales/en.yml +2 -0
- data/lib/govuk_publishing_components/presenters/shared_helper.rb +5 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83542c59d80d443eb01ea0451640ef185c26104d231d603a9842fb05b55bb26c
|
4
|
+
data.tar.gz: e9cd38b7ca3a3430c63c212a12b1a9444579175d6c9ef55693d5b0c373c8108b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcabb52ef323f944b938498968946e797e6c3b868393768fa42bd5fa350206e381d0d612bf9d158f6d6c00ed226aa7f89a4b737ba7a6acc32a390d4ef967d3a6
|
7
|
+
data.tar.gz: 1c79526993a09351120f3459a5096e9e95974fc35557e031607e52babdb9099115b61462adc6e7b712d04300688a19ce35478d217323d60beae29ad839cc38a6
|
@@ -7,12 +7,41 @@
|
|
7
7
|
|
8
8
|
if (document.querySelectorAll && document.addEventListener) {
|
9
9
|
var els = document.querySelectorAll('.js-header-toggle')
|
10
|
-
var i
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
for (var i = 0; i < els.length; i++) {
|
11
|
+
// Reassign current index to bypass rules in Chrome and Firefox around indexed property setting
|
12
|
+
var thisEl = els[i]
|
13
|
+
|
14
|
+
// If the element is an a tag, convert it to a button
|
15
|
+
// This is to target instances where we want to change behaviour between a js and a no-js view eg: the search button on the mobile menu for some government pages. On no-js it's just a link to /search
|
16
|
+
// This swaps a link for no-js to a button, making it interactable. Using a link for interactivity is poor accessibility as it's a misuse of the link tag and can be confusing to assistive tech users
|
17
|
+
|
18
|
+
if (thisEl.tagName === 'A') {
|
19
|
+
var attributes = thisEl.attributes
|
20
|
+
var button = document.createElement('button')
|
21
|
+
|
22
|
+
for (var k = 0; k < attributes.length; k++) {
|
23
|
+
var thisAttr = attributes[k].name
|
24
|
+
|
25
|
+
if (thisAttr === 'href') {
|
26
|
+
if (button.getAttribute('data-search-toggle-for')) {
|
27
|
+
continue
|
28
|
+
} else {
|
29
|
+
button.setAttribute('data-search-toggle-for', thisEl.getAttribute('href').substr(1))
|
30
|
+
}
|
31
|
+
} else if (thisAttr !== 'data-button-text') {
|
32
|
+
button.setAttribute(thisAttr, thisEl.getAttribute(thisAttr))
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
button.innerText = thisEl.getAttribute('data-button-text') || thisEl.innerText
|
37
|
+
|
38
|
+
thisEl.parentNode.replaceChild(button, thisEl)
|
39
|
+
thisEl = button
|
40
|
+
}
|
41
|
+
|
42
|
+
thisEl.addEventListener('click', function (e) {
|
14
43
|
e.preventDefault()
|
15
|
-
var target =
|
44
|
+
var target = document.getElementById(this.getAttribute('data-search-toggle-for'))
|
16
45
|
var targetClass = target.getAttribute('class') || ''
|
17
46
|
var sourceClass = this.getAttribute('class') || ''
|
18
47
|
var isSearchToggle = sourceClass.match('search-toggle')
|
@@ -30,27 +30,21 @@
|
|
30
30
|
var moduleNames = element.data('module').split(' ')
|
31
31
|
|
32
32
|
for (var j = 0, k = moduleNames.length; j < k; j++) {
|
33
|
-
var module
|
34
33
|
var moduleName = camelCaseAndCapitalise(moduleNames[j])
|
35
34
|
var started = element.data(moduleNames[j] + '-module-started')
|
36
35
|
|
37
|
-
if (
|
38
|
-
|
39
|
-
!GOVUK.Modules[moduleName].prototype.init
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
module.start(element)
|
44
|
-
element.data(moduleNames[j] + '-module-started', true)
|
45
|
-
}
|
36
|
+
if (typeof GOVUK.Modules[moduleName] === 'function' && !started) {
|
37
|
+
// GOV.UK Legacy Modules using jQuery
|
38
|
+
if (!GOVUK.Modules[moduleName].prototype.init) {
|
39
|
+
new GOVUK.Modules[moduleName]().start(element)
|
40
|
+
element.data(moduleNames[j] + '-module-started', true)
|
41
|
+
}
|
46
42
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
module = new GOVUK.Modules[moduleName](element[0]).init()
|
53
|
-
element.data(moduleNames[j] + '-module-started', true)
|
43
|
+
// Vanilla JavaScript GOV.UK Modules and GOV.UK Frontend Modules
|
44
|
+
if (GOVUK.Modules[moduleName].prototype.init) {
|
45
|
+
new GOVUK.Modules[moduleName](element[0]).init()
|
46
|
+
element.data(moduleNames[j] + '-module-started', true)
|
47
|
+
}
|
54
48
|
}
|
55
49
|
}
|
56
50
|
}
|
@@ -1,10 +1,8 @@
|
|
1
|
+
@import "govuk/components/notification-banner/notification-banner";
|
2
|
+
|
1
3
|
.gem-c-notice {
|
2
|
-
@include govuk-text-colour;
|
3
|
-
@include govuk-responsive-padding(4);
|
4
4
|
@include govuk-responsive-margin(8, "bottom");
|
5
|
-
|
6
5
|
clear: both;
|
7
|
-
border: $govuk-border-width solid govuk-colour("blue");
|
8
6
|
|
9
7
|
.govuk-govspeak {
|
10
8
|
p:last-child {
|
@@ -18,22 +16,9 @@
|
|
18
16
|
}
|
19
17
|
|
20
18
|
.gem-c-notice__title {
|
21
|
-
@include govuk-font(24, $weight: bold);
|
22
|
-
margin-top: 0;
|
23
|
-
@include govuk-responsive-margin(4, "bottom");
|
24
|
-
|
25
|
-
&:last-child {
|
26
|
-
margin-bottom: 0;
|
27
|
-
}
|
28
|
-
|
29
19
|
a {
|
30
20
|
@include govuk-link-common;
|
31
21
|
@include govuk-link-style-default;
|
32
22
|
@include govuk-link-print-friendly;
|
33
23
|
}
|
34
24
|
}
|
35
|
-
|
36
|
-
.gem-c-notice__description {
|
37
|
-
@include govuk-font(19);
|
38
|
-
margin: 0;
|
39
|
-
}
|
@@ -5,7 +5,7 @@
|
|
5
5
|
describedby ||= nil
|
6
6
|
role ||= nil
|
7
7
|
heading_level ||= nil
|
8
|
-
heading_size = false unless
|
8
|
+
heading_size = false unless shared_helper.valid_heading_size?(heading_size)
|
9
9
|
error_message ||= nil
|
10
10
|
error_id ||= nil
|
11
11
|
id ||= nil
|
@@ -23,7 +23,7 @@
|
|
23
23
|
hint_id = "hint-#{SecureRandom.hex(4)}"
|
24
24
|
error_id = "error-#{SecureRandom.hex(4)}"
|
25
25
|
search_icon ||= nil
|
26
|
-
heading_size = false unless
|
26
|
+
heading_size = false unless shared_helper.valid_heading_size?(heading_size)
|
27
27
|
heading_level ||= nil
|
28
28
|
prefix ||= nil
|
29
29
|
suffix ||= nil
|
@@ -1,16 +1,18 @@
|
|
1
1
|
<%
|
2
|
-
|
2
|
+
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
3
|
+
|
4
|
+
hint_text ||= ""
|
3
5
|
is_radio_label ||= false
|
4
6
|
bold ||= false
|
5
|
-
heading_size = false unless
|
7
|
+
heading_size = false unless shared_helper.valid_heading_size?(heading_size)
|
6
8
|
is_page_heading ||= false
|
7
9
|
|
8
|
-
css_classes = %w
|
10
|
+
css_classes = %w[gem-c-label govuk-label]
|
9
11
|
css_classes << "govuk-label--s" if bold
|
10
12
|
css_classes << "govuk-radios__label" if is_radio_label
|
11
13
|
css_classes << "govuk-label--#{heading_size}" if heading_size
|
12
14
|
|
13
|
-
hint_text_css_classes = %w
|
15
|
+
hint_text_css_classes = %w[govuk-hint]
|
14
16
|
hint_text_css_classes << "govuk-radios__hint" if is_radio_label
|
15
17
|
%>
|
16
18
|
|
@@ -8,29 +8,35 @@
|
|
8
8
|
local_assigns[:margin_bottom] ||= 8
|
9
9
|
local_assigns[:margin_bottom] = 8 if local_assigns[:margin_bottom] > 9
|
10
10
|
|
11
|
+
banner_title ||= t("components.notice.banner_title")
|
12
|
+
banner_title_id ||= "govuk-notification-banner-title-#{SecureRandom.hex(4)}"
|
13
|
+
show_banner_title ||= false
|
14
|
+
heading_level = show_banner_title ? "h3" : "h2"
|
15
|
+
|
11
16
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
12
17
|
|
13
|
-
css_classes = %w[gem-c-notice]
|
18
|
+
css_classes = %w[govuk-notification-banner gem-c-notice]
|
14
19
|
css_classes << (shared_helper.get_margin_bottom)
|
15
20
|
|
16
|
-
aria_attributes =
|
21
|
+
aria_attributes = {label: 'Notice'}
|
22
|
+
aria_attributes[:live] = 'polite' if aria_live
|
23
|
+
aria_attributes[:labelledby] = banner_title_id if show_banner_title
|
17
24
|
|
18
25
|
description_present = description.present? || description_text.present? || description_govspeak.present?
|
19
26
|
%>
|
20
27
|
<% if title || description_present %>
|
21
28
|
<%= tag.section class: css_classes, aria: aria_attributes, lang: lang, role: "region" do %>
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
<%= tag.div class: "govuk-notification-banner__header" do %>
|
30
|
+
<%= tag.h2 banner_title, class: "govuk-notification-banner__title", id: banner_title_id %>
|
31
|
+
<% end if show_banner_title %>
|
32
|
+
<%= tag.div class: "govuk-notification-banner__content" do %>
|
33
|
+
<%= content_tag(heading_level, title, class: "gem-c-notice__title govuk-notification-banner__heading") if description_present && title %>
|
34
|
+
<%= tag.span title, class: "gem-c-notice__title govuk-notification-banner__heading" if !description_present && title %>
|
35
|
+
<%= tag.p description_text, class: "gem-c-notice__description" if description_text %>
|
29
36
|
|
30
|
-
|
37
|
+
<%= description if description %>
|
31
38
|
|
32
|
-
|
33
|
-
|
34
|
-
<%= render 'govuk_publishing_components/components/govspeak', content: description_govspeak if description_govspeak %>
|
39
|
+
<%= render 'govuk_publishing_components/components/govspeak', content: description_govspeak if description_govspeak %>
|
40
|
+
<% end %>
|
35
41
|
<% end %>
|
36
42
|
<% end %>
|
@@ -15,12 +15,12 @@
|
|
15
15
|
heading_classes = %w(govuk-fieldset__heading)
|
16
16
|
heading_classes << "gem-c-radio__heading-text" if heading_level == 'h1'
|
17
17
|
|
18
|
-
if
|
18
|
+
if (shared_helper.valid_heading_size?(heading_size))
|
19
19
|
size = heading_size
|
20
|
-
elsif heading_level ==
|
21
|
-
size =
|
20
|
+
elsif heading_level == "h1"
|
21
|
+
size = "xl"
|
22
22
|
else
|
23
|
-
size =
|
23
|
+
size = "m"
|
24
24
|
end
|
25
25
|
|
26
26
|
description ||= nil
|
@@ -4,6 +4,7 @@
|
|
4
4
|
aria_controls ||= nil
|
5
5
|
button_text ||= t("components.search_box.search_button")
|
6
6
|
id ||= "search-main-" + SecureRandom.hex(4)
|
7
|
+
label_size ||= nil
|
7
8
|
label_text ||= t("components.search_box.label")
|
8
9
|
name ||= "q"
|
9
10
|
no_border ||= false
|
@@ -13,6 +14,13 @@
|
|
13
14
|
data_attributes ||= {}
|
14
15
|
data_attributes[:module] = 'gem-track-click'
|
15
16
|
|
17
|
+
label_classes = []
|
18
|
+
if (shared_helper.valid_heading_size?(label_size))
|
19
|
+
label_classes << "govuk-label govuk-label--#{label_size}"
|
20
|
+
else
|
21
|
+
label_classes << "gem-c-search__label"
|
22
|
+
end
|
23
|
+
|
16
24
|
classes = %w[gem-c-search govuk-!-display-none-print]
|
17
25
|
classes << (shared_helper.get_margin_top)
|
18
26
|
classes << (shared_helper.get_margin_bottom) if local_assigns[:margin_bottom]
|
@@ -23,13 +31,13 @@
|
|
23
31
|
else
|
24
32
|
classes << "gem-c-search--on-white"
|
25
33
|
end
|
26
|
-
classes << "gem-c-search--separate-label" if local_assigns.include?(:inline_label)
|
34
|
+
classes << "gem-c-search--separate-label" if local_assigns.include?(:inline_label) or local_assigns.include?(:label_size)
|
27
35
|
%>
|
28
36
|
|
29
37
|
<div class="<%= classes.join(" ") %>" data-module="gem-toggle-input-class-on-focus">
|
30
|
-
|
38
|
+
<%= tag.label({ for: id, class: label_classes }) do %>
|
31
39
|
<%= label_text %>
|
32
|
-
|
40
|
+
<% end %>
|
33
41
|
<div class="gem-c-search__item-wrapper">
|
34
42
|
<%= tag.input(
|
35
43
|
aria: {
|
@@ -1,11 +1,13 @@
|
|
1
1
|
<%
|
2
|
+
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
3
|
+
|
2
4
|
options ||= []
|
3
5
|
id ||= false
|
4
6
|
label ||= false
|
5
7
|
full_width ||= false
|
6
8
|
name ||= id
|
7
9
|
is_page_heading ||= false
|
8
|
-
heading_size = false unless
|
10
|
+
heading_size = false unless shared_helper.valid_heading_size?(heading_size)
|
9
11
|
error_message ||= nil
|
10
12
|
error_id ||= nil
|
11
13
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%
|
2
2
|
local_assigns[:heading_level] ||= 3
|
3
|
-
heading_size = 'm' unless ['s', 'm', 'l', 'xl'].include?(heading_size)
|
4
3
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
4
|
+
heading_size = "m" unless shared_helper.valid_heading_size?(heading_size)
|
5
5
|
|
6
6
|
id ||= nil
|
7
7
|
title ||= nil
|
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
context ||= false
|
5
5
|
context_locale ||= false
|
6
|
+
context_inside ||= false
|
6
7
|
|
7
8
|
inverse ||= false
|
8
9
|
local_assigns[:margin_top] ||= 8
|
@@ -18,13 +19,22 @@
|
|
18
19
|
heading_classes = %w[gem-c-title__text]
|
19
20
|
heading_classes << (average_title_length.present? ? 'govuk-heading-l' : 'govuk-heading-xl')
|
20
21
|
%>
|
22
|
+
|
23
|
+
<% @context_block = capture do %>
|
24
|
+
<span class="govuk-caption-xl gem-c-title__context" <%= "lang=#{context_locale}" if context_locale.present? %>>
|
25
|
+
<%= context %>
|
26
|
+
</span>
|
27
|
+
<% end %>
|
28
|
+
|
21
29
|
<%= content_tag(:div, class: classes) do %>
|
22
|
-
<% if context %>
|
23
|
-
|
24
|
-
<%= context %>
|
25
|
-
</span>
|
30
|
+
<% if context && !context_inside %>
|
31
|
+
<%= @context_block %>
|
26
32
|
<% end %>
|
33
|
+
|
27
34
|
<h1 class="<%= heading_classes.join(" ") %>">
|
35
|
+
<% if context && context_inside %>
|
36
|
+
<%= @context_block %>
|
37
|
+
<% end %>
|
28
38
|
<%= title %>
|
29
39
|
</h1>
|
30
40
|
<% end %>
|
@@ -50,3 +50,18 @@ examples:
|
|
50
50
|
title: 'This publication was withdrawn on 30 September 2015'
|
51
51
|
description_govspeak: <p>This document is no longer current. We published a new version on 30 September 2015.</p>
|
52
52
|
lang: 'en'
|
53
|
+
with_banner_title:
|
54
|
+
description: |
|
55
|
+
By default, the notice component renders with a banner title of "Important" if `show_banner_title` is `true`.
|
56
|
+
data:
|
57
|
+
title: 'This publication was withdrawn on 30 September 2015'
|
58
|
+
description_govspeak: <p>This document is no longer current. We published a new version on 30 September 2015.</p>
|
59
|
+
show_banner_title: true
|
60
|
+
with_custom_banner_title:
|
61
|
+
description: |
|
62
|
+
The default banner title can be overruled by specifying a `banner_title` option.
|
63
|
+
data:
|
64
|
+
title: 'This publication was withdrawn on 30 September 2015'
|
65
|
+
description_govspeak: <p>This document is no longer current. We published a new version on 30 September 2015.</p>
|
66
|
+
show_banner_title: true
|
67
|
+
banner_title: "Information"
|
@@ -64,3 +64,8 @@ examples:
|
|
64
64
|
This is visually hidden text -- to check for changes use a screen reader or inspect the button element.
|
65
65
|
data:
|
66
66
|
button_text: "Search absolutely everywhere"
|
67
|
+
with_set_label_size:
|
68
|
+
description: |
|
69
|
+
Allows the label text size to be set to `xl`, `l`, `m`, or `s`. If this is set, then `inline_label` is automatically set to `false`.
|
70
|
+
data:
|
71
|
+
label_size: "xl"
|
@@ -24,6 +24,13 @@ examples:
|
|
24
24
|
data:
|
25
25
|
context: Publication
|
26
26
|
title: My page title
|
27
|
+
with_context_inside:
|
28
|
+
description: |
|
29
|
+
If the context should be considered part of the page heading, you can nest the context within the <code><h1></code>.
|
30
|
+
data:
|
31
|
+
context: Publication
|
32
|
+
title: My page title
|
33
|
+
context_inside: true
|
27
34
|
with_context_language_labelled:
|
28
35
|
description: |
|
29
36
|
Sometimes this component appears on a page that has been translated. The title will naturally be supplied in the required language but the context string may fall back to the default. In these instances we need to label the language so the page remains semantic and screenreaders can handle the switch.
|
data/config/locales/en.yml
CHANGED
@@ -183,6 +183,8 @@ en:
|
|
183
183
|
toggle_more: "+ %{number} more"
|
184
184
|
modal_dialogue:
|
185
185
|
close_modal: Close modal dialogue
|
186
|
+
notice:
|
187
|
+
banner_title: Important
|
186
188
|
organisation_schema:
|
187
189
|
all_content_search_description: Find all content from %{organisation}
|
188
190
|
previous_and_next_navigation:
|
@@ -31,10 +31,14 @@ module GovukPublishingComponents
|
|
31
31
|
"span"
|
32
32
|
end
|
33
33
|
|
34
|
+
def valid_heading_size?(size)
|
35
|
+
%w[xl l m s].include?(size)
|
36
|
+
end
|
37
|
+
|
34
38
|
def get_heading_size(option, fallback)
|
35
39
|
govuk_class = "govuk-heading-"
|
36
40
|
|
37
|
-
if
|
41
|
+
if valid_heading_size?(option)
|
38
42
|
"#{govuk_class}#{option}"
|
39
43
|
else
|
40
44
|
"#{govuk_class}#{fallback}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_publishing_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 25.
|
4
|
+
version: 25.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|