Skip to content

Commit 45c672f

Browse files
Merge branch 'main' into feature/indent-description-list-dd
2 parents 23b005c + f0d0a79 commit 45c672f

File tree

20 files changed

+75
-107
lines changed

20 files changed

+75
-107
lines changed

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: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
/**
22
* Add anchor links to any H2 - H6 within the <main> element that:
3+
* - have an id
34
* - are not children of a <nav> element
45
* - do not have an ancestor with the data-anchor="no" attribute, with
56
* the `hidden` attribute or with the .visuallyhidden class
67
* - do not themselves have the data-anchor="no" attribute, the `hidden`
78
* attribute or the .visuallyhidden class
89
*
9-
* If a heading does not already possess an ID, use regular expressions on
10-
* the textContent of the heading to generate a string that is valid to
11-
* use for both the heading ID and the anchor href. Supports non-Latin
12-
* scripts by matching any Unicode letter - \p{L} - or number - \p{N}. The
13-
* u flag enables Unicode matching, to support characters from any script.
14-
*
15-
* Otherwise, generate the anchor using the existing heading ID value.
10+
* Generate the anchor using the existing heading ID value.
1611
*/
1712

1813
import {translate} from './translations';
@@ -24,7 +19,7 @@ let headingAnchors = function () {
2419
// Only add heading anchor links on "full" sites
2520
if (languageCode === 'en' || languageCode === 'ja' || languageCode === 'zh-hans') {
2621

27-
let headingsArray= Array.from(document.querySelectorAll('main h2, main h3, main h4, main h5, main h6'));
22+
let headingsArray= Array.from(document.querySelectorAll('main h2[id], main h3[id], main h4[id], main h5[id], main h6[id]'));
2823

2924
if (headingsArray.length > 0) {
3025

@@ -52,31 +47,13 @@ let headingAnchors = function () {
5247
targetedHeadings.forEach(function(heading) {
5348

5449
let anchor = document.createElement('a');
55-
let anchorHref;
56-
57-
// If the heading already has an ID, use this for constructing the anchor
58-
if (heading.getAttribute('id')) {
59-
anchorHref = heading.id;
60-
} else {
61-
// If the heading does not already have an ID, generate anchor href from the heading text. Steps are:
62-
// - Remove leading/trailing spaces
63-
// - Use RegEx to remove invalid characters but keep all Unicode letters/numbers
64-
// - Use RegEx to replace spaces with hyphens
65-
// - convert to lowercase as per URL policy
66-
anchorHref = heading.textContent
67-
.trim()
68-
.replace(/[^\p{L}\p{N}\s-]/gu, '')
69-
.replace(/\s+/g, '-')
70-
.toLowerCase();
71-
heading.id = anchorHref;
72-
}
73-
74-
anchor.setAttribute('href', '#' + anchorHref);
50+
51+
anchor.setAttribute('href', '#' + heading.id);
7552
anchor.setAttribute('class', 'heading-anchor');
7653
anchor.innerHTML = '<span aria-hidden="true">&sect;</span>'
7754
+'<span class="visuallyhidden">'
7855
+ translate.translate('anchor', languageCode) + '</span>';
79-
heading.textContent += '\xa0';
56+
heading.append('\xa0');
8057
heading.appendChild(anchor);
8158

8259
});
@@ -88,4 +65,4 @@ let headingAnchors = function () {
8865

8966
}
9067

91-
export {headingAnchors};
68+
export {headingAnchors};

assets-src/styles/sass/50-core-components/_family-series-list.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
\*------------------------------------*/
44

55
.family-grouping {
6-
padding-top: rem(40);
6+
padding-block-start: rem(28);
77
}
88

99
.family-grouping h2 + * {
10-
margin-top: 1rem;
10+
margin-block-start: 1rem;
1111
}

assets-src/styles/sass/80-templates/_technical-reports.scss

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
.hero {
1111
background-color: $white;
12-
margin-bottom: rem(20);
13-
padding-bottom: rem(40);
12+
margin-block-end: rem(20);
13+
padding-block-end: 0;
1414

1515
.l-box {
1616
background-color: #f3f3f6;
@@ -31,14 +31,20 @@
3131
background-color: $white;
3232
}
3333

34+
// Close visual gap between end of visible text and CSS-inserted colon caused by visuallyhidden <span>
35+
// Only works while there is a single visuallyhidden <span> as the last child in the <dt>
36+
.translation-list dt:has(span.visuallyhidden)::after {
37+
margin-inline-start: rem(-4);
38+
}
3439
}
3540

3641
.tr-list {
3742
.tr-list__item {
3843
@include stack(0.5em);
3944
@include txt-pluto;
40-
padding-bottom: rem(24);
41-
padding-top: rem(24);
45+
border-block-end: 1px solid $twiki-gray;
46+
padding-block-end: rem(8);
47+
padding-block-start: rem(20);
4248

4349
> * {
4450
max-width: rem(820);
@@ -49,21 +55,17 @@
4955
@include txt-mars;
5056
}
5157

52-
.tr-list__item + .tr-list__item {
53-
border-top: 1px solid $twiki-gray;
54-
}
55-
5658
.tr-list__item__header {
5759
@include stack;
5860
align-items: flex-start;
5961

6062
h3 {
61-
margin-bottom: 0;
62-
margin-top: rem(5);
63+
margin-block-end: 0;
64+
margin-block-start: rem(5);
6365
}
6466

6567
h3 + * {
66-
margin-top: 0;
68+
margin-block-start: 0;
6769
order: -1;
6870
}
6971
}

design-system-templates/components/tr-search-results-family.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<dd>Michael Cooper</dd>
5656
</div>
5757
<div class="translation-list">
58-
<dt>2 translations for Accessible Rich Internet Applications (WAI-ARIA) 1.0</dt>
58+
<dt>Translations <span class="visuallyhidden">for Accessible Rich Internet Applications (WAI-ARIA) 1.0</span></dt>
5959
<dd><a hreflang="ja" href="path/to/page"><span lang="ja">日本語</span></a></dd>
6060
<dd><a hreflang="hu-HU" href="path/to/page"><span lang="hu-HU">Magyar</span></a></dd>
6161
</div>

design-system-templates/components/tr-search-results-item-standard.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<dd>Michael Cooper</dd>
1919
</div>
2020
<div class="translation-list">
21-
<dt>2 translations for Accessible Rich Internet Applications (WAI-ARIA) 1.0</dt>
21+
<dt>Translations <span class="visuallyhidden">for Accessible Rich Internet Applications (WAI-ARIA) 1.0</span></dt>
2222
<dd><a hreflang="ja" href="path/to/page"><span lang="ja">日本語</span></a></dd>
2323
<dd><a hreflang="hu-HU" href="path/to/page"><span lang="hu-HU">Magyar</span></a></dd>
2424
</div>

design-system-templates/example-pages/profile.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<nav id="profile-nav" aria-label="Details">
2020
<div class="profile-nav__inner">
21-
<ul class="clean-list" role="list">
21+
<ul>
2222
<li><a href="#" aria-current="true">Overview</a></li>
2323
<li><a href="path/to/page">Edit profile</a></li>
2424
<li><a href="path/to/page">Calendar</a></li>
@@ -39,4 +39,4 @@
3939
{% endblock %}
4040

4141
{% block scripts %}
42-
{% endblock %}
42+
{% endblock %}

docs/scripts/heading-anchors.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Heading anchors
22

3-
This script is part of `main.js`/`main.min.js`. To help linking to specific parts of pages, this script automatically creates and appends a visible anchor link to the end of any H2-H6 heading within the `<main>` element, with the following exclusions:
3+
This script is part of `main.js`/`main.min.js`. To help linking to specific parts of pages, this script automatically creates and appends a visible anchor link to the end of any H2-H6 heading that have an `id` attribute within the `<main>` element, with the following exclusions:
44

55
- where the heading is a child of a `<nav>` element
66
- where the heading carries the attribute `data-anchor="no"`, the `hidden` attribute or the `.visuallyhidden` class
77
- where a heading has an ancestor carrying the attribute `data-anchor="no"`, the `hidden` attribute or the `.visuallyhidden` class
88

9-
If a heading already has an `id` attribute, this is used when creating the `href` for the `<a>`. Otherwise, the script parses the text content of the heading to create both the heading `id` and the anchor `href`.
9+
The `id` attribute is used when creating the `href` for the `<a>`.
1010

1111
To override the default behaviour of the script and prevent the addition of anchor links to headings, modify the HTML markup to apply the `data-anchor="no"` attribute to an individual heading (or to a parent container, if targeting a group of headings).
1212

@@ -18,4 +18,4 @@ The `data-anchor="no"` attribute has been added directly to the markup to overri
1818
- [collapsible containers](../components/collapsible-containers.md)
1919
- [evangelists](../components/evangelists.md)
2020
- [group list](../components/group-list.md)
21-
- [notes](../components/notes.md)
21+
- [notes](../components/notes.md)

public/dist/assets/js/main.js

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ const flashes = function () {
887887
if (type.startsWith('title-') || type === 'length' || !flashes.hasOwnProperty(type)) {
888888
continue;
889889
}
890-
html += '<div class="l-box note note--' + type + '" role="' + (type === 'error' ? 'alert' : 'status') + '" aria-labelledby="' + type + '-summary-title" tabindex="-1" data-component = "' + type + '-summary" >';
890+
html += '<div class="l-box note note--' + type + '" role="' + (type === 'error' ? 'alert' : 'status') + '" aria-labelledby="' + type + '-summary-title" tabindex="-1" ' + 'data-component = "' + type + '-summary" data-anchor="no">';
891891
html += '<h2 id="' + type + '-summary-title" class="txt-saturn">' + flashes['title-' + type] + '</h2>';
892892
html += '<ul class="clean-list" role="list">';
893893
for (let i in flashes[type]) {
@@ -916,19 +916,14 @@ __webpack_require__.r(__webpack_exports__);
916916
/* harmony import */ var _translations__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
917917
/**
918918
* Add anchor links to any H2 - H6 within the <main> element that:
919+
* - have an id
919920
* - are not children of a <nav> element
920921
* - do not have an ancestor with the data-anchor="no" attribute, with
921922
* the `hidden` attribute or with the .visuallyhidden class
922923
* - do not themselves have the data-anchor="no" attribute, the `hidden`
923924
* attribute or the .visuallyhidden class
924925
*
925-
* If a heading does not already possess an ID, use regular expressions on
926-
* the textContent of the heading to generate a string that is valid to
927-
* use for both the heading ID and the anchor href. Supports non-Latin
928-
* scripts by matching any Unicode letter - \p{L} - or number - \p{N}. The
929-
* u flag enables Unicode matching, to support characters from any script.
930-
*
931-
* Otherwise, generate the anchor using the existing heading ID value.
926+
* Generate the anchor using the existing heading ID value.
932927
*/
933928

934929

@@ -937,7 +932,7 @@ let headingAnchors = function () {
937932

938933
// Only add heading anchor links on "full" sites
939934
if (languageCode === 'en' || languageCode === 'ja' || languageCode === 'zh-hans') {
940-
let headingsArray = Array.from(document.querySelectorAll('main h2, main h3, main h4, main h5, main h6'));
935+
let headingsArray = Array.from(document.querySelectorAll('main h2[id], main h3[id], main h4[id], main h5[id], main h6[id]'));
941936
if (headingsArray.length > 0) {
942937
// Filter out headings that:
943938
// - Are not children of <nav>
@@ -960,24 +955,10 @@ let headingAnchors = function () {
960955
if (targetedHeadings.length > 0) {
961956
targetedHeadings.forEach(function (heading) {
962957
let anchor = document.createElement('a');
963-
let anchorHref;
964-
965-
// If the heading already has an ID, use this for constructing the anchor
966-
if (heading.getAttribute('id')) {
967-
anchorHref = heading.id;
968-
} else {
969-
// If the heading does not already have an ID, generate anchor href from the heading text. Steps are:
970-
// - Remove leading/trailing spaces
971-
// - Use RegEx to remove invalid characters but keep all Unicode letters/numbers
972-
// - Use RegEx to replace spaces with hyphens
973-
// - convert to lowercase as per URL policy
974-
anchorHref = heading.textContent.trim().replace(/[^\p{L}\p{N}\s-]/gu, '').replace(/\s+/g, '-').toLowerCase();
975-
heading.id = anchorHref;
976-
}
977-
anchor.setAttribute('href', '#' + anchorHref);
958+
anchor.setAttribute('href', '#' + heading.id);
978959
anchor.setAttribute('class', 'heading-anchor');
979960
anchor.innerHTML = '<span aria-hidden="true">&sect;</span>' + '<span class="visuallyhidden">' + _translations__WEBPACK_IMPORTED_MODULE_0__.translate.translate('anchor', languageCode) + '</span>';
980-
heading.textContent += '\xa0';
961+
heading.append('\xa0');
981962
heading.appendChild(anchor);
982963
});
983964
}

public/dist/assets/js/main.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)