@ilo-org/twig 0.0.1 → 0.0.2

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # @ilo-org/twig
2
+
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - b61692a: CSS should default to assuming fonts are being loaded via a server rather than by means of the monorepo
8
+ - Updated dependencies [b61692a]
9
+ - @ilo-org/fonts@0.0.2
10
+ - @ilo-org/styles@0.0.2
@@ -1,2 +1,2 @@
1
1
  @import '~@ilo-org/fonts';
2
- @import '@ilo-org/styles/scss';
2
+ @import '@ilo-org/styles/scss/monorepo';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilo-org/twig",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Twig components for the ILO's Design System",
6
6
  "main": "",
@@ -20,9 +20,9 @@
20
20
  "components"
21
21
  ],
22
22
  "dependencies": {
23
- "@ilo-org/fonts": "0.0.1",
23
+ "@ilo-org/fonts": "0.0.2",
24
24
  "@ilo-org/icons": "0.0.1",
25
- "@ilo-org/styles": "0.0.1",
25
+ "@ilo-org/styles": "0.0.2",
26
26
  "@ilo-org/themes": "0.0.1",
27
27
  "@ilo-org/utils": "0.0.1",
28
28
  "@wingsuit-designsystem/preset-scss": "^1.2.3",
@@ -1,6 +1,6 @@
1
1
  import Callout from './callout';
2
2
 
3
- Drupal.behaviors.tag = {
3
+ Drupal.behaviors.callout = {
4
4
  attach() {
5
5
  Array.prototype.forEach.call(
6
6
  document.querySelectorAll(`[data-loadcomponent="Callout"]`),
@@ -34,6 +34,9 @@ export default class Callout {
34
34
  */
35
35
  init() {
36
36
  this.cacheDomReferences().setupHandlers().enable();
37
+ if (!this.toggleOpen) {
38
+ this.calcHeight();
39
+ }
37
40
 
38
41
  return this;
39
42
  }
@@ -51,10 +54,12 @@ export default class Callout {
51
54
  */
52
55
  this.toggle = this.element.querySelector('.ilo--callout--toggle');
53
56
  this.toggleOpen = this.element.classList.value.includes('ilo--callout--open');
54
- this.toggleLabel = this.toggle.querySelector('.ilo--callout--button-text');
55
- this.toggleLabelOpen = this.toggle.getAttribute('data-open');
56
- this.toggleLabelClosed = this.toggle.getAttribute('data-closed');
57
- this.button = this.element.querySelectorAll('.ilo--button');
57
+ if (this.toggle) {
58
+ this.toggleLabel = this.toggle.querySelector('.ilo--callout--button-text');
59
+ this.toggleLabelOpen = this.toggle.getAttribute('data-open');
60
+ this.toggleLabelClosed = this.toggle.getAttribute('data-closed');
61
+ }
62
+ this.button = this.element.querySelector('.ilo--button');
58
63
 
59
64
  return this;
60
65
  }
@@ -79,8 +84,29 @@ export default class Callout {
79
84
  * @chainable
80
85
  */
81
86
  enable() {
82
- this.toggle.addEventListener(EVENTS.CLICK, onToggle);
83
- this.button.addEventListener(EVENTS.CLICK, onClick);
87
+ if (this.toggle) {
88
+ console.log('this is toggle');
89
+ this.toggle.addEventListener(EVENTS.CLICK, this.onToggle);
90
+ }
91
+
92
+ if (this.button) {
93
+ console.log('this is button');
94
+ this.button.addEventListener(EVENTS.CLICK, this.onClick);
95
+ }
96
+
97
+ return this;
98
+ }
99
+
100
+ /**
101
+ * calcHeight
102
+ *
103
+ * @return {Object} Callout A reference to the instance of the class
104
+ * @chainable
105
+ */
106
+ calcHeight() {
107
+ this.header = this.element.querySelector('[class*="--header"]');
108
+ this.height = this.header.offsetHeight;
109
+ this.element.style.maxHeight = `${this.height + 25}px`;
84
110
 
85
111
  return this;
86
112
  }
@@ -113,7 +139,7 @@ export default class Callout {
113
139
 
114
140
  const label = this.toggleOpen ? this.toggleLabelOpen : this.toggleLabelClosed;
115
141
 
116
- this.element.classList.toggle('ilo--toggle--open');
142
+ this.element.classList.toggle('ilo--callout--open');
117
143
  this.toggleLabel.innerText = label;
118
144
 
119
145
  return this;
@@ -1,7 +1,7 @@
1
1
  {#
2
2
  CALLOUT COMPONENT
3
3
  #}
4
- <div class="{{prefix}}--callout {{prefix}}--callout--{{alert}} {% if isOpen %} {{prefix}}--callout--open {% endif %}" data-loadcomponent="Callout" >
4
+ <div class="{{prefix}}--callout {{prefix}}--callout--{{alert}} {% if isOpen %} {{prefix}}--callout--open {% endif %} {% if isCollapsible %} {{prefix}}--callout--collapse {% endif %}" data-loadcomponent="Callout" >
5
5
  <div class="{{prefix}}--callout--sidebar">
6
6
  <span class="{{prefix}}--callout--icon icon icon--{{alert}}"></span>
7
7
  </div>
@@ -22,7 +22,7 @@
22
22
  class="{{prefix}}--button {{prefix}}--button--small {{prefix}}--button--tertiary"
23
23
  type="button"
24
24
  >
25
- {{ buttonLabel }}
25
+ <span class="button__label">{{ buttonLabel }}</span>
26
26
  </button>
27
27
  </div>
28
28
  {% endif %}
@@ -4,3 +4,4 @@
4
4
  // Module template
5
5
  import './callout.twig';
6
6
  import './callout.wingsuit.yml';
7
+ import './callout.behavior';