@internetstiftelsen/styleguide 2.24.0-beta.0.2 → 2.24.0

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 (37) hide show
  1. package/README.md +8 -20
  2. package/dist/assets/js/youtube.js +8 -0
  3. package/dist/components.js +6 -4
  4. package/dist/molecules/form/Form.js +1 -1
  5. package/dist/molecules/glider/glider-hero.js +39 -0
  6. package/dist/organisms/timeline/timeline.js +89 -1
  7. package/dist/organisms/video-guide/video-guide.js +3 -49
  8. package/package.json +2 -4
  9. package/src/app.js +2 -3
  10. package/src/app.scss +3 -0
  11. package/src/assets/js/youtube.js +5 -0
  12. package/src/assets/video/metadata.vtt +9 -9
  13. package/src/atoms/tag/_tag.scss +1 -0
  14. package/src/atoms/tag/tag.config.js +10 -0
  15. package/src/components.js +6 -2
  16. package/src/configurations/forms/_fields.scss +8 -0
  17. package/src/globals.scss +1 -27
  18. package/src/molecules/continue-video-guide/continue-video-guide.config.js +7 -0
  19. package/src/molecules/continue-video-guide/continue-video-guide.js +84 -0
  20. package/src/molecules/continue-video-guide/continue-video-guide.scss +110 -0
  21. package/src/molecules/continue-video-guide/readme.md +3 -0
  22. package/src/molecules/form/Form.js +1 -1
  23. package/src/molecules/glider/_glider-hero.scss +1 -6
  24. package/src/molecules/glider/glider-hero.js +39 -0
  25. package/src/molecules/natural-language-form/_natural-language-form.scss +8 -0
  26. package/src/organisms/event-listing-item/_event-listing-item.scss +3 -1
  27. package/src/organisms/hero/_hero.scss +20 -0
  28. package/src/organisms/hero/hero.config.js +15 -1
  29. package/src/organisms/timeline/_timeline.scss +328 -0
  30. package/src/organisms/timeline/timeline.config.js +7 -0
  31. package/src/organisms/timeline/timeline.js +185 -0
  32. package/src/organisms/video-guide/_video-guide.scss +508 -0
  33. package/src/organisms/video-guide/video-guide.config.js +17 -0
  34. package/src/organisms/video-guide/video-guide.js +261 -0
  35. package/src/structures/_article.scss +1 -1
  36. package/src/utilities/_gutter.scss +1 -1
  37. package/src/utilities/_manifest.scss +29 -0
@@ -0,0 +1,328 @@
1
+ @charset "UTF-8";
2
+
3
+ html {
4
+ scroll-behavior: smooth;
5
+ }
6
+
7
+ @include organism(timeline) {
8
+ position: sticky;
9
+ top: -1px;
10
+ left: 0;
11
+ right: 0;
12
+ z-index: z_index(middlegroundImportant);
13
+ background: $color-ash;
14
+
15
+ @include card-shadow($color-cyberspace, 0.2);
16
+
17
+ &::after {
18
+ background-color: $color-concrete;
19
+ content: '';
20
+ display: block;
21
+ height: rhythm(1);
22
+ position: absolute;
23
+ top: 0;
24
+ left: 0;
25
+ right: 0;
26
+ z-index: -1;
27
+ }
28
+
29
+
30
+ @include e(progress-bar) {
31
+ display:flex;
32
+ height: rhythm(1);
33
+ background-image: linear-gradient(90deg, #55c7b4 0vw, #55c7b4 14.285vw, #c27fec 14.285vw, #c27fec 28.57vw, #ffa94d 28.57vw, #ffa94d 42.855vw, #ffce2e 42.855vw, #ffce2e 57.14vw, #50b2fc 57.14vw, #50b2fc 71.425vw, #ff4069 71.425vw, #ff4069 85.71vw, #8E9297 85.71vw, #8E9297 100%);
34
+ width: 0;
35
+ }
36
+
37
+ @include e(decades-container) {
38
+ display: flex;
39
+ justify-content: space-around;
40
+ align-items: stretch;
41
+
42
+ > a {
43
+ display: block;
44
+ flex: 1;
45
+ text-decoration: none;
46
+ color: $color-cyberspace;
47
+ text-align: center;
48
+ padding-top: rhythm(1);
49
+ padding-bottom: rhythm(1);
50
+ font-family: $font-family-headings;
51
+ font-size: $size-medium;
52
+
53
+ &.is-reading {
54
+ &:nth-child(1) {
55
+ color: $color-jade;
56
+ }
57
+
58
+ &:nth-child(2) {
59
+ color: $color-peacock;
60
+ }
61
+
62
+ &:nth-child(3) {
63
+ color: $color-sandstone;
64
+ }
65
+
66
+ &:nth-child(4) {
67
+ color: $color-lemon;
68
+ }
69
+
70
+ &:nth-child(5) {
71
+ color: $color-ocean;
72
+ }
73
+
74
+ &:nth-child(6) {
75
+ color: $color-ruby;
76
+ }
77
+
78
+ &:nth-child(7) {
79
+ color: $color-granit;
80
+ }
81
+ }
82
+
83
+ @include bp-up(lg) {
84
+ font-size: $size-base;
85
+ padding-top: rhythm(2);
86
+ padding-bottom: rhythm(2);
87
+ }
88
+ }
89
+ }
90
+
91
+ @include e(decade) {
92
+ @include e(intro) {
93
+ padding-top: rhythm(4);
94
+ margin-bottom: rhythm(8);
95
+
96
+ @include bp-up(sm) {
97
+ margin-bottom: rhythm(10);
98
+ }
99
+
100
+ @include bp-up(md) {
101
+ margin-bottom: rhythm(12);
102
+ }
103
+
104
+ @include bp-up(lg) {
105
+ margin-bottom: rhythm(14);
106
+ }
107
+
108
+ @include bp-up(xl) {
109
+ margin-bottom: rhythm(18);
110
+ }
111
+ }
112
+ }
113
+
114
+
115
+ // "Parallax" scroll items
116
+ @include e(parallax) {
117
+ opacity: 0;
118
+ transition: opacity 1s ease-out, transform 5s cubic-bezier(0, 1, 0, 1);
119
+ transform: translateY(200px);
120
+ will-change: opacity, transform;
121
+ transition-delay: 0.5s;
122
+ flex: 100%;
123
+
124
+ &.animate {
125
+ transform: translateY(0);
126
+ opacity: 1;
127
+ z-index: z_index(middleGround);
128
+
129
+
130
+ }
131
+ }
132
+
133
+ @include e(item) {
134
+ @include e(content) {
135
+ display: none;
136
+ padding-bottom: 0;
137
+ margin-top: 0;
138
+ min-height: 45px;
139
+ background-image: url("data:image/svg+xml,%3Csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='xMidYMid' class='lds-ring' style='background: none;'%3E%3Ccircle cx='50' cy='50' ng-attr-r='%7B%7Bconfig.radius%7D%7D' ng-attr-stroke='%7B%7Bconfig.base%7D%7D' ng-attr-stroke-width='%7B%7Bconfig.width%7D%7D' fill='none' r='43' stroke='%23a7d8fd' stroke-width='7'%3E%3C/circle%3E%3Ccircle cx='50' cy='50' ng-attr-r='%7B%7Bconfig.radius%7D%7D' ng-attr-stroke='%7B%7Bconfig.stroke%7D%7D' ng-attr-stroke-width='%7B%7Bconfig.innerWidth%7D%7D' ng-attr-stroke-linecap='%7B%7Bconfig.linecap%7D%7D' fill='none' r='43' stroke='%2350b2fc' stroke-width='7' stroke-linecap='square' transform='rotate(27.6965 50 50)'%3E%3CanimateTransform attributeName='transform' type='rotate' calcMode='linear' values='0 50 50;180 50 50;720 50 50' keyTimes='0;0.5;1' dur='2.5s' begin='0s' repeatCount='indefinite'%3E%3C/animateTransform%3E%3Canimate attributeName='stroke-dasharray' calcMode='linear' values='9.42477796076938 179.0707812546182;188.4955592153876 -2.842170943040401e-14;9.42477796076938 179.0707812546182' keyTimes='0;0.5;1' dur='2.5' begin='0s' repeatCount='indefinite'%3E%3C/animate%3E%3C/circle%3E%3C/svg%3E%0A");
140
+ background-repeat: no-repeat;
141
+ background-position: center center;
142
+ background-size: 45px 45px;
143
+
144
+ @include bp-up(lg) {
145
+ min-height: 100px;
146
+ background-size: 100px 100px;
147
+ }
148
+
149
+ &[data-timeline-post-expanded-content="true"] {
150
+ background-image: none;
151
+ }
152
+
153
+ @include e(meta) {
154
+ @include e(related) {
155
+ margin-top: rhythm(4);
156
+ border-top: 1px solid $color-granit;
157
+ padding-top: rhythm(4);
158
+
159
+ img {
160
+ max-height: 100px;
161
+ width: 100%;
162
+ object-fit: cover;
163
+ object-position: 50% 25%;
164
+ border-radius: $border-radius;
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+ [data-youtube],
171
+ [data-youtube] * {
172
+ pointer-events: none;
173
+ }
174
+
175
+ &.is-open {
176
+ flex: 0 0 100%;
177
+ background-color: $color-cyberspace;
178
+ width: 100vw;
179
+ max-width: 100vw;
180
+ min-width: 100vw;
181
+ margin-left: calc(50% - 50vw);
182
+ margin-right: calc(50% - 50vw);
183
+ transform: translateY(0) !important;
184
+ z-index: z_index(middlegroundImportant);
185
+ padding-top: rhythm(6);
186
+ padding-bottom: rhythm(4);
187
+
188
+ @include bp-up(md) {
189
+ padding-top: rhythm(8);
190
+ padding-bottom: rhythm(8);
191
+ }
192
+
193
+ h1,
194
+ h2,
195
+ h3,
196
+ h4,
197
+ p,
198
+ a,
199
+ li {
200
+ color: $color-snow;
201
+ }
202
+
203
+ p a,
204
+ li a,
205
+ h1 a,
206
+ h2 a,
207
+ h3 a,
208
+ h4 a {
209
+ &:hover,
210
+ &:focus {
211
+ color: $color-cyberspace;
212
+ }
213
+ }
214
+
215
+ a[data-scroll-ignore] {
216
+ pointer-events: none;
217
+
218
+ &:hover,
219
+ &:focus {
220
+ text-decoration: none;
221
+ cursor: default;
222
+ }
223
+
224
+ &::after {
225
+ display: none;
226
+ }
227
+
228
+ h1 {
229
+ @extend %alpha;
230
+ }
231
+ }
232
+
233
+ p[class*='card__text'] {
234
+ @extend %preamble;
235
+ }
236
+
237
+ .wp-block-iis-timeline-post {
238
+ margin-left: auto;
239
+ margin-right: auto;
240
+
241
+ @include bp-up(sm) {
242
+ width: make_col(16);
243
+ }
244
+
245
+ @include bp-up(md) {
246
+ width: make_col(12);
247
+ }
248
+
249
+ @include bp-up(lg) {
250
+ width: make_col(12);
251
+ }
252
+
253
+ @include bp-up(xl) {
254
+ width: make_col(9);
255
+ }
256
+ }
257
+
258
+ & + .grid-18 {
259
+ transform: translateY(0) !important;
260
+ }
261
+
262
+ [data-youtube],
263
+ [data-youtube] * {
264
+ pointer-events: initial;
265
+ }
266
+
267
+ button[class*="close"] {
268
+ display: inline-block;
269
+ position: absolute;
270
+ right: rhythm(1);
271
+ transform: translateY(-#{rhythm(1)});
272
+
273
+ &:first-child {
274
+ top: rhythm(1);
275
+ transform: none;
276
+ }
277
+
278
+ @include bp-up(md) {
279
+ right: rhythm(2);
280
+ transform: translateY(rhythm(2));
281
+
282
+ &:first-child {
283
+ top: rhythm(2);
284
+ }
285
+ }
286
+ }
287
+
288
+ [class*='content'] {
289
+ display: block;
290
+ }
291
+ }
292
+ }
293
+
294
+ @include e(item-close) {
295
+ display: none;
296
+ }
297
+
298
+ @include e(heading) {
299
+ @include plumber(
300
+ $font-size: 2,
301
+ $line-height: 3,
302
+ $leading-top: 0,
303
+ $leading-bottom: 0,
304
+ $baseline: $body-baseline
305
+ );
306
+
307
+ @include bp-up(sm) {
308
+ @include plumber(
309
+ $font-size: 2.2,
310
+ $line-height: 3,
311
+ $leading-top: 0,
312
+ $leading-bottom: 0,
313
+ );
314
+ }
315
+ }
316
+
317
+ @include e(card-text) {
318
+ display: none;
319
+
320
+ @include bp-up(lg) {
321
+ display: block;
322
+ }
323
+ }
324
+ }
325
+
326
+ .row-has-open-child {
327
+ margin-bottom: 0 !important;
328
+ }
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ status: 'wip',
3
+
4
+ context: {
5
+
6
+ }
7
+ }
@@ -0,0 +1,185 @@
1
+ import '../../assets/js/parallax';
2
+
3
+ const { offsetTop, offsetBottom, offsetLeft } = require('../../assets/js/offset');
4
+
5
+ const dataLayer = window.dataLayer || [];
6
+ const progressBar = document.querySelector('.js-progress-bar');
7
+ const decadeContainer = document.querySelector('.js-decade-container');
8
+ const decadeSections = document.querySelectorAll('.js-timeline-decade');
9
+ const firstDecade = document.querySelector('h2.godzilla');
10
+ const decades = document.querySelectorAll('h2.godzilla');
11
+ let triggerPoint = 0;
12
+
13
+ // Create decade links in timeline
14
+ function buildTimelineNavigation() {
15
+ [].forEach.call(decades, (decade) => {
16
+ const decadeLink = document.createElement('a');
17
+ const { textContent } = decade;
18
+ decadeLink.setAttribute('href', `#${textContent}`);
19
+ decadeLink.innerText = textContent;
20
+ decadeContainer.appendChild(decadeLink);
21
+ });
22
+ }
23
+
24
+ /* Set trigger point (vertical position in viewport)
25
+ for when a new decade should start being "active" */
26
+ function setTriggerPoint() {
27
+ triggerPoint = window.innerHeight * 0.5;
28
+ }
29
+
30
+ // Animate progress bar when user is scolling within the timeline
31
+ function animateProgressBar() {
32
+ let currentSection = 0;
33
+ let sectionIndex = 0;
34
+ const currentPosition = document.documentElement.scrollTop + triggerPoint;
35
+ const decadeLinks = document.querySelectorAll('.js-decade-container a');
36
+ let progressBarWidth = 0;
37
+
38
+ // Check if we are above the first section
39
+ if (currentPosition < offsetTop(firstDecade)) {
40
+ currentSection = 0;
41
+ progressBarWidth = 0;
42
+ progressBar.style.width = '0';
43
+
44
+ [].forEach.call(decadeLinks, (decadeLink) => {
45
+ decadeLink.classList.remove('is-reading');
46
+ });
47
+ } else {
48
+ // Otherwise add 1 to sectionIndex while scrolling;
49
+ [].forEach.call(decades, (decade) => {
50
+ const sectionTop = offsetTop(decade);
51
+
52
+ if (currentPosition >= sectionTop) {
53
+ currentSection = sectionIndex;
54
+
55
+ [].forEach.call(decadeLinks, (decadeLink) => {
56
+ decadeLink.classList.remove('is-reading');
57
+ });
58
+
59
+ decadeLinks[sectionIndex].classList.add('is-reading');
60
+ }
61
+
62
+ sectionIndex += 1;
63
+ });
64
+ }
65
+
66
+ // Calculate speed of the progressBar width while scrolling based on section height
67
+ const startPoint = decadeLinks[currentSection];
68
+ const startPointX = offsetLeft(startPoint);
69
+ const startPointWidth = startPoint.offsetWidth;
70
+ const startSection = decadeSections[currentSection];
71
+ const startSectionY = offsetTop(startSection);
72
+ const endSectionY = offsetBottom(startSection);
73
+ const sectionLength = endSectionY - startSectionY;
74
+ const scrollY = currentPosition - startSectionY;
75
+ const sectionProgress = scrollY / sectionLength;
76
+ progressBarWidth = startPointX + (startPointWidth * sectionProgress);
77
+
78
+ // Use result to animate progressbar
79
+ progressBar.style.width = `${progressBarWidth}px`;
80
+ }
81
+
82
+ function isInViewport(element) {
83
+ let top = element.offsetTop;
84
+ const height = element.offsetHeight;
85
+
86
+ while (element.offsetParent) {
87
+ element = element.offsetParent; // eslint-disable-line
88
+ top += element.offsetTop;
89
+ }
90
+
91
+ return (
92
+ top < (window.pageYOffset + window.innerHeight)
93
+ && (top + height) > window.pageYOffset
94
+ );
95
+ }
96
+
97
+ function decadeIsVisible() {
98
+ [].forEach.call(decadeSections, (decadeSection) => {
99
+ if (isInViewport(decadeSection) && !decadeSection.classList.contains('is-in-view')) {
100
+ decadeSection.classList.add('is-in-view');
101
+
102
+ const decade = decadeSection.id;
103
+
104
+ dataLayer.push({
105
+ event: 'timeline',
106
+ eventInfo: {
107
+ category: 'timeline',
108
+ action: 'active_year',
109
+ label: decade,
110
+ },
111
+ });
112
+ } else if (!isInViewport(decadeSection)) {
113
+ decadeSection.classList.remove('is-in-view');
114
+ }
115
+ });
116
+ }
117
+
118
+ // Run functions on page load
119
+ if (progressBar) {
120
+ buildTimelineNavigation();
121
+ setTriggerPoint();
122
+ animateProgressBar();
123
+
124
+ // Re-run functions on window events
125
+ window.addEventListener('resize', () => {
126
+ setTriggerPoint();
127
+ animateProgressBar();
128
+ });
129
+ window.addEventListener('scroll', () => {
130
+ animateProgressBar();
131
+ decadeIsVisible();
132
+ });
133
+ }
134
+
135
+ // DUMMY TIMELINE ITEM OPEN/CLOSE
136
+ // function wrap(el, wrapper) {
137
+ // el.parentNode.insertBefore(wrapper, el);
138
+ // wrapper.classList.add('wrapper');
139
+ // wrapper.appendChild(el);
140
+ // }
141
+ //
142
+ // const timeLineItems = document.querySelectorAll('.js-timeline-item');
143
+ // let timeLineItemScrollPosition = 0;
144
+ //
145
+ // [].forEach.call(timeLineItems, (timeLineItem) => {
146
+ // const timeLineItemLink = timeLineItem.querySelector('a');
147
+ // const timeLineItemClose = timeLineItem.querySelector('.js-timeline-item-close');
148
+ // const timeLineItemBottomClose = timeLineItem.querySelector('.js-timeline-item-bottom-close');
149
+ //
150
+ // timeLineItemLink.addEventListener('click', () => {
151
+ // timeLineItemScrollPosition = window.pageYOffset;
152
+ // sessionStorage.setItem('scroll-position', timeLineItemScrollPosition);
153
+ //
154
+ // if (!timeLineItem.classList.contains('is-open')) {
155
+ // timeLineItem.classList.add('is-open');
156
+ // timeLineItem.closest('.row').classList.add('row-has-open-child');
157
+ //
158
+ // // Wrap open timeline item
159
+ // wrap(timeLineItem.querySelector('.wp-block-iis-timeline-post'),
160
+ // document.createElement('div'));
161
+ // }
162
+ // });
163
+ //
164
+ // timeLineItemClose.addEventListener('click', () => {
165
+ // timeLineItem.classList.remove('is-open');
166
+ // timeLineItem.closest('.row').classList.remove('row-has-open-child');
167
+ //
168
+ // // Destroy generated wrapper
169
+ // const wrapper = timeLineItemClose.nextElementSibling;
170
+ // wrapper.replaceWith(...wrapper.childNodes);
171
+ //
172
+ // const top = sessionStorage.getItem('scroll-position');
173
+ // if (top !== null) {
174
+ // window.scrollTo(0, parseInt(top, 10));
175
+ // }
176
+ // sessionStorage.removeItem('scroll-position');
177
+ //
178
+ // // Trigger scroll event to reveal timeline items not yet parallaxed into view
179
+ // window.dispatchEvent(new CustomEvent('scroll'));
180
+ // });
181
+ //
182
+ // timeLineItemBottomClose.addEventListener('click', () => {
183
+ // timeLineItemClose.click();
184
+ // });
185
+ // });