Skip to content

Commit a11ea9a

Browse files
committed
Merge branch 'main' into deployer7
2 parents 765607d + bdf7ca3 commit a11ea9a

File tree

151 files changed

+528
-24669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+528
-24669
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@
4949
node_modules
5050

5151
# Design system build files
52-
_dist
52+
_dist
53+
/public/dist

assets-src/js/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {formErrorSummary} from "./main/form-error-summary";
66
import {navigation} from "./main/navigation";
77
import {responsiveTables} from "./main/responsive-tables";
88
import {flashes} from "./main/flashes";
9+
import {headingAnchors} from './main/heading-anchors';
910

1011
function domLoadedActions() {
1112
accountMenu();
@@ -15,6 +16,7 @@ function domLoadedActions() {
1516
formErrorSummary();
1617
responsiveTables();
1718
flashes();
19+
headingAnchors();
1820

1921
/* Create a navDoubleLevel object and initiate double-level navigation for a <ul> with the correct data-component attribute */
2022
const navDoubleIntro = document.querySelector('ul[data-component="nav-double-intro"]');

assets-src/js/main/account-menu.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {translate} from "./translations";
33
let accountMenu = function () {
44

55
let userInfo = null;
6+
let maxWidth = 1120;
67

78
const buildAccountMenu = function(userInfo) {
89
if (userInfo == null || userInfo.length < 1) {
@@ -54,7 +55,8 @@ let accountMenu = function () {
5455
toggleButton.innerHTML = '<span class="sr-only">' + translate.translate('my-account', languageCode) + ' <span class="visuallyhidden">(' + translate.translate( 'logged-in' , languageCode) + ')</span></span><div class="avatar avatar--small icon"><img alt="" src="' + userInfo.avatar.thumbnail + '"/></div>';
5556

5657
// Media query event handler
57-
let mq = window.matchMedia('(min-width: 71.25em)');
58+
let mqValue = maxWidth / 16;
59+
let mq = window.matchMedia('(min-width: ' + mqValue + 'em)');
5860
mq.addListener(insertAccountBtn);
5961
insertAccountBtn(mq);
6062

assets-src/js/main/collapsibles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let collapsibles = function () {
2020
headingsArray.forEach(function (heading, index) {
2121

2222
// Insert a button for opening/closing the collapsible section
23-
heading.innerHTML = '<button type="button" class="button--ghost" aria-expanded="false">' + heading.innerHTML + '<svg xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 320 512" class="icon icon--larger" focusable="false" aria-hidden="true" width="30px" height="30px"><path class="angle-down" d="M143 352.3L7 216.3c-9.4-9.4-9.4-24.6 0-33.9l22.6-22.6c9.4-9.4 24.6-9.4 33.9 0l96.4 96.4 96.4-96.4c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9l-136 136c-9.2 9.4-24.4 9.4-33.8 0z"/><path class="angle-up" d="M177 159.7l136 136c9.4 9.4 9.4 24.6 0 33.9l-22.6 22.6c-9.4 9.4-24.6 9.4-33.9 0L160 255.9l-96.4 96.4c-9.4 9.4-24.6 9.4-33.9 0L7 329.7c-9.4-9.4-9.4-24.6 0-33.9l136-136c9.4-9.5 24.6-9.5 34-.1z"/></svg></button>';
23+
heading.innerHTML = '<button type="button" class="button button--ghost" aria-expanded="false">' + heading.innerHTML + '</svg></button>';
2424

2525
// Add appropriate aria role to the collapsible section
2626
heading.nextElementSibling.setAttribute('aria-hidden', 'true');

assets-src/js/main/flashes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const flashes = (function () {
2727
}
2828

2929
html += '<div class="l-box note note--' + type + '" role="' + (type === 'error' ? 'alert' : 'status')
30-
+ '" aria-labelledby="' + type + '-summary-title" tabindex="-1" data-component = "' + type + '-summary" >';
30+
+ '" aria-labelledby="' + type + '-summary-title" tabindex="-1" ' +
31+
'data-component = "' + type + '-summary" data-anchor="no">';
3132
html += '<h2 id="' + type + '-summary-title" class="txt-saturn">' + flashes['title-' + type] + '</h2>';
3233
html += '<ul class="clean-list" role="list">';
3334
for (let i in flashes[type]) {
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* Add anchor links to any H2 - H6 within the <main> element that:
3+
* - have an id
4+
* - are not children of a <nav> element
5+
* - do not have an ancestor with the data-anchor="no" attribute, with
6+
* the `hidden` attribute or with the .visuallyhidden class
7+
* - do not themselves have the data-anchor="no" attribute, the `hidden`
8+
* attribute or the .visuallyhidden class
9+
*
10+
* Generate the anchor using the existing heading ID value.
11+
*/
12+
13+
import {translate} from './translations';
14+
15+
let headingAnchors = function () {
16+
17+
let languageCode = document.documentElement.lang;
18+
19+
// Only add heading anchor links on "full" sites
20+
if (languageCode === 'en' || languageCode === 'ja' || languageCode === 'zh-hans') {
21+
22+
let headingsArray= Array.from(document.querySelectorAll('main h2[id], main h3[id], main h4[id], main h5[id], main h6[id]'));
23+
24+
if (headingsArray.length > 0) {
25+
26+
// Filter out headings that:
27+
// - Are not children of <nav>
28+
// - Do not have an ancestor with the data-anchor="no" attribute
29+
// - Do not have an ancestor with the `hidden` attribute
30+
// - Do not have an ancestor with the `.visuallyhidden` class
31+
// - Do not themselves have the data-anchor="no" attribute
32+
// - Do not themselves have the `hidden` attribute
33+
// - Do not themselves have the `.visuallyhidden` class
34+
let targetedHeadings = headingsArray.filter(function(heading) {
35+
let insideNav = heading.closest('nav') !== null;
36+
let parentHasDataAttribute = heading.closest('[data-anchor="no"]') !== null;
37+
let hiddenParent = heading.closest('[hidden]') !== null;
38+
let visuallyhiddenParent = heading.closest('.visuallyhidden') !== null;
39+
let hasDataAttribute = heading.getAttribute('data-anchor') === 'no';
40+
let isHidden = heading.getAttribute('hidden');
41+
let isVisuallyhidden = heading.classList.contains('visuallyhidden');
42+
43+
return !insideNav && !parentHasDataAttribute && !hiddenParent && !visuallyhiddenParent && !hasDataAttribute && !isHidden && !isVisuallyhidden;
44+
});
45+
46+
if (targetedHeadings.length > 0) {
47+
targetedHeadings.forEach(function(heading) {
48+
49+
let anchor = document.createElement('a');
50+
51+
anchor.setAttribute('href', '#' + heading.id);
52+
anchor.setAttribute('class', 'heading-anchor');
53+
anchor.innerHTML = '<span aria-hidden="true">&sect;</span>'
54+
+'<span class="visuallyhidden">'
55+
+ translate.translate('anchor', languageCode) + '</span>';
56+
heading.append('\xa0');
57+
heading.appendChild(anchor);
58+
59+
});
60+
}
61+
62+
}
63+
64+
}
65+
66+
}
67+
68+
export {headingAnchors};

assets-src/js/main/navigation.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,8 @@ const navigation = function(menu, options) {
197197
// Insert a "back" button
198198
const backButton = document.createElement('button');
199199
backButton.setAttribute('data-button', 'mobile-back');
200-
backButton.setAttribute('class', 'button button--ghost u-full-width with-icon--before with-icon--larger');
201-
backButton.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 512" height="16" width="16" class="icon icon--submenu" focusable="false" aria-hidden="true" fill="currentColor">' +
202-
'<path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"/>' +
203-
'</svg>' + translate.translate('backToMainMenu', languageCode);
200+
backButton.setAttribute('class', 'button button--ghost u-full-width');
201+
backButton.innerHTML = translate.translate('backToMainMenu', languageCode);
204202
if (settings.submenuIntro === true) {
205203
subMenu.parentNode.insertBefore(backButton, subMenu.parentNode.children[0]);
206204
} else subMenu.parentNode.insertBefore(backButton, subMenu);

assets-src/js/main/translations.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const translate = {
4040
},
4141
'en': {
4242
'admin': 'Admin',
43+
'anchor': 'anchor',
4344
'backToMainMenu': 'Back to main menu',
4445
'cancelReply': 'Cancel reply',
4546
'controlsDescription': 'carousel controls',
@@ -116,6 +117,7 @@ const translate = {
116117
},
117118
'ja': {
118119
'admin': 'アドミン',
120+
'anchor': '__anchor',
119121
'backToMainMenu': 'メインメニューに戻る',
120122
'cancelReply': '返信をキャンセル',
121123
'controlsDescription': 'コントロールの説明',
@@ -154,6 +156,7 @@ const translate = {
154156
},
155157
'zh-hans': {
156158
'admin': '管理',
159+
'anchor': '__anchor',
157160
'backToMainMenu': '返回主目录',
158161
'cancelReply': '取消回复',
159162
'controlsDescription': '轮播图控件',

assets-src/js/multiselect-module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const MultiselectButtons = function (selectEl, params) {
193193
ulCombo.setAttribute('aria-multiselectable', 'true');
194194
ulCombo.id = baseId + '-listbox';
195195
ulCombo.setAttribute('aria-labelledby', baseId + '-label');
196-
ulCombo.classList.add('combo-menu');
196+
ulCombo.classList.add('combo-menu', 'clean-list');
197197

198198
div.appendChild(divComboBox);
199199
div.appendChild(ulCombo);

assets-src/js/slider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ let contentSlider = (function () {
6666
function createControls() {
6767

6868
let controls = document.createElement('ul');
69-
controls.setAttribute('class', 'slider-controls');
69+
controls.setAttribute('class', 'clean-list slider-controls');
7070
controls.setAttribute('aria-label', controlsDescription);
7171
controls.innerHTML = '<li><button class="button button--ghost js-previous with-icon--larger" aria-label="' + previousSlide + '" style="padding:0.4375rem;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 320 512" class="icon icon--larger" focusable="false" aria-hidden="true" width="1em" height="1em"><path class="chevron-left" d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"/><path class="chevron-right" d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg></button></li>'
7272
+ '<li style="margin-top:0;margin-inline-start:0.25rem;"><button class="button button--ghost js-next with-icon--larger" aria-label="' + nextSlide + '" style="padding:0.4375rem;"><svg xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 320 512" class="icon icon--larger" focusable="false" aria-hidden="true" width="1em" height="1em"><path class="chevron-left" d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"/><path class="chevron-right" d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg></button></li>';

0 commit comments

Comments
 (0)