@foeewni/web-core 3.0.0-alpha.18 → 3.0.0-alpha.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foeewni/web-core",
3
- "version": "3.0.0-alpha.18",
3
+ "version": "3.0.0-alpha.19",
4
4
  "description": "Friend of the Earth EWNI Core for frontend projects",
5
5
  "browser": {
6
6
  "foe-core.js": "dist/js/foe.core.min.js",
@@ -110,8 +110,9 @@ Form `type=submit`s, `button`s are by default uncolorized, please use one of the
110
110
  }
111
111
 
112
112
  .btn-sunset {
113
- color: $foe-extradark;
114
113
  @include button-variant($foe-sunset, $foe-sunset);
114
+
115
+ color: $foe-extradark;
115
116
  }
116
117
 
117
118
  .btn-donate {
@@ -27,11 +27,11 @@
27
27
  display: block;
28
28
  }
29
29
 
30
- > .container {
31
- @include media-breakpoint-up(md) {
32
- justify-content: flex-end;
33
- }
30
+ > .container {
31
+ @include media-breakpoint-up(md) {
32
+ justify-content: flex-end;
34
33
  }
34
+ }
35
35
 
36
36
  &.megamenu-search { // Allow the search "megamenu" to persist at smaller breakpoints
37
37
  @include media-breakpoint-up(sm) {
@@ -228,7 +228,7 @@ ul.navbar-nav.menu-main {
228
228
  }
229
229
 
230
230
  > a {
231
- line-height: calc($foe-submenu-tile-height / 4 - 0.4rem);
231
+ line-height: calc($foe-submenu-tile-height / 4 - .4rem);
232
232
  font-weight: 600;
233
233
  color: $foe-extradark;
234
234
  transition: color 400ms ease-in-out;
@@ -85,6 +85,7 @@
85
85
  }
86
86
  }
87
87
 
88
+ /* stylelint-disable no-descending-specificity */
88
89
  > li {
89
90
  > a {
90
91
  background: linear-gradient(90deg, $foe-accent 0%, $foe-accent 50%, transparent 50%, transparent 100%);
@@ -100,6 +101,7 @@
100
101
  }
101
102
  }
102
103
  }
104
+ /* stylelint-enable no-descending-specificity */
103
105
 
104
106
  &.menu-main {
105
107
  display: block;
@@ -172,7 +174,7 @@
172
174
  }
173
175
  }
174
176
  }
175
-
177
+
176
178
  div.foe-megamenu-container { /* just for mobile menu */
177
179
  position: relative;
178
180
  background-color: transparent;
@@ -17,7 +17,7 @@ https://www.bennadel.com/blog/4310-detecting-rendered-line-breaks-in-a-text-node
17
17
 
18
18
  (() => {
19
19
  // Config
20
- const ROTATION_MAX_DEGREES = 2; // Degrees. "Normal" is around 2.5
20
+ // const ROTATION_MAX_DEGREES = 2; // Degrees. "Normal" is around 2.5
21
21
  const BACKGROUND_EXTENSION = 0.5; // rem. Normal is around 1
22
22
  const CORNER_JIGGLE_MAX = 1; // rem. Normal is around .2
23
23
  const BREAK_RATIO = 2.5; // ratio for when the variation on the side happens
@@ -72,6 +72,11 @@ https://www.bennadel.com/blog/4310-detecting-rendered-line-breaks-in-a-text-node
72
72
 
73
73
  // Figure out the bounding boxes
74
74
  // Get the bounding boxes
75
+ if (getComputedStyle(target.parentNode).position === 'static') {
76
+ // static parents were resultibngin top drift on the top positioning
77
+ // A lot of the button elements have a parent with relative anyway
78
+ target.parentNode.style.position = 'relative';
79
+ }
75
80
  const targetBox = target.getBoundingClientRect();
76
81
  const parentBox = target.offsetParent ? target.offsetParent.getBoundingClientRect() : targetBox;
77
82
 
@@ -86,27 +91,27 @@ https://www.bennadel.com/blog/4310-detecting-rendered-line-breaks-in-a-text-node
86
91
  canvas.id = target.dataset.backgroundCanvasId;
87
92
  canvas.style.position = 'absolute';
88
93
  canvas.style.zIndex = -1;
89
- canvas.style.top = `${(targetBox.top - parentBox.top) - 2 * extension}px`;
90
- canvas.style.left = `${(targetBox.left - parentBox.left) - 2 * extension}px`;
91
- canvas.style.width = `${targetBox.width + 4 * extension}px`;
92
- canvas.style.height = `${targetBox.height + 4 * extension}px`;
93
- canvas.width = targetBox.width + 4 * extension;
94
- canvas.height = targetBox.height + 4 * extension;
94
+ canvas.style.top = `${(targetBox.top - parentBox.top) - (2 * extension)}px`;
95
+ canvas.style.left = `${(targetBox.left - parentBox.left) - (2 * extension)}px`;
96
+ canvas.style.width = `${targetBox.width + (4 * extension)}px`;
97
+ canvas.style.height = `${targetBox.height + (4 * extension)}px`;
98
+ canvas.width = targetBox.width + (4 * extension);
99
+ canvas.height = targetBox.height + (4 * extension);
95
100
  canvas.style.pointerEvents = 'none';
96
101
  target.parentNode.insertBefore(canvas, target);
97
102
 
98
103
  // Add rotation
99
- if (!target.dataset.jauntRotation) {
100
- const middle = jauntSeed.length / 2 + 1;
101
- let rotationSeed = jauntSeed.substring(1, middle);
102
- rotationSeed = Number(`0x${rotationSeed}`);
103
- rotationSeed /= 10 ** (`${rotationSeed}`).length;
104
- const rotationFactor = ROTATION_MAX_DEGREES * jauntFactor
105
- * (rotationSeed * 2 - 1); // -1 to +1
106
- target.dataset.jauntRotation = rotationFactor;
107
- }
108
- target.style.transform = `rotate(${target.dataset.jauntRotation}deg)`;
109
- canvas.style.transform = `rotate(${target.dataset.jauntRotation}deg)`;
104
+ // if (!target.dataset.jauntRotation) {
105
+ // const middle = jauntSeed.length / 2 + 1;
106
+ // let rotationSeed = jauntSeed.substring(1, middle);
107
+ // rotationSeed = Number(`0x${rotationSeed}`);
108
+ // rotationSeed /= 10 ** (`${rotationSeed}`).length;
109
+ // const rotationFactor = ROTATION_MAX_DEGREES * jauntFactor
110
+ // * (rotationSeed * 2 - 1); // -1 to +1
111
+ // target.dataset.jauntRotation = rotationFactor;
112
+ // }
113
+ // target.style.transform = `rotate(${target.dataset.jauntRotation}deg)`;
114
+ // canvas.style.transform = `rotate(${target.dataset.jauntRotation}deg)`;
110
115
 
111
116
  const context = canvas.getContext('2d');
112
117
 
@@ -121,17 +126,24 @@ https://www.bennadel.com/blog/4310-detecting-rendered-line-breaks-in-a-text-node
121
126
  target.style.backgroundColor = 'transparent';
122
127
  target.style.borderColor = 'transparent';
123
128
 
124
- // Collapse whitespace
125
- target.textContent = target.textContent.replace(/\s+/g, ' ').trim();
126
-
127
- // Get the individual lines as rendered on screen
128
- const { textContent } = target.firstChild;
129
- const range = document.createRange();
130
- range.setStart(target.firstChild, 0);
131
- range.setEnd(target.firstChild, textContent.length);
129
+ const boxes = target.dataset.jauntFull ? [targetBox] : [];
130
+ if (!target.dataset.jauntFull) {
131
+ target.childNodes.forEach((text) => {
132
+ if (text.nodeType === Node.TEXT_NODE) {
133
+ // Collapse whitespace
134
+ text.textContent = text.textContent.replace(/\s+/g, ' ').trim();
135
+ // Get the individual lines as rendered on screen
136
+ const nodeRange = document.createRange();
137
+ nodeRange.setStart(text, 0);
138
+ nodeRange.setEnd(text, text.textContent.length);
139
+ Array.from(nodeRange.getClientRects()).forEach((rect) => {
140
+ boxes.push(rect);
141
+ });
142
+ }
143
+ });
144
+ }
132
145
 
133
146
  // const outerBox = range.getBoundingClientRect();
134
- const boxes = target.dataset.jauntFull ? [targetBox] : Array.from(range.getClientRects());
135
147
  const storedPoints = [];
136
148
 
137
149
  // function to jiggle the points around using a seed
@@ -192,12 +204,15 @@ https://www.bennadel.com/blog/4310-detecting-rendered-line-breaks-in-a-text-node
192
204
  boxes.forEach((lineBox, i) => {
193
205
  const points = [];
194
206
  // dimension constants to use for points
195
- const lineWidth = lineBox.width + (target.dataset.jauntFull ? -extension : (4 * extension));
196
- const lineHeight = lineBox.height + (target.dataset.jauntFull ? -extension : (4 * extension));
197
- const left = lineBox.left - targetBox.left + (target.dataset.jauntFull ? (3 * extension) : 0);
198
- const right = lineBox.left - targetBox.left + (target.dataset.jauntFull ? (3 * extension) : 0) + lineWidth;
199
- const top = lineBox.top - targetBox.top + (target.dataset.jauntFull ? (2 * extension) : 0);
200
- const bottom = lineBox.top - targetBox.top + (target.dataset.jauntFull ? (2 * extension) : 0) + lineHeight;
207
+ const lineWidth = lineBox.width + (target.dataset.jauntFull ? 0 : (4 * extension));
208
+ const lineHeight = lineBox.height + (target.dataset.jauntFull ? 0 : (4 * extension));
209
+ if (!lineWidth || !lineHeight) {
210
+ return;
211
+ }
212
+ const left = lineBox.left - targetBox.left + (target.dataset.jauntFull ? 2 * extension : 0);
213
+ const right = lineBox.left - targetBox.left + lineWidth + (target.dataset.jauntFull ? 2 * extension : 0);
214
+ const top = lineBox.top - targetBox.top + (target.dataset.jauntFull ? 2 * extension : 0);
215
+ const bottom = lineBox.top - targetBox.top + lineHeight + (target.dataset.jauntFull ? 2 * extension : 0);
201
216
  // number of intemidiate points vertically and horizontally
202
217
  const widthPointCount = Math.ceil(lineWidth / (lineHeight * BREAK_RATIO)) - 1;
203
218
  const heightPointCount = Math.ceil(lineHeight / (lineWidth * BREAK_RATIO)) - 1;