@ilo-org/twig 0.0.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 (204) hide show
  1. package/.browserslistrc +4 -0
  2. package/.editorconfig +12 -0
  3. package/.eslintignore +11 -0
  4. package/.eslintrc.js +66 -0
  5. package/.prettierignore +16 -0
  6. package/.prettierrc.js +13 -0
  7. package/.stylelintignore +9 -0
  8. package/.stylelintrc +23 -0
  9. package/.turbo/turbo-build.log +15313 -0
  10. package/LICENSE +201 -0
  11. package/README.md +23 -0
  12. package/apps/storybook/assets.js +5 -0
  13. package/apps/storybook/config/prefix.yml +1 -0
  14. package/apps/storybook/main.js +16 -0
  15. package/apps/storybook/manager.js +7 -0
  16. package/apps/storybook/patterns/colors.stories.mdx +18 -0
  17. package/apps/storybook/patterns/typeset.stories.mdx +28 -0
  18. package/apps/storybook/patterns/welcome.stories.mdx +24 -0
  19. package/apps/storybook/preview-body.html +4 -0
  20. package/apps/storybook/preview-head.html +11 -0
  21. package/apps/storybook/preview.js +38 -0
  22. package/apps/storybook/styles.scss +2 -0
  23. package/apps/storybook/theme.js +11 -0
  24. package/babel.config.js +16 -0
  25. package/contributing.md +5 -0
  26. package/importprefix.js +18 -0
  27. package/importsvgs.js +5 -0
  28. package/jest.config.js +18 -0
  29. package/outputtwigs.js +54 -0
  30. package/package.json +108 -0
  31. package/postcss.config.js +6 -0
  32. package/src/namespaces.js +14 -0
  33. package/src/patterns/components/accordion/accordion-item.twig +16 -0
  34. package/src/patterns/components/accordion/accordion-item.wingsuit.yml +30 -0
  35. package/src/patterns/components/accordion/accordion.behavior.js +14 -0
  36. package/src/patterns/components/accordion/accordion.js +178 -0
  37. package/src/patterns/components/accordion/accordion.stories.jsx +7 -0
  38. package/src/patterns/components/accordion/accordion.twig +17 -0
  39. package/src/patterns/components/accordion/accordion.wingsuit.yml +59 -0
  40. package/src/patterns/components/accordion/index.js +7 -0
  41. package/src/patterns/components/breadcrumb/breadcrumb.behavior.js +14 -0
  42. package/src/patterns/components/breadcrumb/breadcrumb.js +93 -0
  43. package/src/patterns/components/breadcrumb/breadcrumb.stories.jsx +7 -0
  44. package/src/patterns/components/breadcrumb/breadcrumb.twig +32 -0
  45. package/src/patterns/components/breadcrumb/breadcrumb.wingsuit.yml +35 -0
  46. package/src/patterns/components/breadcrumb/index.js +7 -0
  47. package/src/patterns/components/button/button.stories.jsx +7 -0
  48. package/src/patterns/components/button/button.twig +18 -0
  49. package/src/patterns/components/button/button.wingsuit.yml +104 -0
  50. package/src/patterns/components/button/index.js +6 -0
  51. package/src/patterns/components/callout/callout.behaviors.js +14 -0
  52. package/src/patterns/components/callout/callout.js +121 -0
  53. package/src/patterns/components/callout/callout.stories.jsx +7 -0
  54. package/src/patterns/components/callout/callout.twig +30 -0
  55. package/src/patterns/components/callout/callout.wingsuit.yml +66 -0
  56. package/src/patterns/components/callout/index.js +6 -0
  57. package/src/patterns/components/card/card.stories.jsx +7 -0
  58. package/src/patterns/components/card/card.twig +98 -0
  59. package/src/patterns/components/card/card.wingsuit.yml +300 -0
  60. package/src/patterns/components/card/index.js +6 -0
  61. package/src/patterns/components/cardgroup/cardgroup.stories.jsx +7 -0
  62. package/src/patterns/components/cardgroup/cardgroup.twig +30 -0
  63. package/src/patterns/components/cardgroup/cardgroup.wingsuit.yml +419 -0
  64. package/src/patterns/components/cardgroup/index.js +6 -0
  65. package/src/patterns/components/contextmenu/contextmenu.stories.jsx +7 -0
  66. package/src/patterns/components/contextmenu/contextmenu.twig +12 -0
  67. package/src/patterns/components/contextmenu/contextmenu.wingsuit.yml +23 -0
  68. package/src/patterns/components/contextmenu/index.js +6 -0
  69. package/src/patterns/components/dropdown/dropdown.stories.jsx +7 -0
  70. package/src/patterns/components/dropdown/dropdown.twig +20 -0
  71. package/src/patterns/components/dropdown/dropdown.wingsuit.yml +71 -0
  72. package/src/patterns/components/dropdown/index.js +6 -0
  73. package/src/patterns/components/fieldset/fieldset.twig +43 -0
  74. package/src/patterns/components/footer/footer.stories.jsx +7 -0
  75. package/src/patterns/components/footer/footer.twig +62 -0
  76. package/src/patterns/components/footer/footer.wingsuit.yml +104 -0
  77. package/src/patterns/components/footer/index.js +6 -0
  78. package/src/patterns/components/form/checkbox.twig +13 -0
  79. package/src/patterns/components/form/checkboxgroup.twig +5 -0
  80. package/src/patterns/components/form/datepicker.twig +32 -0
  81. package/src/patterns/components/form/file.twig +14 -0
  82. package/src/patterns/components/form/fileupload.behavior.js +14 -0
  83. package/src/patterns/components/form/fileupload.js +118 -0
  84. package/src/patterns/components/form/form.stories.jsx +7 -0
  85. package/src/patterns/components/form/form.twig +94 -0
  86. package/src/patterns/components/form/form.wingsuit.yml +973 -0
  87. package/src/patterns/components/form/index.js +7 -0
  88. package/src/patterns/components/form/input.twig +13 -0
  89. package/src/patterns/components/form/number.twig +13 -0
  90. package/src/patterns/components/form/radio.twig +4 -0
  91. package/src/patterns/components/form/textarea.twig +13 -0
  92. package/src/patterns/components/hero/hero.stories.jsx +7 -0
  93. package/src/patterns/components/hero/hero.twig +24 -0
  94. package/src/patterns/components/hero/hero.wingsuit.yml +56 -0
  95. package/src/patterns/components/hero/index.js +6 -0
  96. package/src/patterns/components/herocard/herocard.stories.jsx +7 -0
  97. package/src/patterns/components/herocard/herocard.twig +31 -0
  98. package/src/patterns/components/herocard/herocard.wingsuit.yml +43 -0
  99. package/src/patterns/components/herocard/index.js +6 -0
  100. package/src/patterns/components/icon/icon.twig +4 -0
  101. package/src/patterns/components/icon/index.js +6 -0
  102. package/src/patterns/components/image/image.stories.jsx +7 -0
  103. package/src/patterns/components/image/image.twig +19 -0
  104. package/src/patterns/components/image/image.wingsuit.yml +37 -0
  105. package/src/patterns/components/image/index.js +6 -0
  106. package/src/patterns/components/link/index.js +6 -0
  107. package/src/patterns/components/link/link.stories.jsx +7 -0
  108. package/src/patterns/components/link/link.twig +8 -0
  109. package/src/patterns/components/link/link.wingsuit.yml +35 -0
  110. package/src/patterns/components/linklist/index.js +6 -0
  111. package/src/patterns/components/linklist/linklist.stories.jsx +7 -0
  112. package/src/patterns/components/linklist/linklist.twig +26 -0
  113. package/src/patterns/components/linklist/linklist.wingsuit.yml +53 -0
  114. package/src/patterns/components/list/index.js +6 -0
  115. package/src/patterns/components/list/list-item.twig +6 -0
  116. package/src/patterns/components/list/list-item.wingsuit.yml +18 -0
  117. package/src/patterns/components/list/list.stories.jsx +7 -0
  118. package/src/patterns/components/list/list.twig +30 -0
  119. package/src/patterns/components/list/list.wingsuit.yml +48 -0
  120. package/src/patterns/components/loading/index.js +7 -0
  121. package/src/patterns/components/loading/loading.behavior.js +14 -0
  122. package/src/patterns/components/loading/loading.js +102 -0
  123. package/src/patterns/components/loading/loading.stories.jsx +7 -0
  124. package/src/patterns/components/loading/loading.twig +8 -0
  125. package/src/patterns/components/loading/loading.wingsuit.yml +37 -0
  126. package/src/patterns/components/modal/index.js +7 -0
  127. package/src/patterns/components/modal/modal.behavior.js +14 -0
  128. package/src/patterns/components/modal/modal.js +130 -0
  129. package/src/patterns/components/modal/modal.stories.jsx +7 -0
  130. package/src/patterns/components/modal/modal.twig +18 -0
  131. package/src/patterns/components/modal/modal.wingsuit.yml +54 -0
  132. package/src/patterns/components/notification/index.js +7 -0
  133. package/src/patterns/components/notification/notification.behavior.js +15 -0
  134. package/src/patterns/components/notification/notification.js +95 -0
  135. package/src/patterns/components/notification/notification.stories.jsx +7 -0
  136. package/src/patterns/components/notification/notification.twig +18 -0
  137. package/src/patterns/components/notification/notification.wingsuit.yml +58 -0
  138. package/src/patterns/components/pagination/Pagination.stories.jsx +7 -0
  139. package/src/patterns/components/pagination/index.js +6 -0
  140. package/src/patterns/components/pagination/pagination.twig +48 -0
  141. package/src/patterns/components/pagination/pagination.wingsuit.yml +72 -0
  142. package/src/patterns/components/polyfill/index.js +6 -0
  143. package/src/patterns/components/polyfill/polyfill.twig +10 -0
  144. package/src/patterns/components/profile/index.js +6 -0
  145. package/src/patterns/components/profile/profile.stories.jsx +7 -0
  146. package/src/patterns/components/profile/profile.twig +18 -0
  147. package/src/patterns/components/profile/profile.wingsuit.yml +35 -0
  148. package/src/patterns/components/readmore/index.js +7 -0
  149. package/src/patterns/components/readmore/readmore.behavior.js +14 -0
  150. package/src/patterns/components/readmore/readmore.js +119 -0
  151. package/src/patterns/components/readmore/readmore.stories.jsx +7 -0
  152. package/src/patterns/components/readmore/readmore.twig +16 -0
  153. package/src/patterns/components/readmore/readmore.wingsuit.yml +32 -0
  154. package/src/patterns/components/richtext/index.js +6 -0
  155. package/src/patterns/components/richtext/richtext.stories.jsx +7 -0
  156. package/src/patterns/components/richtext/richtext.twig +6 -0
  157. package/src/patterns/components/richtext/richtext.wingsuit.yml +12 -0
  158. package/src/patterns/components/searchfield/index.js +6 -0
  159. package/src/patterns/components/searchfield/searchfield.stories.jsx +7 -0
  160. package/src/patterns/components/searchfield/searchfield.twig +7 -0
  161. package/src/patterns/components/searchfield/searchfield.wingsuit.yml +22 -0
  162. package/src/patterns/components/table/index.js +7 -0
  163. package/src/patterns/components/table/table.behavior.js +14 -0
  164. package/src/patterns/components/table/table.js +279 -0
  165. package/src/patterns/components/table/table.stories.jsx +7 -0
  166. package/src/patterns/components/table/table.twig +36 -0
  167. package/src/patterns/components/table/table.wingsuit.yml +112 -0
  168. package/src/patterns/components/tableofcontents/index.js +6 -0
  169. package/src/patterns/components/tableofcontents/tableofcontents.stories.jsx +7 -0
  170. package/src/patterns/components/tableofcontents/tableofcontents.twig +14 -0
  171. package/src/patterns/components/tableofcontents/tableofcontents.wingsuit.yml +22 -0
  172. package/src/patterns/components/tabs/index.js +7 -0
  173. package/src/patterns/components/tabs/tabs.behavior.js +23 -0
  174. package/src/patterns/components/tabs/tabs.js +209 -0
  175. package/src/patterns/components/tabs/tabs.stories.jsx +7 -0
  176. package/src/patterns/components/tabs/tabs.twig +30 -0
  177. package/src/patterns/components/tabs/tabs.wingsuit.yml +168 -0
  178. package/src/patterns/components/tag/index.js +7 -0
  179. package/src/patterns/components/tag/tag-set.twig +15 -0
  180. package/src/patterns/components/tag/tag.behavior.js +14 -0
  181. package/src/patterns/components/tag/tag.stories.jsx +7 -0
  182. package/src/patterns/components/tag/tag.twig +24 -0
  183. package/src/patterns/components/tag/tag.wingsuit.yml +43 -0
  184. package/src/patterns/components/tag/tagset.js +160 -0
  185. package/src/patterns/components/tag/tagset.wingsuit.yml +43 -0
  186. package/src/patterns/components/tooltip/index.js +7 -0
  187. package/src/patterns/components/tooltip/tooltip.behavior.js +14 -0
  188. package/src/patterns/components/tooltip/tooltip.js +184 -0
  189. package/src/patterns/components/tooltip/tooltip.stories.jsx +7 -0
  190. package/src/patterns/components/tooltip/tooltip.twig +11 -0
  191. package/src/patterns/components/tooltip/tooltip.wingsuit.yml +30 -0
  192. package/src/patterns/components/video/index.js +7 -0
  193. package/src/patterns/components/video/video.behavior.js +14 -0
  194. package/src/patterns/components/video/video.js +114 -0
  195. package/src/patterns/components/video/video.stories.jsx +7 -0
  196. package/src/patterns/components/video/video.twig +17 -0
  197. package/src/patterns/components/video/video.wingsuit.yml +44 -0
  198. package/src/patterns/components/video/videoplayer.twig +10 -0
  199. package/src/tokens/exports/_colors.scss +7 -0
  200. package/src/tokens/exports/_font-families.scss +6 -0
  201. package/src/tokens/exports/_font-sizes-heading.scss +10 -0
  202. package/src/tokens/index.scss +7 -0
  203. package/src/vendorjs/lib.vendor.js +1 -0
  204. package/wingsuit.config.js +27 -0
@@ -0,0 +1,160 @@
1
+ import { getUpdatedItems, EVENTS, ARIA } from '@ilo-org/utils';
2
+
3
+ /**
4
+ * The Tag module which handles rendering field labels inline on a form.
5
+ *
6
+ * @class Tag
7
+ */
8
+ export default class Tag {
9
+ /**
10
+ * Tag constructor which assigns the element passed into the constructor
11
+ * to the `this.element` property for later reference
12
+ *
13
+ * @param {HTMLElement} element - REQUIRED - the module's container
14
+ */
15
+ constructor(element) {
16
+ /**
17
+ * Reference to the DOM element that is the root of the component
18
+ * @property {Object}
19
+ */
20
+ this.element = element;
21
+ this.multipleActive = true;
22
+ this.itemStatuses = [];
23
+
24
+ // Initialize the view
25
+ this.init();
26
+ }
27
+
28
+ /**
29
+ * Initializes the view by calling the functions to
30
+ * create DOM references, setup event handlers and
31
+ * then create the event listeners
32
+ *
33
+ * @return {Object} Tag A reference to the instance of the class
34
+ * @chainable
35
+ */
36
+ init() {
37
+ this.cacheDomReferences().setupHandlers().enable();
38
+
39
+ return this;
40
+ }
41
+
42
+ /**
43
+ * Find all necessary DOM elements used in the view and cache them
44
+ *
45
+ * @return {Object} Tag A reference to the instance of the class
46
+ * @chainable
47
+ */
48
+ cacheDomReferences() {
49
+ /**
50
+ * The field that a user interacts with on a form
51
+ * @type {Object}
52
+ */
53
+ this.buttonTags = this.element.querySelectorAll('.ilo--tag--button');
54
+ this.multipleActive = this.element.getAttribute('data-multipleactive');
55
+
56
+ this.buttonTags.forEach((button, i) => {
57
+ const expanded = button.dataset['active'];
58
+ const id = this.buttonTags[i].getAttribute('id');
59
+ if (expanded === 'true') {
60
+ this.itemStatuses = getUpdatedItems({
61
+ id,
62
+ itemStatuses: this.itemStatuses,
63
+ allowMultipleActive: this.multipleActive,
64
+ });
65
+ }
66
+ });
67
+
68
+ return this;
69
+ }
70
+
71
+ /**
72
+ * Bind event handlers with the proper context of `this`.
73
+ *
74
+ * @return {Object} Tag A reference to the current instance of the class
75
+ * @chainable
76
+ */
77
+ setupHandlers() {
78
+ this.onClick = this.onClick.bind(this);
79
+ this.updateTagItems = this.updateTagItems.bind(this);
80
+
81
+ return this;
82
+ }
83
+
84
+ /**
85
+ * Creates event listeners to enable interaction with view
86
+ *
87
+ * @return {Object} Tag A reference to the instance of the class
88
+ * @chainable
89
+ */
90
+ enable() {
91
+ if (this.buttonTags.length > 0) {
92
+ this.buttonTags.forEach((button, i) => {
93
+ button.addEventListener(EVENTS.CLICK, () => this.onClick(i));
94
+ });
95
+ }
96
+
97
+ return this;
98
+ }
99
+
100
+ /**
101
+ * Onclick interaction with the tag button
102
+ *
103
+ * @return {Object} Tag A reference to the instance of the class
104
+ * @chainable
105
+ */
106
+ onClick(i) {
107
+ const id = this.buttonTags[i].getAttribute('id');
108
+
109
+ this.itemStatuses = getUpdatedItems({
110
+ id,
111
+ itemStatuses: this.itemStatuses,
112
+ allowMultipleacmultipleActive: this.multipleActive,
113
+ });
114
+
115
+ // this.updateTagItems();
116
+ console.log(id);
117
+ this.removeParentDom(id);
118
+
119
+ return this;
120
+ }
121
+
122
+ /**
123
+ *
124
+ * @param {String} id The element id of the child of the node to be removed
125
+ *
126
+ * @return {Object} Tag A reference to the instance of the class
127
+ * @chainable
128
+ */
129
+ removeParentDom(id) {
130
+ const buttonTag = document.getElementById(id);
131
+
132
+ if (buttonTag) {
133
+ buttonTag.parentElement.remove();
134
+ }
135
+
136
+ return this;
137
+ }
138
+
139
+ /**
140
+ * Update tag items based off of new statuses
141
+ *
142
+ * @return {Object} Tag A reference to the instance of the class
143
+ * @chainable
144
+ */
145
+ updateTagItems() {
146
+ this.tags.forEach((item, i) => {
147
+ const id = item.getAttribute('id');
148
+ const open = this.itemStatuses.indexOf(id) > -1;
149
+ if (open) {
150
+ this.tags[i].classList.add('ilo--tag--active');
151
+ this.tags[i].setAttribute('data-active', 'true');
152
+ } else {
153
+ this.tags[i].classList.remove('ilo--tag--active');
154
+ this.tags[i].setAttribute('data-active', 'true');
155
+ }
156
+ });
157
+
158
+ return this;
159
+ }
160
+ }
@@ -0,0 +1,43 @@
1
+ tagset:
2
+ use: '@components/tag/tag-set.twig'
3
+ label: Tag Set
4
+ description: A set of tags
5
+ fields:
6
+ items:
7
+ type: object
8
+ label: Items
9
+ description: The tag items.
10
+ required: true
11
+ preview:
12
+ - content: content 1
13
+ id: tag1
14
+ defaultActive: true
15
+ url: https://www.google.com/
16
+ - content: content 2
17
+ id: tag2
18
+ defaultActive: true
19
+ url: https://www.google.com/
20
+ - content: content 3
21
+ id: tag3
22
+ defaultActive: false
23
+ settings:
24
+ allowMultipleActive:
25
+ type: select
26
+ label: Allow Multiple Active
27
+ description: Allow mutiple tag items to be active at once.
28
+ options:
29
+ true: True
30
+ false: False
31
+ preview: true
32
+ required: false
33
+ tagType:
34
+ type: select
35
+ label: Tag Type
36
+ description: Type of tags
37
+ options:
38
+ anchor: Anchor
39
+ button: Button
40
+ display: Display
41
+ preview: display
42
+ required: true
43
+ visibility: storybook
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tooltip
3
+ */
4
+ // Module template
5
+ import './tooltip.twig';
6
+ import './tooltip.wingsuit.yml';
7
+ import './tooltip.behavior';
@@ -0,0 +1,14 @@
1
+ import Tooltip from './tooltip';
2
+
3
+ Drupal.behaviors.tooltip = {
4
+ attach() {
5
+ Array.prototype.forEach.call(
6
+ document.querySelectorAll(`[data-loadcomponent="Tooltip"]`),
7
+ (element) => {
8
+ // eslint-disable-next-line no-console
9
+ console.log('loading Tooltip component....');
10
+ new Tooltip(element);
11
+ }
12
+ );
13
+ },
14
+ };
@@ -0,0 +1,184 @@
1
+ /**
2
+ * The Tooltip module which handles showing a bit of markup on mouseover
3
+ *
4
+ * @class Tooltip
5
+ */
6
+ export default class Tooltip {
7
+ /**
8
+ * Tooltip constructor which assigns the element passed into the constructor
9
+ * to the `this.element` property for later reference
10
+ *
11
+ * @param {HTMLElement} element - REQUIRED - the module's container
12
+ */
13
+ constructor(element) {
14
+ /**
15
+ * Reference to the DOM element that is the root of the component
16
+ * @property {Object}
17
+ */
18
+ this.element = element;
19
+
20
+ // Initialize the view
21
+ this.init();
22
+ }
23
+
24
+ /**
25
+ * Initializes the view by calling the functions to
26
+ * create DOM references, setup event handlers and
27
+ * then create the event listeners
28
+ *
29
+ * @return {Object} ReadMore A reference to the instance of the class
30
+ * @chainable
31
+ */
32
+ init() {
33
+ this.cacheDomReferences().setupHandlers().enable();
34
+
35
+ return this;
36
+ }
37
+
38
+ /**
39
+ * Find all necessary DOM elements used in the view and cache them
40
+ *
41
+ * @return {Object} ReadMore A reference to the instance of the class
42
+ * @chainable
43
+ */
44
+ cacheDomReferences() {
45
+ /**
46
+ * The button for toggling Read More state
47
+ * @type {Object}
48
+ */
49
+
50
+ // enable defaults
51
+ this.prefix = this.element.getAttribute('data-prefix');
52
+ this.tooltip = this.element.querySelector(`.${this.prefix}--tooltip`);
53
+ this.arrow = this.element.querySelector(`.${this.prefix}--tooltip--arrow`);
54
+ this.alignment = this.arrow.getAttribute('data-alignment');
55
+ this.placement = this.tooltip.getAttribute('data-placement');
56
+
57
+ return this;
58
+ }
59
+
60
+ /**
61
+ * Bind event handlers with the proper context of `this`.
62
+ *
63
+ * @return {Object} Tooltip A reference to the current instance of the class
64
+ * @chainable
65
+ */
66
+ setupHandlers() {
67
+ this.onMouseOver = this.handleOnMouseOver.bind(this);
68
+ this.onFocus = this.handleOnMouseOver.bind(this);
69
+ this.onMouseOut = this.handleOnMouseOut.bind(this);
70
+ this.onBlur = this.handleOnMouseOut.bind(this);
71
+
72
+ return this;
73
+ }
74
+
75
+ /**
76
+ * Creates event listeners to enable interaction with view
77
+ *
78
+ * @return {Object} ReadMore A reference to the instance of the class
79
+ * @chainable
80
+ */
81
+ enable() {
82
+ this.element.addEventListener('mouseover', this.onMouseOver);
83
+ this.element.addEventListener('focus', this.onMouseOver);
84
+ this.element.addEventListener('mouseout', this.onMouseOut);
85
+ this.element.addEventListener('blur', this.onMouseOut);
86
+ return this;
87
+ }
88
+
89
+ handleOnMouseOver(e) {
90
+ const target = e.currentTarget;
91
+
92
+ if (target != null) {
93
+ const rect = target.getBoundingClientRect();
94
+ this.tooltip.classList.add(`${this.prefix}--tooltip--visible`);
95
+ this.postMouseOver(rect);
96
+ }
97
+
98
+ return this;
99
+ }
100
+
101
+ handleOnMouseOut(e) {
102
+ this.tooltip.classList.remove(`${this.prefix}--tooltip--visible`);
103
+
104
+ return this;
105
+ }
106
+
107
+ postMouseOver(hoverRect) {
108
+ // position the tooltip after showing it
109
+ let placement = 'center';
110
+ let alignment = 'left';
111
+
112
+ const ttNode = this.tooltip;
113
+ if (ttNode != null) {
114
+ let x = 0,
115
+ y = 0;
116
+
117
+ const docWidth = document.documentElement.clientWidth,
118
+ docHeight = document.documentElement.clientHeight;
119
+
120
+ const rx = hoverRect.x + hoverRect.width, // most right x
121
+ lx = hoverRect.x, // most left x
122
+ ty = hoverRect.y, // most top y
123
+ by = hoverRect.y + hoverRect.height; // most bottom y
124
+
125
+ // tooltip rectange
126
+ const ttRect = ttNode.getBoundingClientRect();
127
+
128
+ const bRight =
129
+ rx + ttRect.width <= window.scrollX + docWidth &&
130
+ ty + ttRect.height <= window.scrollY + docHeight;
131
+ const bLeft = lx - ttRect.width >= 0 && ty + ttRect.height <= window.scrollY + docHeight;
132
+ const bAbove = ty - ttRect.height >= 0;
133
+ const bBellow = by + ttRect.height <= window.scrollY + docHeight;
134
+
135
+ // the tooltip doesn't fit to the left
136
+ if (bRight) {
137
+ x = hoverRect.width + 32;
138
+ y = 0;
139
+ placement = 'negative';
140
+ alignment = 'right';
141
+ } else if (bBellow) {
142
+ x = 0;
143
+ y = hoverRect.height + 32;
144
+
145
+ placement = 'center';
146
+ alignment = 'bottom';
147
+ } else if (bLeft) {
148
+ x = -ttRect.width - 32;
149
+ y = 0;
150
+
151
+ placement = 'negative';
152
+ alignment = 'left';
153
+ } else if (bAbove) {
154
+ x = 0;
155
+ y = -ttRect.height - 32;
156
+
157
+ placement = 'center';
158
+ alignment = 'top';
159
+ }
160
+
161
+ // set style top and left on tooltip
162
+ // setPosition({ x: x, y: y });
163
+ this.tooltip.style.top = y;
164
+ this.tooltip.style.left = x;
165
+
166
+ // set class for placement on arrow
167
+ // setArrowPlacement(placement);
168
+ this.arrow.classList.remove(`${this.prefix}--tooltip--arrow--placement-${this.placement}`);
169
+ this.arrow.classList.add(`${this.prefix}--tooltip--arrow--placement-${this.placement}`);
170
+ this.placement = placement;
171
+ this.arrow.setAttribute('data-placement', placement);
172
+
173
+ // set class for alignment on tooltip
174
+ // setArrowAlignment(alignment);
175
+ this.tooltip.classList.remove(`${this.prefix}--tooltip--alignment-${this.alignment}`);
176
+ this.tooltip.classList.add(`${this.prefix}--tooltip--alignment-${this.alignment}`);
177
+ this.alignment = alignment;
178
+
179
+ this.tooltip.setAttribute('data-alignment', alignment);
180
+ }
181
+
182
+ return this;
183
+ }
184
+ }
@@ -0,0 +1,7 @@
1
+ import './index';
2
+
3
+ const patternDefinition = require('./tooltip.wingsuit.yml');
4
+
5
+ export const wingsuit = {
6
+ patternDefinition,
7
+ };
@@ -0,0 +1,11 @@
1
+ {#
2
+ TOOLTIP COMPONENT
3
+ #}
4
+ <div
5
+ class="{{prefix}}--tooltip--wrapper{% if icon %} has-icon{% endif %}" role="status" aria-live="polite" aria-relevant="additions" data-loadcomponent="Tooltip" data-prefix="{{prefix}}"
6
+ >
7
+ <span class="{{prefix}}--tooltip {{prefix}}--tooltip--{{theme}}" data-alignment="left">
8
+ <span class="{{prefix}}--tooltip--arrow {{prefix}}--tooltip--arrow--placement-negative" data-placement="negative" role="presentation"></span>
9
+ {{label}}
10
+ </span>
11
+ </div>
@@ -0,0 +1,30 @@
1
+ tooltip:
2
+ use: '@components/tooltip/tooltip.twig'
3
+ label: Tooltip
4
+ description: A component for displaying a tooltip
5
+ fields:
6
+ label:
7
+ type: string
8
+ label: label
9
+ description: label shown on the tooltip
10
+ required: true
11
+ preview: 'Tooltip text'
12
+ icon:
13
+ type: select
14
+ label: Icon
15
+ description: does this tooltip have the "info" icon?
16
+ fields:
17
+ true: 'true'
18
+ false: false
19
+ preview: 'true'
20
+ required: true
21
+ theme:
22
+ type: select
23
+ label: Theme
24
+ description: choose the tooltip's theme
25
+ fields:
26
+ light: light
27
+ dark: dark
28
+ preview: dark
29
+ required: true
30
+ visibility: storybook
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Video
3
+ */
4
+ // Module template
5
+ import './video.twig';
6
+ import './video.wingsuit.yml';
7
+ import './video.behavior';
@@ -0,0 +1,14 @@
1
+ import Video from './video';
2
+
3
+ Drupal.behaviors.media = {
4
+ attach() {
5
+ Array.prototype.forEach.call(
6
+ document.querySelectorAll(`[data-loadcomponent="Video"]`),
7
+ (element) => {
8
+ // eslint-disable-next-line no-console
9
+ console.log('loading Video component....');
10
+ new Video(element);
11
+ }
12
+ );
13
+ },
14
+ };
@@ -0,0 +1,114 @@
1
+ import { EVENTS, ARIA } from '@ilo-org/utils';
2
+ import videojs from 'video.js';
3
+
4
+ /**
5
+ * The Video module which handles rendering field labels inline on a form.
6
+ *
7
+ * @class Video
8
+ */
9
+ export default class Video {
10
+ /**
11
+ * Video constructor which assigns the element passed into the constructor
12
+ * to the `this.element` property for later reference
13
+ *
14
+ * @param {HTMLElement} element - REQUIRED - the module's container
15
+ */
16
+ constructor(element) {
17
+ /**
18
+ * Reference to the DOM element that is the root of the component
19
+ * @property {Object}
20
+ */
21
+ this.element = element;
22
+
23
+ // get the theme prefix
24
+ this.prefix = this.element.dataset.prefix;
25
+ this.controlsprefix = `${this.prefix}--video--controls`;
26
+
27
+ // Initialize the view
28
+ this.init();
29
+ }
30
+
31
+ /**
32
+ * Initializes the view by calling the functions to
33
+ * create DOM references, setup event handlers and
34
+ * then create the event listeners
35
+ *
36
+ * @return {Object} ReadMore A reference to the instance of the class
37
+ * @chainable
38
+ */
39
+ init() {
40
+ this.cacheDomReferences().start().setupHandlers().enable();
41
+
42
+ return this;
43
+ }
44
+
45
+ /**
46
+ * Find all necessary DOM elements used in the view and cache them
47
+ *
48
+ * @return {Object} ReadMore A reference to the instance of the class
49
+ * @chainable
50
+ */
51
+ cacheDomReferences() {
52
+ /**
53
+ * The button for toggling Read More state
54
+ * @type {Object}
55
+ */
56
+ this.VideoElement = this.element.querySelector(`.${this.prefix}--video--element`);
57
+
58
+ return this;
59
+ }
60
+
61
+ /**
62
+ * Bind event handlers with the proper context of `this`.
63
+ *
64
+ * @return {Object} Video A reference to the current instance of the class
65
+ * @chainable
66
+ */
67
+ setupHandlers() {
68
+ return this;
69
+ }
70
+
71
+ /**
72
+ * Creates event listeners to enable interaction with view
73
+ *
74
+ * @return {Object} ReadMore A reference to the instance of the class
75
+ * @chainable
76
+ */
77
+ enable() {
78
+ return this;
79
+ }
80
+
81
+ /**
82
+ * Starts up videojs
83
+ *
84
+ * @return {Object} Video A reference to the instance of the class
85
+ * @chainable
86
+ */
87
+ start() {
88
+ console.log('this.VideoElement', this.VideoElement);
89
+
90
+ this.player = videojs(this.VideoElement, {
91
+ autoplay: false,
92
+ controls: true,
93
+ preload: 'auto',
94
+ bigPlayButton: false,
95
+ controlBar: {
96
+ descriptionsButton: false,
97
+ playbackRateMenuButton: false,
98
+ chaptersButton: false,
99
+ audioTrackButton: false,
100
+ pictureInPictureToggle: false,
101
+ subsCapsButton: false,
102
+ seekToLive: false,
103
+ liveDisplay: false,
104
+ },
105
+ textTrackDisplay: false,
106
+ liveTracker: false,
107
+ errorDisplay: false,
108
+ textTrackSettings: false,
109
+ resizeManager: false,
110
+ });
111
+
112
+ return this;
113
+ }
114
+ }
@@ -0,0 +1,7 @@
1
+ import './index';
2
+
3
+ const patternDefinition = require('./video.wingsuit.yml');
4
+
5
+ export const wingsuit = {
6
+ patternDefinition,
7
+ };
@@ -0,0 +1,17 @@
1
+ {#
2
+ VIDEO COMPONENT
3
+ #}
4
+
5
+ <figure class="{{prefix}}--video" data-prefix="{{prefix}}">
6
+ <div class="{{prefix}}--video--wrapper">
7
+ {% include "@components/video/videoplayer.twig" with {
8
+ alt: alt,
9
+ controls: video.controls,
10
+ prefix: prefix,
11
+ src: video.src,
12
+ tracks: video.tracks,
13
+ url: url
14
+ } %}
15
+ </div>
16
+ <figcaption class="{{prefix}}--video--caption">{{caption}}</figcaption>
17
+ </figure>
@@ -0,0 +1,44 @@
1
+ video:
2
+ use: '@components/video/video.twig'
3
+ label: Video
4
+ description: A component for displaying a video, source from either a server or YouTube.
5
+ fields:
6
+ alt:
7
+ type: string
8
+ label: Alt
9
+ description: alt text for the image
10
+ required: true
11
+ preview: 'My alt text'
12
+ caption:
13
+ type: string
14
+ label: Caption
15
+ description: string
16
+ preview: 'my image caption'
17
+ url:
18
+ type: object
19
+ label: URL
20
+ description: The image url(s), and at which breakpoint each should be displayed.
21
+ required: true
22
+ preview:
23
+ - breakpoint: 0
24
+ src: 'https://place-hold.it/400x300?text=SmallBreakpointImage'
25
+ - breakpoint: 800
26
+ src: 'https://place-hold.it/800x600?text=MediumBreakpointImage'
27
+ - breakpoint: 1200
28
+ src: 'https://place-hold.it/1200x900?text=LargeBreakpointImage'
29
+ - breakpoint: 1440
30
+ src: 'https://place-hold.it/1600x1200?text=LargestBreakpointImage'
31
+ video:
32
+ type: object
33
+ label: Video
34
+ description: video player settings
35
+ required: true
36
+ preview:
37
+ controls:
38
+ fullscreen: "Fullscreen"
39
+ play: "Play"
40
+ pause: "Pause"
41
+ volume: "Volume"
42
+ src: "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"
43
+ tracks: null
44
+ visibility: storybook
@@ -0,0 +1,10 @@
1
+ {#
2
+ VIDEO PLAYER SUB-COMPONENT
3
+ #}
4
+ {% set poster = url|last %}
5
+ <div class="{{prefix}}--videoplayer" data-loadcomponent="Video" data-prefix="{{prefix}}"">
6
+ <video class="{{prefix}}--video--element" poster="{{poster.src}}">
7
+ <source src="{{src}}" />
8
+ </video>
9
+ </div>
10
+
@@ -0,0 +1,7 @@
1
+ @use "@ilo-org/themes/build/scss/tokens" as *;
2
+
3
+ @each $color, $value in $brand {
4
+ :export {
5
+ #{$color}: $value;
6
+ }
7
+ }