@qhealth-design-system/core 1.17.2 → 1.18.0

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.
Files changed (46) hide show
  1. package/.storybook/globals.js +10 -0
  2. package/.storybook/preview.js +9 -13
  3. package/CHANGELOG.md +2 -0
  4. package/package.json +1 -1
  5. package/src/assets/img/QLD-Health-icons.svg +10 -6
  6. package/src/assets/img/QLD-icons.svg +12 -8
  7. package/src/assets/img/qgov-coa.svg +65 -0
  8. package/src/components/_global/css/forms/general/component.scss +1 -1
  9. package/src/components/_global/css/icons/component.scss +40 -38
  10. package/src/components/_global/css/tags/component.scss +28 -27
  11. package/src/components/_global/html/head.html +1 -1
  12. package/src/components/basic_search/html/component.hbs +2 -1
  13. package/src/components/card_single_action/css/component.scss +15 -0
  14. package/src/components/footer/html/component.hbs +18 -15
  15. package/src/components/header/css/component.scss +25 -85
  16. package/src/components/header/html/component.hbs +4 -176
  17. package/src/components/header/js/global.js +189 -181
  18. package/src/components/left_hand_navigation/css/component.scss +32 -29
  19. package/src/components/left_hand_navigation/html/component.hbs +10 -6
  20. package/src/components/left_hand_navigation/js/global.js +49 -26
  21. package/src/components/main_navigation/css/component.scss +115 -89
  22. package/src/components/main_navigation/html/component.hbs +9 -3
  23. package/src/components/mega_main_navigation/css/component.scss +6 -6
  24. package/src/components/mega_main_navigation/html/component.hbs +9 -3
  25. package/src/components/multi_column/css/component.scss +2 -32
  26. package/src/components/overflow_menu/css/component.scss +19 -41
  27. package/src/components/search_box/css/component.scss +42 -0
  28. package/src/components/tab/css/component.scss +56 -41
  29. package/src/components/tab/html/component.hbs +13 -13
  30. package/src/components/tab/js/global.js +43 -114
  31. package/src/components/tab/js/manifest.json +881 -873
  32. package/src/data/site.json +28 -4
  33. package/src/index.js +11 -2
  34. package/src/stories/BackToTop/BackToTop.js +8 -0
  35. package/src/stories/BackToTop/BackToTop.mdx +42 -0
  36. package/src/stories/BackToTop/BackToTop.stories.js +28 -0
  37. package/src/stories/CTALink/CTALink.js +5 -0
  38. package/src/stories/CTALink/CTALink.mdx +39 -0
  39. package/src/stories/CTALink/CTALink.stories.js +151 -0
  40. package/src/assets/data-tables-csv-test.csv +0 -191
  41. package/src/assets/img/header-logo-agov.png +0 -0
  42. package/src/assets/img/header-search.svg +0 -3
  43. package/src/assets/img/layers-2x.png +0 -0
  44. package/src/assets/img/layers.png +0 -0
  45. package/src/assets/img/marker-icon.png +0 -0
  46. package/src/assets/img/video-play.svg +0 -3
@@ -35,42 +35,39 @@
35
35
  * @param {HTMLElement} tabList - The tab list element to scroll
36
36
  */
37
37
 
38
- function scrollRight(tabList, ScrollRightBtn, ScrollLeftBtn) {
38
+ function scrollRight(tabList, scrollRightBtn, scrollLeftBtn) {
39
39
  // Check if the current scroll position is at the maximum scroll position
40
- if (
41
- tabList.scrollLeft + SCROLL_AMOUNT >=
42
- tabList.scrollWidth - tabList.clientWidth
43
- ) {
40
+ if (tabList.scrollLeft + SCROLL_AMOUNT >= tabList.scrollWidth - tabList.clientWidth) {
44
41
  // Hide the scroll right button
45
- ScrollRightBtn.style.display = "none";
42
+ scrollRightBtn.style.display = "none";
46
43
  }
47
44
 
48
45
  tabList.scrollLeft += SCROLL_AMOUNT;
49
- ScrollLeftBtn.style.display = "block";
46
+ scrollLeftBtn.style.display = "block";
50
47
  }
51
48
 
52
- function scrollLeft(tabList, ScrollRightBtn, ScrollLeftBtn) {
49
+ function scrollLeft(tabList, scrollRightBtn, scrollLeftBtn) {
53
50
  // Check if the current scroll position is at the beginning of the scroll
54
51
  if (tabList.scrollLeft - SCROLL_AMOUNT <= 0) {
55
52
  // Hide the scroll left button
56
- ScrollLeftBtn.style.display = "none";
53
+ scrollLeftBtn.style.display = "none";
57
54
  }
58
55
 
59
56
  tabList.scrollLeft -= SCROLL_AMOUNT;
60
- ScrollRightBtn.style.display = "block";
57
+ scrollRightBtn.style.display = "block";
61
58
  }
62
59
 
63
60
  /**
64
61
  * The function below checks if the tab list overflows the tab element and display the appropriate scroll buttons
65
- * @param {HTMLElement} TabHeader - The tab nav element
62
+ * @param {HTMLElement} tabHeader - The tab nav element
66
63
  * @param {HTMLElement} tabList - The tab list element
67
- * @param {HTMLElement} ScrollRightBtn - The right scroll button element
68
- * @param {HTMLElement} ScrollLeftBtn - The left scroll button element
64
+ * @param {HTMLElement} scrollRightBtn - The right scroll button element
65
+ * @param {HTMLElement} scrollLeftBtn - The left scroll button element
69
66
  */
70
67
 
71
- function overflow(TabHeader, tabList, ScrollRightBtn, ScrollLeftBtn) {
68
+ function overflow(tabHeader, tabList, scrollRightBtn, scrollLeftBtn) {
72
69
  const cusidEle = tabList.querySelectorAll(".qld__tab-button");
73
- const menuWidth = TabHeader.clientWidth;
70
+ const menuWidth = tabHeader.clientWidth;
74
71
  let totalWidth = 0;
75
72
  // Calculate the total width of all the nav items
76
73
  for (let i = 0; i < cusidEle.length; i++) {
@@ -79,12 +76,12 @@
79
76
  // If the total width is greater than the menu width, display the right scroll button
80
77
  // and scroll the link list to the left by the defined amount
81
78
  if (totalWidth > menuWidth) {
82
- ScrollRightBtn.style.display = "block";
79
+ scrollRightBtn.style.display = "block";
83
80
  tabList.scrollLeft -= SCROLL_AMOUNT;
84
- ScrollLeftBtn.style.display = "none";
81
+ scrollLeftBtn.style.display = "none";
85
82
  } else {
86
- ScrollRightBtn.style.display = "none";
87
- ScrollLeftBtn.style.display = "none";
83
+ scrollRightBtn.style.display = "none";
84
+ scrollLeftBtn.style.display = "none";
88
85
  }
89
86
  }
90
87
 
@@ -126,37 +123,7 @@
126
123
 
127
124
  function correctSelectors(selector) {
128
125
  if (!selector) return "";
129
- const specialChars = [
130
- "!",
131
- '"',
132
- "$",
133
- "%",
134
- "&",
135
- "'",
136
- "(",
137
- ")",
138
- "*",
139
- "+",
140
- ",",
141
- ".",
142
- "/",
143
- ":",
144
- ";",
145
- "<",
146
- "=",
147
- ">",
148
- "?",
149
- "@",
150
- "[",
151
- "\\",
152
- "]",
153
- "^",
154
- "`",
155
- "{",
156
- "|",
157
- "}",
158
- "~",
159
- ];
126
+ const specialChars = ["!", '"', "$", "%", "&", "'", "(", ")", "*", "+", ",", ".", "/", ":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "`", "{", "|", "}", "~"];
160
127
  const regex = new RegExp(`([${specialChars.join("\\")}])`, "g");
161
128
  return selector.replace(regex, "\\$1");
162
129
  }
@@ -181,8 +148,7 @@
181
148
  // Loop through each tab component
182
149
  tabComponents.forEach((tabComponent) => {
183
150
  // Get all tab heading elements within the tab component
184
- const tabHeadings =
185
- tabComponent.querySelectorAll(".qld__tab-button");
151
+ const tabHeadings = tabComponent.querySelectorAll(".qld__tab-button");
186
152
 
187
153
  // Set tab index and aria-selected attributes for the first tab heading and its corresponding content element
188
154
  if (tabHeadings.length) {
@@ -191,9 +157,7 @@
191
157
  const tabContentId = tabHeadings[0].getAttribute("data-tab");
192
158
  tabHeadings[0].classList.add("active");
193
159
 
194
- const tabContent = tabComponent.querySelector(
195
- `.qld__tab-content[data-tab="${tabContentId}"]`
196
- );
160
+ const tabContent = tabComponent.querySelector(`.qld__tab-content[data-tab="${tabContentId}"]`);
197
161
 
198
162
  if (tabContent.length) {
199
163
  tabContent.setAttribute("tabindex", "0");
@@ -209,15 +173,13 @@
209
173
  // Attach a click event listener to the tab heading
210
174
  tabHeading.addEventListener("click", (event) => {
211
175
  // Remove the 'active' class from all tab heading and content elements
212
- const tabHeadings =
213
- tabComponent.querySelectorAll(".qld__tab-button");
176
+ const tabHeadings = tabComponent.querySelectorAll(".qld__tab-button");
214
177
  tabHeadings.forEach((tabHeading) => {
215
178
  tabHeading.classList.remove("active");
216
179
  tabHeading.setAttribute("aria-selected", "false");
217
180
  tabHeading.setAttribute("tabindex", "-1");
218
181
  });
219
- const tabContents =
220
- tabComponent.querySelectorAll(".qld__tab-content");
182
+ const tabContents = tabComponent.querySelectorAll(".qld__tab-content");
221
183
  tabContents.forEach((tabContent) => {
222
184
  tabContent.classList.remove("active");
223
185
  tabContent.setAttribute("aria-hidden", "true");
@@ -227,11 +189,8 @@
227
189
  event.currentTarget.classList.add("active");
228
190
  event.currentTarget.setAttribute("aria-selected", "true");
229
191
  event.currentTarget.setAttribute("tabindex", "0");
230
- const tabContentId =
231
- event.currentTarget.getAttribute("data-tab");
232
- const tabContent = tabComponent.querySelector(
233
- `.qld__tab-content[data-tab="${tabContentId}"]`
234
- );
192
+ const tabContentId = event.currentTarget.getAttribute("data-tab");
193
+ const tabContent = tabComponent.querySelector(`.qld__tab-content[data-tab="${tabContentId}"]`);
235
194
  tabContent.classList.add("active");
236
195
  tabContent.setAttribute("aria-hidden", "false");
237
196
  tabContent.setAttribute("tabindex", "0");
@@ -249,41 +208,30 @@
249
208
  } else if (event.key === "ArrowLeft") {
250
209
  event.preventDefault();
251
210
  // Navigate to the previous tab
252
- currentTabIndex =
253
- (currentTabIndex - 1 + tabHeadings.length) %
254
- tabHeadings.length;
211
+ currentTabIndex = (currentTabIndex - 1 + tabHeadings.length) % tabHeadings.length;
255
212
  setFocusOnTab(currentTabIndex);
256
213
  } else if (event.key === "ArrowRight") {
257
214
  event.preventDefault();
258
215
  // Navigate to the next tab
259
- currentTabIndex =
260
- (currentTabIndex + 1) % tabHeadings.length;
216
+ currentTabIndex = (currentTabIndex + 1) % tabHeadings.length;
261
217
  setFocusOnTab(currentTabIndex);
262
218
  }
263
219
  });
264
220
 
265
221
  // Focus event to sync currentTabIndex
266
222
  tabHeading.addEventListener("focus", (event) => {
267
- const tabIndex = Array.from(tabHeadings).indexOf(
268
- event.currentTarget
269
- );
223
+ const tabIndex = Array.from(tabHeadings).indexOf(event.currentTarget);
270
224
  currentTabIndex = tabIndex; // Update the global index
271
225
 
272
- const tabContentId =
273
- event.currentTarget.getAttribute("data-tab");
274
- const tabContent = tabComponent.querySelector(
275
- `.qld__tab-content[data-tab="${tabContentId}"]`
276
- );
226
+ const tabContentId = event.currentTarget.getAttribute("data-tab");
227
+ const tabContent = tabComponent.querySelector(`.qld__tab-content[data-tab="${tabContentId}"]`);
277
228
  if (tabContent) tabContent.classList.add("focused");
278
229
  });
279
230
 
280
231
  // Blur event to remove focused class
281
232
  tabHeading.addEventListener("blur", (event) => {
282
- const tabContentId =
283
- event.currentTarget.getAttribute("data-tab");
284
- const tabContent = tabComponent.querySelector(
285
- `.qld__tab-content[data-tab="${tabContentId}"]`
286
- );
233
+ const tabContentId = event.currentTarget.getAttribute("data-tab");
234
+ const tabContent = tabComponent.querySelector(`.qld__tab-content[data-tab="${tabContentId}"]`);
287
235
  if (tabContent) tabContent.classList.remove("focused");
288
236
  });
289
237
  });
@@ -313,49 +261,28 @@
313
261
  */
314
262
 
315
263
  // Get the main nav elements and the tab list elements
316
- const TabHeaders = document.getElementsByClassName(
317
- "qld__tab-container__fixed"
318
- );
264
+ const tabHeaders = document.getElementsByClassName("qld__tab-container__fixed");
319
265
  const tabLists = [];
320
266
 
321
- for (let i = 0; i < TabHeaders.length; i++) {
322
- const tabs = TabHeaders[i].getElementsByClassName("qld__tabs");
267
+ for (let i = 0; i < tabHeaders.length; i++) {
268
+ const tabs = tabHeaders[i].getElementsByClassName("qld__tabs");
323
269
  tabLists.push(tabs[0]);
324
270
  }
325
271
 
326
272
  // Attach event listeners to each component
327
273
 
328
- for (let i = 0; i < TabHeaders.length; i++) {
329
- const TabHeader = TabHeaders[i];
274
+ for (let i = 0; i < tabHeaders.length; i++) {
275
+ const tabHeader = tabHeaders[i];
330
276
  const tabList = tabLists[i];
331
- const ScrollRightBtn = TabHeader.querySelector(
332
- ".tab-overflow-nav-button-right"
333
- );
334
- const ScrollLeftBtn = TabHeader.querySelector(
335
- ".tab-overflow-nav-button-left"
336
- );
337
- window.addEventListener("load", () =>
338
- overflow(TabHeader, tabList, ScrollRightBtn, ScrollLeftBtn)
339
- );
277
+ const scrollRightBtn = tabHeader.querySelector(".tab-overflow-nav-button-right");
278
+ const scrollLeftBtn = tabHeader.querySelector(".tab-overflow-nav-button-left");
279
+ window.addEventListener("load", () => overflow(tabHeader, tabList, scrollRightBtn, scrollLeftBtn));
340
280
  window.addEventListener(
341
281
  "resize",
342
- debounce(
343
- () =>
344
- overflow(
345
- TabHeader,
346
- tabList,
347
- ScrollRightBtn,
348
- ScrollLeftBtn
349
- ),
350
- 250
351
- )
352
- );
353
- ScrollRightBtn.addEventListener("click", () =>
354
- scrollRight(tabList, ScrollRightBtn, ScrollLeftBtn)
355
- );
356
- ScrollLeftBtn.addEventListener("click", () =>
357
- scrollLeft(tabList, ScrollRightBtn, ScrollLeftBtn)
282
+ debounce(() => overflow(tabHeader, tabList, scrollRightBtn, scrollLeftBtn), 250),
358
283
  );
284
+ scrollRightBtn.addEventListener("click", () => scrollRight(tabList, scrollRightBtn, scrollLeftBtn));
285
+ scrollLeftBtn.addEventListener("click", () => scrollLeft(tabList, scrollRightBtn, scrollLeftBtn));
359
286
  }
360
287
  };
361
288
 
@@ -364,6 +291,8 @@
364
291
  window.addEventListener("DOMContentLoaded", function () {
365
292
  QLD.tab.init();
366
293
  tabFixInitializer();
294
+ // Update href paths for SVG icons in the tab component
295
+ QLD.utils.updateSvgIconPath(".qld__tab-container .qld__tabs svg.qld__icon > use");
367
296
  });
368
297
  window.addEventListener("scroll", handleScroll);
369
298
  })();