@internetstiftelsen/styleguide 2.26.4-beta.0.5 → 2.26.4-beta.0.6

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.
@@ -17,6 +17,7 @@ var _hasCookieConsent2 = _interopRequireDefault(_hasCookieConsent);
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
18
 
19
19
  // TODO: Should probably implement a way to localize texts in the styleguide
20
+ var consent = (0, _hasCookieConsent2.default)('C0004');
20
21
  var missingConsentMessage = 'För att spela Youtubefilmer krävs att "Riktade kakor" tillåts. Tryck för att "Anpassa kakor"';
21
22
 
22
23
  function loadYoutubeAPI() {
@@ -53,6 +54,7 @@ function createConsentWarning(el) {
53
54
  var div = document.createElement('div');
54
55
  var button = document.createElement('button');
55
56
  var message = document.createElement('p');
57
+ message.classList.add('color-cyberspace');
56
58
 
57
59
  div.setAttribute('data-youtube-consent-warning', true);
58
60
  div.className = (0, _className2.default)('m-icon-overlay__message');
@@ -66,9 +68,19 @@ function createConsentWarning(el) {
66
68
  el.appendChild(div);
67
69
  }
68
70
 
71
+ function destroyConsentWarning(el) {
72
+ var div = el.querySelector('[data-youtube-consent-warning]');
73
+
74
+ if (div) {
75
+ div.parentNode.removeChild(div);
76
+ }
77
+ }
78
+
69
79
  function createCover(el) {
70
- if (!(0, _hasCookieConsent2.default)('C0004')) {
80
+ if (!consent) {
71
81
  createConsentWarning(el);
82
+ } else {
83
+ destroyConsentWarning(el);
72
84
  }
73
85
 
74
86
  if (el.getElementsByTagName('img').length) {
@@ -165,4 +177,13 @@ window.onYouTubeIframeAPIReady = function () {
165
177
  };
166
178
 
167
179
  setupPlayers(document);
168
- loadYoutubeAPI();
180
+ loadYoutubeAPI();
181
+
182
+ window.addEventListener('consent.onetrust', function (e) {
183
+ if (e.detail.includes('C0004')) {
184
+ consent = true;
185
+
186
+ setupPlayers(document);
187
+ loadYoutubeAPI();
188
+ }
189
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetstiftelsen/styleguide",
3
- "version": "2.26.4-beta.0.5",
3
+ "version": "2.26.4-beta.0.6",
4
4
  "main": "dist/components.js",
5
5
  "ports": {
6
6
  "fractal": "3000"
@@ -2,6 +2,7 @@
2
2
  import className from './className';
3
3
  import hasCookieConsent from './hasCookieConsent';
4
4
 
5
+ let consent = hasCookieConsent('C0004');
5
6
  const missingConsentMessage = 'För att spela Youtubefilmer krävs att "Riktade kakor" tillåts. Tryck för att "Anpassa kakor"';
6
7
 
7
8
  function loadYoutubeAPI() {
@@ -52,9 +53,19 @@ function createConsentWarning(el) {
52
53
  el.appendChild(div);
53
54
  }
54
55
 
56
+ function destroyConsentWarning(el) {
57
+ const div = el.querySelector('[data-youtube-consent-warning]');
58
+
59
+ if (div) {
60
+ div.parentNode.removeChild(div);
61
+ }
62
+ }
63
+
55
64
  function createCover(el) {
56
- if (!hasCookieConsent('C0004')) {
65
+ if (!consent) {
57
66
  createConsentWarning(el);
67
+ } else {
68
+ destroyConsentWarning(el);
58
69
  }
59
70
 
60
71
  if (el.getElementsByTagName('img').length) {
@@ -150,3 +161,12 @@ window.onYouTubeIframeAPIReady = () => {
150
161
 
151
162
  setupPlayers(document);
152
163
  loadYoutubeAPI();
164
+
165
+ window.addEventListener('consent.onetrust', (e) => {
166
+ if (e.detail.includes('C0004')) {
167
+ consent = true;
168
+
169
+ setupPlayers(document);
170
+ loadYoutubeAPI();
171
+ }
172
+ });