@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,102 @@
1
+ import { EVENTS, ARIA } from '@ilo-org/utils';
2
+
3
+ /**
4
+ * The Loading module which handles rendering field labels inline on a form.
5
+ *
6
+ * To use this, you'll need to have the Javascript that's making the API call send custom events equal to
7
+ * the constants EVENTS.ITEMSLOADED and EVENTS.ITEMSLOADING to the document. Send EVENTS.ITEMSLOADING when the * API call is made, and EVENTS.ITEMSLOADED when the data has successfully loaded.
8
+ *
9
+ * @class Loading
10
+ */
11
+ export default class Loading {
12
+ /**
13
+ * Loading constructor which assigns the element passed into the constructor
14
+ * to the `this.element` property for later reference
15
+ *
16
+ * @param {HTMLElement} element - REQUIRED - the module's container
17
+ */
18
+ constructor(element) {
19
+ /**
20
+ * Reference to the DOM element that is the root of the component
21
+ * @property {Object}
22
+ */
23
+ this.element = element;
24
+
25
+ // get the theme prefix
26
+ this.prefix = `${this.element.dataset.prefix}--loading`;
27
+
28
+ // set some values
29
+ this.status = 'idle';
30
+
31
+ // Initialize the view
32
+ this.init();
33
+ }
34
+
35
+ /**
36
+ * Initializes the view by calling the functions to
37
+ * create DOM references, setup event handlers and
38
+ * then create the event listeners
39
+ *
40
+ * @return {Object} Loading A reference to the instance of the class
41
+ * @chainable
42
+ */
43
+ init() {
44
+ this.setupHandlers().enable();
45
+
46
+ return this;
47
+ }
48
+
49
+ /**
50
+ * Bind event handlers with the proper context of `this`.
51
+ *
52
+ * @return {Object} Loading A reference to the current instance of the class
53
+ * @chainable
54
+ */
55
+ setupHandlers() {
56
+ this.LoadingHandler = this.loading.bind(this);
57
+ this.LoadedHandler = this.loaded.bind(this);
58
+
59
+ return this;
60
+ }
61
+
62
+ /**
63
+ * Creates event listeners to enable interaction with view
64
+ *
65
+ * @return {Object} Loading A reference to the instance of the class
66
+ * @chainable
67
+ */
68
+ enable() {
69
+ document.addEventListener(EVENTS.ITEMSLOADING, () => this.LoadingHandler);
70
+ document.addEventListener(EVENTS.ITEMSLOADED, () => this.LoadedHandler);
71
+
72
+ return this;
73
+ }
74
+
75
+ /**
76
+ * Items are loading
77
+ *
78
+ * @return {Object} Loading A reference to the instance of the class
79
+ * @chainable
80
+ */
81
+ loading() {
82
+ this.element.classList.remove(`${this.prefix}--idle`);
83
+ this.element.classList.add(`${this.prefix}--loading`);
84
+
85
+ return this;
86
+ }
87
+
88
+ /**
89
+ * What happens when the items have loaded
90
+ *
91
+ * @return {Object} Loading A reference to the instance of the class
92
+ * @chainable
93
+ */
94
+ loaded() {
95
+ this.element.classList.remove(`${this.prefix}--loading`);
96
+ this.element.classList.add(`${this.prefix}--loaded`);
97
+ this.element.querySelector(`.${this.prefix}--copy`).innerHTML =
98
+ this.element.dataset.loadedmessage;
99
+
100
+ return this;
101
+ }
102
+ }
@@ -0,0 +1,7 @@
1
+ import './index';
2
+
3
+ const patternDefinition = require('./loading.wingsuit.yml');
4
+
5
+ export const wingsuit = {
6
+ patternDefinition,
7
+ };
@@ -0,0 +1,8 @@
1
+ {#
2
+ LOADING COMPONENT
3
+ #}
4
+ <div class="storybook {{prefix}}--loading {{prefix}}--loading--{{size}} {{prefix}}--loading--{{status}}" role="alert" aria-live="assertive" data-loadcomponent="Loading" data-prefix="{{prefix}}">
5
+ {% if message or loadedmessage %}
6
+ <p class="{{prefix}}--loading--copy">{% if message and not status == 'loaded' %}{{message}}{% endif %}{% if loadedmessage and status == 'loaded' %}{{loadedmessage}}{% endif %}</p>
7
+ {% endif %}
8
+ </div>
@@ -0,0 +1,37 @@
1
+ loading:
2
+ use: '@components/loading/loading.twig'
3
+ label: Loading
4
+ description: The Loading component displays a loading state. (See Javascript comments in loading.js for how to use this with vanilla JS).
5
+ fields:
6
+ size:
7
+ type: select
8
+ label: Size
9
+ description: The size of the loader
10
+ required: true
11
+ options:
12
+ small: Small
13
+ large: Large
14
+ preview: 'large'
15
+ status:
16
+ type: select
17
+ label: Status
18
+ description: The status of the loading content
19
+ required: true
20
+ options:
21
+ idle: Idle
22
+ loading: Loading
23
+ loaded: Loaded
24
+ preview: 'loading'
25
+ message:
26
+ type: string
27
+ label: Message
28
+ description: The loading message
29
+ preview: 'Submitting'
30
+ required: true
31
+ loadedmessage:
32
+ type: string
33
+ label: LOaded Message
34
+ description: The loaded message
35
+ preview: 'Completed'
36
+ required: true
37
+ visibility: storybook
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Modal
3
+ */
4
+ // Module template
5
+ import './modal.twig';
6
+ import './modal.wingsuit.yml';
7
+ import './modal.behavior.js';
@@ -0,0 +1,14 @@
1
+ import Modal from './modal';
2
+
3
+ Drupal.behaviors.modal = {
4
+ attach() {
5
+ Array.prototype.forEach.call(
6
+ document.querySelectorAll(`[data-loadcomponent="Modal"]`),
7
+ (element) => {
8
+ // eslint-disable-next-line no-console
9
+ console.log('loading Modal component....');
10
+ new Modal(element);
11
+ }
12
+ );
13
+ },
14
+ };
@@ -0,0 +1,130 @@
1
+ import { EVENTS } from '@ilo-org/utils';
2
+
3
+ /**
4
+ * The Modal module which handles control and display of a modal dialog
5
+ *
6
+ *
7
+ * @class Modal
8
+ */
9
+ export default class Modal {
10
+ /**
11
+ * Modal 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
+ // Initialize the view
24
+ this.init();
25
+ }
26
+
27
+ /**
28
+ * Initializes the view by calling the functions to
29
+ * create DOM references, setup event handlers and
30
+ * then create the event listeners
31
+ *
32
+ * @return {Object} Modal A reference to the instance of the class
33
+ * @chainable
34
+ */
35
+ init() {
36
+ this.cacheDomReferences().setupHandlers().enable();
37
+
38
+ return this;
39
+ }
40
+
41
+ /**
42
+ * Find all necessary DOM elements used in the view and cache them
43
+ *
44
+ * @return {Object} ReadMore A reference to the instance of the class
45
+ * @chainable
46
+ */
47
+ cacheDomReferences() {
48
+ /**
49
+ * The button for toggling Read More state
50
+ * @type {Object}
51
+ */
52
+ this.OpenButton = this.element.querySelector(`.modal--open`);
53
+ this.CloseButton = this.element.querySelector(`.modal--close`);
54
+
55
+ return this;
56
+ }
57
+
58
+ /**
59
+ * Bind event handlers with the proper context of `this`.
60
+ *
61
+ * @return {Object} Modal A reference to the current instance of the class
62
+ * @chainable
63
+ */
64
+ setupHandlers() {
65
+ this.OpenButtonHandler = this.openButtonClick.bind(this);
66
+ this.CloseHandler = this.closeButtonClick.bind(this);
67
+ this.KeyPressHandler = this.keyPress.bind(this);
68
+
69
+ return this;
70
+ }
71
+
72
+ /**
73
+ * Creates event listeners to enable interaction with view
74
+ *
75
+ * @return {Object} Modal A reference to the instance of the class
76
+ * @chainable
77
+ */
78
+ enable() {
79
+ this.OpenButton.addEventListener(EVENTS.CLICK, () => this.OpenButtonHandler());
80
+ this.CloseButton.addEventListener(EVENTS.CLICK, () => this.CloseHandler());
81
+
82
+ return this;
83
+ }
84
+
85
+ /**
86
+ * Actions performed on click of the open button
87
+ *
88
+ * @return {Object} Modal A reference to the instance of the class
89
+ * @chainable
90
+ */
91
+ openButtonClick() {
92
+ this.element.classList.add('show');
93
+ setTimeout(() => {
94
+ this.element.classList.add('fadein');
95
+ }, 125);
96
+ window.addEventListener(EVENTS.KEY_DOWN, (e) => this.KeyPressHandler(e));
97
+
98
+ return this;
99
+ }
100
+
101
+ /**
102
+ * Actions performed on click of the close button
103
+ *
104
+ * @return {Object} Modal A reference to the instance of the class
105
+ * @chainable
106
+ */
107
+ closeButtonClick() {
108
+ this.element.classList.remove('fadeout');
109
+ setTimeout(() => {
110
+ this.element.classList.remove('show');
111
+ }, 125);
112
+ window.removeEventListener(EVENTS.KEY_DOWN, (e) => this.KeyPressHandler(e));
113
+
114
+ return this;
115
+ }
116
+
117
+ /**
118
+ * Actions performed on key press
119
+ *
120
+ * @return {Object} Modal A reference to the instance of the class
121
+ * @chainable
122
+ */
123
+ keyPress(e) {
124
+ if (e.key === 'Escape') {
125
+ this.closeButtonClick();
126
+ }
127
+
128
+ return this;
129
+ }
130
+ }
@@ -0,0 +1,7 @@
1
+ import './index';
2
+
3
+ const patternDefinition = require('./modal.wingsuit.yml');
4
+
5
+ export const wingsuit = {
6
+ patternDefinition,
7
+ };
@@ -0,0 +1,18 @@
1
+ {#
2
+ MODAL COMPONENT
3
+
4
+ The modal calls another Twig into it, and therefore passes `modaldata` into it. `modaldata` should contain the fields for the component in question, just as if the component were being used anywhere else.
5
+ #}
6
+
7
+ {% if component != 'modal' %}
8
+ <div class="{{prefix}}--modal" data-loadcomponent="Modal" data-prefix="{{prefix}}">
9
+ {% include '@components/button/button.twig' with openbutton %}
10
+ <div class="{{prefix}}--modal--wrapper" aria-modal="true" role="alertdialog">
11
+ <div class="{{prefix}}--modal--background" role="presentation"></div>
12
+ <div class="{{prefix}}--modal--contents">
13
+ {% include '@components/' ~ component ~ '/' ~ component ~ '.twig' with modaldata %}
14
+ {% include '@components/button/button.twig' with closebutton %}
15
+ </div>
16
+ </div>
17
+ </div>
18
+ {% endif %}
@@ -0,0 +1,54 @@
1
+ modal:
2
+ use: '@components/modal/modal.twig'
3
+ label: Modal
4
+ description: The Modal displays a div containing a button which is visible on page load. On click of this button, a modal dialog is opened which displays a semitransparent fixed-position background and the contents of the chosen component.
5
+ fields:
6
+ closebutton:
7
+ type: object
8
+ label: Closee Button
9
+ description: Label and settings for the "close" button
10
+ preview:
11
+ size: 'small'
12
+ type: 'secondary'
13
+ label: 'Close Button'
14
+ icon: close
15
+ iconPos: center
16
+ icononly: true
17
+ className: 'modal--close'
18
+ required: true
19
+ component:
20
+ type: string
21
+ label: Component
22
+ description: The component to add to this modal
23
+ preview: "image"
24
+ required: true
25
+ modaldata:
26
+ type: object
27
+ label: Modal Data
28
+ description: The fields needed to populate the component being displayed by the modal
29
+ preview:
30
+ alt: 'My alt text'
31
+ caption: 'my image caption'
32
+ credit: 'Photo: copyright 2022 Person S. Name'
33
+ url:
34
+ - breakpoint: 0
35
+ src: 'https://place-hold.it/400x300?text=SmallBreakpointImage'
36
+ - breakpoint: 800
37
+ src: 'https://place-hold.it/800x600?text=MediumBreakpointImage'
38
+ - breakpoint: 1200
39
+ src: 'https://place-hold.it/1200x900?text=LargeBreakpointImage'
40
+ - breakpoint: 1440
41
+ src: 'https://place-hold.it/1600x1200?text=LargestBreakpointImage'
42
+ required: true
43
+ openbutton:
44
+ type: object
45
+ label: Open Button
46
+ description: The label and settings for the button that will open the modal
47
+ preview:
48
+ size: 'large'
49
+ type: 'primary'
50
+ label: 'Open Button'
51
+ className: 'modal--open'
52
+ opensmodal: true
53
+ required: true
54
+ visibility: storybook
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Notification
3
+ */
4
+ // Module template
5
+ import './notification.twig';
6
+ import './notification.wingsuit.yml';
7
+ import './notification.behavior';
@@ -0,0 +1,15 @@
1
+ import Notification from './notification';
2
+
3
+ Drupal.behaviors.notification = {
4
+ attach() {
5
+ console.log('got here....');
6
+ Array.prototype.forEach.call(
7
+ document.querySelectorAll(`[data-loadcomponent="Notification"]`),
8
+ (element) => {
9
+ // eslint-disable-next-line no-console
10
+ console.log('loading Notification component....');
11
+ new Notification(element);
12
+ }
13
+ );
14
+ },
15
+ };
@@ -0,0 +1,95 @@
1
+ import { EVENTS } from '@ilo-org/utils';
2
+
3
+ /**
4
+ * The Notification module which handles rendering field labels inline on a form.
5
+ *
6
+ * @class Notification
7
+ */
8
+ export default class Notification {
9
+ /**
10
+ * Notification 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.parent = this.element.parentElement;
22
+
23
+ // get the theme prefix
24
+ this.prefix = this.element.dataset.prefix;
25
+
26
+ // Initialize the view
27
+ this.init();
28
+ }
29
+
30
+ /**
31
+ * Initializes the view by calling the functions to
32
+ * create DOM references, setup event handlers and
33
+ * then create the event listeners
34
+ *
35
+ * @return {Object} Notification A reference to the instance of the class
36
+ * @chainable
37
+ */
38
+ init() {
39
+ this.cacheDomReferences().setupHandlers().enable();
40
+
41
+ return this;
42
+ }
43
+
44
+ /**
45
+ * Find all necessary DOM elements used in the view and cache them
46
+ *
47
+ * @return {Object} Notification A reference to the instance of the class
48
+ * @chainable
49
+ */
50
+ cacheDomReferences() {
51
+ /**
52
+ * The button for toggling Read More state
53
+ * @type {Object}
54
+ */
55
+ this.CloseButton = this.element.querySelector(`.${this.prefix}--notification--close`);
56
+
57
+ return this;
58
+ }
59
+
60
+ /**
61
+ * Bind event handlers with the proper context of `this`.
62
+ *
63
+ * @return {Object} Notification A reference to the current instance of the class
64
+ * @chainable
65
+ */
66
+ setupHandlers() {
67
+ this.onClick = this.onClick.bind(this);
68
+
69
+ return this;
70
+ }
71
+
72
+ /**
73
+ * Creates event listeners to enable interaction with view
74
+ *
75
+ * @return {Object} Notification A reference to the instance of the class
76
+ * @chainable
77
+ */
78
+ enable() {
79
+ this.CloseButton.addEventListener(EVENTS.CLICK, () => this.onClick());
80
+
81
+ return this;
82
+ }
83
+
84
+ /**
85
+ * Onclick interaction with the Notification button
86
+ *
87
+ * @return {Object} Notification A reference to the instance of the class
88
+ * @chainable
89
+ */
90
+ onClick() {
91
+ this.parent.removeChild(this.element);
92
+
93
+ return this;
94
+ }
95
+ }
@@ -0,0 +1,7 @@
1
+ import './index';
2
+
3
+ const patternDefinition = require('./notification.wingsuit.yml');
4
+
5
+ export const wingsuit = {
6
+ patternDefinition,
7
+ };
@@ -0,0 +1,18 @@
1
+ {#
2
+ NOTIFICATION COMPONENT
3
+ #}
4
+ <div class="{{prefix}}--notification {{prefix}}--notification--{{placement}} icon icon--{{type}}" role="status" aria-live="polite" aria-relevant="additions" data-loadcomponent="Notification" data-prefix="{{prefix}}">
5
+ <div class="{{prefix}}--notification--content">
6
+ <h2 class="{{prefix}}--notification--headline">{{headline}}</h2>
7
+ <p class="{{prefix}}--notification--copy">{{copy}}</p>
8
+ {% if timestamp %}
9
+ <time class="{{prefix}}--notification--date" datetime="{{timestamp.unix}}">{{timestamp.human}}</time>
10
+ {% endif %}
11
+ {% if cta %}
12
+ <a class="{{prefix}}--notification--cta {{prefix}}--button {{prefix}}--button--small {{prefix}}--button--secondary --light" href="{{cta.url}}">
13
+ <span class="link__label">{{cta.label}}</span>
14
+ </a>
15
+ {% endif %}
16
+ </div>
17
+ <button class="{{prefix}}--notification--close" type="button"><span>{{closelabel}}</span></button>
18
+ </div>
@@ -0,0 +1,58 @@
1
+ notification:
2
+ use: '@components/notification/notification.twig'
3
+ label: Notification
4
+ description: The Notification component presents a dismissible alert.
5
+ fields:
6
+ closelabel:
7
+ type: string
8
+ label: Close Button Label
9
+ description: The label for the close button
10
+ required: true
11
+ preview: 'Close'
12
+ copy:
13
+ type: string
14
+ label: Copy
15
+ description: The text content of the notification
16
+ required: true
17
+ preview: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
18
+ cta:
19
+ type: object
20
+ label: Call To Action
21
+ description: an optional call to action button
22
+ preview:
23
+ label: Optional CTA
24
+ url: 'http://www.google.com'
25
+ headline:
26
+ type: string
27
+ label: Headline
28
+ description: The headline of the notification
29
+ required: true
30
+ preview: 'With CTA'
31
+ placement:
32
+ type: select
33
+ label: Placement
34
+ description: The placement of the notification
35
+ required: true
36
+ options:
37
+ inline: Inline
38
+ dialog: Dialog
39
+ preview: 'dialog'
40
+ type:
41
+ type: select
42
+ label: Type
43
+ description: What kind of notification is it?
44
+ required: true
45
+ options:
46
+ error: Error
47
+ info: Info
48
+ success: Success
49
+ warning: Warning
50
+ preview: 'info'
51
+ timestamp:
52
+ type: object
53
+ label: Timestamp
54
+ description: an optional date object, with human-readable and unix timestamps
55
+ preview:
56
+ human: Dec 7, 2022
57
+ unix: 1670389200
58
+ visibility: storybook
@@ -0,0 +1,7 @@
1
+ import './index';
2
+
3
+ const patternDefinition = require('./pagination.wingsuit.yml');
4
+
5
+ export const wingsuit = {
6
+ patternDefinition,
7
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Pagination
3
+ */
4
+ // Module template
5
+ import './pagination.twig';
6
+ import './pagination.wingsuit.yml';
@@ -0,0 +1,48 @@
1
+ {#
2
+ PAGINATION COMPONENT
3
+ #}
4
+ <div class="{{prefix}}--pagination icon icon--{{type}}">
5
+ <div class="{{prefix}}--pagination--previous-set">
6
+ <a
7
+ class="{{prefix}}--pagination--first-page {{prefix}}--pagination--link {% if currentPage == 0 %}{{prefix}}--pagination--disable{% endif %}"
8
+ href="{{ firstPageUrl }}"
9
+ title="{{ firstPageTitle }}"
10
+ >
11
+ {{ firstPageTitle }}
12
+ </a>
13
+
14
+ <a
15
+ class="{{prefix}}--pagination--prev-page {{prefix}}--pagination--link {% if currentPage == 0 %}{{prefix}}--pagination--disable{% endif %}"
16
+ href="{{ prevPageUrl }}"
17
+ title="{{ prevPageTitle }}"
18
+ >
19
+ {{ prevPageTitle }}
20
+ </a>
21
+ </div>
22
+
23
+ <p class="{{prefix}}--pagination--page">
24
+ {% set currentPageZeroIndex = currentPage * 1 %}
25
+ {% set currentPageIndex = currentPageZeroIndex + 1 %}
26
+
27
+ <span>{{currentPageIndex}}</span> {{pageCountPreposition}}
28
+ <span>{{totalPages}}</span>
29
+ </p>
30
+
31
+ <div class="{{prefix}}--next-set">
32
+ <a
33
+ class="{{prefix}}--pagination--next-page {{prefix}}--pagination--link {% if currentPageIndex == totalPages %}{{prefix}}--pagination--disable{% endif %}"
34
+ href="{{ nextPageUrl }}"
35
+ title="{{ nextPageTitle }}"
36
+ >
37
+ {{ nextPageTitle }}
38
+ </a>
39
+
40
+ <a
41
+ class="{{prefix}}--pagination--last-page {{prefix}}--pagination--link {% if currentPageIndex == totalPages %}{{prefix}}--pagination--disable{% endif %}"
42
+ href="{{ lastPageUrl }}"
43
+ title="{{ lastPageTitle }}"
44
+ >
45
+ {{ lastPageTitle }}
46
+ </a>
47
+ </div>
48
+ </div>