@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,84 @@
1
+ import className from '../../assets/js/className';
2
+
3
+ class ProgressRing extends HTMLElement {
4
+ constructor() {
5
+ super();
6
+ const stroke = this.getAttribute('stroke');
7
+ const radius = this.getAttribute('radius');
8
+ const normalizedRadius = radius - stroke * 2;
9
+ this.circumference = normalizedRadius * 2 * Math.PI;
10
+
11
+ this.root = this.attachShadow({ mode: 'open' });
12
+ this.root.innerHTML = `
13
+ <svg
14
+ height="${radius * 2}"
15
+ width="${radius * 2}"
16
+ >
17
+ <circle
18
+ stroke="white"
19
+ stroke-dasharray="${this.circumference} ${this.circumference}"
20
+ style="stroke-dashoffset:${this.circumference}"
21
+ stroke-width="${stroke}"
22
+ fill="transparent"
23
+ r="${normalizedRadius}"
24
+ cx="${radius}"
25
+ cy="${radius}"
26
+ />
27
+ </svg>
28
+
29
+ <style>
30
+ circle {
31
+ transition: stroke-dashoffset 0.35s;
32
+ transform: rotate(-90deg);
33
+ transform-origin: 50% 50%;
34
+ }
35
+ </style>
36
+ `;
37
+ }
38
+
39
+ setProgress(percent) {
40
+ const offset = this.circumference - ((percent / 100) * this.circumference);
41
+ const circle = this.root.querySelector('circle');
42
+ circle.style.strokeDashoffset = offset;
43
+ }
44
+
45
+ static get observedAttributes() {
46
+ return ['progress'];
47
+ }
48
+
49
+ attributeChangedCallback(name, oldValue, newValue) {
50
+ if (name === 'progress') {
51
+ this.setProgress(newValue);
52
+ }
53
+ }
54
+ }
55
+
56
+ window.customElements.define('progress-ring', ProgressRing);
57
+
58
+ // Get value from localStorage if present
59
+ if (localStorage.getItem('InmsCurrentTime')) {
60
+ const videoCurrentTime = localStorage.getItem('InmsCurrentTime');
61
+ const videoDuration = localStorage.getItem('InmsDuration');
62
+ const continueElement = document.querySelector('.js-guide-continue');
63
+ const progressRing = document.querySelector('progress-ring');
64
+ const continueLink = document.querySelector('.js-guide-continue-link');
65
+ const guideURL = localStorage.getItem('InmsCurrentGuideURL');
66
+ const guideImage = localStorage.getItem('InmsCurrentGuideImage');
67
+
68
+ if ((videoCurrentTime > 0)
69
+ && progressRing
70
+ && continueElement
71
+ && guideImage
72
+ && continueLink) {
73
+ const alternativeText = continueLink.dataset.altText;
74
+ const currentProgress = videoCurrentTime / videoDuration;
75
+ const currentGuideImage = document.querySelector('.js-guide-continue-image');
76
+
77
+ continueElement.classList.add(className('m-continue-video-guide--has-progress'));
78
+ continueLink.setAttribute('href', guideURL);
79
+ currentGuideImage.src = guideImage;
80
+ continueLink.querySelector('span').innerText = alternativeText;
81
+ // Calculate percentage played
82
+ progressRing.setAttribute('progress', Math.floor(currentProgress * 100));
83
+ }
84
+ }
@@ -0,0 +1,110 @@
1
+ @charset "UTF-8";
2
+
3
+ @include molecule(continue-video-guide) {
4
+ position: fixed;
5
+ bottom: 0;
6
+ right: 0;
7
+ z-index: z_index(middlegroundImportant);
8
+ width: 100px;
9
+ height: calc(100px + 23px + rhythm(1));
10
+ transform: scale(0.7);
11
+
12
+ @include bp-up(md) {
13
+ transform: scale(1);
14
+ bottom: rhythm(2);
15
+ right: rhythm(2);
16
+ }
17
+
18
+ @include e(inner) {
19
+ position: relative;
20
+ }
21
+
22
+ @include e(progressbar) {
23
+ display: none;
24
+ }
25
+
26
+ @include e(continue) {
27
+ position: absolute;
28
+ z-index: 3;
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ width: 100px;
33
+ height: 100px;
34
+ border-color: $color-snow;
35
+
36
+ &::after {
37
+ content: 'Guidad tur';
38
+ display: block;
39
+ position: absolute;
40
+ left: auto;
41
+ right: auto;
42
+ bottom: 0;
43
+ transform: translateY(calc(100% + rhythm(1)));
44
+ text-align: center;
45
+ background-color: $color-peacock-light;
46
+ font-size: $size-medium;
47
+ font-family: $font-family-headings;
48
+ border-radius: $border-radius;
49
+ color: $color-cyberspace;
50
+ padding: rhythm(0.5) rhythm(1);
51
+ line-height: 1;
52
+ }
53
+ }
54
+
55
+ @include m(has-progress) {
56
+ @include e(continue) {
57
+ &::after {
58
+ content: 'Fortsätt';
59
+ }
60
+
61
+ @include e(arrow) {
62
+ width: 0;
63
+ height: 0;
64
+ border-style: solid;
65
+ border-width: 15px 0 15px 20px;
66
+ transition: border-width 0.25s ease-out;
67
+ border-bottom: 15px solid transparent;
68
+ border-left-color: inherit;
69
+ border-left-style: solid;
70
+ border-left-width: 20px;
71
+ border-right: 0 solid transparent;
72
+ border-top: 15px solid transparent;
73
+ }
74
+
75
+ &:hover,
76
+ &:focus {
77
+ > div {
78
+ border-width: 20px 0 20px 30px;
79
+ }
80
+ }
81
+ }
82
+
83
+ @include e(progressbar) {
84
+ display: block;
85
+ position: absolute;
86
+ z-index: 2;
87
+ border-radius: 50%;
88
+
89
+ &::after {
90
+ position: absolute;
91
+ top: 6px;
92
+ left: 6px;
93
+ width: 88px;
94
+ height: 88px;
95
+ border-radius: 50%;
96
+ content: '';
97
+ display: block;
98
+ border: 4px solid rgba($color-snow, 0.5);
99
+ }
100
+ }
101
+ }
102
+
103
+ @include e(image) {
104
+ position: absolute;
105
+ z-index: 1;
106
+ width: 100px;
107
+ height: 100px;
108
+ border-radius: 50%;
109
+ }
110
+ }
@@ -0,0 +1,3 @@
1
+ # Continue Video Guide
2
+
3
+ This component is dependent on the [Video Guide Component](/components/detail/video-guide). Continuing a guided tour is only possible if the video player has a saved timestamp in sessionStorage
@@ -237,7 +237,7 @@ export default class Form {
237
237
  help.innerHTML = '';
238
238
  }
239
239
 
240
- const fieldGroup = input.closest('.field-group');
240
+ const fieldGroup = input.closest('[class*="field-group"]');
241
241
 
242
242
  if (fieldGroup) {
243
243
  fieldGroup.classList.remove('is-invalid');
@@ -272,7 +272,6 @@
272
272
  @include bp-up(xl) {
273
273
  bottom: rhythm(8);
274
274
  left: rhythm(8);
275
- max-width: 50%;
276
275
 
277
276
  @include plumber(
278
277
  $font-size: 7,
@@ -280,10 +279,6 @@
280
279
  $leading-bottom: 0
281
280
  );
282
281
  }
283
-
284
- @include bp-up(xxl) {
285
- max-width: 45%;
286
- }
287
282
  }
288
283
  }
289
284
  }
@@ -292,7 +287,7 @@
292
287
  transform: scale(0.7) translateY(-100%);
293
288
 
294
289
  @include bp-up(md) {
295
- transform: scale(1) translateY(0);
290
+ transform: scale(1) translateY(-50%);
296
291
  }
297
292
 
298
293
  @include m(hero) {
@@ -1,6 +1,8 @@
1
1
  import Glider from 'glider-js';
2
2
 
3
3
  const gliderElementHero = document.querySelector('.js-glider-hero');
4
+ const dataLayer = window.dataLayer || [];
5
+ const gliderLinks = document.querySelectorAll('.glider-slide a');
4
6
 
5
7
  if (gliderElementHero) {
6
8
  const GliderHero = new Glider(gliderElementHero, {
@@ -35,6 +37,43 @@ if (gliderElementHero) {
35
37
  }, autoplayDelay);
36
38
  }
37
39
  }, 0);
40
+ } else {
41
+ document.querySelector('.js-glider-prev').addEventListener('click', () => {
42
+ dataLayer.push({
43
+ event: 'carousel',
44
+ eventInfo: {
45
+ category: 'carousel',
46
+ action: 'click',
47
+ label: 'arrow_left',
48
+ },
49
+ });
50
+ });
51
+
52
+ document.querySelector('.js-glider-next').addEventListener('click', () => {
53
+ dataLayer.push({
54
+ event: 'carousel',
55
+ eventInfo: {
56
+ category: 'carousel',
57
+ action: 'click',
58
+ label: 'arrow_right',
59
+ },
60
+ });
61
+ });
62
+
63
+ [].forEach.call(gliderLinks, (gliderLink) => {
64
+ gliderLink.addEventListener('click', () => {
65
+ const linkTarget = gliderLink.href;
66
+ console.log(linkTarget);
67
+ dataLayer.push({
68
+ event: 'carousel',
69
+ eventInfo: {
70
+ category: 'carousel',
71
+ action: 'click',
72
+ label: linkTarget,
73
+ },
74
+ });
75
+ });
76
+ });
38
77
  }
39
78
 
40
79
  module.exports = GliderHero;
@@ -26,6 +26,10 @@
26
26
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' id='icon-arrow-down' fill='%2355c7b4' viewBox='0 0 32 18.9' width='100%25' height='100%25'%3E%3Cpolygon points='32,2.9 16,18.9 0,2.9 2.9,0 16,13.1 29.1,0 '%3E%3C/polygon%3E%3C/svg%3E%0A");
27
27
  }
28
28
 
29
+ &[data-color='sandstone'] {
30
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' id='icon-arrow-down' fill='%23f99963' viewBox='0 0 32 18.9' width='100%25' height='100%25'%3E%3Cpolygon points='32,2.9 16,18.9 0,2.9 2.9,0 16,13.1 29.1,0 '%3E%3C/polygon%3E%3C/svg%3E%0A");
31
+ }
32
+
29
33
  @include bp-up(sm) {
30
34
  border-bottom: 4px solid currentColor;
31
35
  background-position: calc(100%) 60%;
@@ -70,6 +74,10 @@
70
74
  &[data-color='jade'] {
71
75
  color: $color-jade;
72
76
  }
77
+
78
+ &[data-color='sandstone'] {
79
+ color: $color-sandstone;
80
+ }
73
81
  }
74
82
 
75
83
  @include e(input) {
@@ -41,9 +41,11 @@
41
41
 
42
42
  @include e(footer) {
43
43
  margin-bottom: rhythm(2);
44
+ margin-top: rhythm(2);
44
45
 
45
- @include bp-up(sm) {
46
+ @include bp-up(sm-xs) {
46
47
  margin-bottom: 0;
48
+ margin-top: 0;
47
49
  }
48
50
  }
49
51
 
@@ -73,6 +73,14 @@
73
73
  @include bp-up(lg) {
74
74
  margin-top: rhythm(3);
75
75
  }
76
+
77
+ @include bp-down(sm-xs) {
78
+ [class*="tag--light"] {
79
+ [class*="tag__text"] {
80
+ color: $color-cyberspace;
81
+ }
82
+ }
83
+ }
76
84
  }
77
85
 
78
86
  @include e(buttons) {
@@ -209,6 +217,10 @@
209
217
 
210
218
  @include b(a-tag) {
211
219
  @include tag;
220
+
221
+ [class*=text] {
222
+ color: $color-cyberspace;
223
+ }
212
224
  }
213
225
 
214
226
  @include bp-up(md) {
@@ -258,6 +270,14 @@
258
270
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba($color-black, 0) 55%, rgba($color-black, 1) 100%);
259
271
  text-shadow: 0 0 rhythm(2) rgba($color-black, 0.5);
260
272
  }
273
+
274
+ @include bp-down(md) {
275
+ [class*="tag--light"] {
276
+ [class*="tag__text"] {
277
+ color: $color-cyberspace;
278
+ }
279
+ }
280
+ }
261
281
  }
262
282
 
263
283
  @include e(text) {
@@ -9,7 +9,8 @@ module.exports = {
9
9
  has_buttons: false,
10
10
  has_tags: true,
11
11
  hero_image: '/assets/images/hero.jpg',
12
- has_link: true
12
+ has_link: true,
13
+ has_pre_heading: false,
13
14
  },
14
15
  variants: [
15
16
  {
@@ -56,6 +57,19 @@ module.exports = {
56
57
  has_buttons: false,
57
58
  }
58
59
  },
60
+ {
61
+ name: 'Pre heading',
62
+ context: {
63
+ has_pre_heading: true,
64
+ pre_heading: 'Publicerad 11 oktober 2022',
65
+ no_image_class: true,
66
+ has_radius: false,
67
+ limited_width: false,
68
+ has_video: false,
69
+ has_image: true,
70
+ has_buttons: true,
71
+ }
72
+ },
59
73
  {
60
74
  name: 'Event hero',
61
75
  context: {