@internetstiftelsen/styleguide 3.0.8 → 3.0.10-beta.0.1

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.
@@ -187,7 +187,6 @@ function display() {
187
187
  (0, _focusTrap2.default)(active.el);
188
188
 
189
189
  active.el.setAttribute('aria-hidden', 'false');
190
- active.el.setAttribute('data-a11y-toggle-open', 'true');
191
190
 
192
191
  if (active.settings.onOpen) {
193
192
  active.settings.onOpen(active.id, active.el);
@@ -255,7 +254,6 @@ function dispatchOnCloseHandlers(el, id) {
255
254
  function close() {
256
255
  if (active) {
257
256
  active.el.setAttribute('aria-hidden', 'true');
258
- active.el.removeAttribute('data-a11y-toggle-open');
259
257
 
260
258
  if (active.settings.onClose) {
261
259
  active.settings.onClose(active.id);
@@ -70,6 +70,15 @@ window.a11yTabs = function tabsComponentIIFE(global, document) {
70
70
  this.tabList.addEventListener('keydown', this.eventCallback, false);
71
71
 
72
72
  tabInstances.set(this.element, this);
73
+
74
+ this.eventCallback = handleEvents.bind(this); // eslint-disable-line
75
+ this.tabList.addEventListener('click', this.eventCallback, false);
76
+ this.tabList.addEventListener('keydown', this.eventCallback, false);
77
+
78
+ tabInstances.set(this.element, this);
79
+
80
+ // New line to select the correct tab based on URL hash
81
+ this.selectTabFromHash(); // Call the new method after setup
73
82
  };
74
83
 
75
84
  TabComponent.prototype = {
@@ -126,6 +135,22 @@ window.a11yTabs = function tabsComponentIIFE(global, document) {
126
135
  this.tabPanels[index].focus();
127
136
 
128
137
  return this;
138
+ },
139
+ /**
140
+ * Selects a tab based on the URL hash
141
+ */
142
+ selectTabFromHash: function selectTabFromHash() {
143
+ var hash = global.location.hash;
144
+
145
+ if (hash) {
146
+ var targetId = hash.substring(1); // Remove the '#' character
147
+ var targetIndex = this.tabLinks.findIndex(function (link) {
148
+ return link.id === targetId;
149
+ });
150
+ if (targetIndex !== -1) {
151
+ this.handleTabInteraction(targetIndex);
152
+ }
153
+ }
129
154
  }
130
155
  };
131
156
 
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
4
+
5
+ // DUMMY TIMELINE ITEM OPEN/CLOSE
6
+ function wrap(el, wrapper) {
7
+ el.parentNode.insertBefore(wrapper, el);
8
+ wrapper.classList.add('wrapper');
9
+ wrapper.appendChild(el);
10
+ }
11
+
12
+ var timeLineItems = document.querySelectorAll('.js-timeline-item');
13
+ var timeLineItemScrollPosition = 0;
14
+
15
+ [].forEach.call(timeLineItems, function (timeLineItem) {
16
+ var timeLineItemLink = timeLineItem.querySelector('a');
17
+ var timeLineItemClose = timeLineItem.querySelector('.js-timeline-item-close');
18
+ var timeLineItemBottomClose = timeLineItem.querySelector('.js-timeline-item-bottom-close');
19
+
20
+ timeLineItemLink.addEventListener('click', function () {
21
+ timeLineItemScrollPosition = window.pageYOffset;
22
+ sessionStorage.setItem('scroll-position', timeLineItemScrollPosition);
23
+
24
+ if (!timeLineItem.classList.contains('is-open')) {
25
+ timeLineItem.classList.add('is-open');
26
+ timeLineItem.closest('.row').classList.add('row-has-open-child');
27
+
28
+ // Wrap open timeline item
29
+ wrap(timeLineItem.querySelector('.wp-block-iis-timeline-post'), document.createElement('div'));
30
+ }
31
+ });
32
+
33
+ timeLineItemClose.addEventListener('click', function () {
34
+ timeLineItem.classList.remove('is-open');
35
+ timeLineItem.closest('.row').classList.remove('row-has-open-child');
36
+
37
+ // Destroy generated wrapper
38
+ var wrapper = timeLineItemClose.nextElementSibling;
39
+ wrapper.replaceWith.apply(wrapper, _toConsumableArray(wrapper.childNodes));
40
+
41
+ var top = sessionStorage.getItem('scroll-position');
42
+ if (top !== null) {
43
+ window.scrollTo(0, parseInt(top, 10));
44
+ }
45
+ sessionStorage.removeItem('scroll-position');
46
+
47
+ // Trigger scroll event to reveal timeline items not yet parallaxed into view
48
+ window.dispatchEvent(new CustomEvent('scroll'));
49
+ });
50
+
51
+ timeLineItemBottomClose.addEventListener('click', function () {
52
+ timeLineItemClose.click();
53
+ });
54
+ });
@@ -141,56 +141,4 @@ if (progressBar) {
141
141
  animateProgressBar();
142
142
  decadeIsVisible();
143
143
  });
144
- }
145
-
146
- // DUMMY TIMELINE ITEM OPEN/CLOSE
147
- // function wrap(el, wrapper) {
148
- // el.parentNode.insertBefore(wrapper, el);
149
- // wrapper.classList.add('wrapper');
150
- // wrapper.appendChild(el);
151
- // }
152
- //
153
- // const timeLineItems = document.querySelectorAll('.js-timeline-item');
154
- // let timeLineItemScrollPosition = 0;
155
- //
156
- // [].forEach.call(timeLineItems, (timeLineItem) => {
157
- // const timeLineItemLink = timeLineItem.querySelector('a');
158
- // const timeLineItemClose = timeLineItem.querySelector('.js-timeline-item-close');
159
- // const timeLineItemBottomClose = timeLineItem.querySelector('.js-timeline-item-bottom-close');
160
- //
161
- // timeLineItemLink.addEventListener('click', () => {
162
- // timeLineItemScrollPosition = window.pageYOffset;
163
- // sessionStorage.setItem('scroll-position', timeLineItemScrollPosition);
164
- //
165
- // if (!timeLineItem.classList.contains('is-open')) {
166
- // timeLineItem.classList.add('is-open');
167
- // timeLineItem.closest('.row').classList.add('row-has-open-child');
168
- //
169
- // // Wrap open timeline item
170
- // wrap(timeLineItem.querySelector('.wp-block-iis-timeline-post'),
171
- // document.createElement('div'));
172
- // }
173
- // });
174
- //
175
- // timeLineItemClose.addEventListener('click', () => {
176
- // timeLineItem.classList.remove('is-open');
177
- // timeLineItem.closest('.row').classList.remove('row-has-open-child');
178
- //
179
- // // Destroy generated wrapper
180
- // const wrapper = timeLineItemClose.nextElementSibling;
181
- // wrapper.replaceWith(...wrapper.childNodes);
182
- //
183
- // const top = sessionStorage.getItem('scroll-position');
184
- // if (top !== null) {
185
- // window.scrollTo(0, parseInt(top, 10));
186
- // }
187
- // sessionStorage.removeItem('scroll-position');
188
- //
189
- // // Trigger scroll event to reveal timeline items not yet parallaxed into view
190
- // window.dispatchEvent(new CustomEvent('scroll'));
191
- // });
192
- //
193
- // timeLineItemBottomClose.addEventListener('click', () => {
194
- // timeLineItemClose.click();
195
- // });
196
- // });
144
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetstiftelsen/styleguide",
3
- "version": "3.0.8",
3
+ "version": "3.0.10-beta.0.1",
4
4
  "main": "dist/components.js",
5
5
  "ports": {
6
6
  "fractal": "3000"
package/src/app.js CHANGED
@@ -37,7 +37,7 @@ if (demoModal) {
37
37
  content: '<p>My modal content.</p>',
38
38
  actions: [
39
39
  {
40
- text: 'Close modal',
40
+ text: 'Open modal',
41
41
  color: 'peacock-light',
42
42
  modifier: 'primary',
43
43
  attrs: {
@@ -164,7 +164,6 @@ function display() {
164
164
  focusTrap(active.el);
165
165
 
166
166
  active.el.setAttribute('aria-hidden', 'false');
167
- active.el.setAttribute('data-a11y-toggle-open', 'true');
168
167
 
169
168
  if (active.settings.onOpen) {
170
169
  active.settings.onOpen(active.id, active.el);
@@ -230,7 +229,6 @@ function dispatchOnCloseHandlers(el, id) {
230
229
  function close() {
231
230
  if (active) {
232
231
  active.el.setAttribute('aria-hidden', 'true');
233
- active.el.removeAttribute('data-a11y-toggle-open');
234
232
 
235
233
  if (active.settings.onClose) {
236
234
  active.settings.onClose(active.id);
@@ -96,7 +96,7 @@
96
96
  }
97
97
  }
98
98
 
99
- @keyframes pulse {
99
+ @keyframes xPulse {
100
100
  0% {
101
101
  right: 0;
102
102
  opacity: 1;
@@ -245,7 +245,7 @@
245
245
  right: rhythm(3);
246
246
  width: rhythm(7);
247
247
  height: 0;
248
- animation: pulse 2s infinite;
248
+ animation: xPulse 2s infinite;
249
249
  font-family: $font-family-mono;
250
250
  font-size: 80%;
251
251
  text-transform: uppercase;
@@ -257,7 +257,7 @@
257
257
  z-index: z_index(background);
258
258
  top: -#{rem(4px)};
259
259
  right: 0;
260
- animation: pulse 2s infinite;
260
+ animation: xPulse 2s infinite;
261
261
  font-family: $font-family-mono;
262
262
  }
263
263
  }
@@ -39,6 +39,34 @@
39
39
  padding-bottom: rhythm(10);
40
40
  }
41
41
  }
42
+
43
+ @include e(button) {
44
+ position: absolute;
45
+ bottom: 0;
46
+ transform: translateY(50%);
47
+
48
+ @extend %box-shadow;
49
+ }
50
+
51
+ @include e(text) {
52
+ color: $color-snow;
53
+ margin-left: rhythm(4);
54
+ transition: opacity 0.25s ease;
55
+ overflow: hidden;
56
+ opacity: 1;
57
+
58
+ &.is-minimized {
59
+ opacity: 0;
60
+ }
61
+
62
+ @include bp-up(md) {
63
+ max-width: 60%;
64
+ }
65
+
66
+ @include bp-up(lg) {
67
+ max-width: 60%;
68
+ }
69
+ }
42
70
  }
43
71
 
44
72
  @include e(gauge) {
@@ -110,32 +138,4 @@
110
138
  left: -#{rem(20px)};
111
139
  }
112
140
  }
113
-
114
- @include e(button) {
115
- position: absolute;
116
- bottom: 0;
117
- transform: translateY(50%);
118
-
119
- @extend %box-shadow;
120
- }
121
-
122
- @include e(text) {
123
- color: $color-snow;
124
- margin-left: rhythm(4);
125
- transition: opacity 0.25s ease;
126
- overflow: hidden;
127
- opacity: 1;
128
-
129
- &.is-minimized {
130
- opacity: 0;
131
- }
132
-
133
- @include bp-up(md) {
134
- max-width: 60%;
135
- }
136
-
137
- @include bp-up(lg) {
138
- max-width: 60%;
139
- }
140
- }
141
141
  }
@@ -62,10 +62,16 @@
62
62
  }
63
63
 
64
64
  @include e(paragraph) {
65
+ color: $color-cyberspace;
66
+
65
67
  @include plumber(
66
68
  $font-size: 2.5,
67
69
  $line-height: 3
68
70
  );
71
+
72
+ @include bp-up(sm) {
73
+ color: $color-snow;
74
+ }
69
75
  }
70
76
 
71
77
  @include e(tags) {
@@ -196,6 +202,10 @@
196
202
  }
197
203
  }
198
204
 
205
+ @include e(paragraph) {
206
+ color: $color-cyberspace;
207
+ }
208
+
199
209
  &.alignfull {
200
210
  @include e(caption) {
201
211
  .wrapper {
@@ -22,7 +22,7 @@ module.exports = {
22
22
  limited_width: true,
23
23
  has_radius: true,
24
24
  has_buttons: false,
25
- text: 'Nästan alla i Sverige använder internet – men hur meningsfull är tiden vi spenderar där? I rapporten Svenskarna och internet 2019 frågar vi för första gången om meningsfullhet, och det syns stora skillnader mellan olika aktiviteter. Tid på sociala medier tycker bara var fjärde är meningsfull.',
25
+ text: 'Nästan alla i Sverige använder internet – men hur meningsfull är tiden vi spenderar där? I rapporten Svenskarna och internet 2019 frågar vi för första gången om meningsfullhet, och det syns stora skillnader mellan olika aktiviteter.',
26
26
  }
27
27
  },
28
28
  {
@@ -6,12 +6,12 @@ module.exports = {
6
6
  {
7
7
  id: 'tab-1',
8
8
  heading: 'De här',
9
- content: '<p>Klinisk och min drink. Reserverad potten var nu en kund, men inte bara protein. Renare TV, uppvärmning för någon, chips start. Antioxidanter eller om barnen orienterade, fotboll framför datorn. Medlemmar i dörren var intakt protein. Läxor fotbollstips lejon kartong bananer. Smartphones och bananer temperatur.</p>'
9
+ content: '<p>Klinisk och min drink. Reserverad potten var nu en kund, men inte bara protein. Renare TV, uppvärmning för någon, chips start. <a href="#">Antioxidanter</a> eller om barnen orienterade, fotboll framför datorn. Medlemmar i dörren var intakt protein. Läxor fotbollstips lejon kartong bananer. Smartphones och bananer temperatur.</p>'
10
10
  },
11
11
  {
12
12
  id: 'tab-2',
13
13
  heading: 'Tabbarna',
14
- content: '<p>Ta färdväg åker rot häst se precis det blev därmed se, söka smultron för ingalunda brunsås fram se vi miljoner jäst olika, groda sällan dunge när tiden fram helt sig dock. För sax blivit redan av där vid upprätthållande omfångsrik det på bra, icke dunge på mjuka groda ser del kan stora. År denna gör erfarenheter häst bland tre ta söka redan år, dimma om händer rot dimma att om själv av sjö, sig stig genom och sorgliga själv verkligen nya där.</p>'
14
+ content: '<p>Ta färdväg åker rot häst se precis det blev därmed se, <a href="#">söka smultron</a> för ingalunda brunsås fram se vi miljoner jäst olika, groda sällan dunge när tiden fram helt sig dock. För sax blivit redan av där vid upprätthållande omfångsrik det på bra, icke dunge på mjuka groda ser del kan stora. År denna gör erfarenheter häst bland tre ta söka redan år, dimma om händer rot dimma att om själv av sjö, sig stig genom och sorgliga själv verkligen nya där.</p>'
15
15
  },
16
16
  {
17
17
  id: 'tab-3',
@@ -74,6 +74,15 @@ window.a11yTabs = (function tabsComponentIIFE(global, document) {
74
74
  this.tabList.addEventListener('keydown', this.eventCallback, false);
75
75
 
76
76
  tabInstances.set(this.element, this);
77
+
78
+ this.eventCallback = handleEvents.bind(this); // eslint-disable-line
79
+ this.tabList.addEventListener('click', this.eventCallback, false);
80
+ this.tabList.addEventListener('keydown', this.eventCallback, false);
81
+
82
+ tabInstances.set(this.element, this);
83
+
84
+ // New line to select the correct tab based on URL hash
85
+ this.selectTabFromHash(); // Call the new method after setup
77
86
  };
78
87
 
79
88
  TabComponent.prototype = {
@@ -130,6 +139,19 @@ window.a11yTabs = (function tabsComponentIIFE(global, document) {
130
139
 
131
140
  return this;
132
141
  },
142
+ /**
143
+ * Selects a tab based on the URL hash
144
+ */
145
+ selectTabFromHash() {
146
+ const { hash } = global.location;
147
+ if (hash) {
148
+ const targetId = hash.substring(1); // Remove the '#' character
149
+ const targetIndex = this.tabLinks.findIndex((link) => link.id === targetId);
150
+ if (targetIndex !== -1) {
151
+ this.handleTabInteraction(targetIndex);
152
+ }
153
+ }
154
+ },
133
155
  };
134
156
 
135
157
  /**