@undrr/undrr-mangrove 1.3.3 → 1.4.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.
- package/README.md +33 -29
- package/components/BarChart.js +2 -2
- package/components/BookCard.js +6 -0
- package/components/BookCard.js.LICENSE.txt +11 -0
- package/components/Breadcrumbs.js +6 -0
- package/components/Breadcrumbs.js.LICENSE.txt +9 -0
- package/components/Checkbox.js +6 -0
- package/components/Checkbox.js.LICENSE.txt +9 -0
- package/components/Chips.js +6 -0
- package/components/Chips.js.LICENSE.txt +9 -0
- package/components/CtaButton.js +6 -0
- package/components/CtaButton.js.LICENSE.txt +9 -0
- package/components/EmbedContainer.js +6 -0
- package/components/EmbedContainer.js.LICENSE.txt +9 -0
- package/components/Fetcher.js +2 -2
- package/components/Footer.js +6 -0
- package/components/Footer.js.LICENSE.txt +9 -0
- package/components/FormErrorSummary.js +6 -0
- package/components/FormErrorSummary.js.LICENSE.txt +9 -0
- package/components/FormGroup.js +6 -0
- package/components/FormGroup.js.LICENSE.txt +9 -0
- package/components/FullWidth.js +6 -0
- package/components/FullWidth.js.LICENSE.txt +9 -0
- package/components/Gallery.js +1 -1
- package/components/Hero.js +6 -0
- package/components/Hero.js.LICENSE.txt +9 -0
- package/components/HighlightBox.js +6 -0
- package/components/HighlightBox.js.LICENSE.txt +9 -0
- package/components/HorizontalBookCard.js +6 -0
- package/components/HorizontalBookCard.js.LICENSE.txt +11 -0
- package/components/HorizontalCard.js +6 -0
- package/components/HorizontalCard.js.LICENSE.txt +11 -0
- package/components/IconCard.js +2 -2
- package/components/Loader.js +6 -0
- package/components/Loader.js.LICENSE.txt +9 -0
- package/components/MapComponent.js +2 -2
- package/components/MegaMenu.js +2 -2
- package/components/PageHeader.js +6 -0
- package/components/PageHeader.js.LICENSE.txt +9 -0
- package/components/Pager.js +2 -2
- package/components/QuoteHighlight.js +1 -1
- package/components/Radio.js +6 -0
- package/components/Radio.js.LICENSE.txt +9 -0
- package/components/ScrollContainer.js +1 -1
- package/components/Select.js +6 -0
- package/components/Select.js.LICENSE.txt +9 -0
- package/components/ShareButtons.js +1 -1
- package/components/ShowMore.js +6 -0
- package/components/ShowMore.js.LICENSE.txt +9 -0
- package/components/StatsCard.js +2 -2
- package/components/SyndicationSearchWidget.js +2 -2
- package/components/Tab.js +6 -0
- package/components/Tab.js.LICENSE.txt +9 -0
- package/components/TextCta.js +6 -0
- package/components/TextCta.js.LICENSE.txt +11 -0
- package/components/TextInput.js +6 -0
- package/components/TextInput.js.LICENSE.txt +9 -0
- package/components/Textarea.js +6 -0
- package/components/Textarea.js.LICENSE.txt +9 -0
- package/components/VerticalCard.js +6 -0
- package/components/VerticalCard.js.LICENSE.txt +11 -0
- package/components/hydrate.js +1 -1
- package/css/style-delta.css +467 -0
- package/css/style-delta.css.map +1 -0
- package/css/style-gutenberg.css +21 -18
- package/css/style-gutenberg.css.map +1 -1
- package/css/style-irp-legacy.css +472 -0
- package/css/style-irp-legacy.css.map +1 -0
- package/css/style-irp.css +99 -103
- package/css/style-irp.css.map +1 -1
- package/css/style-legacy.css +465 -0
- package/css/style-legacy.css.map +1 -0
- package/css/style-mcr-legacy.css +472 -0
- package/css/style-mcr-legacy.css.map +1 -0
- package/css/style-mcr.css +99 -103
- package/css/style-mcr.css.map +1 -1
- package/css/style-preventionweb-legacy.css +472 -0
- package/css/style-preventionweb-legacy.css.map +1 -0
- package/css/style-preventionweb.css +99 -103
- package/css/style-preventionweb.css.map +1 -1
- package/css/style.css +99 -103
- package/css/style.css.map +1 -1
- package/error-pages/401.html +10 -11
- package/error-pages/403.html +11 -12
- package/error-pages/404.html +13 -14
- package/error-pages/429.html +12 -13
- package/error-pages/500.html +10 -11
- package/error-pages/502.html +12 -13
- package/error-pages/503.html +12 -13
- package/error-pages/504.html +10 -11
- package/error-pages/5xx.html +10 -11
- package/error-pages/challenge.html +12 -13
- package/error-pages/managed-challenge.html +12 -13
- package/js/README.md +57 -0
- package/js/__tests__/show-more.test.js +76 -0
- package/js/__tests__/table-of-contents.test.js +198 -0
- package/js/on-this-page-nav.js +531 -0
- package/js/show-more.js +24 -3
- package/js/table-of-contents.js +168 -0
- package/js/tabs.js +445 -83
- package/package.json +1 -1
- package/scss/Atom/BaseTypography/Blockquote/blockquote.scss +1 -8
- package/scss/Atom/BaseTypography/Cite/cite.scss +2 -2
- package/scss/Atom/Images/AuthorImage/author-image.scss +4 -4
- package/scss/Atom/Images/ImageCaptionCredit/image-caption-credit.scss +24 -28
- package/scss/Atom/Images/ImageCredit/image-credit.scss +1 -1
- package/scss/Atom/Layout/Container/container.scss +2 -2
- package/scss/Atom/Layout/Grid/grid.scss +1 -1
- package/scss/Atom/ReachElement/Details/details.scss +6 -6
- package/scss/Atom/ReachElement/Figcaption/figcaption.scss +1 -1
- package/scss/Atom/Table/table.scss +0 -8
- package/scss/Components/Boilerplate/boilerplate.scss +2 -2
- package/scss/Components/Breadcrumbs/breadcrumbs.scss +2 -9
- package/scss/Components/Buttons/Chips/chips.scss +5 -19
- package/scss/Components/Buttons/CtaButton/buttons.scss +3 -124
- package/scss/Components/Buttons/CtaButton/cta-button.scss +99 -0
- package/scss/Components/Buttons/ShareButtons/share-buttons.scss +2 -2
- package/scss/Components/Cards/Card/card.scss +45 -6
- package/scss/Components/Cards/StatsCard/stats-card.scss +2 -2
- package/scss/Components/ErrorPages/error-pages.scss +12 -12
- package/scss/Components/Footer/footer.scss +72 -4
- package/scss/Components/Forms/Select/select.scss +2 -2
- package/scss/Components/Forms/_form-base.scss +5 -5
- package/scss/Components/Forms/_form-legacy.scss +1 -1
- package/scss/Components/Gallery/gallery.scss +7 -7
- package/scss/Components/Hero/hero.scss +43 -23
- package/scss/Components/HighlightBox/highlight-box.scss +5 -5
- package/scss/Components/MegaMenu/mega-menu.scss +750 -0
- package/scss/Components/MegaMenu/megamenu.scss +3 -733
- package/scss/Components/OnThisPageNav/on-this-page-nav.scss +206 -0
- package/scss/Components/PageHeader/page-header.scss +5 -5
- package/scss/Components/Pagination/pagination.scss +2 -2
- package/scss/Components/ScrollContainer/scroll-container.scss +1 -1
- package/scss/Components/Snackbar/snackbar.scss +1 -1
- package/scss/Components/SyndicationSearchWidget/SyndicationSearchWidget.scss +3 -1480
- package/scss/Components/SyndicationSearchWidget/syndication-search-widget.scss +1515 -0
- package/scss/Components/Tab/tab.scss +68 -9
- package/scss/Components/TableOfContents/TableOfContents.scss +3 -17
- package/scss/Components/TableOfContents/table-of-contents.scss +17 -0
- package/scss/Components/TextCta/text-cta.scss +139 -0
- package/scss/Components/TextCta/textcta.scss +3 -27
- package/scss/Molecules/ImageCaption/image-caption.scss +6 -16
- package/scss/Molecules/SectionHeader/section-header.scss +8 -0
- package/scss/Molecules/SectionHeader/sectionheader.scss +3 -8
- package/scss/Utilities/FullWidth/FullWidth.scss +3 -23
- package/scss/Utilities/FullWidth/full-width.scss +23 -0
- package/scss/Utilities/Loader/loader.scss +1 -1
- package/scss/Utilities/ShowMore/ShowMore.scss +3 -26
- package/scss/Utilities/ShowMore/show-more.scss +26 -0
- package/scss/assets/scss/_components.scss +15 -9
- package/scss/assets/scss/_foundational.scss +13 -7
- package/scss/assets/scss/_mixins.scss +9 -314
- package/scss/assets/scss/_utility.scss +19 -71
- package/scss/assets/scss/_variables-delta.scss +110 -0
- package/scss/assets/scss/_variables-irp.scss +1 -1
- package/scss/assets/scss/_variables-mcr.scss +1 -1
- package/scss/assets/scss/_variables-preventionweb.scss +1 -1
- package/scss/assets/scss/_variables.scss +101 -34
- package/scss/assets/scss/style-delta.scss +8 -0
- package/scss/assets/scss/style-gutenberg.scss +2 -2
- package/scss/assets/scss/style-irp-legacy.scss +20 -0
- package/scss/assets/scss/style-legacy.scss +20 -0
- package/scss/assets/scss/style-mcr-legacy.scss +20 -0
- package/scss/assets/scss/style-preventionweb-legacy.scss +20 -0
- package/scss/Components/BlockquoteComponent/blockquotecomp.scss +0 -31
- package/scss/Components/Buttons/CtaLink/cta-link.scss +0 -61
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a table of contents (TOC) for a given content element.
|
|
3
|
+
*
|
|
4
|
+
* Can be used in two ways:
|
|
5
|
+
* 1. Auto-init: place a `<section data-mg-table-of-contents>` element on the
|
|
6
|
+
* page and this script will find it, locate the content area, and build the
|
|
7
|
+
* TOC automatically on DOMContentLoaded.
|
|
8
|
+
* 2. Manual: import `mgTableOfContents` and call it with your own elements.
|
|
9
|
+
*
|
|
10
|
+
* Data attributes (for auto-init):
|
|
11
|
+
* data-mg-table-of-contents — Required. Activates the component.
|
|
12
|
+
* data-mg-table-of-contents-content — CSS selector for the content area
|
|
13
|
+
* to scan for headings. Defaults to
|
|
14
|
+
* document.body.
|
|
15
|
+
* data-mg-table-of-contents-title — Title text for the TOC header.
|
|
16
|
+
* Defaults to "On this page".
|
|
17
|
+
* Set to "hidden" for sr-only.
|
|
18
|
+
* data-mg-table-of-contents-show-title — Set to "false" to hide the title.
|
|
19
|
+
* data-mg-table-of-contents-skip-auto-init — Opt out of auto-init.
|
|
20
|
+
*
|
|
21
|
+
* @param {HTMLElement} contentElement - The element containing the content to
|
|
22
|
+
* generate TOC for. This only selects h2 elements.
|
|
23
|
+
* @param {HTMLElement} tocElement - The TOC container element.
|
|
24
|
+
* @param {boolean} showNumbers - Whether to use ordered list (true) or
|
|
25
|
+
* unordered list (false).
|
|
26
|
+
*/
|
|
27
|
+
export function mgTableOfContents(
|
|
28
|
+
contentElement,
|
|
29
|
+
tocElement,
|
|
30
|
+
showNumbers = false
|
|
31
|
+
) {
|
|
32
|
+
if (!contentElement || !tocElement) {
|
|
33
|
+
console.error('Content element or TOC element is not provided.');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Ensure tocElement is a valid DOM element
|
|
38
|
+
if (!(tocElement instanceof HTMLElement)) {
|
|
39
|
+
console.error('TOC element is not a valid DOM element.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const showTitle =
|
|
44
|
+
tocElement.getAttribute('data-mg-table-of-contents-show-title') !== 'false';
|
|
45
|
+
|
|
46
|
+
if (showTitle) {
|
|
47
|
+
const tocHeader = document.createElement('h2');
|
|
48
|
+
tocHeader.textContent =
|
|
49
|
+
tocElement.getAttribute('data-mg-table-of-contents-title') ||
|
|
50
|
+
'On this page';
|
|
51
|
+
tocHeader.id = 'on-this-page';
|
|
52
|
+
tocHeader.classList.add('mg-on-this-page-header');
|
|
53
|
+
if (tocHeader.textContent === 'hidden') {
|
|
54
|
+
tocHeader.classList.add('mg-u-sr-only');
|
|
55
|
+
}
|
|
56
|
+
tocElement.prepend(tocHeader);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const ListComponent = showNumbers ? 'ol' : 'ul';
|
|
60
|
+
const tocList = document.createElement(ListComponent);
|
|
61
|
+
tocElement.appendChild(tocList);
|
|
62
|
+
|
|
63
|
+
// Select all H2 elements within the content
|
|
64
|
+
const headings = contentElement.querySelectorAll('h2');
|
|
65
|
+
|
|
66
|
+
headings.forEach(heading => {
|
|
67
|
+
if (heading.id === 'on-this-page') return;
|
|
68
|
+
if (heading.classList.contains('mg-table-of-contents--exclude')) return;
|
|
69
|
+
if (heading.classList.contains('mg-u-sr-only')) return;
|
|
70
|
+
|
|
71
|
+
if (!heading.id) {
|
|
72
|
+
heading.id = heading.textContent
|
|
73
|
+
.trim()
|
|
74
|
+
.toLowerCase()
|
|
75
|
+
.replace(/[^\w\s-]/g, '')
|
|
76
|
+
.replace(/\s+/g, '-');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const listItem = document.createElement('li');
|
|
80
|
+
const link = document.createElement('a');
|
|
81
|
+
link.href = `#${heading.id}`;
|
|
82
|
+
link.textContent = heading.textContent;
|
|
83
|
+
|
|
84
|
+
// Smooth scroll on click, with reduced-motion and focus management
|
|
85
|
+
link.addEventListener('click', e => {
|
|
86
|
+
const target = document.getElementById(heading.id);
|
|
87
|
+
if (!target) return;
|
|
88
|
+
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
|
|
91
|
+
const smooth =
|
|
92
|
+
typeof window.matchMedia !== 'function' ||
|
|
93
|
+
!window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
94
|
+
|
|
95
|
+
target.scrollIntoView({
|
|
96
|
+
behavior: smooth ? 'smooth' : 'auto',
|
|
97
|
+
block: 'start',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Update URL hash without triggering a second scroll
|
|
101
|
+
if (window.history && window.history.pushState) {
|
|
102
|
+
window.history.pushState(null, null, `#${heading.id}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Move focus to target for keyboard users
|
|
106
|
+
target.setAttribute('tabindex', '-1');
|
|
107
|
+
target.focus({ preventScroll: true });
|
|
108
|
+
target.addEventListener(
|
|
109
|
+
'blur',
|
|
110
|
+
() => target.removeAttribute('tabindex'),
|
|
111
|
+
{ once: true }
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
listItem.appendChild(link);
|
|
116
|
+
tocList.appendChild(listItem);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Auto-initialize TOC elements on the page.
|
|
122
|
+
* @param {NodeList|HTMLElement[]|HTMLElement} [scope] - Elements to init.
|
|
123
|
+
* Defaults to all [data-mg-table-of-contents] on the page.
|
|
124
|
+
*/
|
|
125
|
+
export function mgTableOfContentsInit(scope) {
|
|
126
|
+
const containers = scope
|
|
127
|
+
? scope instanceof HTMLElement
|
|
128
|
+
? [scope]
|
|
129
|
+
: scope
|
|
130
|
+
: document.querySelectorAll('[data-mg-table-of-contents]');
|
|
131
|
+
|
|
132
|
+
containers.forEach(tocElement => {
|
|
133
|
+
if (
|
|
134
|
+
!scope &&
|
|
135
|
+
tocElement.hasAttribute('data-mg-table-of-contents-skip-auto-init')
|
|
136
|
+
)
|
|
137
|
+
return;
|
|
138
|
+
if (tocElement.dataset.mgTableOfContentsInitialized) return;
|
|
139
|
+
tocElement.dataset.mgTableOfContentsInitialized = 'true';
|
|
140
|
+
|
|
141
|
+
// Determine content element from data attribute or default to document.body
|
|
142
|
+
const contentSelector = tocElement.getAttribute(
|
|
143
|
+
'data-mg-table-of-contents-content'
|
|
144
|
+
);
|
|
145
|
+
const contentElement = contentSelector
|
|
146
|
+
? document.querySelector(contentSelector)
|
|
147
|
+
: document.body;
|
|
148
|
+
|
|
149
|
+
if (contentElement) {
|
|
150
|
+
mgTableOfContents(contentElement, tocElement);
|
|
151
|
+
} else if (contentSelector) {
|
|
152
|
+
console.warn(
|
|
153
|
+
`[mg-table-of-contents] Content element not found: "${contentSelector}"`
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Auto-init on DOMContentLoaded
|
|
160
|
+
if (document.readyState === 'loading') {
|
|
161
|
+
document.addEventListener(
|
|
162
|
+
'DOMContentLoaded',
|
|
163
|
+
() => mgTableOfContentsInit(),
|
|
164
|
+
false
|
|
165
|
+
);
|
|
166
|
+
} else {
|
|
167
|
+
mgTableOfContentsInit();
|
|
168
|
+
}
|