@ulu/frontend 0.0.3

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 (323) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/ulu-frontend.min.css +1 -0
  4. package/dist/ulu-frontend.min.js +1 -0
  5. package/index.js +2 -0
  6. package/js/deprecated/doc-ready.js +28 -0
  7. package/js/deprecated/jquery-prototypes.js +309 -0
  8. package/js/deprecated/mini-collapsible-popper-positioning.js +126 -0
  9. package/js/deprecated/mini-collapsible.js +607 -0
  10. package/js/deprecated/script-loader.js +60 -0
  11. package/js/events/index.js +42 -0
  12. package/js/helpers/css-breakpoint.js +247 -0
  13. package/js/helpers/file-save.js +48 -0
  14. package/js/helpers/node-data-manager.js +74 -0
  15. package/js/helpers/pause-youtube-video.js +42 -0
  16. package/js/helpers/scrollbar-width-property.js +10 -0
  17. package/js/index.js +15 -0
  18. package/js/polyfills/element-closest.js +17 -0
  19. package/js/ui/flipcard.js +202 -0
  20. package/js/ui/grid.js +67 -0
  21. package/js/ui/modals.js +219 -0
  22. package/js/ui/overflow-scroller-pager.js +58 -0
  23. package/js/ui/overflow-scroller.js +160 -0
  24. package/js/ui/programmatic-modal.js +91 -0
  25. package/js/ui/resizer.js +60 -0
  26. package/js/ui/slider.js +468 -0
  27. package/js/ui/tabs.js +109 -0
  28. package/js/ui/tooltip.js +82 -0
  29. package/js/utils/array.js +28 -0
  30. package/js/utils/dom.js +122 -0
  31. package/js/utils/logger.js +69 -0
  32. package/js/utils/object.js +22 -0
  33. package/js/utils/performance.js +43 -0
  34. package/js/utils/regex.js +10 -0
  35. package/js/utils/string.js +107 -0
  36. package/js/waypoints/README.md +3 -0
  37. package/js/waypoints/anchor-menu.js +76 -0
  38. package/js/waypoints/element-waypoint.js +75 -0
  39. package/js/waypoints/examples/page-link-menu.md +106 -0
  40. package/js/waypoints/state-in-attribute.js +32 -0
  41. package/package.json +38 -0
  42. package/scss/README.md +58 -0
  43. package/scss/_breakpoint.scss +190 -0
  44. package/scss/_button.scss +241 -0
  45. package/scss/_calculate.scss +64 -0
  46. package/scss/_color.scss +211 -0
  47. package/scss/_cssvar.scss +116 -0
  48. package/scss/_element.scss +276 -0
  49. package/scss/_grid.scss +699 -0
  50. package/scss/_index.scss +29 -0
  51. package/scss/_layout.scss +202 -0
  52. package/scss/_path.scss +58 -0
  53. package/scss/_selector.scss +81 -0
  54. package/scss/_typography.scss +320 -0
  55. package/scss/_units.scss +47 -0
  56. package/scss/_utility.scss +12 -0
  57. package/scss/_utils.scss +209 -0
  58. package/scss/base/_color.scss +13 -0
  59. package/scss/base/_elements.scss +188 -0
  60. package/scss/base/_index.scss +62 -0
  61. package/scss/base/_keyframes.scss +78 -0
  62. package/scss/base/_layout.scss +100 -0
  63. package/scss/base/_normalize.scss +315 -0
  64. package/scss/base/_typography.scss +41 -0
  65. package/scss/components/README.md +5 -0
  66. package/scss/components/README.todos +15 -0
  67. package/scss/components/_button.scss +95 -0
  68. package/scss/components/_index.scss +63 -0
  69. package/scss/components/_links.scss +34 -0
  70. package/scss/components/_list-lines.scss +73 -0
  71. package/scss/components/_list-ordered.scss +16 -0
  72. package/scss/components/_list-unordered.scss +21 -0
  73. package/scss/components/_rule.scss +93 -0
  74. package/scss/helpers/_color.scss +14 -0
  75. package/scss/helpers/_display.scss +73 -0
  76. package/scss/helpers/_index.scss +67 -0
  77. package/scss/helpers/_print.scss +58 -0
  78. package/scss/helpers/_typography.scss +80 -0
  79. package/scss/helpers/_units.scss +79 -0
  80. package/scss/helpers/_utilities.scss +102 -0
  81. package/scss/stylesheets/README.md +3 -0
  82. package/scss/stylesheets/full.scss +17 -0
  83. package/trash/js-old/deprecated/doc-ready.js +28 -0
  84. package/trash/js-old/deprecated/jquery-prototypes.js +309 -0
  85. package/trash/js-old/deprecated/mini-collapsible-popper-positioning.js +126 -0
  86. package/trash/js-old/deprecated/mini-collapsible.js +607 -0
  87. package/trash/js-old/deprecated/script-loader.js +60 -0
  88. package/trash/js-old/events/index.js +42 -0
  89. package/trash/js-old/helpers/css-breakpoint.js +247 -0
  90. package/trash/js-old/helpers/file-save.js +48 -0
  91. package/trash/js-old/helpers/node-data-manager.js +74 -0
  92. package/trash/js-old/helpers/pause-youtube-video.js +42 -0
  93. package/trash/js-old/index.js +15 -0
  94. package/trash/js-old/polyfills/element-closest.js +17 -0
  95. package/trash/js-old/ui/flipcard.js +202 -0
  96. package/trash/js-old/ui/grid.js +67 -0
  97. package/trash/js-old/ui/modals.js +219 -0
  98. package/trash/js-old/ui/programmatic-modal.js +91 -0
  99. package/trash/js-old/ui/resizer.js +60 -0
  100. package/trash/js-old/ui/slider.js +469 -0
  101. package/trash/js-old/ui/tabs.js +109 -0
  102. package/trash/js-old/ui/tooltip.js +82 -0
  103. package/trash/js-old/utils/array.js +28 -0
  104. package/trash/js-old/utils/dom.js +122 -0
  105. package/trash/js-old/utils/logger.js +69 -0
  106. package/trash/js-old/utils/object.js +22 -0
  107. package/trash/js-old/utils/performance.js +43 -0
  108. package/trash/js-old/utils/regex.js +10 -0
  109. package/trash/js-old/utils/string.js +107 -0
  110. package/trash/js-old/waypoints/README.md +3 -0
  111. package/trash/js-old/waypoints/anchor-menu.js +76 -0
  112. package/trash/js-old/waypoints/element-waypoint.js +75 -0
  113. package/trash/js-old/waypoints/examples/page-link-menu.md +106 -0
  114. package/trash/js-old/waypoints/state-in-attribute.js +32 -0
  115. package/trash/js-old-230729/deprecated/doc-ready.js +28 -0
  116. package/trash/js-old-230729/deprecated/jquery-prototypes.js +309 -0
  117. package/trash/js-old-230729/deprecated/mini-collapsible-popper-positioning.js +126 -0
  118. package/trash/js-old-230729/deprecated/mini-collapsible.js +607 -0
  119. package/trash/js-old-230729/deprecated/script-loader.js +60 -0
  120. package/trash/js-old-230729/events/index.js +42 -0
  121. package/trash/js-old-230729/helpers/css-breakpoint.js +247 -0
  122. package/trash/js-old-230729/helpers/file-save.js +48 -0
  123. package/trash/js-old-230729/helpers/node-data-manager.js +74 -0
  124. package/trash/js-old-230729/helpers/pause-youtube-video.js +42 -0
  125. package/trash/js-old-230729/helpers/scrollbar-width-property.js +10 -0
  126. package/trash/js-old-230729/index.js +15 -0
  127. package/trash/js-old-230729/polyfills/element-closest.js +17 -0
  128. package/trash/js-old-230729/ui/flipcard.js +202 -0
  129. package/trash/js-old-230729/ui/grid.js +67 -0
  130. package/trash/js-old-230729/ui/modals.js +219 -0
  131. package/trash/js-old-230729/ui/overflow-scroller-pager.js +58 -0
  132. package/trash/js-old-230729/ui/overflow-scroller.js +160 -0
  133. package/trash/js-old-230729/ui/programmatic-modal.js +91 -0
  134. package/trash/js-old-230729/ui/resizer.js +60 -0
  135. package/trash/js-old-230729/ui/slider.js +468 -0
  136. package/trash/js-old-230729/ui/tabs.js +109 -0
  137. package/trash/js-old-230729/ui/tooltip.js +82 -0
  138. package/trash/js-old-230729/utils/array.js +28 -0
  139. package/trash/js-old-230729/utils/dom.js +122 -0
  140. package/trash/js-old-230729/utils/logger.js +69 -0
  141. package/trash/js-old-230729/utils/object.js +22 -0
  142. package/trash/js-old-230729/utils/performance.js +43 -0
  143. package/trash/js-old-230729/utils/regex.js +10 -0
  144. package/trash/js-old-230729/utils/string.js +107 -0
  145. package/trash/js-old-230729/waypoints/README.md +3 -0
  146. package/trash/js-old-230729/waypoints/anchor-menu.js +76 -0
  147. package/trash/js-old-230729/waypoints/element-waypoint.js +75 -0
  148. package/trash/js-old-230729/waypoints/examples/page-link-menu.md +106 -0
  149. package/trash/js-old-230729/waypoints/state-in-attribute.js +32 -0
  150. package/trash/logo-1.svg +13 -0
  151. package/trash/logo.svg +16 -0
  152. package/trash/scss-before-cqc-update/README.md +58 -0
  153. package/trash/scss-before-cqc-update/_breakpoint.scss +190 -0
  154. package/trash/scss-before-cqc-update/_button.scss +229 -0
  155. package/trash/scss-before-cqc-update/_calculate.scss +65 -0
  156. package/trash/scss-before-cqc-update/_color.scss +211 -0
  157. package/trash/scss-before-cqc-update/_cssvar.scss +116 -0
  158. package/trash/scss-before-cqc-update/_element.scss +275 -0
  159. package/trash/scss-before-cqc-update/_index.scss +29 -0
  160. package/trash/scss-before-cqc-update/_layout.scss +247 -0
  161. package/trash/scss-before-cqc-update/_path.scss +59 -0
  162. package/trash/scss-before-cqc-update/_selector.scss +82 -0
  163. package/trash/scss-before-cqc-update/_typography.scss +322 -0
  164. package/trash/scss-before-cqc-update/_units.scss +48 -0
  165. package/trash/scss-before-cqc-update/_utility.scss +13 -0
  166. package/trash/scss-before-cqc-update/_utils.scss +211 -0
  167. package/trash/scss-before-cqc-update/base/_color.scss +14 -0
  168. package/trash/scss-before-cqc-update/base/_elements.scss +189 -0
  169. package/trash/scss-before-cqc-update/base/_index.scss +63 -0
  170. package/trash/scss-before-cqc-update/base/_keyframes.scss +74 -0
  171. package/trash/scss-before-cqc-update/base/_layout.scss +88 -0
  172. package/trash/scss-before-cqc-update/base/_normalize.scss +316 -0
  173. package/trash/scss-before-cqc-update/base/_typography.scss +42 -0
  174. package/trash/scss-before-cqc-update/components/README.md +5 -0
  175. package/trash/scss-before-cqc-update/components/README.todos +15 -0
  176. package/trash/scss-before-cqc-update/components/_button.scss +96 -0
  177. package/trash/scss-before-cqc-update/components/_grid.scss +671 -0
  178. package/trash/scss-before-cqc-update/components/_index.scss +70 -0
  179. package/trash/scss-before-cqc-update/components/_links.scss +35 -0
  180. package/trash/scss-before-cqc-update/components/_list-lines.scss +74 -0
  181. package/trash/scss-before-cqc-update/components/_list-ordered.scss +17 -0
  182. package/trash/scss-before-cqc-update/components/_list-unordered.scss +22 -0
  183. package/trash/scss-before-cqc-update/components/_rule.scss +94 -0
  184. package/trash/scss-before-cqc-update/helpers/_color.scss +15 -0
  185. package/trash/scss-before-cqc-update/helpers/_display.scss +73 -0
  186. package/trash/scss-before-cqc-update/helpers/_index.scss +68 -0
  187. package/trash/scss-before-cqc-update/helpers/_print.scss +59 -0
  188. package/trash/scss-before-cqc-update/helpers/_typography.scss +73 -0
  189. package/trash/scss-before-cqc-update/helpers/_units.scss +79 -0
  190. package/trash/scss-before-cqc-update/helpers/_utilities.scss +88 -0
  191. package/trash/scss-before-cqc-update/stylesheets/README.md +3 -0
  192. package/trash/scss-before-cqc-update/stylesheets/full.scss +17 -0
  193. package/trash/scss-old/README.md +58 -0
  194. package/trash/scss-old/_breakpoint.scss +140 -0
  195. package/trash/scss-old/_button.scss +223 -0
  196. package/trash/scss-old/_calculate.scss +64 -0
  197. package/trash/scss-old/_color.scss +200 -0
  198. package/trash/scss-old/_element.scss +262 -0
  199. package/trash/scss-old/_grid.scss +558 -0
  200. package/trash/scss-old/_index.scss +25 -0
  201. package/trash/scss-old/_layout.scss +170 -0
  202. package/trash/scss-old/_path.scss +58 -0
  203. package/trash/scss-old/_selector.scss +81 -0
  204. package/trash/scss-old/_typography.scss +320 -0
  205. package/trash/scss-old/_units.scss +47 -0
  206. package/trash/scss-old/_utility.scss +12 -0
  207. package/trash/scss-old/_utils.scss +186 -0
  208. package/trash/scss-old/base/_color.scss +13 -0
  209. package/trash/scss-old/base/_elements.scss +183 -0
  210. package/trash/scss-old/base/_index.scss +62 -0
  211. package/trash/scss-old/base/_keyframes.scss +74 -0
  212. package/trash/scss-old/base/_layout.scss +81 -0
  213. package/trash/scss-old/base/_normalize.scss +316 -0
  214. package/trash/scss-old/base/_typography.scss +42 -0
  215. package/trash/scss-old/components/README.md +5 -0
  216. package/trash/scss-old/components/README.todos +15 -0
  217. package/trash/scss-old/components/_button.scss +74 -0
  218. package/trash/scss-old/components/_index.scss +63 -0
  219. package/trash/scss-old/components/_links.scss +34 -0
  220. package/trash/scss-old/components/_list-lines.scss +73 -0
  221. package/trash/scss-old/components/_list-ordered.scss +16 -0
  222. package/trash/scss-old/components/_list-unordered.scss +21 -0
  223. package/trash/scss-old/components/_rule.scss +84 -0
  224. package/trash/scss-old/helpers/_color.scss +14 -0
  225. package/trash/scss-old/helpers/_display.scss +68 -0
  226. package/trash/scss-old/helpers/_index.scss +67 -0
  227. package/trash/scss-old/helpers/_print.scss +59 -0
  228. package/trash/scss-old/helpers/_typography.scss +73 -0
  229. package/trash/scss-old/helpers/_units.scss +68 -0
  230. package/trash/scss-old/helpers/_utilities.scss +82 -0
  231. package/trash/scss-old/packages/README.md +3 -0
  232. package/trash/scss-old/packages/everything.scss +17 -0
  233. package/trash/scss-old-2/README.md +58 -0
  234. package/trash/scss-old-2/_breakpoint.scss +139 -0
  235. package/trash/scss-old-2/_button.scss +223 -0
  236. package/trash/scss-old-2/_calculate.scss +64 -0
  237. package/trash/scss-old-2/_color.scss +202 -0
  238. package/trash/scss-old-2/_element.scss +263 -0
  239. package/trash/scss-old-2/_grid.scss +558 -0
  240. package/trash/scss-old-2/_index.scss +25 -0
  241. package/trash/scss-old-2/_layout.scss +170 -0
  242. package/trash/scss-old-2/_path.scss +58 -0
  243. package/trash/scss-old-2/_selector.scss +81 -0
  244. package/trash/scss-old-2/_typography.scss +320 -0
  245. package/trash/scss-old-2/_units.scss +47 -0
  246. package/trash/scss-old-2/_utility.scss +12 -0
  247. package/trash/scss-old-2/_utils.scss +186 -0
  248. package/trash/scss-old-2/base/_color.scss +13 -0
  249. package/trash/scss-old-2/base/_elements.scss +182 -0
  250. package/trash/scss-old-2/base/_index.scss +62 -0
  251. package/trash/scss-old-2/base/_keyframes.scss +73 -0
  252. package/trash/scss-old-2/base/_layout.scss +83 -0
  253. package/trash/scss-old-2/base/_normalize.scss +315 -0
  254. package/trash/scss-old-2/base/_typography.scss +41 -0
  255. package/trash/scss-old-2/components/README.md +5 -0
  256. package/trash/scss-old-2/components/README.todos +15 -0
  257. package/trash/scss-old-2/components/_button.scss +95 -0
  258. package/trash/scss-old-2/components/_index.scss +63 -0
  259. package/trash/scss-old-2/components/_links.scss +33 -0
  260. package/trash/scss-old-2/components/_list-lines.scss +73 -0
  261. package/trash/scss-old-2/components/_list-ordered.scss +16 -0
  262. package/trash/scss-old-2/components/_list-unordered.scss +21 -0
  263. package/trash/scss-old-2/components/_rule.scss +84 -0
  264. package/trash/scss-old-2/helpers/_color.scss +14 -0
  265. package/trash/scss-old-2/helpers/_display.scss +67 -0
  266. package/trash/scss-old-2/helpers/_index.scss +67 -0
  267. package/trash/scss-old-2/helpers/_print.scss +58 -0
  268. package/trash/scss-old-2/helpers/_typography.scss +72 -0
  269. package/trash/scss-old-2/helpers/_units.scss +68 -0
  270. package/trash/scss-old-2/helpers/_utilities.scss +81 -0
  271. package/trash/scss-old-2/packages/README.md +3 -0
  272. package/trash/scss-old-2/packages/everything.scss +17 -0
  273. package/trash/scss-old-230729/README.md +58 -0
  274. package/trash/scss-old-230729/_breakpoint.scss +139 -0
  275. package/trash/scss-old-230729/_button.scss +223 -0
  276. package/trash/scss-old-230729/_calculate.scss +64 -0
  277. package/trash/scss-old-230729/_color.scss +202 -0
  278. package/trash/scss-old-230729/_element.scss +273 -0
  279. package/trash/scss-old-230729/_grid.scss +694 -0
  280. package/trash/scss-old-230729/_index.scss +25 -0
  281. package/trash/scss-old-230729/_layout.scss +193 -0
  282. package/trash/scss-old-230729/_path.scss +58 -0
  283. package/trash/scss-old-230729/_selector.scss +81 -0
  284. package/trash/scss-old-230729/_typography.scss +320 -0
  285. package/trash/scss-old-230729/_units.scss +47 -0
  286. package/trash/scss-old-230729/_utility.scss +12 -0
  287. package/trash/scss-old-230729/_utils.scss +186 -0
  288. package/trash/scss-old-230729/base/_color.scss +13 -0
  289. package/trash/scss-old-230729/base/_elements.scss +188 -0
  290. package/trash/scss-old-230729/base/_index.scss +62 -0
  291. package/trash/scss-old-230729/base/_keyframes.scss +73 -0
  292. package/trash/scss-old-230729/base/_layout.scss +83 -0
  293. package/trash/scss-old-230729/base/_normalize.scss +315 -0
  294. package/trash/scss-old-230729/base/_typography.scss +41 -0
  295. package/trash/scss-old-230729/components/README.md +5 -0
  296. package/trash/scss-old-230729/components/README.todos +15 -0
  297. package/trash/scss-old-230729/components/_button.scss +95 -0
  298. package/trash/scss-old-230729/components/_index.scss +63 -0
  299. package/trash/scss-old-230729/components/_links.scss +34 -0
  300. package/trash/scss-old-230729/components/_list-lines.scss +73 -0
  301. package/trash/scss-old-230729/components/_list-ordered.scss +16 -0
  302. package/trash/scss-old-230729/components/_list-unordered.scss +21 -0
  303. package/trash/scss-old-230729/components/_rule.scss +93 -0
  304. package/trash/scss-old-230729/helpers/_color.scss +14 -0
  305. package/trash/scss-old-230729/helpers/_display.scss +73 -0
  306. package/trash/scss-old-230729/helpers/_index.scss +67 -0
  307. package/trash/scss-old-230729/helpers/_print.scss +58 -0
  308. package/trash/scss-old-230729/helpers/_typography.scss +72 -0
  309. package/trash/scss-old-230729/helpers/_units.scss +68 -0
  310. package/trash/scss-old-230729/helpers/_utilities.scss +87 -0
  311. package/trash/scss-old-230729/packages/README.md +3 -0
  312. package/trash/scss-old-230729/packages/everything.scss +17 -0
  313. package/trash/vue/directives/background-image-url.js +12 -0
  314. package/trash/vue/helpers/add-required-components.js +14 -0
  315. package/trash/vue/ui/CollapsibleRegion/CollapsibleRegion.vue +277 -0
  316. package/trash/vue/ui/CollapsibleRegion/Demo.vue +101 -0
  317. package/trash/vue/ui/Dropdown/Dropdown.vue +184 -0
  318. package/trash/vue/ui/Modals/components/Modal.vue +49 -0
  319. package/trash/vue/ui/Modals/components/Modals.vue +103 -0
  320. package/trash/vue/ui/Modals/plugin.js +215 -0
  321. package/trash/vue/ui/Modals/readme.note +10 -0
  322. package/trash/vue/ui/Modals/reference/example-usage.vue +27 -0
  323. package/trash/vue/ui/Modals/reference/wcag-example/dialog.js +324 -0
@@ -0,0 +1,202 @@
1
+ // =============================================================================
2
+ // Flipcard
3
+ // =============================================================================
4
+
5
+ // Version: 1.0.1
6
+
7
+ // Changes 1.0.1 | Added allow selection
8
+
9
+ import { log, logError } from "../utils/logger.js";
10
+ import { trimWhitespace } from "../utils/string.js";
11
+ const debugMode = false; // Global dev debug
12
+
13
+ export class Flipcard {
14
+ static instances = [];
15
+ static defaults = {
16
+ namespace: "Flipcard",
17
+ proxyClick: {
18
+ allowSelection: true, // Don't proxy click if the user has more than the minmimum selected
19
+ selectionMin: 10, // Minimum length that qualifies as a selection
20
+ exclude: "a, input, textarea, button" // Selectors to avoid closing a flipcard onProxyclick
21
+ },
22
+ }
23
+ constructor(container, front, back, config, debug = false) {
24
+ if (!container, !front, !back) {
25
+ logError(this, 'Missing an element (container, front, back)');
26
+ }
27
+ this.options = Object.assign({}, Flipcard.defaults, config);
28
+ const { namespace } = this.options;
29
+ Flipcard.instances.push(this);
30
+
31
+ this.debug = debugMode || debug;
32
+ this.elements = { container, front, back };
33
+ this.isOpen = false;
34
+ this.uid = `${ namespace }-id-${ Flipcard.instances.length }`;
35
+ this.stateAttr = `data-${ namespace }-state`.toLowerCase();
36
+ this.setup();
37
+ this.setVisiblity(false);
38
+ log(this, this);
39
+ }
40
+ toggle() {
41
+ this.setVisiblity(!this.isOpen);
42
+ }
43
+ setup() {
44
+ const { uid } = this;
45
+ const { namespace, proxyClick } = this.options;
46
+ const { container, front, back } = this.elements;
47
+ const control = this.elements.control = document.createElement("button");
48
+
49
+ // Styling and markup
50
+ control.classList.add(this.getClass("control-button"));
51
+ control.setAttribute("type", "button");
52
+ control.innerHTML = this.createControlContent();
53
+ control.style.gridArea = namespace;
54
+ control.style.zIndex = "-1"; // Behind everything only used for focus
55
+ control.addEventListener('focusin', () => {
56
+ control.style.zIndex = "20"; // above the back
57
+ });
58
+ control.addEventListener('focusout', () => {
59
+ control.style.zIndex = "-1"
60
+ });
61
+ control.addEventListener("click", this.toggle.bind(this));
62
+ back.parentNode.insertBefore(control, back);
63
+
64
+ container.classList.add(this.options.namespace);
65
+ container.setAttribute("style", trimWhitespace(this.containerCss()));
66
+ if (proxyClick) {
67
+ container.addEventListener("click", this.onProxyClick.bind(this));
68
+ }
69
+
70
+ front.style.gridArea = namespace;
71
+ back.style.gridArea = namespace;
72
+
73
+ // Accessibility
74
+ control.id = `${ uid }-control`;
75
+ control.setAttribute("aria-controls", back.id);
76
+ control.setAttribute("aria-expanded", "false");
77
+ back.id = `${ uid }-back`;
78
+ back.setAttribute('aria-labelledby', control.id)
79
+ back.setAttribute('aria-hidden', "true");
80
+ }
81
+ /**
82
+ * Click handler on everything on container
83
+ * - Determines if click was something that should be ignored (link, etc)
84
+ */
85
+ onProxyClick({ target }) {
86
+ const { exclude, allowSelection, selectionMin } = this.options.proxyClick;
87
+ const selection = window.getSelection();
88
+ if (exclude && !target.matches(exclude)) {
89
+ if (!allowSelection || selection.toString().length < selectionMin) {
90
+ this.toggle();
91
+ }
92
+ }
93
+ }
94
+ getClass(child) {
95
+ const { namespace } = this.options;
96
+ return child ? `${ namespace }__${ child }` : namespace;
97
+ }
98
+ createControlContent() {
99
+ return `
100
+ <span class="hidden-visually">Show More Information</span>
101
+ `;
102
+ }
103
+ setVisiblity(visible) {
104
+ const { back, container, control } = this.elements;
105
+ const state = visible ? "open" : "closed";
106
+ back.style.zIndex = visible ? "10" : "1";
107
+ back.style.visibility = visible ? "visible" : "hidden";
108
+ container.setAttribute(this.stateAttr, state);
109
+ back.setAttribute('aria-hidden', visible ? "false" : "true");
110
+ control.setAttribute('aria-expanded', visible ? "true" : "false");
111
+ this.isOpen = visible;
112
+ }
113
+ containerCss() {
114
+ return `
115
+ display: -ms-grid;
116
+ display: grid;
117
+ position: relative;
118
+ -ms-grid-columns: 1fr;
119
+ grid-template-columns: 1fr;
120
+ justify-items: stretch;
121
+ grid-template-areas: "${ this.options.namespace }";
122
+ cursor: pointer;
123
+ `;
124
+ }
125
+ panelCss(zIndex = 1) {
126
+ return `
127
+ grid-area: ${ this.options.namespace };
128
+ z-index: ${ zIndex }
129
+ `;
130
+ }
131
+ }
132
+ export default Flipcard;
133
+
134
+ /**
135
+ * Preliminary Notes:
136
+ * Considerations for Accessiblity:
137
+ * - https://webaim.org/standards/wcag/checklist
138
+ * - https://www.w3.org/TR/WCAG21/#on-focus
139
+ * - https://a11y-style-guide.com/style-guide/section-cards.html
140
+ * - Reduced Motion
141
+ * - Percievable (interactive)
142
+ * - Final Descision
143
+ * - Use a buttons
144
+ * - Why?
145
+ * - Can't use whole card surface as click
146
+ * * Selections
147
+ * * Other interactions
148
+ * * How to make that make sense to SR
149
+ * * Keyboard focuses and then clicks
150
+ * * Accidental flipping on zoom
151
+ * - Can't use hover
152
+ *
153
+ * - BRAINSTORM START:
154
+ * - Don't use hover or focus (motor control issues)
155
+ * - Needs to use click
156
+ * - Run through screenreader expierence
157
+ * - Hits button (reads title, click to reveal)
158
+ * - Focuses the content button (reads content, backside, click to unreveal)
159
+ * - NO BUTTONS CAN"T HAVE CONTENT, BUTTONS NEED TO STATE THEIR INTENT
160
+ * - Try Again, Run through screenreader expierence
161
+ * - Screen reader encounters flipcard
162
+ * - Headline is read
163
+ * - Button is read (reveal description)
164
+ * - Button is clicked
165
+ * - Content is shown and focused
166
+ * - Button to flip back
167
+ * - For Keybaord users
168
+ * - The accessible buttons can be used or a click handler can be attached to the
169
+ * flipcard and given
170
+ * - Why not always show the content to screenreaders?
171
+ * - How to hide controls from them? (controls can't be hidden)
172
+ * - How to not have events interfere click
173
+ * - Maybe use a single control and make it say "jumpto definition"
174
+ * - Kind of lame
175
+ * - What about going back to focus and then attaching a click handler?
176
+ * - Visual users will see the content on keyboard or mouse or touch
177
+ * - We can reduce the motion with query
178
+ * - Note: WCAG AAA - 1.4.13 Content on Hover or Focus
179
+ * - Need to bind escape
180
+ * - Mouse users and touch will need to click
181
+ * - How does it focus and work on a screenreader?
182
+ * - Cannot use FOCUS!
183
+ * - https://www.w3.org/WAI/WCAG21/Understanding/on-focus.html
184
+ * - What if the user was zoomed? They may never see the title/front
185
+ * - I think it MUST use buttons or a button to flip
186
+ * - Because users need to be able to scroll, interact and select text in a back
187
+ * @example html
188
+ * <div class="flipcard">
189
+ * <h3 class="flipcard__front">
190
+ * Term Name
191
+ * <button class="flipcard__toggle">
192
+ * <span class="hidden-visually">Show Definition</span>
193
+ * </button>
194
+ * </h3>
195
+ * <div class="flipcard__back">
196
+ * Some definiton example lorem ipsum et depsi anu olor.
197
+ * <button class="flipcard__toggle">
198
+ * <span class="hidden-visually">Hide Definition</span>
199
+ * </button>
200
+ * </div>
201
+ * </div>
202
+ */
package/js/ui/grid.js ADDED
@@ -0,0 +1,67 @@
1
+ import { getName } from "../events/index.js";
2
+
3
+ /**
4
+ * Sets up document for grid position classes
5
+ * @param {String} selector The selector for the parent element
6
+ * @param {Object} classes Classes (optional) @see setPositionClasses
7
+ */
8
+ export function init(selector = "[data-grid]", classes) {
9
+ document.addEventListener(getName("pageModified"), () => setup(selector, classes));
10
+ document.addEventListener(getName("pageResized"), () => setup(selector, classes));
11
+ setup(selector, classes);
12
+ }
13
+
14
+ /**
15
+ * Goes through document and finds elements that need to have positioning classes
16
+ * @param {String} selector The selector for the parent element
17
+ * @param {Object} classes Classes (optional) @see setPositionClasses
18
+ */
19
+ export function setup(selector, classes) {
20
+ document.querySelectorAll(selector).forEach(element => setPositionClasses(element, classes || undefined));
21
+ }
22
+
23
+ /**
24
+ * Sets up the positonal classes that would come from the equal
25
+ * height module. Needs to be rerun by user when layout changes
26
+ * or new instances are added to the screen
27
+ * - Used for gutter crops
28
+ * - Used for rule placement
29
+ * - **Devs** Remember that default classes should match sass defaults
30
+ * @param {Node} parent The grid parent <data-grid="">
31
+ * @param {Object} classes Override the default equal heights classes
32
+ */
33
+ export function setPositionClasses(parent, classes = {
34
+ columnFirst: 'position-column-first',
35
+ columnLast: 'position-column-last',
36
+ rowFirst: 'position-row-first',
37
+ rowLast: 'position-row-last'
38
+ }) {
39
+ const children = [...parent.children];
40
+ const rows = [];
41
+ let lastY;
42
+ // Check element against last
43
+ // If they don't match it's a new row create a new array
44
+ // Then push into the last array in the rows array
45
+ children.forEach((child) => {
46
+ const y = child.getBoundingClientRect().y;
47
+ if (lastY !== y) rows.push([]);
48
+ rows[rows.length - 1].push(child);
49
+ lastY = y;
50
+ child.classList.remove(...Object.values(classes)); // Remove previously set classes
51
+ });
52
+ // Apply Classes
53
+ rows.forEach((row, index) => {
54
+ if (index === 0)
55
+ row.forEach(child => child.classList.add(classes.rowFirst));
56
+ if (index == rows.length - 1)
57
+ row.forEach(child => child.classList.add(classes.rowLast));
58
+
59
+ row.forEach((child, childIndex) => {
60
+ if (childIndex === 0)
61
+ child.classList.add(classes.columnFirst);
62
+ if (childIndex == row.length - 1)
63
+ child.classList.add(classes.columnLast);
64
+ });
65
+ });
66
+
67
+ }
@@ -0,0 +1,219 @@
1
+ // Version: 1.0.4
2
+ // Changes:
3
+ // 1.0.4 | The modal library has a bug with multiple modals and using a custom close handler
4
+ // In the future we want to abandon this library but for now it works by setting up our own open and close buttons
5
+ // This is not setup to work with programmatic modals!!
6
+ // 1.0.3 | Added youtube video closing stuff
7
+ // 1.0.3 | Added youtube video closing stuff
8
+ // 1.0.2 | Added custom close handler and checked to make sure resizer doesn't trigger click
9
+ // 1.0.1 | Added optional resizable (allowResize)
10
+ // Todo: - Make the container the content is getting the orginal classes, or don't remove them. And allow user to pass classes via config
11
+
12
+ // Javascript builds strucutre, modal's live in content in simple container.
13
+ // Modal theme and strucutre is added in scripting That way if we change the
14
+ // interface in the future we don't need to change/update markup.
15
+ import MicroModal from 'micromodal';
16
+ import Resizer from './resizer.js';
17
+ import { createElementFromHtml } from '../utils/dom.js';
18
+ import { pauseVideos, prepVideos } from '../helpers/pause-youtube-video.js';
19
+ const classes = {
20
+ open: 'site-modal--open',
21
+ container: "site-modal__container",
22
+ body: "site-modal__body",
23
+ resizer: "site-modal__resizer"
24
+ };
25
+ const triggerAttr = "data-site-modal-trigger";
26
+ export { triggerAttr };
27
+ const triggerSelector = `[${ triggerAttr }]`;
28
+ const defaults = {
29
+ allowResize: true,
30
+ position: "center",
31
+ containerClass: "",
32
+ closeSelector: "[data-site-modal-close]"
33
+ };
34
+ const configMicroModal = {
35
+ openClass: classes.open,
36
+ disableScroll: true,
37
+ openTrigger: 'data-site-modal-trigger',
38
+ closeTrigger: 'data-NOT-USED', // Proxied to avoid this click handler (on keydown, allow click on things underneath)
39
+ onClose: function(modal) {
40
+ pauseVideos(modal);
41
+ }
42
+ };
43
+ const wrappers = [];
44
+
45
+
46
+ // Create a grouping container to grab all modals from content of the
47
+ // page and move to the bottom of the page
48
+ // const container = createContainer();
49
+
50
+ // The [data-site-modal] is used to seperate the libraries' interface
51
+ // and the modal's styling classes, so it can be adjusted or extended
52
+ // in the future
53
+ document.querySelectorAll('[data-site-modal]').forEach((element) => setupModal(element));
54
+
55
+ // Intialize modal library script
56
+ // init();
57
+ attachTriggers();
58
+
59
+ export function attachTriggers(context = document) {
60
+ const flag = 'data-site-modal-trigger-attached';
61
+ context.querySelectorAll(triggerSelector).forEach(trigger => {
62
+ if (!trigger.hasAttribute(flag)) {
63
+ const mid = trigger.getAttribute(triggerAttr);
64
+ if (!mid) {
65
+ console.warn("Unable to get modal trigger id");
66
+ } else {
67
+ trigger.setAttribute(flag, "");
68
+ trigger.addEventListener("click", () => {
69
+ show(mid)
70
+ });
71
+ }
72
+ }
73
+ });
74
+ }
75
+
76
+ /**
77
+ * Function to setup each modal
78
+ * - Creates structure
79
+ * - Gets settings from elements data attrite
80
+ * - Moves it to the end of the document
81
+ * - Adds resizer if position (left || right)
82
+ * @param {Node} modal Modal element ie. `[data-site-modal]`
83
+ * @param {Object} settings Custom settings object to merge, same interface as `[data-site-modal]` settings
84
+ */
85
+ export function setupModal(modal, settings) {
86
+ // Grab things from original element before modifying
87
+ const id = modal.id;
88
+ const originalClasses = modal.getAttribute('class') || '';
89
+ // Grab settings from element and optionally from settings passed
90
+ let data = {};
91
+ if (modal.dataset.siteModal) {
92
+ data = JSON.parse(modal.dataset.siteModal)
93
+ }
94
+ data = Object.assign({}, defaults, data, settings);
95
+ const { allowResize, position } = data;
96
+ const notCenter = position !== "center";
97
+ const hasResizer = notCenter && allowResize;
98
+ const resizerMarkup = hasResizer ? `<div class="${ classes.resizer }"></div>` : '';
99
+ const resizerModifierClass = allowResize ? "resize" : "no-resize";
100
+ const closeAttr = "data-site-modal-close";
101
+ // Remove attributes
102
+ modal.removeAttribute('data-site-modal');
103
+ modal.removeAttribute('id');
104
+ modal.removeAttribute('class');
105
+ // Template for new modal container (modal's body, the original element is
106
+ // appended after as not to lose any listerner's/etc
107
+ const markup = `
108
+ <div
109
+ class="
110
+ site-modal
111
+ site-modal--${ position }
112
+ site-modal--${ resizerModifierClass }
113
+ ${ data.containerClass }
114
+ "
115
+ id="${ id }" aria-hidden="true"
116
+ >
117
+ <div class="site-modal__overlay" tabindex="-1" ${ closeAttr }>
118
+ <div class="site-modal__container" role="dialog" aria-modal="true" aria-labelledby="${ id }-title">
119
+ <div class="site-modal__header">
120
+ <h2 class="site-modal__title" id="${ id }-title" tabindex="0">${ data.title }</h2>
121
+ <button class="site-modal__close" aria-label="Close modal" ${ closeAttr }>
122
+ <span class="site-modal__close-icon" aria-hidden="true" ${ closeAttr }></span>
123
+ </button>
124
+ </div>
125
+ <div class="${ classes.body } ${ originalClasses }"></div>
126
+ ${ resizerMarkup }
127
+ </div>
128
+ </div>
129
+ </div>`;
130
+
131
+ // Create wrapped modal (with repeatable structure), and insert
132
+ // the original modal content into it
133
+ const select = (container, classKey) => container.querySelector("." + classes[classKey]);
134
+ const wrapper = createElementFromHtml(markup.trim());
135
+ const elements = {
136
+ body: select(wrapper, 'body'),
137
+ resizer: select(wrapper, 'resizer'),
138
+ container: select(wrapper, 'container')
139
+ };
140
+
141
+ // Move the orginal content into the modal's body
142
+ elements.body.appendChild(modal);
143
+ // Add resizer if not a center positioned modal
144
+ if (hasResizer) {
145
+ new Resizer(elements.container, elements.resizer, {
146
+ fromLeft: position === "right"
147
+ });
148
+ }
149
+
150
+ // Prep Youtube Videos to be able to close
151
+ prepVideos(wrapper);
152
+
153
+ // Add modal to the end of docuemnt
154
+ wrappers.push(wrapper);
155
+ document.body.appendChild(wrapper);
156
+ // Add our own close handlers to avoide the native
157
+ const closeButtons = wrapper.querySelectorAll(data.closeSelector);
158
+ closeButtons.forEach(b => b.addEventListener('click', ({ target }) => {
159
+ const outsideContainer = !elements.container.contains(target) && target !== elements.container;
160
+ // Last condition is the overlay/backdrop (click outside)
161
+ if (target.matches(`[${ closeAttr }]`) || outsideContainer) {
162
+ close(id);
163
+ }
164
+ }));
165
+ }
166
+ /**
167
+ * Intialize all modals on the page
168
+ * - can be used after AJAX adds content
169
+ */
170
+ // export function init() {
171
+ // MicroModal.init(configMicroModal);
172
+ // }
173
+ /**
174
+ * Open a modal
175
+ * @param {String} id The id of the modal to open
176
+ */
177
+ export function show(id, config) {
178
+ const merged = Object.assign({}, configMicroModal, config);
179
+ MicroModal.show(id, merged);
180
+ }
181
+ /**
182
+ * Close a modal
183
+ * @param {String} id The id of the modal to open
184
+ */
185
+ export function close(id) {
186
+ MicroModal.close(id);
187
+ }
188
+
189
+
190
+
191
+ // function createContainer() {
192
+ // const container = document.createElement('div');
193
+ // container.classList.add('site-modals');
194
+ // document.body.appendChild(container);
195
+ // return container;
196
+ // }
197
+
198
+ // From GITHUB Issues (user remedy)
199
+ // export function refresh() {
200
+ // // Use whatever selector you're using for MicroModal triggers.
201
+ // const modalTrigger = 'data-micromodal-trigger';
202
+
203
+ // // Get all triggers.
204
+ // const modalTriggers = document.querySelectorAll( `[${modalTrigger}]` );
205
+
206
+ // modalTriggers.forEach( trigger => {
207
+ // // Get the attribute to save.
208
+ // const triggerElement = trigger.getAttribute( modalTrigger );
209
+
210
+ // // Remove the attribute briefly to clear memory/existing modals.
211
+ // trigger.removeAttribute( modalTrigger );
212
+
213
+ // // Immediately add it back.
214
+ // trigger.setAttribute( modalTrigger, triggerElement );
215
+
216
+ // // Re-initialize.
217
+ // init();
218
+ // } );
219
+ // }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Function to be used in overflow scrollers "amount" option. This function will
3
+ * determine how many items can fit in the viewport, taking into account scroll padding left,
4
+ * and will set the scroll amount to paginate between items. Items size can be anything
5
+ * (ie. one per screen vs 3.5 per screen will both work). This seperated from the plugin
6
+ * for tree shaking incase it's unneeded. Currently this is only setup for horizontal scrolling
7
+ *
8
+ * Note: This is setup to return the function, incase configuration is needed in the future
9
+ * it can be passed to the create function
10
+ *
11
+ * @return {Function} A function to be used in overflow scrollers "amount" configuration property
12
+ */
13
+
14
+ export default function create() {
15
+ return function pager(instance, dir) {
16
+ const isNext = dir === "next";
17
+ const { track } = instance.elements;
18
+ if (!track.children) return 400;
19
+ const trackStyle = window.getComputedStyle(track);
20
+ // Note we are banking on the scroll padding string to be in "px", not doing any conversions here
21
+ const scrollPaddingRaw = trackStyle.getPropertyValue( 'scroll-padding-left' ).replace( 'auto', '0px' );
22
+ const scrollPadding = parseInt(scrollPaddingRaw, 10);
23
+
24
+ const { scrollLeft, offsetWidth } = track;
25
+ const right = scrollLeft + offsetWidth;
26
+ // Get all slide positions into an array
27
+ const slides = [ ...track.children ].map(element => {
28
+ const { offsetLeft, offsetWidth } = element;
29
+ return {
30
+ element,
31
+ offsetLeft,
32
+ offsetRight: offsetLeft + offsetWidth
33
+ };
34
+ });
35
+ // Test edges to see what can fit, slide found will be the slide to scroll to
36
+ let slideFound;
37
+ if (isNext) {
38
+ // Find the first item that didn't make it
39
+ slideFound = slides.find(slide => slide.offsetRight >= right);
40
+ } else {
41
+ let slideBeforeIndex = slides.findLastIndex(slide => slide.offsetLeft <= scrollLeft);
42
+ // Find the slides before this slide that can fit, including the slide before
43
+ if (slideBeforeIndex) {
44
+ let slideBefore = slides[slideBeforeIndex];
45
+ let slidesBefore = slides.slice(0, slideBeforeIndex + 1);
46
+ slideFound = slidesBefore.find(slide => {
47
+ const rightEdge = slide.offsetLeft + scrollPadding + offsetWidth;
48
+ return rightEdge >= slideBefore.offsetRight;
49
+ });
50
+ }
51
+ }
52
+ if (slideFound) {
53
+ return isNext ? slideFound.offsetLeft : slideFound.offsetLeft + scrollPadding;
54
+ } else {
55
+ return 400;
56
+ }
57
+ }
58
+ }