@qhealth-design-system/core 1.18.3 → 1.19.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 (91) hide show
  1. package/.storybook/assets/accordion-js.js +344 -0
  2. package/.storybook/assets/animate-js.js +247 -0
  3. package/.storybook/assets/index.js +15 -0
  4. package/.storybook/globals.js +39 -41
  5. package/.storybook/main.js +4 -3
  6. package/.storybook/preview.js +11 -13
  7. package/CHANGELOG.md +4 -0
  8. package/README.md +1 -1
  9. package/package.json +10 -15
  10. package/src/component-loader.js +23 -0
  11. package/src/components/_global/css/body/component.scss +3 -3
  12. package/src/components/_global/css/btn/component.scss +1 -1
  13. package/src/components/_global/css/cta_links/component.scss +2 -2
  14. package/src/components/_global/css/example/component.scss +11 -19
  15. package/src/components/_global/css/forms/control_inputs/component.scss +2 -2
  16. package/src/components/_global/css/forms/general/component.scss +5 -5
  17. package/src/components/_global/css/headings/component.scss +42 -44
  18. package/src/components/_global/css/img/images.scss +20 -36
  19. package/src/components/_global/css/link_columns/component.scss +2 -2
  20. package/src/components/_global/css/modal/component.scss +20 -26
  21. package/src/components/_global/css/table/component.scss +14 -21
  22. package/src/components/_global/css/tabs/component.scss +2 -2
  23. package/src/components/_global/css/tags/component.scss +1 -1
  24. package/src/components/_global/css/toggle_and_tool_tip/component.scss +3 -3
  25. package/src/components/_global/js/global.js +1 -1
  26. package/src/components/_global/js/select_boxes/global.js +26 -35
  27. package/src/components/accordion/css/component.scss +289 -326
  28. package/src/components/banner/css/component.scss +77 -173
  29. package/src/components/banner/html/component.hbs +2 -4
  30. package/src/components/banner_advanced/html/component.hbs +2 -2
  31. package/src/components/banner_advanced/js/manifest.json +1422 -1386
  32. package/src/components/basic_search/css/component.scss +13 -14
  33. package/src/components/basic_search/html/component.hbs +11 -20
  34. package/src/components/breadcrumbs/js/global.js +6 -1
  35. package/src/components/callout/css/component.scss +37 -40
  36. package/src/components/card_feature/css/component.scss +28 -167
  37. package/src/components/card_multi_action/css/component.scss +46 -58
  38. package/src/components/code/css/component.scss +3 -3
  39. package/src/components/code/html/component.hbs +12 -12
  40. package/src/components/code/js/global.js +6 -1
  41. package/src/components/file_upload/css/component.scss +5 -5
  42. package/src/components/file_upload/js/global.js +46 -43
  43. package/src/components/footer/css/component.scss +3 -3
  44. package/src/components/global_alert/css/component.scss +8 -14
  45. package/src/components/global_alert/html/component.hbs +3 -3
  46. package/src/components/header/css/component.scss +16 -4
  47. package/src/components/header/html/component.hbs +3 -2
  48. package/src/components/header/js/global.js +8 -1
  49. package/src/components/in_page_navigation/css/component.scss +14 -16
  50. package/src/components/in_page_navigation/js/global.js +48 -58
  51. package/src/components/internal_navigation/css/component.scss +3 -3
  52. package/src/components/internal_navigation/js/global.js +27 -35
  53. package/src/components/left_hand_navigation/css/component.scss +8 -2
  54. package/src/components/main_navigation/css/component.scss +16 -7
  55. package/src/components/main_navigation/html/component.hbs +1 -0
  56. package/src/components/mega_main_navigation/css/component.scss +5 -5
  57. package/src/components/mega_main_navigation/html/component.hbs +1 -0
  58. package/src/components/pagination/css/component.scss +32 -28
  59. package/src/components/pagination/html/component.hbs +37 -40
  60. package/src/components/promo_panel/css/component.scss +1 -4
  61. package/src/components/promo_panel/html/component.hbs +11 -5
  62. package/src/components/promo_panel/js/global.js +24 -39
  63. package/src/components/promo_panel/js/manifest.json +8 -0
  64. package/src/components/tab/css/component.scss +3 -3
  65. package/src/components/toggle_tip/css/component.scss +1 -1
  66. package/src/components/tool_tip/css/component.scss +1 -1
  67. package/src/components/video_player/js/global.js +16 -13
  68. package/src/data/current.json +33 -1
  69. package/src/helpers/global-helpers.js +56 -0
  70. package/src/html/component-in_page_navigation.html +2 -2
  71. package/src/index.js +4 -8
  72. package/src/stories/BackToTop/BackToTop.mdx +3 -21
  73. package/src/stories/CTALink/CTALink.mdx +1 -4
  74. package/src/stories/Checkboxes/Checkboxes.mdx +1 -4
  75. package/src/stories/DirectionLinks/DirectionLinks.mdx +1 -4
  76. package/src/stories/InPageAlert/InPageAlert.mdx +1 -4
  77. package/src/stories/Introduction.mdx +9 -5
  78. package/src/stories/LinkColumns/LinkColumns.mdx +1 -4
  79. package/src/stories/Pagination/Pagination.mdx +26 -0
  80. package/src/stories/Pagination/Pagination.stories.js +257 -0
  81. package/src/stories/PromoPanel/PromoPanel.mdx +26 -0
  82. package/src/stories/PromoPanel/PromoPanel.stories.js +219 -0
  83. package/src/stories/RadioButtons/RadioButtons.mdx +1 -4
  84. package/src/stories/SelectBox/SelectBox.mdx +1 -4
  85. package/src/stories/Tags/Tags.js +3 -3
  86. package/src/stories/Tags/Tags.mdx +1 -4
  87. package/src/stories/VideoPlayer/VideoPlayer.mdx +3 -28
  88. package/src/stories/VideoPlayer/VideoPlayer.stories.js +19 -46
  89. package/src/styles/imports/utilities.scss +3 -3
  90. package/src/styles/imports/variables.scss +5 -0
  91. package/src/stories/VideoPlayer/VideoPlayer.js +0 -0
@@ -0,0 +1,344 @@
1
+ // This file is temporarily added to Storybook to allow testing of the accordion component in isolation, while the main global.js file is being refactored into modules.
2
+
3
+ /**
4
+ * @module accordion
5
+ */
6
+
7
+ export default function initAccordion(document = document, element) {
8
+ let accordion = {};
9
+
10
+ if (element == "overflow") {
11
+ const overflowMenuButtons = document.querySelectorAll(".qld__overflow_menu__btn");
12
+ overflowMenuButtons.forEach(function (button) {
13
+ button.addEventListener("click", function () {
14
+ accordion.Toggle(button);
15
+ });
16
+ });
17
+ } else {
18
+ const accordionButtons = document.querySelectorAll(".qld__accordion__title");
19
+ accordionButtons.forEach(function (button) {
20
+ button.addEventListener("click", function () {
21
+ accordion.Toggle(button);
22
+ });
23
+ });
24
+
25
+ const accordionAllButtton = document.querySelectorAll(".qld__accordion__toggle-btn");
26
+ accordionAllButtton.forEach(function (button) {
27
+ button.addEventListener("click", function () {
28
+ accordion.ToggleAll(button);
29
+ });
30
+ });
31
+ }
32
+
33
+ function setAriaRoles(element, state) {
34
+ if (state === "closing") {
35
+ element.setAttribute("aria-expanded", false);
36
+ } else {
37
+ element.setAttribute("aria-expanded", true);
38
+ }
39
+ }
40
+
41
+ function toggleClasses(element, state, openingClass, closingClass) {
42
+ if (state === "opening" || state === "open") {
43
+ var oldClass = openingClass || "qld__accordion--closed";
44
+ var newClass = closingClass || "qld__accordion--open";
45
+ } else {
46
+ var oldClass = closingClass || "qld__accordion--open";
47
+ var newClass = openingClass || "qld__accordion--closed";
48
+ }
49
+
50
+ removeClass(element, oldClass);
51
+ addClass(element, newClass);
52
+ }
53
+
54
+ function removeClass(element, className) {
55
+ if (element.classList) {
56
+ element.classList.remove(className);
57
+ } else {
58
+ element.className = element.className.replace(new RegExp("(^|\\b)" + className.split(" ").join("|") + "(\\b|$)", "gi"), " ");
59
+ }
60
+ }
61
+
62
+ function addClass(element, className) {
63
+ if (element.classList) {
64
+ element.classList.add(className);
65
+ } else {
66
+ element.className = element.className + " " + className;
67
+ }
68
+ }
69
+
70
+ accordion.Toggle = function (elements, speed, callbacks) {
71
+ // stop event propagation
72
+ try {
73
+ window.event.cancelBubble = true;
74
+ event.stopPropagation();
75
+ } catch (error) {
76
+ console.error(error);
77
+ }
78
+
79
+ // making sure we can iterate over just one DOM element
80
+ if (elements.length === undefined) {
81
+ elements = [elements];
82
+ }
83
+
84
+ // check this once
85
+ if (typeof callbacks != "object") {
86
+ callbacks = {};
87
+ }
88
+
89
+ for (var i = 0; i < elements.length; i++) {
90
+ var element = elements[i];
91
+ var targetId = element.getAttribute("aria-controls");
92
+ var target = document.getElementById(targetId);
93
+
94
+ if (target == null) {
95
+ throw new Error(
96
+ "accordion.Toggle cannot find the target to be toggled from inside aria-controls.\n" +
97
+ "Make sure the first argument you give accordion.Toggle is the DOM element (a button or a link) that has an aria-controls attribute that points " +
98
+ "to a div that you want to toggle.",
99
+ );
100
+ }
101
+
102
+ target.style.display = "block";
103
+
104
+ QLD.animate.Toggle({
105
+ element: target,
106
+ property: "height",
107
+ speed: speed || 250,
108
+ prefunction: function (target, state) {
109
+ if (state === "opening") {
110
+ target.style.display = "block";
111
+
112
+ // run when opening
113
+ if (typeof callbacks.onOpen === "function") {
114
+ callbacks.onOpen();
115
+ }
116
+ } else {
117
+ // run when closing
118
+ if (typeof callbacks.onClose === "function") {
119
+ callbacks.onClose();
120
+ }
121
+ }
122
+
123
+ setAriaRoles(element, target, state);
124
+ toggleClasses(element, state);
125
+ },
126
+ postfunction: function (target, state) {
127
+ if (state === "closed") {
128
+ // run after closing
129
+ target.style.display = "";
130
+ target.style.height = "";
131
+
132
+ // GTM event
133
+ if (typeof window.dataLayer !== "undefined") {
134
+ window.dataLayer.push({
135
+ event: "accordion closed",
136
+ category: "accordion",
137
+ action: "close",
138
+ label: targetId,
139
+ });
140
+ }
141
+
142
+ if (typeof callbacks.afterClose === "function") {
143
+ callbacks.afterClose();
144
+ }
145
+ } else {
146
+ // run after opening
147
+ target.style.display = "";
148
+ target.style.height = "";
149
+
150
+ // GTM event
151
+ if (typeof window.dataLayer !== "undefined") {
152
+ window.dataLayer.push({
153
+ event: "accordion open",
154
+ category: "accordion",
155
+ action: "open",
156
+ label: targetId,
157
+ });
158
+ }
159
+
160
+ if (typeof callbacks.afterOpen === "function") {
161
+ callbacks.afterOpen();
162
+ }
163
+
164
+ if (target.classList.contains("qld__overflow_menu")) {
165
+ var overFlowLinks = [];
166
+ overFlowLinks = target.querySelectorAll("a.qld__overflow_menu_list-item-link");
167
+
168
+ if (overFlowLinks[0]) {
169
+ setTimeout(function () {
170
+ overFlowLinks[0].focus();
171
+ }, 10);
172
+ }
173
+ }
174
+ }
175
+
176
+ toggleClasses(target, state);
177
+ },
178
+ callback: function (target, state) {
179
+ const controller = new AbortController();
180
+
181
+ function toggleNavOnDocumentClick(event) {
182
+ if (!event.target.closest(".qld__main-nav__menu-sub.qld__accordion__body.qld__accordion--open")) {
183
+ controller.abort();
184
+ if (elements[0].classList.contains("qld__accordion--open")) {
185
+ accordion.Toggle(elements, speed, callbacks);
186
+ }
187
+ }
188
+ }
189
+
190
+ if (state === "open" || state === "opening") {
191
+ //if it is a mega nav add an event listener to close it when document is clicked
192
+ if (this.element.classList.contains("qld__main-nav__menu-sub") || this.element.classList.contains("qld__overflow_menu")) {
193
+ document.addEventListener("click", toggleNavOnDocumentClick, { signal: controller.signal });
194
+ }
195
+ } else {
196
+ if (this.element.classList.contains("qld__main-nav__menu-sub") || this.element.classList.contains("qld__overflow_menu")) {
197
+ document.removeEventListener("click", toggleNavOnDocumentClick, { signal: controller.signal });
198
+ controller.abort();
199
+ }
200
+ }
201
+ },
202
+ });
203
+ }
204
+
205
+ return false;
206
+ };
207
+
208
+ accordion.ToggleAll = function (elements, speed, callbacks) {
209
+ // stop event propagation
210
+ try {
211
+ window.event.cancelBubble = true;
212
+ event.stopPropagation();
213
+ } catch (error) {
214
+ console.error(error);
215
+ }
216
+
217
+ var toogleAllButton = elements;
218
+ // find the accordion wrapper
219
+ var wrapper = toogleAllButton.closest(".qld__accordion-group");
220
+ // get all the accordion buttons
221
+ var accordionButtons = wrapper.querySelectorAll(".qld__accordion__title");
222
+
223
+ // check this once
224
+ if (typeof callbacks != "object") {
225
+ callbacks = {};
226
+ }
227
+
228
+ // Check if opened or closed
229
+ if (toogleAllButton.classList.contains("qld__accordion__toggle-btn--closed")) {
230
+ toogleAllButton.classList.remove("qld__accordion__toggle-btn--closed");
231
+ toogleAllButton.setAttribute("aria-expanded", "true");
232
+ toogleAllButton.classList.add("qld__accordion__toggle-btn--open");
233
+ toogleAllButton.textContent = "Close all";
234
+ accordion.Open(accordionButtons);
235
+ } else if (toogleAllButton.classList.contains("qld__accordion__toggle-btn--open")) {
236
+ toogleAllButton.classList.remove("qld__accordion__toggle-btn--open");
237
+ toogleAllButton.setAttribute("aria-expanded", "false");
238
+ toogleAllButton.classList.add("qld__accordion__toggle-btn--closed");
239
+ toogleAllButton.textContent = "Open all";
240
+ accordion.Close(accordionButtons);
241
+ }
242
+
243
+ return false;
244
+ };
245
+
246
+ accordion.Open = function (elements, speed) {
247
+ // stop event propagation
248
+ try {
249
+ window.event.cancelBubble = true;
250
+ event.stopPropagation();
251
+ } catch (error) {
252
+ console.error(error);
253
+ }
254
+
255
+ if (elements.length === undefined) {
256
+ elements = [elements];
257
+ }
258
+
259
+ for (var i = 0; i < elements.length; i++) {
260
+ var element = elements[i];
261
+ var targetId = element.getAttribute("aria-controls");
262
+ var target = document.getElementById(targetId);
263
+
264
+ // let’s find out if this accordion is still closed
265
+ var height = 0;
266
+ if (typeof getComputedStyle !== "undefined") {
267
+ height = window.getComputedStyle(target).height;
268
+ } else {
269
+ height = target.currentStyle.height;
270
+ }
271
+
272
+ if (parseInt(height) === 0) {
273
+ target.style.height = "0px";
274
+ }
275
+
276
+ target.style.display = "";
277
+ toggleClasses(target, "opening");
278
+ toggleClasses(element, "opening");
279
+ setAriaRoles(element, target, "opening");
280
+
281
+ if (typeof window.dataLayer !== "undefined") {
282
+ window.dataLayer.push({
283
+ event: "accordion open",
284
+ category: "accordion",
285
+ action: "close",
286
+ label: targetId,
287
+ });
288
+ }
289
+
290
+ QLD.animate.Run({
291
+ element: target,
292
+ property: "height",
293
+ endSize: "auto",
294
+ speed: speed || 250,
295
+ callback: function () {
296
+ toggleClasses(element, "opening");
297
+ },
298
+ });
299
+ }
300
+ };
301
+
302
+ accordion.Close = function (elements, speed) {
303
+ // stop event propagation
304
+ try {
305
+ window.event.cancelBubble = true;
306
+ event.stopPropagation();
307
+ } catch (error) {
308
+ console.error(error);
309
+ }
310
+
311
+ if (elements.length === undefined) {
312
+ elements = [elements];
313
+ }
314
+
315
+ for (var i = 0; i < elements.length; i++) {
316
+ var element = elements[i];
317
+ var targetId = element.getAttribute("aria-controls");
318
+ var target = document.getElementById(targetId);
319
+
320
+ toggleClasses(element, "closing");
321
+ setAriaRoles(element, target, "closing");
322
+
323
+ if (typeof window.dataLayer !== "undefined") {
324
+ window.dataLayer.push({
325
+ event: "accordion close",
326
+ category: "accordion",
327
+ action: "close",
328
+ label: targetId,
329
+ });
330
+ }
331
+
332
+ QLD.animate.Run({
333
+ element: target,
334
+ property: "height",
335
+ endSize: 0,
336
+ speed: speed || 250,
337
+ callback: function () {
338
+ target.style.display = "";
339
+ toggleClasses(target, "close");
340
+ },
341
+ });
342
+ }
343
+ };
344
+ }
@@ -0,0 +1,247 @@
1
+ // This file is temporarily added to Storybook to allow testing of the animate component in isolation, while the main global.js file is being refactored into modules.
2
+
3
+ /**
4
+ * @module animate
5
+ */
6
+
7
+ export default function initAnimate(document = document) {
8
+ let animate = {};
9
+
10
+ function CalculateAnimationSpecs(initialSize, endSize, speed) {
11
+ if (initialSize === endSize) {
12
+ return {
13
+ stepSize: 0,
14
+ steps: 0,
15
+ intervalTime: 0,
16
+ };
17
+ }
18
+
19
+ var distance = endSize - initialSize; // the overall distance the animation needs to travel
20
+ var intervalTime = speed / distance; // the time each setInterval iteration will take
21
+ var stepSize = distance < 0 ? -1 : 1; // if distance is negative then we set stepSize to -1
22
+ var steps = Math.abs(distance / stepSize); // the amount of steps required to get to endSize
23
+ intervalTime = speed / steps;
24
+
25
+ // we need to adjust our animation specs if interval time exceeds 60FPS eg intervalTime < 16.67ms
26
+ if (Math.abs(intervalTime) < 1000 / 60) {
27
+ intervalTime = 1000 / 60; // let’s not get lower that 60FPS
28
+ steps = Math.ceil(Math.abs(speed / intervalTime)); // we now need the steps and make sure we ceil them so -1 won't make them negative
29
+ stepSize = distance / steps; // last thing is step sizes which are derived from all of the above
30
+ }
31
+
32
+ return {
33
+ stepSize: stepSize,
34
+ steps: steps - 1,
35
+ intervalTime: intervalTime,
36
+ };
37
+ }
38
+
39
+ // export for node and babel environments
40
+ if (typeof module !== "undefined") {
41
+ animate.CalculateAnimationSpecs = CalculateAnimationSpecs;
42
+ }
43
+
44
+ animate.GetCSSPropertyBecauseIE = function (element, property) {
45
+ if (typeof getComputedStyle !== "undefined") {
46
+ return window.getComputedStyle(element)[property];
47
+ } else {
48
+ var space = element.currentStyle[property];
49
+
50
+ if (space === "auto") {
51
+ space = QLD.animate.CalculateAuto(element, property);
52
+ }
53
+
54
+ return space;
55
+ }
56
+ };
57
+
58
+ animate.CalculateAuto = function (element, dimension) {
59
+ var initialSize;
60
+ var endSize;
61
+
62
+ if (dimension === "height") {
63
+ initialSize = element.clientHeight; // get current height
64
+ element.style[dimension] = "auto"; // set height to auto
65
+ endSize = element.clientHeight; // get height again
66
+ element.style[dimension] = initialSize + "px"; // set back to initial height
67
+ } else {
68
+ initialSize = element.clientWidth;
69
+ element.style[dimension] = "auto";
70
+ endSize = element.clientWidth;
71
+ element.style[dimension] = initialSize + "px";
72
+ }
73
+
74
+ return parseInt(endSize);
75
+ };
76
+
77
+ animate.Stop = function (element) {
78
+ clearInterval(element.QLDanimation);
79
+ };
80
+
81
+ animate.Run = function (options) {
82
+ // defaults
83
+ var elements = options.element;
84
+ var speed = options.speed || 250;
85
+
86
+ // making a single DOM element iteratable
87
+ if (elements.length === undefined) {
88
+ elements = [elements];
89
+ }
90
+
91
+ // making a callback if none was provided
92
+ if (typeof options.callback !== "function") {
93
+ options.callback = function () {};
94
+ }
95
+
96
+ // adding iteration counts
97
+ elements[0].QLDinteration = 0;
98
+ elements[0].QLDinterations = elements.length;
99
+
100
+ // iterate over all DOM nodes
101
+ for (var i = 0; i < elements.length; i++) {
102
+ var element = elements[i]; // this element
103
+ QLD.animate.Stop(element); // stop any previous animations
104
+ var initialSize = parseInt(QLD.animate.GetCSSPropertyBecauseIE(element, options.property)); // the elements current size
105
+ var endSize = options.endSize; // the element end size
106
+
107
+ if (options.endSize === "auto") {
108
+ // calculate what 'auto' means in pixel
109
+ endSize = QLD.animate.CalculateAuto(element, options.property);
110
+ }
111
+
112
+ // calculate our animation specs
113
+ var animationSpecs = CalculateAnimationSpecs(initialSize, endSize, speed);
114
+ var iterateCounter = initialSize;
115
+
116
+ // set state
117
+ if (animationSpecs.stepSize < 0) {
118
+ element.QLDtoggleState = "closing";
119
+ } else if (animationSpecs.stepSize > 0) {
120
+ element.QLDtoggleState = "opening";
121
+ }
122
+
123
+ // scoping variable
124
+ (function (element, initialSize, iterateCounter, animationSpecs, endSize) {
125
+ // keep track of animation by adding it to the DOM element
126
+ element.QLDanimation = setInterval(function () {
127
+ // when we are at the end
128
+ if (initialSize === endSize || animationSpecs.steps === 0) {
129
+ QLD.animate.Stop(element);
130
+
131
+ element.style[options.property] = endSize + "px"; // set to endSize
132
+ element.QLDtoggleState = "";
133
+
134
+ elements[0].QLDinteration++;
135
+
136
+ // removing auto so CSS can take over
137
+ if (options.endSize === "auto") {
138
+ element.style[options.property] = "";
139
+ }
140
+
141
+ // when all iterations have finished, run the callback
142
+ if (elements[0].QLDinteration >= elements[0].QLDinterations) {
143
+ return options.callback();
144
+ }
145
+ }
146
+
147
+ // if we are still animating
148
+ else {
149
+ iterateCounter += animationSpecs.stepSize;
150
+ element.style[options.property] = iterateCounter + "px";
151
+
152
+ animationSpecs.steps--;
153
+ }
154
+ }, Math.abs(animationSpecs.intervalTime));
155
+ })(element, initialSize, iterateCounter, animationSpecs, endSize);
156
+ }
157
+ };
158
+
159
+ animate.Toggle = function (options) {
160
+ var elements = options.element;
161
+ var property = options.property || "height";
162
+ var speed = options.speed || 250;
163
+ var closeSize = options.closeSize === undefined ? 0 : options.closeSize;
164
+ var openSize = options.openSize === undefined ? "auto" : options.openSize;
165
+
166
+ // making a single DOM element iteratable
167
+ if (elements.length === undefined) {
168
+ elements = [elements];
169
+ }
170
+
171
+ // making a prefunction if none was provided
172
+ if (typeof options.prefunction !== "function") {
173
+ options.prefunction = function () {};
174
+ }
175
+
176
+ // making a postfunction if none was provided
177
+ if (typeof options.postfunction !== "function") {
178
+ options.postfunction = function () {};
179
+ }
180
+
181
+ // making a callback if none was provided
182
+ if (typeof options.callback !== "function") {
183
+ options.callback = function () {};
184
+ }
185
+
186
+ // adding iteration counts
187
+ elements[0].QLDtoggleInteration = 0;
188
+ elements[0].QLDtoggleInterations = elements.length;
189
+
190
+ // iterate over all DOM nodes
191
+ for (var i = 0; i < elements.length; i++) {
192
+ var element = elements[i];
193
+
194
+ QLD.animate.Stop(element);
195
+
196
+ var targetSize; // the size the element should open/close to after toggle is clicked
197
+ var preState = ""; // the state we animate to for the prefunction and callback functions
198
+ var postState = ""; // the state we animate to for the prefunction and callback functions
199
+ var currentSize = parseInt(QLD.animate.GetCSSPropertyBecauseIE(element, options.property)); // the current size of the element
200
+
201
+ if (currentSize === closeSize || element.QLDtoggleState === "closing") {
202
+ targetSize = openSize;
203
+ preState = "opening";
204
+ postState = "open";
205
+ } else if (currentSize !== closeSize || element.QLDtoggleState === "opening") {
206
+ targetSize = closeSize;
207
+ preState = "closing";
208
+ postState = "closed";
209
+ } else {
210
+ throw new Error("QLD.animate.Toggle cannot determine state of element");
211
+ }
212
+
213
+ // run prefunction once per element
214
+ options.prefunction(element, preState);
215
+
216
+ // shoot off animation
217
+ QLD.animate.Run({
218
+ element: element,
219
+ endSize: targetSize,
220
+ property: property,
221
+ speed: speed,
222
+ callback: function () {
223
+ // making sure we fire the callback only once
224
+ elements[0].QLDtoggleInteration++;
225
+
226
+ if (elements[0].QLDtoggleInteration === elements[0].QLDinterations) {
227
+ var returnParam = options.callback(element, postState);
228
+
229
+ // run postfunction once per element
230
+ options.postfunction(element, postState);
231
+
232
+ return returnParam;
233
+ }
234
+
235
+ // run postfunction once per element
236
+ options.postfunction(element, postState);
237
+ },
238
+ });
239
+ }
240
+ };
241
+
242
+ if (!window.QLD) {
243
+ window.QLD = {};
244
+ }
245
+
246
+ window.QLD.animate = animate;
247
+ }
@@ -0,0 +1,15 @@
1
+ // Storybook index file to import storybook related assets
2
+ import "../core-assets/handlebar-helpers.js";
3
+ import "../core-assets/main.js";
4
+ import initAnimate from "./animate-js.js";
5
+ import initAccordion from "./accordion-js.js";
6
+ import initComponents from "../../src/component-loader.js";
7
+
8
+ // ES module initialisation for Core components
9
+ initComponents();
10
+
11
+ // ES module initialisation for Storybook specific components
12
+ document.addEventListener("DOMContentLoaded", () => {
13
+ initAnimate(document);
14
+ initAccordion(document);
15
+ });