@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,14 @@
1
+ /**
2
+ * Global namespaces
3
+ */
4
+
5
+ const path = require('path');
6
+
7
+ const patterns = path.resolve(__dirname, 'patterns');
8
+
9
+ module.exports = {
10
+ patterns: patterns,
11
+ components: path.resolve(patterns, 'components'),
12
+ tokens: path.resolve(__dirname, 'tokens'),
13
+ svgs: path.resolve(__dirname, 'svgs'),
14
+ };
@@ -0,0 +1,16 @@
1
+ {#
2
+ ACCORDION ITEM COMPONENT
3
+ #}
4
+ {% set uid = "now"|date('Uv') %}
5
+ <li class="{{prefix}}--accordion--item" id=" {{ id }}{{ uid }}">
6
+ <div class="ilo--h3">
7
+ <button class="{{prefix}}--accordion--button {{prefix}}--accordion--button--{{ size|default('small') }}" aria-expanded="{{ defaultExpanded }}" aria-controls="panel-{{ id }}{{ uid }}" id="button-{{ id }}{{ uid }}">
8
+ {{label}}
9
+ </button>
10
+ </div>
11
+ <div class="{{prefix}}--accordion--panel{% if defaultExpanded == 'true'%} {{prefix}}--accordion--panel--open{% endif %}" id="panel-{{ id }}{{ uid }}" aria-labelledby="button-{{ id }}{{ uid }}" role="region">
12
+ <div class="{{prefix}}--accordion--innerpanel">
13
+ {{content|raw}}
14
+ </div>
15
+ </div>
16
+ </li>
@@ -0,0 +1,30 @@
1
+ accordion:
2
+ use: '@components/accordion/accordion-item.twig'
3
+ label: Accordion Item
4
+ description: A collapsible accordion item.
5
+ fields:
6
+ label:
7
+ type: text
8
+ label: Label
9
+ description: The accordion item's heading.
10
+ preview:
11
+ faker: lorem.word
12
+ content:
13
+ type: text
14
+ label: Content
15
+ description: The accordion item's collapsed content.
16
+ preview:
17
+ faker: lorem.word
18
+ id:
19
+ type: text
20
+ label: ID
21
+ description: The accordion item's id.
22
+ preview:
23
+ faker: lorem.word
24
+ defaultExpanded:
25
+ type: text
26
+ label: Default Expanded
27
+ description: The accordion item loads in default expanded state.
28
+ preview:
29
+ faker: lorem.word
30
+ visibility: storybook
@@ -0,0 +1,14 @@
1
+ import Accordion from './accordion';
2
+
3
+ Drupal.behaviors.accordion = {
4
+ attach() {
5
+ Array.prototype.forEach.call(
6
+ document.querySelectorAll(`[data-loadcomponent="Accordion"]`),
7
+ (element) => {
8
+ // eslint-disable-next-line no-console
9
+ console.log('loading Accordion component....');
10
+ new Accordion(element);
11
+ }
12
+ );
13
+ },
14
+ };
@@ -0,0 +1,178 @@
1
+ import { getUpdatedItems, EVENTS, ARIA, MISC } from '@ilo-org/utils';
2
+
3
+ /**
4
+ * The Accordion module which handles rendering field labels inline on a form.
5
+ *
6
+ * @class Accordion
7
+ */
8
+ export default class Accordion {
9
+ /**
10
+ * Accordion 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.multipleExpanded = false;
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} Accordion A reference to the instance of the class
33
+ * @chainable
34
+ */
35
+ init() {
36
+ this.cacheDomReferences().setupHandlers().enable().evaluateAccordionHeights();
37
+
38
+ return this;
39
+ }
40
+
41
+ /**
42
+ * Find all necessary DOM elements used in the view and cache them
43
+ *
44
+ * @return {Object} Accordion A reference to the instance of the class
45
+ * @chainable
46
+ */
47
+ cacheDomReferences() {
48
+ /**
49
+ * The field that a user interacts with on a form
50
+ * @type {Object}
51
+ */
52
+ this.accordionItems = this.element.querySelectorAll('.ilo--accordion--item');
53
+ this.multipleExpanded = this.element.getAttribute('data-multipleexpanded') === 'true';
54
+ this.accordionPanels = this.element.querySelectorAll('.ilo--accordion--panel');
55
+ this.accordionButtons = this.element.querySelectorAll('.ilo--accordion--button');
56
+ console.log(this.multipleExpanded);
57
+
58
+ return this;
59
+ }
60
+
61
+ /**
62
+ * Bind event handlers with the proper context of `this`.
63
+ *
64
+ * @return {Object} Accordion A reference to the current instance of the class
65
+ * @chainable
66
+ */
67
+ setupHandlers() {
68
+ this.collapseSection = this.collapseSection.bind(this);
69
+ this.expandSection = this.expandSection.bind(this);
70
+ this.onClick = this.onClick.bind(this);
71
+ this.updateAccordionItems = this.updateAccordionItems.bind(this);
72
+
73
+ return this;
74
+ }
75
+
76
+ /**
77
+ * Creates event listeners to enable interaction with view
78
+ *
79
+ * @return {Object} Accordion A reference to the instance of the class
80
+ * @chainable
81
+ */
82
+ enable() {
83
+ if (this.accordionButtons.length > 0) {
84
+ this.accordionButtons.forEach((button, i) => {
85
+ button.addEventListener(EVENTS.CLICK, (e) => this.onClick(e));
86
+ });
87
+ }
88
+
89
+ return this;
90
+ }
91
+
92
+ /**
93
+ * Onclick interaction with the accordion button
94
+ *
95
+ * @return {Object} Accordion A reference to the instance of the class
96
+ * @chainable
97
+ */
98
+ onClick(e) {
99
+ this.updateAccordionItems(e.target);
100
+
101
+ return this;
102
+ }
103
+
104
+ /**
105
+ * Evaluate accordion panel heights
106
+ *
107
+ * @chainable
108
+ */
109
+ evaluateAccordionHeights() {
110
+ this.accordionPanels.forEach((item, i) => {
111
+ item.style.setProperty(
112
+ '--height',
113
+ item.querySelector('.ilo--accordion--innerpanel').scrollHeight + 'px'
114
+ );
115
+ });
116
+
117
+ return this;
118
+ }
119
+
120
+ /**
121
+ * Update accordion items based off of new statuses
122
+ *
123
+ * @chainable
124
+ */
125
+ updateAccordionItems(panelbutton) {
126
+ const panel = panelbutton
127
+ .closest('.ilo--accordion--item')
128
+ .querySelector('.ilo--accordion--panel');
129
+ const isopen = panel.classList.contains('ilo--accordion--panel--open');
130
+
131
+ if (!this.multipleExpanded) {
132
+ this.accordionPanels.forEach((item) => {
133
+ if (panel !== item) {
134
+ this.collapseSection(item);
135
+ }
136
+ });
137
+ }
138
+
139
+ if (!isopen) {
140
+ this.expandSection(panel);
141
+ } else {
142
+ this.collapseSection(panel);
143
+ }
144
+ panelbutton.blur();
145
+
146
+ return this;
147
+ }
148
+
149
+ /**
150
+ * Animates a panel collapse
151
+ *
152
+ * @param {HTMLElement} element - REQUIRED - the accordion panel to be collapsed
153
+ *
154
+ * @chainable
155
+ */
156
+ collapseSection(element) {
157
+ element.parentElement
158
+ .querySelector('.ilo--accordion--button')
159
+ .setAttribute(ARIA.EXPANDED, 'true');
160
+ element.setAttribute(ARIA.HIDDEN, 'false');
161
+ element.classList.remove('ilo--accordion--panel--open');
162
+ }
163
+
164
+ /**
165
+ * Animates a panel expansion
166
+ *
167
+ * @param {HTMLElement} element - REQUIRED - the accordion panel to be expanded
168
+ *
169
+ * @chainable
170
+ */
171
+ expandSection(element) {
172
+ element.parentElement
173
+ .querySelector('.ilo--accordion--button')
174
+ .setAttribute(ARIA.EXPANDED, 'false');
175
+ element.setAttribute(ARIA.HIDDEN, 'true');
176
+ element.classList.add('ilo--accordion--panel--open');
177
+ }
178
+ }
@@ -0,0 +1,7 @@
1
+ import './index';
2
+
3
+ const patternDefinition = require('./accordion.wingsuit.yml');
4
+
5
+ export const wingsuit = {
6
+ patternDefinition,
7
+ };
@@ -0,0 +1,17 @@
1
+ {#
2
+ ACCORDION COMPONENT
3
+ #}
4
+ <ul class="{{prefix}}--accordion {{prefix}}--accordion--{{ size|default('small') }}" data-loadcomponent="Accordion" data-multipleexpanded="{{ allowMultipleExpanded|default(false) }}">
5
+ {% for item in items %}
6
+ {% include "@components/accordion/accordion-item.twig" with {
7
+ label: item.label,
8
+ content: item.content,
9
+ defaultExpanded: item.defaultExpanded,
10
+ size: size,
11
+ headingLevel: headingLevel,
12
+ id: item.id,
13
+ prefix: prefix
14
+ } only %}
15
+ {% endfor %}
16
+ </ul>
17
+ </div>
@@ -0,0 +1,59 @@
1
+ accordion:
2
+ use: '@components/accordion/accordion.twig'
3
+ label: Accordion
4
+ description: The accordion component allows the user to show and hide sections of
5
+ related content on a page. Click the accordions below to
6
+ expand/collapse the accordion content.
7
+ fields:
8
+ size:
9
+ type: select
10
+ label: Size
11
+ description: The size of the accordion.
12
+ required: false
13
+ options:
14
+ small: Small
15
+ large: Large
16
+ preview: small
17
+ allowMultipleExpanded:
18
+ type: string
19
+ label: Allow Multiple Expanded
20
+ description: Allow mutiple accordion items to be expandable at once.
21
+ preview: 'true'
22
+ required: false
23
+ items:
24
+ type: object
25
+ label: Items
26
+ description: The accordion items.
27
+ required: true
28
+ preview:
29
+ - label: label 1
30
+ content: "<p>Content of Item 1</p><p>Content of Item 1</p><p>Content of Item 1</p><p>Content of Item 1</p><p>Content of Item 1</p>"
31
+ id: item1
32
+ defaultExpanded: false
33
+ - label: label 2
34
+ content: "<p>Content of Item 2</p><p>Content of Item 2</p><p>Content of Item 2</p><p>Content of Item 2</p><p>Content of Item 2</p>"
35
+ id: item2
36
+ defaultExpanded: false
37
+ variants:
38
+ default:
39
+ label: Default
40
+ description: the default settings for the Accordion
41
+ expanded:
42
+ label: Expanded
43
+ description: The Accordion with panels opened on page load
44
+ fields:
45
+ items:
46
+ - label: label 1
47
+ content: "<p>Content of Item 1</p><p>Content of Item 1</p><p>Content of Item 1</p><p>Content of Item 1</p><p>Content of Item 1</p>"
48
+ id: item1
49
+ defaultExpanded: 'true'
50
+ - label: label 2
51
+ content: "<p>Content of Item 2</p><p>Content of Item 2</p><p>Content of Item 2</p><p>Content of Item 2</p><p>Content of Item 2</p>"
52
+ id: item2
53
+ defaultExpanded: 'true'
54
+ multiple:
55
+ label: Allow Multiple Expanded
56
+ description: The Accordion set to allow multiple panels to be expanded at once
57
+ fields:
58
+ allowMultipleExpanded: 'true'
59
+ visibility: storybook
@@ -0,0 +1,7 @@
1
+ /**
2
+ * accordion
3
+ */
4
+ // Module template
5
+ import './accordion.twig';
6
+ import './accordion.wingsuit.yml';
7
+ import './accordion.behavior';
@@ -0,0 +1,14 @@
1
+ import Breadcrumb from './breadcrumb';
2
+
3
+ Drupal.behaviors.breadcrumb = {
4
+ attach() {
5
+ Array.prototype.forEach.call(
6
+ document.querySelectorAll(`[data-loadcomponent="Breadcrumb"]`),
7
+ (element) => {
8
+ // eslint-disable-next-line no-console
9
+ console.log('loading Breadcrumb component....');
10
+ new Breadcrumb(element);
11
+ }
12
+ );
13
+ },
14
+ };
@@ -0,0 +1,93 @@
1
+ import { EVENTS } from '@ilo-org/utils';
2
+
3
+ /**
4
+ * The Breadcrumb module which handles rendering field labels inline on a form.
5
+ *
6
+ * @class Breadcrumb
7
+ */
8
+ export default class Breadcrumb {
9
+ /**
10
+ * Breadcrumb 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
+
22
+ // get the theme prefix
23
+ this.prefix = this.element.dataset.prefix;
24
+
25
+ // Initialize the view
26
+ this.init();
27
+ }
28
+
29
+ /**
30
+ * Initializes the view
31
+ *
32
+ * @return {Object} Breadcrumb A reference to the instance of the class
33
+ * @chainable
34
+ */
35
+ init() {
36
+ this.cacheDomReferences().setupHandlers().enable().onResize();
37
+
38
+ return this;
39
+ }
40
+
41
+ /**
42
+ * Find all necessary DOM elements used in the view and cache them
43
+ *
44
+ * @return {Object} Breadcrumb A reference to the instance of the class
45
+ * @chainable
46
+ */
47
+ cacheDomReferences() {
48
+ this.breadcrumbs = this.element.querySelector('.ilo--breadcrumb--items');
49
+ this.breadcrumbwidth = this.breadcrumbs.offsetWidth;
50
+
51
+ return this;
52
+ }
53
+
54
+ /**
55
+ * Bind event handlers with the proper context of `this`.
56
+ *
57
+ * @return {Object} Breadcrumb A reference to the current instance of the class
58
+ * @chainable
59
+ */
60
+ setupHandlers() {
61
+ this.onResize = this.onResize.bind(this);
62
+
63
+ return this;
64
+ }
65
+
66
+ /**
67
+ * Creates event listeners to enable interaction with view
68
+ *
69
+ * @return {Object} Breadcrumb A reference to the instance of the class
70
+ * @chainable
71
+ */
72
+ enable() {
73
+ window.addEventListener(EVENTS.RESIZE, (e) => this.onResize(e));
74
+
75
+ return this;
76
+ }
77
+
78
+ /**
79
+ * onResize interaction with the accordion button
80
+ *
81
+ * @return {Object} Breadcrumb A reference to the instance of the class
82
+ * @chainable
83
+ */
84
+ onResize(e) {
85
+ if (this.breadcrumbwidth > this.element.offsetWidth / 2) {
86
+ this.element.classList.add('contextmenu');
87
+ } else {
88
+ this.element.classList.remove('contextmenu');
89
+ }
90
+
91
+ return this;
92
+ }
93
+ }
@@ -0,0 +1,7 @@
1
+ import './index';
2
+
3
+ const patternDefinition = require('./breadcrumb.wingsuit.yml');
4
+
5
+ export const wingsuit = {
6
+ patternDefinition,
7
+ };
@@ -0,0 +1,32 @@
1
+ {#
2
+ BREADCRUMB COMPONENT
3
+ #}
4
+ {% set lastlink = links|last %}
5
+
6
+ <nav class="{{prefix}}--breadcrumb{% if className %} {{className}}{% endif %}" data-prefix="{{prefix}}" data-loadcomponent="Breadcrumb">
7
+ <ol class="{{prefix}}--breadcrumb--items">
8
+ <li class="{{prefix}}--breadcrumb--item home">
9
+ <a class="{{prefix}}--breadcrumb--link" href="{{home.url}}">
10
+ <span class="{{prefix}}--breadcrumb--link--label">{{home.label}}</span>
11
+ </a>
12
+ </li>
13
+ <li class="{{prefix}}--breadcrumb--item--context">
14
+ <ul class="{{prefix}}--breadcrumb--items context--menu">
15
+ {% for link in links %}
16
+ {% if not loop.last %}
17
+ <li class="{{prefix}}--breadcrumb--item">
18
+ <a href="{{link.url}}" class="{{prefix}}--breadcrumb--link">
19
+ <span class="{{prefix}}--breadcrumb--link--label">{{link.label}}</span>
20
+ </a>
21
+ </li>
22
+ {% endif %}
23
+ {% endfor %}
24
+ </ul>
25
+ </li>
26
+ <li class="{{prefix}}--breadcrumb--item final">
27
+ <a class="{{prefix}}--breadcrumb--link" href="{{lastlink.url}}">
28
+ <span class="{{prefix}}--breadcrumb--link--label">{{lastlink.label}}</span>
29
+ </a>
30
+ </li>
31
+ </ol>
32
+ </nav>
@@ -0,0 +1,35 @@
1
+ breadcrumb:
2
+ use: '@components/breadcrumb/breadcrumb.twig'
3
+ label: Breadcrumb
4
+ description: A component for displaying links in a "breadcrumb" ux
5
+ fields:
6
+ home:
7
+ type: object
8
+ label: Home
9
+ description: url and label for link to site home page
10
+ required: true
11
+ preview:
12
+ label: "Home"
13
+ url: "/"
14
+ links:
15
+ type: object
16
+ label: Home
17
+ description: the links to display in the breadcrumb
18
+ required: true
19
+ preview:
20
+ - label: "Link One"
21
+ url: "/linkone"
22
+ - label: "Link Two"
23
+ url: "/linktwo"
24
+ - label: "Link Three"
25
+ url: "/linkthree"
26
+ - label: "Link Four"
27
+ url: "/linkfour"
28
+ - label: "Link Five"
29
+ url: "/linkfive"
30
+ className:
31
+ type: string
32
+ label: className
33
+ description: optional class name
34
+ preview: "storybook"
35
+ visibility: storybook
@@ -0,0 +1,7 @@
1
+ /**
2
+ * breadcrumb
3
+ */
4
+ // Module template
5
+ import './breadcrumb.twig';
6
+ import './breadcrumb.wingsuit.yml';
7
+ import './breadcrumb.behavior';
@@ -0,0 +1,7 @@
1
+ import './index';
2
+
3
+ const patternDefinition = require('./button.wingsuit.yml');
4
+
5
+ export const wingsuit = {
6
+ patternDefinition,
7
+ };
@@ -0,0 +1,18 @@
1
+ {#
2
+ BUTTON COMPONENT
3
+ #}
4
+ {% if url %}
5
+ <a class="{{prefix}}--button ilo--button--{{size}} {{prefix}}--button--{{type}}{% if icon %} icon icon__position--{{iconPos}}{% endif %}{% if icononly %} icon--only{% endif %}{% if className %} {{className}}{% endif %}" href="{{url}}" {% if target %}target="{{target}}" rel="noopener noreferrer"{% endif %} {% if disabled is defined and disabled == 'true' %}disabled{% endif %}>
6
+ <span class="link__label">{{label}}</span>
7
+ {% if icon %}
8
+ {% include '@components/icon/icon.twig' with {icon: icon} %}
9
+ {% endif %}
10
+ </a>
11
+ {% else %}
12
+ <button class="{{prefix}}--button ilo--button--{{size}} {{prefix}}--button--{{type}}{% if icon %} icon icon__position--{{iconPos}}{% endif %}{% if icononly %} icon--only{% endif %}{% if className %} {{className}}{% endif %}" {% if kind %}type="{{kind}}"{% endif %}{% if opensmodal %} aria-haspopup="dialog"{% endif %} {% if disabled is defined and disabled == 'true' %}disabled{% endif %}>
13
+ <span class="button__label">{{label}}</span>
14
+ {% if icon %}
15
+ {% include '@components/icon/icon.twig' with {icon: icon} %}
16
+ {% endif %}
17
+ </button>
18
+ {% endif %}
@@ -0,0 +1,104 @@
1
+ button:
2
+ use: '@components/button/button.twig'
3
+ label: Button
4
+ description: A button or a link styled like a button.
5
+ fields:
6
+ size:
7
+ type: select
8
+ label: Size
9
+ description: The size of the button.
10
+ required: true
11
+ options:
12
+ small: Small
13
+ medium: Medium
14
+ large: Large
15
+ preview: 'large'
16
+ type:
17
+ type: select
18
+ label: Type
19
+ description: The type of button.
20
+ required: true
21
+ options:
22
+ primary: Primary
23
+ secondary: Secondary
24
+ tertiary: Tertiary
25
+ alert: Alert
26
+ icononly: Icon Only
27
+ preview: 'primary'
28
+ disabled:
29
+ type: select
30
+ label: Disabled
31
+ description: The disabled state of the button.
32
+ required: false
33
+ options:
34
+ true: 'true'
35
+ false: false
36
+ preview: 'false'
37
+ label:
38
+ type: string
39
+ label: Label
40
+ description: The label for the button
41
+ preview: 'Button'
42
+ required: true
43
+ url:
44
+ type: string
45
+ label: url
46
+ description: The url for the button if it's a link
47
+ preview: ''
48
+ required: false
49
+ target:
50
+ type: string
51
+ label: target
52
+ description: Should the button open in a new tab? If so, include the name of the tab. Only evaluated if the url field is populated.
53
+ preview: 'true'
54
+ required: false
55
+ kind:
56
+ type: select
57
+ label: Kind
58
+ description: What kind of functionality does the button have?
59
+ required: false
60
+ options:
61
+ button: button
62
+ reset: reset
63
+ submit: submit
64
+ preview: 'button'
65
+ icon:
66
+ type: string
67
+ label: Icon
68
+ description: optional icon to include in button
69
+ preview: false
70
+ required: false
71
+ iconPosition:
72
+ type: select
73
+ label: Icon Position
74
+ description: if there's an icon, where is it in the button?
75
+ fields:
76
+ left: left
77
+ right: right
78
+ preview: left
79
+ required: false
80
+ icononly:
81
+ type: select
82
+ label: Icon Only
83
+ description: Is this an icon-only button?
84
+ fields:
85
+ true: 'true'
86
+ false: false
87
+ preview: false
88
+ required: false
89
+ className:
90
+ type: string
91
+ label: Class name
92
+ description: optional class name
93
+ preview: 'optionalclass'
94
+ required: false
95
+ opensmodal:
96
+ type: select
97
+ label: Opens Modal
98
+ description: Does this button trigger open a modal?
99
+ fields:
100
+ true: 'true'
101
+ false: false
102
+ preview: false
103
+ required: false
104
+ visibility: storybook
@@ -0,0 +1,6 @@
1
+ /**
2
+ * button
3
+ */
4
+ // Module template
5
+ import './button.twig';
6
+ import './button.wingsuit.yml';