@ilo-org/twig 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/.turbo/turbo-build.log +14680 -15301
  2. package/CHANGELOG.md +24 -0
  3. package/package.json +4 -4
  4. package/src/patterns/components/breadcrumb/breadcrumb.js +24 -0
  5. package/src/patterns/components/button/button.twig +1 -1
  6. package/src/patterns/components/card/card.twig +7 -3
  7. package/src/patterns/components/card/card.wingsuit.yml +0 -1
  8. package/src/patterns/components/cardgroup/cardgroup.wingsuit.yml +9 -10
  9. package/src/patterns/components/form/form.wingsuit.yml +0 -1
  10. package/src/patterns/components/modal/modal.js +1 -1
  11. package/src/patterns/components/modal/modal.wingsuit.yml +2 -2
  12. package/src/patterns/components/navigation/navigation.js +58 -4
  13. package/src/patterns/components/navigation/navigation.twig +28 -2
  14. package/src/patterns/components/notification/notification.wingsuit.yml +9 -9
  15. package/src/patterns/components/searchfield/searchfield.wingsuit.yml +1 -1
  16. package/src/patterns/components/table/table.js +4 -0
  17. package/src/patterns/components/table/table.twig +3 -0
  18. package/src/patterns/components/table/table.wingsuit.yml +1 -1
  19. package/src/patterns/components/tableofcontents/index.js +1 -0
  20. package/src/patterns/components/tableofcontents/tableofcontents.behavior.js +14 -0
  21. package/src/patterns/components/tableofcontents/tableofcontents.js +164 -0
  22. package/src/patterns/components/tableofcontents/tableofcontents.twig +18 -9
  23. package/src/patterns/components/tableofcontents/tableofcontents.wingsuit.yml +29 -0
  24. package/src/patterns/components/tabs/tabs.twig +0 -1
@@ -0,0 +1,164 @@
1
+ import { EVENTS } from '@ilo-org/utils';
2
+
3
+ /**
4
+ * The TableOfContents module which handles control and display of a TableOfContents dialog
5
+ *
6
+ *
7
+ * @class TableOfContents
8
+ */
9
+ export default class TableOfContents {
10
+ /**
11
+ * TableOfContents 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
+
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} TableOfContents 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} ReadMore 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.OpenButton = this.element.querySelector(`.toc--modal--open`);
56
+ this.CloseButton = this.element.querySelector(`.toc--modal--close`);
57
+ this.trigger = this.element.querySelector(`.${this.prefix}--table-of-contents--trigger`);
58
+ this.modalUx = this.element.querySelector(`.${this.prefix}--table-of-contents--modal`);
59
+ this.toc = this.element.querySelector(`.${this.prefix}--table-of-contents`);
60
+ this.tocItems = this.element.querySelectorAll(`.${this.prefix}--table-of-contents--link`);
61
+
62
+ return this;
63
+ }
64
+
65
+ /**
66
+ * Bind event handlers with the proper context of `this`.
67
+ *
68
+ * @return {Object} TableOfContents A reference to the current instance of the class
69
+ * @chainable
70
+ */
71
+ setupHandlers() {
72
+ this.OpenButtonHandler = this.openButtonClick.bind(this);
73
+ this.CloseHandler = this.closeButtonClick.bind(this);
74
+ this.KeyPressHandler = this.keyPress.bind(this);
75
+ this.linkClickHandler = this.linkClick.bind(this);
76
+
77
+ return this;
78
+ }
79
+
80
+ /**
81
+ * Creates event listeners to enable interaction with view
82
+ *
83
+ * @return {Object} TableOfContents A reference to the instance of the class
84
+ * @chainable
85
+ */
86
+ enable() {
87
+ this.OpenButton.addEventListener(EVENTS.CLICK, () => this.OpenButtonHandler());
88
+ this.CloseButton.addEventListener(EVENTS.CLICK, () => this.CloseHandler());
89
+
90
+ if (this.tocItems.length > 0) {
91
+ this.tocItems.forEach((link, i) => {
92
+ link.addEventListener(EVENTS.CLICK, () => this.linkClickHandler());
93
+ });
94
+ }
95
+
96
+ return this;
97
+ }
98
+
99
+ /**
100
+ * Actions performed on click of the open button
101
+ *
102
+ * @return {Object} TableOfContents A reference to the instance of the class
103
+ * @chainable
104
+ */
105
+ openButtonClick() {
106
+ this.trigger.classList.add('hide');
107
+ this.element.classList.add('show');
108
+ this.modalUx.classList.add('show');
109
+ this.toc.classList.add('show');
110
+ setTimeout(() => {
111
+ this.modalUx.classList.add('fadein');
112
+ this.toc.classList.add('fadein');
113
+ }, 125);
114
+ window.addEventListener(EVENTS.KEY_DOWN, (e) => this.KeyPressHandler(e));
115
+
116
+ return this;
117
+ }
118
+
119
+ /**
120
+ * Actions performed on click of the close button
121
+ *
122
+ * @return {Object} TableOfContents A reference to the instance of the class
123
+ * @chainable
124
+ */
125
+ closeButtonClick() {
126
+ this.modalUx.classList.remove('fadein');
127
+ this.toc.classList.remove('fadein');
128
+ setTimeout(() => {
129
+ this.modalUx.classList.remove('show');
130
+ this.toc.classList.remove('show');
131
+ this.element.classList.remove('show');
132
+ this.trigger.classList.remove('hide');
133
+ }, 125);
134
+ window.removeEventListener(EVENTS.KEY_DOWN, (e) => this.KeyPressHandler(e));
135
+
136
+ return this;
137
+ }
138
+
139
+ /**
140
+ * Actions performed on click of any link
141
+ *
142
+ * @return {Object} TableOfContents A reference to the instance of the class
143
+ * @chainable
144
+ */
145
+ linkClick() {
146
+ this.closeButtonClick();
147
+
148
+ return this;
149
+ }
150
+
151
+ /**
152
+ * Actions performed on key press
153
+ *
154
+ * @return {Object} TableOfContents A reference to the instance of the class
155
+ * @chainable
156
+ */
157
+ keyPress(e) {
158
+ if (e.key === 'Escape') {
159
+ this.closeButtonClick();
160
+ }
161
+
162
+ return this;
163
+ }
164
+ }
@@ -2,13 +2,22 @@
2
2
  TABLE OF CONTENTS COMPONENT
3
3
  #}
4
4
  {% if items %}
5
- <nav class="{{prefix}}--table-of-contents">
6
- <ul class="{{prefix}}--table-of-contents--list">
7
- {% for item in items %}
8
- <li class="{{prefix}}--table-of-contents--list--item">
9
- <a class="{{prefix}}--table-of-contents--link" href="{{item.href}}">{{item.label}}</a>
10
- </li>
11
- {% endfor %}
12
- </ul>
13
- </nav>
5
+ <div class="{{prefix}}--table-of-contents--wrapper" data-loadcomponent="TableOfContents" data-prefix="{{prefix}}">
6
+ <div class="{{prefix}}--table-of-contents--trigger">
7
+ {% include '@components/button/button.twig' with openbutton %}
8
+ </div>
9
+ <div class="{{prefix}}--table-of-contents--modal">
10
+ <h3 class="{{prefix}}--table-of-contents--headline">{{headline}}</h3>
11
+ {% include '@components/button/button.twig' with closebutton %}
12
+ </div>
13
+ <nav class="{{prefix}}--table-of-contents">
14
+ <ul class="{{prefix}}--table-of-contents--list">
15
+ {% for item in items %}
16
+ <li class="{{prefix}}--table-of-contents--list--item">
17
+ <a class="{{prefix}}--table-of-contents--link" href="{{item.href}}">{{item.label}}</a>
18
+ </li>
19
+ {% endfor %}
20
+ </ul>
21
+ </nav>
22
+ </div>
14
23
  {% endif %}
@@ -3,6 +3,35 @@ tableofcontents:
3
3
  label: Table Of Contents
4
4
  description: A component for displaying links internal to a page
5
5
  fields:
6
+ openbutton:
7
+ type: object
8
+ label: Open Button
9
+ description: The label and settings for the button that will show the table of contents at small breakpoints
10
+ preview:
11
+ size: 'medium'
12
+ type: 'secondary'
13
+ label: 'Open Button'
14
+ className: 'toc--modal--open'
15
+ opensmodal: true
16
+ required: true
17
+ closebutton:
18
+ type: object
19
+ label: Close Button
20
+ description: Label and settings for the "close" button
21
+ preview:
22
+ size: 'large'
23
+ type: 'tertiary'
24
+ label: 'Close Button'
25
+ icon: close
26
+ iconPos: center
27
+ icononly: true
28
+ className: 'toc--modal--close'
29
+ headline:
30
+ type: string
31
+ label: Headline
32
+ description: A headline for the small breakpoint view of the table of contents, shown when it is opened. Design recommendation is that this matches the page title as shown in the hero.
33
+ preview: "Page Title"
34
+ required: true
6
35
  items:
7
36
  type: object
8
37
  label: Items
@@ -6,7 +6,6 @@
6
6
  {% for item in items %}
7
7
  {% set tabids = tabids|merge([random(100000)]) %}
8
8
  {% endfor %}
9
-
10
9
  <div class="{{prefix}}--tabs" data-prefix="{{prefix}}" id="tabs--{{uid}}" data-loadcomponent="Tabs">
11
10
  <ul class="{{prefix}}--tabs--selection" aria-controls="tabs--{{uid}}" role="tablist" style="--tabscount: {{items|length}};">
12
11
  {% for item in items %}