@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,122 @@
1
+ /**
2
+ * Returns an array of direct descendants
3
+ * @param {Node} element
4
+ * @param {String} selector
5
+ * @return {Array}
6
+ */
7
+ export function getDirectDescandants(element, selector) {
8
+ return [...element.children].filter(child => child.matches(selector));
9
+ };
10
+
11
+ /**
12
+ * Checks if element is overflown vertically
13
+ * @param {Node} element
14
+ * @return {Boolean}
15
+ */
16
+ export function isOverflownY(element) {
17
+ return element.scrollHeight > element.clientHeight;
18
+ }
19
+
20
+ /**
21
+ * Checks if element is overflown both vertically and horizontally
22
+ * @param {Node} element
23
+ * @return {Boolean}
24
+ */
25
+ export function isOverflown(element) {
26
+ return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
27
+ }
28
+
29
+ /**
30
+ * For a given element return the first parent that has scrollable overflow
31
+ * - Helpful for debugging position sticky
32
+ * @param {Node} node Node to start search for first scrollable parent
33
+ * @returns {Node}
34
+ * @example
35
+ * const $navcontent = document.querySelector('.nav__content');
36
+ * if ($navcontent) {
37
+ * console.log(getScrollParent($navcontent));
38
+ * }
39
+ */
40
+ export function getScrollParent(node) {
41
+ if (node == null) {
42
+ return null;
43
+ }
44
+ if (node.scrollHeight > node.clientHeight) {
45
+ return node;
46
+ } else {
47
+ return getScrollParent(node.parentNode);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Returns reliable document height
53
+ * @return {number}
54
+ */
55
+ export function documentHeight() {
56
+ return Math.max(
57
+ document.body.scrollHeight, document.documentElement.scrollHeight,
58
+ document.body.offsetHeight, document.documentElement.offsetHeight,
59
+ document.body.clientHeight, document.documentElement.clientHeight
60
+ );
61
+ }
62
+
63
+ /**
64
+ * Returns reliable window height
65
+ * @return {number}
66
+ */
67
+ export function windowHeight() {
68
+ return Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
69
+ }
70
+
71
+ /**
72
+ * Returns reliable window width
73
+ * @return {number}
74
+ */
75
+ export function windowWidth() {
76
+ return Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
77
+ }
78
+
79
+ /**
80
+ * Check browser support for position: sticky
81
+ * - https://stackoverflow.com/questions/60214332/dynamically-detect-if-positionsticky-is-supported-by-the-browser
82
+ * @return {Boolean}
83
+ */
84
+ export function browserWithPositionSticky() {
85
+ var prop = 'position:';
86
+ var value = 'sticky';
87
+ var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
88
+
89
+ var el = document.createElement('a');
90
+ var mStyle = el.style;
91
+ mStyle.cssText = prop + prefixes.join(value + ';' + prop).slice(0, - prop.length);
92
+
93
+ return mStyle.position.indexOf(value) !== -1;
94
+ }
95
+
96
+ /**
97
+ * Returns Node List from HTML markup string
98
+ * @param {String} markup HTML markup to create into an element
99
+ */
100
+ export function createElementFromHtml(markup) {
101
+ const doc = new DOMParser().parseFromString(markup, 'text/html');
102
+ return doc.body.firstElementChild;
103
+ }
104
+
105
+ /**
106
+ * Creates a new element with attributes and children
107
+ * @param {Object} config Configuration object
108
+ * @param {String} config.tag Node type (ie 'div')
109
+ * @param {Object} config.attributes Attributes to add to the new element
110
+ * @param {Array} config.children Array of children to append into the new element
111
+ */
112
+ export function composeElement(config) { // tag, attributes = {}, children
113
+ const { tag, attributes, children } = config;
114
+ const element = document.createElement(tag);
115
+ if (attributes) {
116
+ Object.entries(attributes).forEach((a, v) => element.setAttribute(a, v));
117
+ }
118
+ if (children) {
119
+ children.forEach(c => element.appendChild(c));
120
+ }
121
+ return element;
122
+ }
@@ -0,0 +1,69 @@
1
+ // Goal: minimzing console conditions for nessasary production log statements
2
+
3
+ /**
4
+ * Configuration Object
5
+ */
6
+ const config = {
7
+ debug: false,
8
+ warningsAlways: true,
9
+ errorsAlways: true,
10
+ outputContext: false
11
+ };
12
+
13
+ const hasConsole = "console" in window;
14
+
15
+ // If no context output only if config (global) debug is enabled
16
+ function allow(context) {
17
+ return hasConsole && config.debug && (context?.debug || context == null);
18
+ };
19
+ function getName(context) {
20
+ return typeof context === "object" && context?.constructor?.name;
21
+ };
22
+ function output(method, context, messages) {
23
+ const label = getName(context) || "Logger";
24
+ console[method](label, ...messages);
25
+ if (config.outputContext) {
26
+ console.log('Context:\n', context);
27
+ }
28
+ };
29
+
30
+ /**
31
+ * Changes to make to configuration
32
+ * @param {Object} changes
33
+ */
34
+ export function set(changes) {
35
+ Object.assign(config, changes);
36
+ }
37
+
38
+ /**
39
+ * Proxy Console.log
40
+ * @param {Object} context Class instance (optional), will rely on classes (debug) property for output
41
+ * @param {...any} messages
42
+ */
43
+ export function log(context, ...messages) {
44
+ if (allow(context)) {
45
+ output("log", context, messages);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Proxy Console.warn
51
+ * @param {Object} context Class instance (optional), will rely on classes (debug) property for output
52
+ * @param {...any} messages
53
+ */
54
+ export function logWarning(context, ...messages) {
55
+ if (config.warningsAlways || allow(context)) {
56
+ output("warn", context, messages);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Proxy Console.error
62
+ * @param {Object} context Class instance (optional), will rely on classes (debug) property for output
63
+ * @param {...any} messages
64
+ */
65
+ export function logError(context, ...messages) {
66
+ if (config.errorsAlways || allow(context)) {
67
+ output("error", context, messages);
68
+ }
69
+ }
@@ -0,0 +1,22 @@
1
+ // Version: 1.0.0
2
+
3
+ /**
4
+ * Checks object has required properties
5
+ * @param {array.string} required Array of properties to check for
6
+ * @return {function} Function for user to use to test for props passed on objects
7
+ * @example
8
+ * const testProps = hasRequiredProps(["name", "date"]);
9
+ * if (testProps(userConfiguration)) {
10
+ * // Stuff
11
+ * }
12
+ */
13
+ export function hasRequiredProps(required) {
14
+ /**
15
+ * Function used for testing on user end
16
+ * @param {object} testObject Object to test on
17
+ * @return {Boolean}
18
+ */
19
+ return function(object) {
20
+ return required.every(value => object.hasOwnProperty(value));
21
+ }
22
+ }
@@ -0,0 +1,43 @@
1
+ // Version: 1.0.0
2
+
3
+ /**
4
+ * Returns a function, that, as long as it continues to be invoked, will not be triggered
5
+ * @param {Function} callback Function to invoke
6
+ * @param {Number} wait Amount of time after (milliseconds)
7
+ * @param {Boolean} immediate trigger the function on the leading edge, instead of the trailing.
8
+ * @param {Object} valueThis Context for function
9
+ * @author David Walsh
10
+ * - https://davidwalsh.name/javascript-debounce-function
11
+ */
12
+ export function debounce(callback, wait, immediate, valueThis) {
13
+ var timeout;
14
+ return function executedFunction() {
15
+ var context = valueThis || this;
16
+ var args = arguments;
17
+ var later = function() {
18
+ timeout = null;
19
+ if (!immediate) callback.apply(context, args);
20
+ };
21
+ var callNow = immediate && !timeout;
22
+ clearTimeout(timeout);
23
+ timeout = setTimeout(later, wait);
24
+ if (callNow) callback.apply(context, args);
25
+ };
26
+ }
27
+
28
+ /**
29
+ * Debounces function using requestAnimationFrame()
30
+ * @param {Function} callback Function to invoke, cancelled if called faster than RAF
31
+ * @param {Object} context Optional context to bind to callback
32
+ */
33
+ export function debounceAnimationFrame(callback, context = null) {
34
+ let tid;
35
+ return function debounced() {
36
+ const args = arguments;
37
+ if (tid) window.cancelAnimationFrame(tid);
38
+ tid = window.requestAnimationFrame(() => {
39
+ tid = false;
40
+ callback.apply(context, args);
41
+ });
42
+ };
43
+ }
@@ -0,0 +1,10 @@
1
+ // Version: 1.0.0
2
+
3
+ /**
4
+ * Common Regular Expression Patterns
5
+ */
6
+ export const patterns = {
7
+ linebreaks: /(\r\n|\n|\r)/gm,
8
+ multiSpace: /\s+/g,
9
+ htmlTag: /<\/?[^>]+(>|$)/g
10
+ };
@@ -0,0 +1,107 @@
1
+ import { patterns } from "./regex.js";
2
+ /**
3
+ * Will return an object with the separation details
4
+ * @param {[type]} string [description]
5
+ * @return {object} keys: value, original, unit
6
+ */
7
+ export function separateCssUnit(original) {
8
+ const pattern = /(px|vw|vh|%|em|rem)/i;
9
+ return {
10
+ original,
11
+ value: original.replace(pattern, ""),
12
+ unit: original.match(pattern)[0]
13
+ };
14
+ }
15
+
16
+ /**
17
+ * Removes HTML tags from string
18
+ * - Note you can use document.createElement and grab textContent (but this could execute code in browser)
19
+ * - The method below will just use regex without creating Nodes
20
+ * @param {String} html HTML string to find/replace
21
+ */
22
+ export function stripTags(html) {
23
+ return html.replace(patterns.htmlTag, "");
24
+ }
25
+
26
+ /**
27
+ *
28
+ * @param {String} string String to trim
29
+ * @returns
30
+ */
31
+ export function trimDoubleSpaces(string) {
32
+ return string.replace(patterns.multiSpace, "");
33
+ }
34
+
35
+ /**
36
+ * Remove line breaks
37
+ * @param {String} string String to trim
38
+ * @returns {String}
39
+ */
40
+ export function trimLineBreaks(string) {
41
+ return string.replace(patterns.linebreaks, "");
42
+ }
43
+
44
+ /**
45
+ * Designed originally to flatten style definitions
46
+ * @param {String} string String to trim
47
+ * @returns {String}
48
+ */
49
+ export function trimWhitespace(string) {
50
+ return string.replace(patterns.linebreaks, "")
51
+ .replace(patterns.multiSpace, " ")
52
+ .trim();
53
+ }
54
+
55
+ /**
56
+ * Truncates string with ellipsis if over the max, note use framework function
57
+ * if you need to know the effects of the truncate process (returns an object
58
+ * with info instead) this function only modifies the string
59
+ * @param {string} string String to possibly truncate
60
+ * @param {number} max How many characters max?
61
+ * @return {string}
62
+ */
63
+ export function truncate(string, max, overflowChar = '…') {
64
+ return string.length <= max ? string : string.slice(0, max) + overflowChar;
65
+ }
66
+
67
+ /**
68
+ * Replaces non safe characters with "-"
69
+ * - Does not escape characters
70
+ * - Used for id's and classnames or things that can't have anything but normal a-z 0-9
71
+ */
72
+ export function urlize(string) {
73
+ var newString;
74
+ string = string.replace(/^[^-_a-zA-Z]+/, '').replace(/^-(?:[-0-9]+)/, '-');
75
+ newString = string && string.replace(/[^-_a-zA-Z0-9]+/g, '-');
76
+ return newString;
77
+ }
78
+
79
+ /**
80
+ * Converts date to abbreviated month date ie "Mar 7, 2018"
81
+ * @param {String|Date} str Date or date string (passed through date constructor)
82
+ * @return {String} Pretty date string
83
+ */
84
+ export function prettyDate(str) {
85
+ const date = new Date(str);
86
+ const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
87
+ return `${ months[date.getMonth()] } ${ date.getDate() }, ${ date.getFullYear() }`;
88
+ }
89
+
90
+ /**
91
+ * Generates a random string of defined length based on
92
+ * a string of allowed characters.
93
+ *
94
+ * @param {number} length How many random characters will be in the returned string. Defaults to 10
95
+ * @param {string} allowed Which characters can be used when creating the random string. Defaults to A-Z,a-z,0-9
96
+ * @return {string} A string of random characters
97
+ */
98
+ export function randomString(
99
+ length = 10,
100
+ allowed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
101
+ ) {
102
+ let result = '';
103
+ for (let i = 0; i < length; i++) {
104
+ result += allowed.charAt(Math.floor(Math.random() * allowed.length));
105
+ }
106
+ return result;
107
+ }
@@ -0,0 +1,3 @@
1
+ # Waypoints
2
+
3
+ Plugins/scripts for waypoints
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @todo This file is untested since conversion to module
3
+ */
4
+
5
+ import ElementWaypoint from "../waypoints/element-waypoint.js";
6
+
7
+ export default function init(anchors, caret, options) {
8
+ const defaults = {
9
+ offsetTop: "20%",
10
+ activeClass: "active"
11
+ };
12
+ options = Object.assign(defaults, options);
13
+
14
+ const targets = anchors.map(a => document.getElementById(a.hash.substr(1)));
15
+ const { activeClass } = options;
16
+ let caretNotEntered = true;
17
+ let caretVisible;
18
+
19
+ targets.forEach(element => new ElementWaypoint({ offsetTop: options.offsetTop, handler, element }));
20
+
21
+ function handler(entering, direction) {
22
+ const { element } = this.options;
23
+ const anchor = anchors[ targets.indexOf(element) ];
24
+ const index = anchors.indexOf(anchor);
25
+
26
+ if (entering) {
27
+ removeActiveAll();
28
+ activateAnchor(anchor);
29
+ anchor.classList.add(activeClass);
30
+ // Above the first
31
+ } else if (index === 0 && direction === "up") {
32
+ removeActiveAll(true);
33
+ // Since we are using headlines instaed of containers we need to
34
+ // activate when user is scrolling up. By finding the index of the anchor
35
+ // above the recently deactivated headline target
36
+ } else if (direction === "up") {
37
+ removeActiveAll();
38
+ activateAnchor(anchors[index - 1]);
39
+ }
40
+ }
41
+ function removeActiveAll(hideCaret) {
42
+ anchors.forEach(anchor => anchor.classList.remove(activeClass));
43
+ if (hideCaret) {
44
+ setCaretVisibility(false);
45
+ }
46
+ }
47
+ function activateAnchor(anchor) {
48
+ // Block transtions on first reveal
49
+ if (caretNotEntered) {
50
+ caret.style.transition = 'none';
51
+ }
52
+ anchor.classList.add(activeClass);
53
+ setCaretPosition(anchor);
54
+ if (!caretVisible) {
55
+ setCaretVisibility(true);
56
+ }
57
+ // Add the transitions back in for the next change to visiblity or position
58
+ if (caret && caretNotEntered) {
59
+ caretNotEntered = false;
60
+ caret.offsetHeight; // Force repaint (visiblity above)
61
+ caret.style.transition = ''; // Then remove the transition block
62
+ }
63
+ }
64
+ function setCaretPosition(anchor) {
65
+ if (!caret) return;
66
+ const position = anchor.offsetTop;
67
+ const height = anchor.clientHeight;
68
+ caret.style.transform = `translateY(${ position + (height / 2) }px)`;
69
+ // caret.style.height = `${ anchor.clientHeight }px`;
70
+ }
71
+ function setCaretVisibility(visible) {
72
+ if (!caret) return;
73
+ caret.style.opacity = +(visible);
74
+ caretVisible = visible;
75
+ }
76
+ }
@@ -0,0 +1,75 @@
1
+ // =============================================================================
2
+ // Element Waypoint
3
+ // =============================================================================
4
+
5
+ // Version: 1.0.1
6
+
7
+ // Requires: Global access to window.Waypoint
8
+
9
+ /**
10
+ * Reusable waypoint class that adds two waypoints in order to call user
11
+ * handler when the element is in view or out of view.
12
+ */
13
+ export default class ElementWaypoint {
14
+ static defaults = {
15
+ context: window,
16
+ offsetTop: 0,
17
+ offsetBottom: 0,
18
+ };
19
+ /**
20
+ * Fired when the scroll trigger enters and leaves an element
21
+ *
22
+ * @callback handler
23
+ * @param {Boolean} entering Whether the user has entered the element
24
+ * @param {String} direction The direction they entered/exited from (up|down)
25
+ */
26
+ /**
27
+ *
28
+ * @param {Object} options Options to merge with defaults
29
+ * @param {HTMLElement} options.element Element to wacth
30
+ * @param {HTMLElement} options.context Context for Waypoints (element scrollable parent)
31
+ * @param {String|Function} options.offsetBottom Offset below the element (see Waypoints API)
32
+ * @param {String|Function} options.offsetTop Offset above the element (see Waypoints API)
33
+ * @param {handler} options.handler Fired when the scroll trigger enters and leaves an element
34
+ */
35
+ constructor(options) {
36
+ this.options = Object.assign({}, ElementWaypoint.defaults, options);
37
+ const {
38
+ handler,
39
+ offsetTop,
40
+ offsetBottom,
41
+ element,
42
+ context
43
+ } = this.options;
44
+ // instantiates waypoint instances (top and bottom of element)
45
+ // The offset bottom is function so it can be recalculated
46
+ // User offsetBottom can be a function as well
47
+ this.top = new Waypoint({
48
+ element,
49
+ context,
50
+ offset: offsetTop,
51
+ handler(d) {
52
+ handler.call(this, d === "down", d);
53
+ },
54
+ });
55
+ this.bottom = new Waypoint({
56
+ element,
57
+ context,
58
+ offset() {
59
+ const offset = typeof offsetBottom === "function" ? offsetBottom() : offsetBottom;
60
+ const height = this.element.offsetHeight;
61
+ return (-height) + offset;
62
+ },
63
+ handler(d) {
64
+ handler.call(this, d === "up", d);
65
+ }
66
+ });
67
+ }
68
+ /**
69
+ * Destroys the waypoints
70
+ */
71
+ destroy() {
72
+ this.top.destroy();
73
+ this.bottom.destroy();
74
+ }
75
+ }
@@ -0,0 +1,106 @@
1
+ Example of anchor menu setup
2
+
3
+ ```js
4
+ /**
5
+ * @todo This needs to be converted for reuse!
6
+ */
7
+
8
+ // Creates anchor menu and attaches waypoints
9
+ import ElementWaypoint from "../waypoints/element-waypoint.js";
10
+ import Tooltip from "../ui/tooltip.js";
11
+
12
+ window.addEventListener("load", init);
13
+
14
+ function init() {
15
+ const anchors = [];
16
+ let idCount = 0;
17
+ const activeClass = 'header__page-link--active';
18
+ const ignoreSelector = '[data-page-link-search-ignore]';
19
+ const searchSelector = `h1:not(${ ignoreSelector }), h2:not(${ ignoreSelector })`;
20
+ const container = document.querySelector('.header__page-links');
21
+ const context = document.querySelector('[data-page-link-search]');
22
+ if (!container || !context) return;
23
+ const headlineNodes = [ ...context.querySelectorAll(searchSelector) ];
24
+ // Filter out parents too
25
+ const headlines = headlineNodes.filter(n => n.closest(ignoreSelector) === null);
26
+
27
+ headlines.forEach(element => {
28
+ const id = getId(element);
29
+ const anchor = document.createElement('a');
30
+ const span = document.createElement('span');
31
+ anchor.classList.add('header__page-link');
32
+ anchor.href = "#" + id;
33
+ span.classList.add('hidden-visually');
34
+ span.textContent = element.textContent;
35
+ anchor.appendChild(span);
36
+ container.append(anchor);
37
+ anchors.push(anchor);
38
+ anchor.addEventListener("focusin", onHover);
39
+ anchor.addEventListener("mouseenter", onHover);
40
+ anchor.addEventListener("focusout", onHoverOut);
41
+ anchor.addEventListener("mouseleave", onHoverOut);
42
+ // Attach watcher
43
+ (new ElementWaypoint({
44
+ offsetTop: '20%',
45
+ handler: waypointHandler,
46
+ element
47
+ }));
48
+ });
49
+
50
+ function waypointHandler(entering, direction) {
51
+ const { element } = this.options;
52
+ const anchor = anchors[ headlines.indexOf(element) ];
53
+ const index = anchors.indexOf(anchor);
54
+
55
+ if (entering) {
56
+ removeActiveAll();
57
+ activateAnchor(anchor);
58
+ // Above the first
59
+ } else if (index === 0 && direction === "up") {
60
+ removeActiveAll();
61
+ // Since we are using headlines instaed of containers we need to
62
+ // activate when user is scrolling up. By finding the index of the anchor
63
+ // above the recently deactivated headline target
64
+ } else if (direction === "up") {
65
+ removeActiveAll();
66
+ activateAnchor(anchors[index - 1]);
67
+ }
68
+ }
69
+ function removeActiveAll() {
70
+ anchors.forEach(anchor => anchor.classList.remove(activeClass));
71
+ }
72
+ function activateAnchor(anchor) {
73
+ anchor.classList.add(activeClass);
74
+ }
75
+ function getId(element) {
76
+ if (!element.id) element.id = `page-link--${ ++idCount }`;
77
+ return element.id;
78
+ }
79
+ }
80
+
81
+ // Tooltip Related
82
+ // =============================================================================
83
+
84
+ let tooltip;
85
+
86
+ function onHover(event) {
87
+ const { target } = event;
88
+ destroy();
89
+ tooltip = new Tooltip(target, target.textContent, {
90
+ classes: [
91
+ "site-tooltip",
92
+ "page-link-tooltip"
93
+ ]
94
+ });
95
+ }
96
+ function onHoverOut() {
97
+ destroy();
98
+ }
99
+ function destroy() {
100
+ if (tooltip) {
101
+ tooltip.destroy();
102
+ tooltip = null;
103
+ }
104
+ }
105
+
106
+ ```
@@ -0,0 +1,32 @@
1
+ import ElementWaypoint from "../waypoints/element-waypoint.js";
2
+
3
+ export default function init(config) {
4
+ const defaults = {
5
+ attr: 'data-site-waypoint',
6
+ options: {
7
+ offsetTop: '20%'
8
+ }
9
+ }
10
+ config = Object.assign(defaults, config);
11
+ const elements = document.querySelectorAll(`[${ options.attr }]`);
12
+
13
+ return [ ...elements ].map((element) => {
14
+
15
+ const options = Object.assign(config.options, element.dataset.siteWaypoint);
16
+ const setState = (active, direction) => {
17
+ element.setAttribute(`${ attr }-state`, `active: ${ active }, direction: ${ direction }`);
18
+ };
19
+
20
+ setState(false, null);
21
+
22
+ return new ElementWaypoint({
23
+ ...options,
24
+ element,
25
+ handler(entering, direction) {
26
+ setState(entering, direction);
27
+ }
28
+ });
29
+ });
30
+ }
31
+
32
+
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 262 203">
3
+ <defs>
4
+ <style>
5
+ .cls-1 {
6
+ fill: #667d8e;
7
+ }
8
+ </style>
9
+ </defs>
10
+ <path class="cls-1" d="m25.98,39.42v82.38c0,16.27,4.92,24.07,15.6,24.07,11.69,0,16.95-8.48,16.95-23.9V39.42h24.92v82.04c0,28.98-13.22,42.54-42.2,42.54S.39,149.93.39,121.29V39.42h25.59Z"/>
11
+ <path class="cls-1" d="m130.39,39.42v102.04h37.97v20.34h-63.9V39.42h25.93Z"/>
12
+ <path class="cls-1" d="m204.8,39.42v82.38c0,16.27,4.92,24.07,15.6,24.07,11.69,0,16.95-8.48,16.95-23.9V39.42h24.92v82.04c0,28.98-13.22,42.54-42.2,42.54s-40.85-14.07-40.85-42.71V39.42h25.59Z"/>
13
+ </svg>