@qhealth-design-system/core 1.18.2 → 1.18.4
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -22,6 +22,8 @@ let isHeaderOpen = false;
|
|
|
22
22
|
let headerSearchEvents = {};
|
|
23
23
|
// Breakpoint for mobile mode
|
|
24
24
|
const mobileBreakpoint = 992;
|
|
25
|
+
// Hold width value to detect resize
|
|
26
|
+
let lastWidth = window.innerWidth;
|
|
25
27
|
|
|
26
28
|
export default function initHeader(document = document) {
|
|
27
29
|
// Add action so the search works only if JS is enabled
|
|
@@ -40,12 +42,17 @@ export default function initHeader(document = document) {
|
|
|
40
42
|
|
|
41
43
|
// We want to ensure the search input is visible on desktop at all times
|
|
42
44
|
window.addEventListener("resize", () => {
|
|
45
|
+
const currentWidth = window.innerWidth;
|
|
46
|
+
// Ignore resize events that do not change the viewport size. Required for Android devices
|
|
47
|
+
if (currentWidth === lastWidth) return;
|
|
48
|
+
else lastWidth = currentWidth;
|
|
49
|
+
|
|
43
50
|
if (window.innerWidth >= mobileBreakpoint && !isHeaderOpen) {
|
|
44
|
-
openHeader();
|
|
51
|
+
openHeader(false);
|
|
45
52
|
// Disable focus trap as it's not needed on desktop
|
|
46
53
|
disableFocusTrap();
|
|
47
54
|
} else if (window.innerWidth < mobileBreakpoint && isHeaderOpen) {
|
|
48
|
-
closeHeader();
|
|
55
|
+
closeHeader(false);
|
|
49
56
|
}
|
|
50
57
|
});
|
|
51
58
|
}
|
|
@@ -88,7 +95,7 @@ function toggleHeaderSearch() {
|
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
97
|
|
|
91
|
-
function openHeader() {
|
|
98
|
+
function openHeader(requireFocusChange = true) {
|
|
92
99
|
isHeaderOpen = true;
|
|
93
100
|
searchToggle.setAttribute("aria-expanded", true);
|
|
94
101
|
searchToggle.classList.remove("qld__main-nav__toggle-search--open");
|
|
@@ -99,7 +106,9 @@ function openHeader() {
|
|
|
99
106
|
// Wait for display: block, and then add class to open smoothly
|
|
100
107
|
setTimeout(function () {
|
|
101
108
|
target.classList.add("qld__main-nav__search--open");
|
|
102
|
-
|
|
109
|
+
if (requireFocusChange) {
|
|
110
|
+
target.querySelector(".qld__text-input").focus();
|
|
111
|
+
}
|
|
103
112
|
|
|
104
113
|
// Close header search on click outside
|
|
105
114
|
headerSearchEvents.background = addEvent(document, "click", function () {
|
|
@@ -128,13 +137,15 @@ function openHeader() {
|
|
|
128
137
|
});
|
|
129
138
|
}
|
|
130
139
|
|
|
131
|
-
function closeHeader() {
|
|
140
|
+
function closeHeader(requireFocusChange = true) {
|
|
132
141
|
isHeaderOpen = false;
|
|
133
142
|
searchToggle.setAttribute("aria-expanded", false);
|
|
134
143
|
searchToggle.classList.remove("qld__main-nav__toggle-search--close");
|
|
135
144
|
searchToggle.classList.add("qld__main-nav__toggle-search--open");
|
|
136
145
|
searchToggleText.textContent = "Search";
|
|
137
|
-
|
|
146
|
+
if (requireFocusChange) {
|
|
147
|
+
searchToggle.focus();
|
|
148
|
+
}
|
|
138
149
|
target.classList.remove("qld__main-nav__search--open");
|
|
139
150
|
target.style.display = "none";
|
|
140
151
|
|
|
@@ -221,5 +232,5 @@ function addEvent(element, event, rawHandler) {
|
|
|
221
232
|
* @param {event} token The event to remove
|
|
222
233
|
*/
|
|
223
234
|
function removeEvent(token) {
|
|
224
|
-
token.element.removeEventListener(token.event, token.handler);
|
|
235
|
+
if (token && token.element) token.element.removeEventListener(token.event, token.handler);
|
|
225
236
|
}
|
|
@@ -388,7 +388,7 @@ $QLD-color-dark__heading: #ffffff !default;
|
|
|
388
388
|
$QLD-color-dark__text: #ffffff !default;
|
|
389
389
|
$QLD-color-dark__text--lighter: #deebf9 !default;
|
|
390
390
|
$QLD-color-dark__link: #ffffff !default;
|
|
391
|
-
$QLD-color-dark__link--visited: #
|
|
391
|
+
$QLD-color-dark__link--visited: #f2cdff !default;
|
|
392
392
|
$QLD-color-dark__link--on-action: #001c37 !default;
|
|
393
393
|
$QLD-color-dark__action--primary: #84d3ff !default;
|
|
394
394
|
$QLD-color-dark__action--primary-hover: #a6f7ff !default;
|
|
@@ -422,7 +422,7 @@ $QLD-color-light__underline--hover-visited: #{$QLD-color-light__link--visited} !
|
|
|
422
422
|
$QLD-color-status__dark-underline: rgba(3, 33, 63, 0.72) !default;
|
|
423
423
|
$QLD-color-dark__underline: #b5cce2 !default;
|
|
424
424
|
$QLD-color-dark__underline--hover: #{$QLD-color-dark__link} !default;
|
|
425
|
-
$QLD-color-dark__underline--visited: #
|
|
425
|
+
$QLD-color-dark__underline--visited: #c6aed9 !default;
|
|
426
426
|
$QLD-color-dark__underline--hover-visited: #{$QLD-color-dark__link--visited} !default;
|
|
427
427
|
|
|
428
428
|
/**
|