@ulu/frontend 0.0.23 → 0.1.0-beta.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.
Files changed (212) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/deprecated/js/drupal-programmatic-modal.js +91 -0
  3. package/{js/ui/modals.js → deprecated/js/micromodal-modals.js} +41 -67
  4. package/dist/ulu-frontend.min.css +1 -1
  5. package/dist/ulu-frontend.min.js +70 -1
  6. package/index.js +6 -1
  7. package/js/events/index.js +58 -7
  8. package/js/index.js +3 -7
  9. package/js/{helpers/css-breakpoint.js → ui/breakpoints.js} +9 -11
  10. package/js/ui/collapsible.js +195 -0
  11. package/js/ui/dialog.js +157 -0
  12. package/js/ui/dialog.todo +37 -0
  13. package/js/ui/flipcard.js +55 -11
  14. package/js/ui/grid.js +2 -47
  15. package/js/ui/index.js +21 -0
  16. package/js/ui/modal-builder.js +197 -0
  17. package/js/ui/overflow-scroller-pager.js +1 -1
  18. package/js/ui/overflow-scroller.js +8 -5
  19. package/js/ui/page.js +14 -0
  20. package/js/ui/popover.js +135 -0
  21. package/js/ui/print-details.js +44 -0
  22. package/js/ui/print.js +67 -0
  23. package/js/ui/programmatic-modal.js +79 -81
  24. package/js/ui/proxy-click.js +80 -0
  25. package/js/ui/resizer.js +3 -3
  26. package/js/ui/scroll-slider.js +56 -0
  27. package/js/ui/scrollpoint.js +300 -0
  28. package/js/ui/slider.js +72 -10
  29. package/js/ui/tabs.js +85 -58
  30. package/js/ui/theme-toggle.js +129 -0
  31. package/js/ui/tooltip.js +268 -67
  32. package/js/utils/{logger.js → class-logger.js} +6 -5
  33. package/js/utils/dom.js +122 -0
  34. package/js/utils/file-save.js +67 -0
  35. package/js/utils/floating-ui.js +83 -0
  36. package/js/utils/id.js +22 -0
  37. package/js/utils/index.js +7 -0
  38. package/js/{helpers → utils}/pause-youtube-video.js +1 -1
  39. package/package.json +33 -13
  40. package/resources/drupal/twig-macros/accordion.twig +99 -0
  41. package/resources/drupal/twig-macros/dropdown.twig +44 -0
  42. package/resources/drupal/twig-macros/flipcard.twig +69 -0
  43. package/resources/drupal/twig-macros/image.twig +30 -0
  44. package/resources/drupal/twig-macros/layout.twig +338 -0
  45. package/resources/drupal/twig-macros/slider.twig +214 -0
  46. package/resources/drupal/twig-macros/tabs.twig +84 -0
  47. package/scss/README.md +13 -1
  48. package/scss/_breakpoint.scss +69 -26
  49. package/scss/_button.scss +148 -57
  50. package/scss/_color.scss +46 -28
  51. package/scss/_cssvar.scss +103 -12
  52. package/scss/_element.scss +84 -67
  53. package/scss/_index.scss +0 -3
  54. package/scss/_layout.scss +57 -26
  55. package/scss/_path.scss +2 -2
  56. package/scss/_selector.scss +20 -11
  57. package/scss/_typography.scss +115 -82
  58. package/scss/_units.scss +14 -13
  59. package/scss/_utils.scss +280 -18
  60. package/scss/base/_color.scss +2 -1
  61. package/scss/base/_elements.scss +61 -35
  62. package/scss/base/_index.scss +60 -23
  63. package/scss/base/_keyframes.scss +115 -16
  64. package/scss/base/_layout.scss +10 -6
  65. package/scss/base/_normalize.scss +6 -122
  66. package/scss/base/_print.scss +49 -0
  67. package/scss/base/_root.scss +28 -0
  68. package/scss/base/_typography.scss +4 -1
  69. package/scss/components/_accordion.scss +217 -0
  70. package/scss/components/_adaptive-spacing.scss +148 -0
  71. package/scss/components/_badge.scss +17 -14
  72. package/scss/components/_button-verbose.scss +138 -0
  73. package/scss/components/_button.scss +9 -4
  74. package/scss/components/_callout.scss +175 -0
  75. package/scss/components/_captioned-figure.scss +173 -0
  76. package/scss/components/_card-grid.scss +75 -0
  77. package/scss/components/_card.scss +420 -0
  78. package/scss/components/_css-icon.scss +433 -0
  79. package/scss/{_grid.scss → components/_data-grid.scss} +100 -68
  80. package/scss/components/_data-table.scss +180 -0
  81. package/scss/components/_fill-context.scss +20 -22
  82. package/scss/components/_flipcard-grid.scss +66 -0
  83. package/scss/components/_flipcard.scss +304 -0
  84. package/scss/components/_form-theme.scss +633 -0
  85. package/scss/components/_hero.scss +183 -0
  86. package/scss/components/_horizontal-rule.scss +51 -0
  87. package/scss/components/_image-grid.scss +71 -0
  88. package/scss/components/_index.scss +276 -38
  89. package/scss/components/_links.scss +1 -1
  90. package/scss/components/_list-lines.scss +14 -3
  91. package/scss/components/_list-ordered.scss +3 -1
  92. package/scss/components/_list-unordered.scss +3 -1
  93. package/scss/components/_menu-stack.scss +245 -0
  94. package/scss/components/_modal.scss +495 -0
  95. package/scss/components/_nav-strip.scss +148 -0
  96. package/scss/components/_overlay-section.scss +122 -0
  97. package/scss/components/_pager.scss +168 -0
  98. package/scss/components/_placeholder-block.scss +121 -0
  99. package/scss/components/_popover.scss +263 -0
  100. package/scss/components/_pull-quote.scss +111 -0
  101. package/scss/components/_ratio-box.scss +64 -0
  102. package/scss/components/_rule.scss +12 -9
  103. package/scss/components/_scroll-slider.scss +204 -0
  104. package/scss/components/_skip-link.scss +92 -0
  105. package/scss/components/_slider.scss +241 -0
  106. package/scss/components/_spoke-spinner.scss +193 -0
  107. package/scss/components/_tabs.scss +179 -0
  108. package/scss/components/_tag.scss +156 -0
  109. package/scss/components/_tile-button.scss +131 -0
  110. package/scss/components/_tile-grid-overlay.scss +132 -0
  111. package/scss/components/_tile-grid.scss +172 -0
  112. package/scss/components/_vignette.scss +65 -0
  113. package/scss/components/_wysiwyg.scss +94 -0
  114. package/scss/helpers/_color.scss +1 -0
  115. package/scss/helpers/_display.scss +2 -1
  116. package/scss/helpers/_index.scss +45 -22
  117. package/scss/helpers/_print.scss +20 -43
  118. package/scss/helpers/_typography.scss +3 -0
  119. package/scss/helpers/_units.scss +10 -13
  120. package/scss/helpers/_utilities.scss +5 -1
  121. package/scss/stylesheets/base-styles.scss +7 -0
  122. package/scss/stylesheets/component-styles.scss +7 -0
  123. package/scss/stylesheets/helper-styles.scss +7 -0
  124. package/types/events/index.d.ts +1 -1
  125. package/types/events/index.d.ts.map +1 -1
  126. package/types/index.d.ts +2 -2
  127. package/types/{helpers/css-breakpoint.d.ts → ui/breakpoints.d.ts} +3 -3
  128. package/types/ui/breakpoints.d.ts.map +1 -0
  129. package/types/ui/collapsible.d.ts +67 -0
  130. package/types/ui/collapsible.d.ts.map +1 -0
  131. package/types/ui/dialog.d.ts +42 -0
  132. package/types/ui/dialog.d.ts.map +1 -0
  133. package/types/ui/flipcard.d.ts +8 -1
  134. package/types/ui/flipcard.d.ts.map +1 -1
  135. package/types/ui/grid.d.ts +0 -11
  136. package/types/ui/grid.d.ts.map +1 -1
  137. package/types/ui/index.d.ts +23 -0
  138. package/types/ui/index.d.ts.map +1 -0
  139. package/types/ui/modal-builder.d.ts +54 -0
  140. package/types/ui/modal-builder.d.ts.map +1 -0
  141. package/types/ui/overflow-scroller-pager.d.ts +1 -1
  142. package/types/ui/overflow-scroller-pager.d.ts.map +1 -1
  143. package/types/ui/overflow-scroller.d.ts +3 -1
  144. package/types/ui/overflow-scroller.d.ts.map +1 -1
  145. package/types/ui/page.d.ts +5 -0
  146. package/types/ui/page.d.ts.map +1 -0
  147. package/types/ui/popover.d.ts +40 -0
  148. package/types/ui/popover.d.ts.map +1 -0
  149. package/types/ui/print-details.d.ts +10 -0
  150. package/types/ui/print-details.d.ts.map +1 -0
  151. package/types/ui/print.d.ts +10 -0
  152. package/types/ui/print.d.ts.map +1 -0
  153. package/types/ui/programmatic-modal.d.ts +19 -1
  154. package/types/ui/programmatic-modal.d.ts.map +1 -1
  155. package/types/ui/proxy-click.d.ts +18 -0
  156. package/types/ui/proxy-click.d.ts.map +1 -0
  157. package/types/ui/resizer.d.ts +1 -1
  158. package/types/ui/resizer.d.ts.map +1 -1
  159. package/types/ui/scroll-slider.d.ts +13 -0
  160. package/types/ui/scroll-slider.d.ts.map +1 -0
  161. package/types/ui/scrollpoint.d.ts +133 -0
  162. package/types/ui/scrollpoint.d.ts.map +1 -0
  163. package/types/ui/slider.d.ts +14 -2
  164. package/types/ui/slider.d.ts.map +1 -1
  165. package/types/ui/tabs.d.ts +22 -0
  166. package/types/ui/tabs.d.ts.map +1 -1
  167. package/types/ui/theme-toggle.d.ts +14 -0
  168. package/types/ui/theme-toggle.d.ts.map +1 -0
  169. package/types/ui/tooltip.d.ts +92 -10
  170. package/types/ui/tooltip.d.ts.map +1 -1
  171. package/types/utils/{logger.d.ts → class-logger.d.ts} +1 -1
  172. package/types/utils/class-logger.d.ts.map +1 -0
  173. package/types/utils/dom.d.ts +48 -0
  174. package/types/utils/dom.d.ts.map +1 -0
  175. package/types/utils/file-save.d.ts +64 -0
  176. package/types/utils/file-save.d.ts.map +1 -0
  177. package/types/utils/floating-ui.d.ts +19 -0
  178. package/types/utils/floating-ui.d.ts.map +1 -0
  179. package/types/utils/id.d.ts +10 -0
  180. package/types/utils/id.d.ts.map +1 -0
  181. package/types/utils/index.d.ts +9 -0
  182. package/types/utils/index.d.ts.map +1 -0
  183. package/types/utils/pause-youtube-video.d.ts.map +1 -0
  184. package/js/helpers/file-save.js +0 -52
  185. package/js/helpers/scrollbar-width-property.js +0 -14
  186. package/project.todo +0 -22
  187. package/scss/_calculate.scss +0 -64
  188. package/scss/_utility.scss +0 -12
  189. package/types/helpers/css-breakpoint.d.ts.map +0 -1
  190. package/types/helpers/file-save.d.ts +0 -17
  191. package/types/helpers/file-save.d.ts.map +0 -1
  192. package/types/helpers/node-data-manager.d.ts +0 -45
  193. package/types/helpers/node-data-manager.d.ts.map +0 -1
  194. package/types/helpers/pause-youtube-video.d.ts.map +0 -1
  195. package/types/helpers/scrollbar-width-property.d.ts +0 -11
  196. package/types/helpers/scrollbar-width-property.d.ts.map +0 -1
  197. package/types/ui/modals.d.ts +0 -27
  198. package/types/ui/modals.d.ts.map +0 -1
  199. package/types/utils/logger.d.ts.map +0 -1
  200. package/vite.config.js +0 -36
  201. /package/{js/deprecated → deprecated/js}/doc-ready.js +0 -0
  202. /package/{js/deprecated → deprecated/js}/jquery-prototypes.js +0 -0
  203. /package/{js/deprecated → deprecated/js}/mini-collapsible-popper-positioning.js +0 -0
  204. /package/{js/deprecated → deprecated/js}/mini-collapsible.js +0 -0
  205. /package/{js/helpers → deprecated/js}/node-data-manager.js +0 -0
  206. /package/{js/deprecated → deprecated/js}/script-loader.js +0 -0
  207. /package/{js/deprecated → deprecated/js}/waypoints/README.md +0 -0
  208. /package/{js/deprecated → deprecated/js}/waypoints/anchor-menu.js +0 -0
  209. /package/{js/deprecated → deprecated/js}/waypoints/element-waypoint.js +0 -0
  210. /package/{js/deprecated → deprecated/js}/waypoints/examples/page-link-menu.md +0 -0
  211. /package/{js/deprecated → deprecated/js}/waypoints/state-in-attribute.js +0 -0
  212. /package/types/{helpers → utils}/pause-youtube-video.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Change Log
2
2
 
3
+ ## Version 0.1.0-beta.1
4
+
5
+ - Remove dev dependencies from package json (vite, autoprefixer) and move specific JS module dependencies (ie. floating ui, ally.js and aria-tablist) to optionalDependencies so they can be installed if the user is using modules that require them
6
+
7
+ ## Version 0.1.0-beta.0
8
+
9
+ - Minor release keeps most of the current API for SASS the same but adds new functions/mixins and components. JS has been slightly reorganized and outdated modules have been replaced
10
+ - Remove calculate module and move the functions to utils (responsive property and pixel-to-em)
11
+ - Add other components modules
12
+ - Update documentation and API documentation
13
+ - Update all sass to work with new/future sass version
14
+ - Add root styles for ulu specific custom properties
15
+ - Add transitions to buttons
16
+ - JS remove mini collapsible and rely on floating ui library for tooltip/popovers
17
+ - JS move to native dialog element instead of micro-modal
18
+ - JS add new collapsible class for popovers or other accessible collapsible containers
19
+ - JS reorganize utils and helpers
20
+ - Create new docs website with api docs and component examples
21
+ - Full build (ie. /dist/) is bundled by Vite
22
+
3
23
  ## Version 0.0.23
4
24
 
5
25
  - Fix mistake introduced in 0.0.22, that broke container css
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @module programmatic-modal
3
+ */
4
+
5
+ // Version: 1.0.3
6
+ // Changes:
7
+ // 1.0.2 | Updates to work with the updated modal script which has
8
+ // to attach it's own trigger handlers
9
+ // Description: Drupal programmatic modal insertion script (interface = jquery prototype)
10
+ // Changes: 1.0.2 - Added ability to pass class to container
11
+
12
+ import { setupModal, show, attachTriggers, triggerAttr } from "./micromodal-modals.js";
13
+ import { dispatch } from "../../js/events.js";
14
+
15
+ const $ = window.jQuery;
16
+ const containerId = 'programmatic-modal';
17
+ const selectorTrigger = '[data-programmatic-modal-trigger]';
18
+ const defaults = {
19
+ removeOnClose: true,
20
+ settings: {},
21
+ classes: []
22
+ };
23
+
24
+ let count = 0;
25
+ let cachedTrigger;
26
+
27
+ // Drupal calls the jquery 'programaticModal' from InvokeCommand())
28
+ $.fn.programaticModal = newModal;
29
+
30
+ // keep track of trigger clicks to return user on close (Drupal doesn't send trigger clicked, that I know of)
31
+ document.addEventListener('click', cacheTrigger, true);
32
+
33
+ /**
34
+ * Sets up a new ajax triggered modal and opens it
35
+ * @param {String} args Arguments provided from Drupal (JSON format)
36
+ */
37
+ function newModal(args) {
38
+ args = args ? JSON.parse(args) : {};
39
+ const config = Object.assign({}, defaults, args);
40
+ const modal = document.querySelector(`#${ containerId }`);
41
+ const id = setModalId(modal, config.id);
42
+ const classes = ["programmatic-modal-content", ...config.classes ];
43
+ modal.classList.add(...classes);
44
+ // Add a new placeholder container
45
+ newContainer();
46
+ // Intialize and open the new modal
47
+ setupModal(modal, config.settings);
48
+ show(id, {
49
+ onShow(modal) {
50
+ dispatch('pageModified', modal);
51
+ },
52
+ onClose(element) {
53
+ if (config.removeOnClose) {
54
+ element.parentNode.removeChild(element);
55
+ }
56
+ // For accessiblity/usablity (return to last clicked trigger)
57
+ if (cachedTrigger) {
58
+ cachedTrigger.focus();
59
+ }
60
+ }
61
+ });
62
+ // Attach handler so that it can reopen that modal
63
+ if (!config.removeOnClose && cachedTrigger) {
64
+ cachedTrigger.setAttribute(triggerAttr, id);
65
+ attachTriggers();
66
+ }
67
+ }
68
+ /**
69
+ * Sets and returns the modal's id
70
+ */
71
+ function setModalId(element, id) {
72
+ element.id = id || `programmatic-modal--id-${ ++count }`;
73
+ return element.id;
74
+ }
75
+ /**
76
+ * Once we remove the placeholder containers id (above)
77
+ * we create another programmatic placeholder container
78
+ * for the next programmitic container
79
+ */
80
+ function newContainer() {
81
+ const container = document.createElement('div');
82
+ container.id = 'programmatic-modal';
83
+ document.body.append(container);
84
+ }
85
+ /**
86
+ * Document click handler, will cache the trigger that caused the modal to open
87
+ */
88
+ function cacheTrigger(event) {
89
+ const trigger = event.target.closest(selectorTrigger);
90
+ if (trigger) cachedTrigger = trigger;
91
+ }
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * @module ui/modals
3
3
  */
4
- // Version: 1.0.4
4
+ // Version: 1.0.5
5
+ //
5
6
  // Changes:
7
+ // 1.0.5 | Added title icon and remove calling of init
8
+ // Moved setup modals stuff to inside init (contextual) [may affect programmatic modals]
6
9
  // 1.0.4 | The modal library has a bug with multiple modals and using a custom close handler
7
10
  // In the future we want to abandon this library but for now it works by setting up our own open and close buttons
8
11
  // This is not setup to work with programmatic modals!!
@@ -10,17 +13,17 @@
10
13
  // 1.0.3 | Added youtube video closing stuff
11
14
  // 1.0.2 | Added custom close handler and checked to make sure resizer doesn't trigger click
12
15
  // 1.0.1 | Added optional resizable (allowResize)
13
- // Todo: - Make the container the content is getting the orginal classes, or don't remove them. And allow user to pass classes via config
16
+ // Todo: - Make the container the content is getting the original classes, or don't remove them. And allow user to pass classes via config
14
17
 
15
- // Javascript builds strucutre, modal's live in content in simple container.
16
- // Modal theme and strucutre is added in scripting That way if we change the
18
+ // Javascript builds structure, modal's live in content in simple container.
19
+ // Modal theme and structure is added in scripting That way if we change the
17
20
  // interface in the future we don't need to change/update markup.
18
- import MicroModal from 'micromodal';
19
- import Resizer from './resizer.js';
20
- import { createElementFromHtml } from '@ulu/utils/browser/dom.js';
21
- import { pauseVideos, prepVideos } from '../helpers/pause-youtube-video.js';
21
+ import MicroModal from "micromodal";
22
+ import { Resizer } from "../resizer.js";
23
+ import { pauseVideos, prepVideos } from "../utils/pause-youtube-video.js";
24
+ import { createElementFromHtml } from "@ulu/utils/browser/dom.js";
22
25
  const classes = {
23
- open: 'site-modal--open',
26
+ open: "site-modal--open",
24
27
  container: "site-modal__container",
25
28
  body: "site-modal__body",
26
29
  resizer: "site-modal__resizer"
@@ -32,13 +35,14 @@ const defaults = {
32
35
  allowResize: true,
33
36
  position: "center",
34
37
  containerClass: "",
35
- closeSelector: "[data-site-modal-close]"
38
+ closeSelector: "[data-site-modal-close]",
39
+ titleIcon: false
36
40
  };
37
41
  const configMicroModal = {
38
42
  openClass: classes.open,
39
43
  disableScroll: true,
40
- openTrigger: 'data-site-modal-trigger',
41
- closeTrigger: 'data-NOT-USED', // Proxied to avoid this click handler (on keydown, allow click on things underneath)
44
+ openTrigger: "data-site-modal-trigger",
45
+ closeTrigger: "data-NOT-USED", // Proxied to avoid this click handler (on keydown, allow click on things underneath)
42
46
  onClose: function(modal) {
43
47
  pauseVideos(modal);
44
48
  }
@@ -50,17 +54,12 @@ const wrappers = [];
50
54
  // page and move to the bottom of the page
51
55
  // const container = createContainer();
52
56
 
53
- // The [data-site-modal] is used to seperate the libraries' interface
54
- // and the modal's styling classes, so it can be adjusted or extended
55
- // in the future
56
- document.querySelectorAll('[data-site-modal]').forEach((element) => setupModal(element));
57
57
 
58
- // Intialize modal library script
59
- // init();
60
- attachTriggers();
61
58
 
62
- export function attachTriggers(context = document) {
63
- const flag = 'data-site-modal-trigger-attached';
59
+ // Initialize modal library script
60
+
61
+ export function init(context = document) {
62
+ const flag = "data-site-modal-trigger-attached";
64
63
  context.querySelectorAll(triggerSelector).forEach(trigger => {
65
64
  if (!trigger.hasAttribute(flag)) {
66
65
  const mid = trigger.getAttribute(triggerAttr);
@@ -69,17 +68,21 @@ export function attachTriggers(context = document) {
69
68
  } else {
70
69
  trigger.setAttribute(flag, "");
71
70
  trigger.addEventListener("click", () => {
72
- show(mid)
71
+ show(mid);
73
72
  });
74
73
  }
75
74
  }
76
75
  });
76
+ // The [data-site-modal] is used to separate the libraries' interface
77
+ // and the modal's styling classes, so it can be adjusted or extended
78
+ // in the future
79
+ context.querySelectorAll("[data-site-modal]").forEach((element) => setupModal(element));
77
80
  }
78
81
 
79
82
  /**
80
83
  * Function to setup each modal
81
84
  * - Creates structure
82
- * - Gets settings from elements data attrite
85
+ * - Gets settings from elements data attribute
83
86
  * - Moves it to the end of the document
84
87
  * - Adds resizer if position (left || right)
85
88
  * @param {Node} modal Modal element ie. `[data-site-modal]`
@@ -88,25 +91,25 @@ export function attachTriggers(context = document) {
88
91
  export function setupModal(modal, settings) {
89
92
  // Grab things from original element before modifying
90
93
  const id = modal.id;
91
- const originalClasses = modal.getAttribute('class') || '';
94
+ const originalClasses = modal.getAttribute("class") || "";
92
95
  // Grab settings from element and optionally from settings passed
93
96
  let data = {};
94
97
  if (modal.dataset.siteModal) {
95
- data = JSON.parse(modal.dataset.siteModal)
98
+ data = JSON.parse(modal.dataset.siteModal);
96
99
  }
97
100
  data = Object.assign({}, defaults, data, settings);
98
101
  const { allowResize, position } = data;
99
102
  const notCenter = position !== "center";
100
103
  const hasResizer = notCenter && allowResize;
101
- const resizerMarkup = hasResizer ? `<div class="${ classes.resizer }"></div>` : '';
104
+ const resizerMarkup = hasResizer ? `<div class="${ classes.resizer }"></div>` : "";
102
105
  const resizerModifierClass = allowResize ? "resize" : "no-resize";
103
106
  const closeAttr = "data-site-modal-close";
104
107
  // Remove attributes
105
- modal.removeAttribute('data-site-modal');
106
- modal.removeAttribute('id');
107
- modal.removeAttribute('class');
108
+ modal.removeAttribute("data-site-modal");
109
+ modal.removeAttribute("id");
110
+ modal.removeAttribute("class");
108
111
  // Template for new modal container (modal's body, the original element is
109
- // appended after as not to lose any listerner's/etc
112
+ // appended after as not to lose any listener's/etc
110
113
  const markup = `
111
114
  <div
112
115
  class="
@@ -120,7 +123,10 @@ export function setupModal(modal, settings) {
120
123
  <div class="site-modal__overlay" tabindex="-1" ${ closeAttr }>
121
124
  <div class="site-modal__container" role="dialog" aria-modal="true" aria-labelledby="${ id }-title">
122
125
  <div class="site-modal__header">
123
- <h2 class="site-modal__title" id="${ id }-title" tabindex="0">${ data.title }</h2>
126
+ <h2 class="site-modal__title" id="${ id }-title" tabindex="0">
127
+ ${ data.titleIcon ? `<span class="site-modal__title-icon ${ data.titleIcon }" aria-hidden="true"></span>` : "" }
128
+ <span class="site-modal__title-text">${ data.title }</span>
129
+ </h2>
124
130
  <button class="site-modal__close" aria-label="Close modal" ${ closeAttr }>
125
131
  <span class="site-modal__close-icon" aria-hidden="true" ${ closeAttr }></span>
126
132
  </button>
@@ -136,9 +142,9 @@ export function setupModal(modal, settings) {
136
142
  const select = (container, classKey) => container.querySelector("." + classes[classKey]);
137
143
  const wrapper = createElementFromHtml(markup.trim());
138
144
  const elements = {
139
- body: select(wrapper, 'body'),
140
- resizer: select(wrapper, 'resizer'),
141
- container: select(wrapper, 'container')
145
+ body: select(wrapper, "body"),
146
+ resizer: select(wrapper, "resizer"),
147
+ container: select(wrapper, "container")
142
148
  };
143
149
 
144
150
  // Move the orginal content into the modal's body
@@ -158,7 +164,7 @@ export function setupModal(modal, settings) {
158
164
  document.body.appendChild(wrapper);
159
165
  // Add our own close handlers to avoide the native
160
166
  const closeButtons = wrapper.querySelectorAll(data.closeSelector);
161
- closeButtons.forEach(b => b.addEventListener('click', ({ target }) => {
167
+ closeButtons.forEach(b => b.addEventListener("click", ({ target }) => {
162
168
  const outsideContainer = !elements.container.contains(target) && target !== elements.container;
163
169
  // Last condition is the overlay/backdrop (click outside)
164
170
  if (target.matches(`[${ closeAttr }]`) || outsideContainer) {
@@ -188,35 +194,3 @@ export function show(id, config) {
188
194
  export function close(id) {
189
195
  MicroModal.close(id);
190
196
  }
191
-
192
-
193
-
194
- // function createContainer() {
195
- // const container = document.createElement('div');
196
- // container.classList.add('site-modals');
197
- // document.body.appendChild(container);
198
- // return container;
199
- // }
200
-
201
- // From GITHUB Issues (user remedy)
202
- // export function refresh() {
203
- // // Use whatever selector you're using for MicroModal triggers.
204
- // const modalTrigger = 'data-micromodal-trigger';
205
-
206
- // // Get all triggers.
207
- // const modalTriggers = document.querySelectorAll( `[${modalTrigger}]` );
208
-
209
- // modalTriggers.forEach( trigger => {
210
- // // Get the attribute to save.
211
- // const triggerElement = trigger.getAttribute( modalTrigger );
212
-
213
- // // Remove the attribute briefly to clear memory/existing modals.
214
- // trigger.removeAttribute( modalTrigger );
215
-
216
- // // Immediately add it back.
217
- // trigger.setAttribute( modalTrigger, triggerElement );
218
-
219
- // // Re-initialize.
220
- // init();
221
- // } );
222
- // }