@foeewni/web-core 3.0.0-alpha.2 → 3.0.0-alpha.4

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.
@@ -250,7 +250,7 @@ The parallax effect needs the file `foe.components.js` to be appended in the pag
250
250
  color: $foe-extradark;
251
251
 
252
252
  span {
253
- background: $foe-offwhite;
253
+ background: $foe-primary;
254
254
  padding: $spacer;
255
255
  display: inline-block;
256
256
  }
@@ -16,3 +16,8 @@ input {
16
16
  .form-group {
17
17
  margin-bottom: 1rem;
18
18
  }
19
+
20
+ p a:not(.btn) {
21
+ text-decoration: underline;
22
+ color: $foe-text;
23
+ }
@@ -42,7 +42,7 @@
42
42
 
43
43
  @include media-breakpoint-up(lg) {
44
44
  padding: 0 18px;
45
- line-height: $foe-nav-height-large/2;
45
+ line-height: $foe-nav-height-large / 3;
46
46
  }
47
47
 
48
48
  &:focus {
@@ -92,8 +92,6 @@
92
92
  // Handheld only
93
93
  @include media-breakpoint-down(md) {
94
94
  &.foe-header-mobile-is-open {
95
- background-color: $foe-extradark !important;
96
-
97
95
  ul.navbar-nav {
98
96
  max-height: calc(100vh - 4rem);
99
97
  overflow-y: auto;
@@ -15,13 +15,18 @@
15
15
  text-decoration: none !important;
16
16
  position: relative;
17
17
  line-height: $foe-nav-height-small;
18
- color: $foe-offwhite !important;
18
+ color: $foe-extradark !important;
19
19
  transition: line-height $foe-transition-duration-base $foe-transition-easing;
20
20
  width: calc($spacer * 3);
21
21
  padding-left: calc($grid-gutter-width / 2);
22
22
  padding-right: calc($grid-gutter-width / 2);
23
23
  display: block;
24
24
 
25
+ .svg-inline--fa {
26
+ height: 1.5em;
27
+ transition: height $foe-transition-duration-base $foe-transition-easing;
28
+ }
29
+
25
30
  .fa-times {
26
31
  display: none;
27
32
  }
@@ -117,6 +122,10 @@
117
122
  &.js-menustack-stuck {
118
123
  .header-search {
119
124
  a.search-button {
125
+ .svg-inline--fa {
126
+ height: 1em;
127
+ }
128
+
120
129
  @include media-breakpoint-up(lg) {
121
130
  line-height: $foe-nav-height-large-scrolled;
122
131
  }
@@ -0,0 +1,209 @@
1
+ /* @docs
2
+
3
+ # Scripts:Jaunty
4
+
5
+ Jauntifies a text header with the data-jaunt-factor attribute.
6
+
7
+ Usage:
8
+ ```
9
+ <h1 data-jaunt-factor="1">Jaunty Title</h1>
10
+
11
+ <h2 data-jaunt-factor="2">Very Jaunty Title</h2>
12
+ ```
13
+
14
+ Based on James South Codepen https://codepen.io/jrsouth/pen/ZEmeoJz with ideas from
15
+ https://www.bennadel.com/blog/4310-detecting-rendered-line-breaks-in-a-text-node-in-javascript.htm
16
+ */
17
+ (() => {
18
+ // Config
19
+ const ROTATION_MAX_DEGREES = 3; // Degrees. "Normal" is around 2.5
20
+ const BACKGROUND_EXTENSION = 1.5; // rem. Normal is around 1
21
+ const CORNER_JIGGLE_MAX = 1; // rem. Normal is around .2
22
+ let oneRemInPx = 0;
23
+ let extension = 0;
24
+
25
+ // Helpers
26
+ const generateRandomHex = (length) => {
27
+ let result = '';
28
+ const characters = 'ABCDEF1234567890';
29
+ const charactersLength = characters.length;
30
+ for (let i = 0; i < length; i++) {
31
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
32
+ }
33
+ return result;
34
+ };
35
+
36
+ const drawPolygon = (context, points) => {
37
+ context.beginPath();
38
+ context.moveTo(points[0].x, points[0].y);
39
+ for (let i = 1; i < points.length; i++) {
40
+ context.lineTo(points[i].x, points[i].y);
41
+ }
42
+ context.lineTo(points[0].x, points[0].y);
43
+ context.fill();
44
+ };
45
+
46
+ // const drawPoint = (context, x, y) => {
47
+ // if (!context.fillStyle) {
48
+ // context.fillStyle = "#61bdaa";
49
+ // }
50
+ // context.fillRect(x - 1.5, y - 1.5, 3, 3);
51
+ // };
52
+
53
+ const jauntTarget = (target) => {
54
+ if (target.firstChild.nodeType !== Node.TEXT_NODE) {
55
+ return;
56
+ }
57
+
58
+ // Create a unique ID to link this element with the canvas background
59
+ if (!target.dataset.backgroundCanvasId) {
60
+ target.dataset.backgroundCanvasId = generateRandomHex(12);
61
+ }
62
+
63
+ // Clean up any existing jauntiness
64
+ const existingCanvas = document.getElementById(
65
+ target.dataset.backgroundCanvasId
66
+ );
67
+ if (existingCanvas) {
68
+ existingCanvas.remove();
69
+ }
70
+ const previousTransform = getComputedStyle(target).transform;
71
+ target.style.transition = 'none';
72
+ target.style.transform = null;
73
+
74
+ // Figure out the bounding boxes
75
+ const jauntFactor = parseFloat(target.dataset.jauntFactor);
76
+
77
+ // Collapse whitespace
78
+ target.textContent = target.textContent.replace(/\s+/g, ' ').trim();
79
+
80
+ // Get the individual lines as rendered on screen
81
+ const { textContent } = target.firstChild;
82
+ const range = document.createRange();
83
+ range.setStart(target.firstChild, 0);
84
+ range.setEnd(target.firstChild, textContent.length);
85
+
86
+ // Get the bounding boxes
87
+ const targetBox = target.getBoundingClientRect();
88
+ const parentBox = target.offsetParent.getBoundingClientRect();
89
+ const outerBox = range.getBoundingClientRect();
90
+ const boxes = Array.from(range.getClientRects());
91
+
92
+ // Insert the new 2D canvas element
93
+ const canvas = document.createElement('canvas');
94
+ canvas.id = target.dataset.backgroundCanvasId;
95
+ target.parentNode.insertBefore(canvas, target);
96
+ canvas.style.position = 'absolute';
97
+ canvas.style.zIndex = -1;
98
+ canvas.style.top = `${(targetBox.top - parentBox.top) - 2 * extension}px`;
99
+ canvas.style.left = `${(targetBox.left - parentBox.left) - 2 * extension}px`;
100
+ canvas.style.width = `${targetBox.width + 4 * extension}px`;
101
+ canvas.style.height = `${targetBox.height + 4 * extension}px`;
102
+ canvas.width = targetBox.width + 4 * extension;
103
+ canvas.height = targetBox.height + 4 * extension;
104
+ canvas.style.pointerEvents = 'none';
105
+
106
+ // Draw the background boxes
107
+ const context = canvas.getContext('2d');
108
+
109
+ // set the background color and remove and existing background
110
+ context.fillStyle = target.dataset.previousBackgroundColor
111
+ ? target.dataset.previousBackgroundColor
112
+ : getComputedStyle(target).backgroundColor;
113
+ if (!context.fillStyle) {
114
+ context.fillStyle = '#61bdaa';
115
+ }
116
+ target.dataset.previousBackgroundColor = context.fillStyle;
117
+ target.style.backgroundColor = 'transparent';
118
+
119
+ boxes.forEach((lineBox) => {
120
+ const points = [];
121
+
122
+ points.push({
123
+ // Top left
124
+ x: lineBox.left - outerBox.left + 2 * extension,
125
+ y: lineBox.top - outerBox.top + 2 * extension,
126
+ });
127
+ points.push({
128
+ // Top right
129
+ x: points[0].x + lineBox.width + 2 * extension,
130
+ y: points[0].y,
131
+ });
132
+ points.push({
133
+ // Bottom right
134
+ x: points[0].x + lineBox.width + 2 * extension,
135
+ y: points[0].y + lineBox.height + 2 * extension,
136
+ });
137
+ points.push({
138
+ // Bottom left
139
+ x: points[0].x,
140
+ y: points[0].y + lineBox.height + 2 * extension,
141
+ });
142
+
143
+ // context.fillRect(
144
+ // lineBox.left - outerBox.left + 2 * extension,
145
+ // lineBox.top - outerBox.top + 2 * extension,
146
+ // lineBox.width + 2 * extension,
147
+ // lineBox.height + 2 * extension,
148
+ // );
149
+
150
+ // Jiggle them points around
151
+ points.forEach((point, index) => {
152
+ points[index] = {
153
+ x:
154
+ point.x
155
+ + (Math.random() * 2 - 1)
156
+ * oneRemInPx
157
+ * CORNER_JIGGLE_MAX
158
+ * jauntFactor,
159
+ y:
160
+ point.y
161
+ + (Math.random() * 2 - 1)
162
+ * oneRemInPx
163
+ * CORNER_JIGGLE_MAX
164
+ * jauntFactor,
165
+ };
166
+ });
167
+
168
+ // points.forEach((point) => {
169
+ // drawPoint(context, point.x, point.y);
170
+ // });
171
+
172
+ drawPolygon(context, points);
173
+ });
174
+
175
+ target.style.transform = previousTransform;
176
+ target.style.transition = null;
177
+
178
+ // Add rotation
179
+ const rotationFactor = ROTATION_MAX_DEGREES * jauntFactor
180
+ * (Math.random() * 2 - 1); // -1 to +1
181
+ target.style.transform = `rotate(${rotationFactor}deg)`;
182
+ canvas.style.transform = `rotate(${rotationFactor}deg)`;
183
+ };
184
+
185
+ // The main event
186
+ const createBackground = () => {
187
+ oneRemInPx = parseFloat(
188
+ getComputedStyle(document.documentElement).fontSize
189
+ );
190
+ extension = BACKGROUND_EXTENSION * oneRemInPx;
191
+
192
+ const targets = document.querySelectorAll('[data-jaunt-factor]');
193
+
194
+ // Insert some jaunt
195
+ targets.forEach((target) => {
196
+ jauntTarget(target);
197
+ });
198
+ };
199
+
200
+ const init = () => {
201
+ createBackground();
202
+ };
203
+
204
+ // Go time
205
+ document.addEventListener('DOMContentLoaded', init);
206
+ document.addEventListener('load', init);
207
+ window.addEventListener('resize', createBackground);
208
+ window.runJaunt = init;
209
+ })();
@@ -19,18 +19,15 @@ The Friends of the Earth blockquotes use the secondary font
19
19
  @import '../../utils/scss/loader';
20
20
 
21
21
  blockquote {
22
- border-color: $gray-400;
23
- border-style: double;
24
- border-width: .2em 0;
25
- padding: $spacer*1.5 0;
22
+ padding: $spacer * 1.5 0;
26
23
  width: 80%;
27
- margin: $spacer*2 auto;
24
+ margin: ($spacer * 2) auto;
28
25
  float: none;
29
26
  clear: both;
30
27
 
31
28
  p {
32
29
  font-family: $font-family-serif;
33
- font-weight: 700;
30
+ font-weight: normal;
34
31
  font-size: $blockquote-font-size;
35
32
  line-height: $blockquote-font-size * 1.35;
36
33
  color: $foe-extradark;
@@ -75,24 +72,25 @@ blockquote {
75
72
 
76
73
  cite,
77
74
  & + .citation {
78
- font-family: $font-family-sans-serif;
79
- font-size: 1rem;
75
+ width: 80%;
76
+ margin: auto;
77
+ font-family: $font-family-serif;
78
+ font-size: $blockquote-font-size;
80
79
  line-height: 1.3rem;
81
- font-weight: 400;
82
- font-style: italic;
83
- color: $gray-500;
80
+ font-weight: bold;
81
+ color: $foe-extradark;
84
82
  display: block;
85
- text-align: right;
86
- margin-top: 1em;
87
- padding-left: 10%;
83
+ text-align: left;
84
+ margin-top: $spacer;
88
85
 
89
- &::before {
90
- content: "\2014\00A0\00A0";
91
- color: $foe-primary;
86
+ @include media-breakpoint-up(sm) {
87
+ width: calc(100% * 4 / 6);
92
88
  }
93
89
  }
94
90
 
95
91
  & + .citation {
96
- margin-top: $spacer * -1;
92
+ margin-top: $spacer * -3.5;
93
+ margin-bottom: $spacer * 2;
94
+ line-height: $spacer * 2;
97
95
  }
98
96
  }
package/src/fonts.js CHANGED
@@ -32,6 +32,7 @@ To use them on your CSS please import the webfonts through Google Fonts
32
32
  // Note, single line deep imports are needed here, for some reason fontawesome messes up
33
33
  // with normal imports and webpack ends up bundling the whole library (1.25mb!)
34
34
  import { library, dom } from '@fortawesome/fontawesome-svg-core';
35
+
35
36
  import { faEnvelope } from '@fortawesome/free-solid-svg-icons/faEnvelope';
36
37
  import { faSearch } from '@fortawesome/free-solid-svg-icons/faSearch';
37
38
  import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
@@ -40,19 +41,6 @@ import { faExternalLinkSquareAlt } from '@fortawesome/free-solid-svg-icons/faExt
40
41
  import { faArrowAltCircleUp } from '@fortawesome/free-solid-svg-icons/faArrowAltCircleUp';
41
42
  import { faShare } from '@fortawesome/free-solid-svg-icons/faShare';
42
43
  import { faLink } from '@fortawesome/free-solid-svg-icons/faLink';
43
- import { faTwitter } from '@fortawesome/free-brands-svg-icons/faTwitter';
44
- import { faFacebook } from '@fortawesome/free-brands-svg-icons/faFacebook';
45
- import { faFacebookF } from '@fortawesome/free-brands-svg-icons/faFacebookF';
46
- import { faPinterest } from '@fortawesome/free-brands-svg-icons/faPinterest';
47
- import { faLinkedin } from '@fortawesome/free-brands-svg-icons/faLinkedin';
48
- import { faInstagram } from '@fortawesome/free-brands-svg-icons/faInstagram';
49
- import { faYoutube } from '@fortawesome/free-brands-svg-icons/faYoutube';
50
- import { faTumblr } from '@fortawesome/free-brands-svg-icons/faTumblr';
51
- import { faWhatsapp } from '@fortawesome/free-brands-svg-icons/faWhatsapp';
52
- import { faFacebookMessenger } from '@fortawesome/free-brands-svg-icons/faFacebookMessenger';
53
- import { faTelegram } from '@fortawesome/free-brands-svg-icons/faTelegram';
54
- import { faTelegramPlane } from '@fortawesome/free-brands-svg-icons/faTelegramPlane';
55
- import { faTiktok } from '@fortawesome/free-brands-svg-icons/faTiktok';
56
44
  import { faChevronDown } from '@fortawesome/free-solid-svg-icons/faChevronDown';
57
45
  import { faChevronUp } from '@fortawesome/free-solid-svg-icons/faChevronUp';
58
46
  import { faAngleDown } from '@fortawesome/free-solid-svg-icons/faAngleDown';
@@ -76,6 +64,23 @@ import { faSave } from '@fortawesome/free-solid-svg-icons/faSave';
76
64
  import { faSignInAlt } from '@fortawesome/free-solid-svg-icons/faSignInAlt';
77
65
  import { faTrashAlt } from '@fortawesome/free-solid-svg-icons/faTrashAlt';
78
66
 
67
+ import { faTwitter } from '@fortawesome/free-brands-svg-icons/faTwitter';
68
+ import { faXTwitter } from '@fortawesome/free-brands-svg-icons/faXTwitter';
69
+ import { faFacebook } from '@fortawesome/free-brands-svg-icons/faFacebook';
70
+ import { faFacebookF } from '@fortawesome/free-brands-svg-icons/faFacebookF';
71
+ import { faPinterest } from '@fortawesome/free-brands-svg-icons/faPinterest';
72
+ import { faLinkedin } from '@fortawesome/free-brands-svg-icons/faLinkedin';
73
+ import { faInstagram } from '@fortawesome/free-brands-svg-icons/faInstagram';
74
+ import { faYoutube } from '@fortawesome/free-brands-svg-icons/faYoutube';
75
+ import { faTumblr } from '@fortawesome/free-brands-svg-icons/faTumblr';
76
+ import { faWhatsapp } from '@fortawesome/free-brands-svg-icons/faWhatsapp';
77
+ import { faFacebookMessenger } from '@fortawesome/free-brands-svg-icons/faFacebookMessenger';
78
+ import { faTelegram } from '@fortawesome/free-brands-svg-icons/faTelegram';
79
+ import { faTelegramPlane } from '@fortawesome/free-brands-svg-icons/faTelegramPlane';
80
+ import { faTiktok } from '@fortawesome/free-brands-svg-icons/faTiktok';
81
+ import { faBluesky } from '@fortawesome/free-brands-svg-icons/faBluesky';
82
+ import { faThreads } from '@fortawesome/free-brands-svg-icons/faThreads';
83
+
79
84
 
80
85
  // Add actually used FA icons
81
86
  library.add(
@@ -88,6 +93,7 @@ library.add(
88
93
  faShare,
89
94
  faLink,
90
95
  faTwitter,
96
+ faXTwitter,
91
97
  faFacebook,
92
98
  faFacebookF,
93
99
  faPinterest,
@@ -121,20 +127,25 @@ library.add(
121
127
  faSave,
122
128
  faTrashAlt,
123
129
  faCloudUploadAlt,
124
- faSignInAlt
130
+ faSignInAlt,
131
+ faBluesky,
132
+ faThreads
125
133
  );
126
134
 
127
135
  // Look for Google fonts and append them if they are not there already
128
136
  // We avoiding using @import url(); because the new URL has semicolons on it
129
137
  // and it tremendously gets broken from some preprocessors.
130
138
 
131
- const fonts = window.document.createElement('link');
132
139
  // eslint-disable-next-line max-len
133
- const href = 'https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital@0;1&family=Libre+Franklin:ital,wght@0,400;0,700;1,400;1,700&display=swap';
134
- fonts.setAttribute('rel', 'stylesheet');
135
- fonts.setAttribute('crossorigin', 'anonymous');
136
- fonts.setAttribute('href', href);
137
- document.head.appendChild(fonts);
140
+ const googleFontsHref = 'https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital@0;1&family=Libre+Franklin:ital,wght@0,400;0,700;1,400;1,700&display=swap';
141
+ const googleFontsLink = window.document.querySelector(`link[href="${googleFontsHref}"]`);
142
+ if (!googleFontsLink) {
143
+ const fonts = window.document.createElement('link');
144
+ fonts.setAttribute('rel', 'stylesheet');
145
+ fonts.setAttribute('crossorigin', 'anonymous');
146
+ fonts.setAttribute('href', googleFontsHref);
147
+ document.head.appendChild(fonts);
148
+ }
138
149
 
139
150
  // Kicks off the process of finding <i> tags and replacing with <svg>
140
151
  dom.watch();
package/src/main.js CHANGED
@@ -19,6 +19,7 @@ import './components/tools/data-click-track';
19
19
  import './components/tools/rubik-tracking';
20
20
  import './components/tools/data-defer-src';
21
21
  import './components/tools/stickystack';
22
+ import './components/tools/jaunty';
22
23
 
23
24
  // Bootstrap helpers
24
25
  import './components/layout/alerts.scss';
@@ -8,17 +8,34 @@
8
8
  //
9
9
 
10
10
  // Colours
11
- $foe-primary: #61bdaa !default;
12
- $foe-light: #dff2ee !default;
13
- $foe-secondary: $foe-light !default;
14
- $foe-dark: #182f2a !default;
15
- $foe-extradark: #1e234d !default;
11
+ $foe-leaf: #61bdaa !default;
12
+ $foe-iris: #5a54a0 !default;
16
13
  $foe-sunset: #ed6132 !default;
14
+ $foe-space: #1e234d !default;
15
+ $foe-ice: #f3f3f7 !default;
16
+ $foe-conch: #f1e2d4 !default;
17
+
18
+ // Tints, would prefer to do this algorithmically but it's useful to have the hex codes on hand to compare with figmas
19
+ $foe-leaf-75: #81cabb !default;
20
+ $foe-leaf-50: #c0e5dd !default;
21
+ $foe-leaf-25: #dff2ee !default;
22
+ $foe-sunset-75: #f1815b !default;
23
+ $foe-sunset-50: #f6b099 !default;
24
+ $foe-sunset-25: #fbdfd6 !default;
25
+ $foe-iris-75: #6d68a7 !default;
26
+ $foe-iris-50: #adaad0 !default;
27
+ $foe-iris-25: #deddec !default;
28
+
29
+ $foe-primary: $foe-leaf !default;
30
+ $foe-light: $foe-leaf-25 !default;
31
+ $foe-secondary: $foe-light !default;
32
+ $foe-dark: #182f2a !default;
33
+ $foe-extradark: $foe-space !default;
17
34
 
18
35
  $foe-white: #fff !default;
19
36
  $foe-gray: #b1b8c0 !default;
20
- $foe-accent: #5a54a0 !default;
21
- $foe-offwhite: #f4f6fa !default;
37
+ $foe-accent: $foe-iris !default;
38
+ $foe-offwhite: $foe-ice !default;
22
39
 
23
40
  $foe-success: #5cb85c !default;
24
41
  $foe-info: #5bc0de !default;
@@ -50,6 +67,11 @@ $foe-nav-shadow: 0 0 .5em .2em rgba(0, 0, 0, .25);
50
67
 
51
68
  $foe-text-shadow: 0 0 .5rem $foe-tint-overlay-heavy !default;
52
69
 
70
+ $foe-backgrounds:
71
+ $foe-leaf-50,
72
+ $foe-sunset-50,
73
+ $foe-iris-50;
74
+
53
75
  //
54
76
  // Palettes vars, needed for Campaignion (mostly) maybe also D8
55
77
  //
@@ -390,7 +412,7 @@ $line-height-sm: 1.5;
390
412
  $border-width: 1px;
391
413
  $border-color: $gray-300;
392
414
 
393
- $border-radius: .1rem * 3;
415
+ $border-radius: 0; // .1rem * 3;
394
416
  $border-radius-lg: .1rem * 4;
395
417
  $border-radius-sm: .1rem * 2;
396
418
 
@@ -464,8 +486,8 @@ $display3-weight: 300;
464
486
  $display4-weight: 300;
465
487
  $display-line-height: $headings-line-height;
466
488
 
467
- $lead-font-size: ($font-size-base * 1.25);
468
- $lead-font-weight: 300;
489
+ $lead-font-size: $font-size-base;
490
+ $lead-font-weight: bold;
469
491
 
470
492
  $small-font-size: 80%;
471
493