@internetstiftelsen/styleguide 3.0.10-beta.0.3 → 3.0.10

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,6 +187,7 @@ 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');
190
191
 
191
192
  if (active.settings.onOpen) {
192
193
  active.settings.onOpen(active.id, active.el);
@@ -254,6 +255,7 @@ function dispatchOnCloseHandlers(el, id) {
254
255
  function close() {
255
256
  if (active) {
256
257
  active.el.setAttribute('aria-hidden', 'true');
258
+ active.el.removeAttribute('data-a11y-toggle-open');
257
259
 
258
260
  if (active.settings.onClose) {
259
261
  active.settings.onClose(active.id);
@@ -122,6 +122,11 @@ window.a11yTabs = function tabsComponentIIFE(global, document) {
122
122
  this.tabPanels[currentIndex].setAttribute('hidden', '');
123
123
  this.tabPanels[newIndex].removeAttribute('hidden');
124
124
 
125
+ // After updating tabs and tab panels, add the URL update feature
126
+ // Update the browser's URL hash to reflect the current tab's ID
127
+ var selectedTabId = this.tabLinks[newIndex].id;
128
+ global.history.pushState(null, '', '#' + selectedTabId);
129
+
125
130
  this.currentIndex = newIndex;
126
131
 
127
132
  return this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetstiftelsen/styleguide",
3
- "version": "3.0.10-beta.0.3",
3
+ "version": "3.0.10",
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: 'Open modal',
40
+ text: 'Close modal',
41
41
  color: 'peacock-light',
42
42
  modifier: 'primary',
43
43
  attrs: {
@@ -164,6 +164,7 @@ 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');
167
168
 
168
169
  if (active.settings.onOpen) {
169
170
  active.settings.onOpen(active.id, active.el);
@@ -229,6 +230,7 @@ function dispatchOnCloseHandlers(el, id) {
229
230
  function close() {
230
231
  if (active) {
231
232
  active.el.setAttribute('aria-hidden', 'true');
233
+ active.el.removeAttribute('data-a11y-toggle-open');
232
234
 
233
235
  if (active.settings.onClose) {
234
236
  active.settings.onClose(active.id);
@@ -197,25 +197,27 @@
197
197
  }
198
198
 
199
199
  @include m(lines) {
200
- tr {
201
- background-image:
202
- linear-gradient(
203
- to right,
204
- $color-cyberspace,
205
- $color-cyberspace 2px,
206
- transparent 2px,
207
- transparent 6px
208
- );
209
- background-repeat: repeat-x;
210
- background-position: bottom left;
211
- background-size: 6px 1px;
212
- }
200
+ tbody {
201
+ tr {
202
+ background-image:
203
+ linear-gradient(
204
+ to right,
205
+ $color-cyberspace,
206
+ $color-cyberspace 2px,
207
+ transparent 2px,
208
+ transparent 6px
209
+ );
210
+ background-repeat: repeat-x;
211
+ background-position: bottom left;
212
+ background-size: 6px 1px;
213
+ }
213
214
 
214
- td,
215
- th {
216
- padding-top: rhythm(2);
217
- padding-bottom: rhythm(2);
218
- border: 0;
215
+ td,
216
+ th {
217
+ padding-top: rhythm(2);
218
+ padding-bottom: rhythm(2);
219
+ border: 0;
220
+ }
219
221
  }
220
222
 
221
223
  tfoot {
@@ -110,6 +110,7 @@
110
110
 
111
111
  .js {
112
112
  .js-accordion {
113
+
113
114
  @include e(header) {
114
115
  border-bottom: 1px solid $color-snow;
115
116
 
@@ -248,6 +249,12 @@
248
249
  margin-bottom: 0;
249
250
  padding-top: 0;
250
251
  padding-bottom: 0;
252
+
253
+ &:last-of-type {
254
+ > button {
255
+ border-bottom: 0;
256
+ }
257
+ }
251
258
  }
252
259
 
253
260
  @include e(logo) {
@@ -32,7 +32,7 @@ module.exports = {
32
32
  },
33
33
  {
34
34
  heading: 'Proin faucibus pretium orci',
35
- content: false,
35
+ content: '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ut elit lacinia, feugiat felis sit amet, congue ante. Morbi vel egestas mi. Nulla urna sapien, gravida et nisl ac, maximus euismod ipsum. Vivamus condimentum, massa non convallis hendrerit, orci mi porttitor nisi, at commodo purus magna non nisi. Duis feugiat lectus in sapien mollis, ac volutpat leo elementum. Nullam euismod massa a nulla placerat sagittis. Integer id purus a dolor fermentum mollis vel feugiat dui. Nullam neque diam, mattis nec cursus at, facilisis nec diam.</p><p>Proin faucibus pretium orci, eu tristique augue condimentum at. Suspendisse potenti. Donec ut luctus eros. Nam justo nunc, facilisis lobortis hendrerit sodales, fermentum at purus. Proin eget elementum nulla, nec tincidunt lacus. Mauris massa eros, interdum eget nunc id, molestie semper libero. Vivamus tortor ex, viverra ut varius vel, finibus hendrerit nunc. Morbi pulvinar arcu erat, consectetu mollis leo vulputate eu.</p>',
36
36
  color: false
37
37
  },
38
38
  ]
@@ -295,7 +295,15 @@
295
295
  @include e(text) {
296
296
  max-width: 100%;
297
297
 
298
+ @include bp-up(md) {
299
+ max-width: 90%;
300
+ }
301
+
298
302
  @include bp-up(lg) {
303
+ max-width: 85%;
304
+ }
305
+
306
+ @include bp-up(xxl) {
299
307
  max-width: 70%;
300
308
  }
301
309
 
@@ -308,10 +316,6 @@
308
316
  );
309
317
  }
310
318
  }
311
-
312
- @include bp-up(xl) {
313
- max-width: 50%;
314
- }
315
319
  }
316
320
 
317
321
  @include e(link) {
@@ -2,6 +2,7 @@ module.exports = {
2
2
  status: 'ready',
3
3
 
4
4
  context: {
5
+ updateURL: false,
5
6
  tab_item: [
6
7
  {
7
8
  id: 'tab-1',
@@ -28,5 +29,19 @@ module.exports = {
28
29
  content: '<p>Dock upprätthållande ta faktor sällan dimmhöljd ingalunda mjuka, vidsträckt bra tidigare vemod samma att lax redan, bra oss strand dimma redan är. Räv att dimmhöljd söka kunde tiden söka vid när, gör del dag söka vad icke se, göras tidigare vid nu dunge kunde tiden. Gamla det som mjuka gamla hans gamla bra sista fram gamla, tiden trevnadens se hwila när själv nu har kanske hwila, helt i när groda göras rännil verkligen tid så. </p>'
29
30
  }
30
31
  ]
31
- }
32
+ },
33
+ variants: [
34
+ {
35
+ name: 'Update URL',
36
+ context: {
37
+ updateURL: true
38
+ }
39
+ },
40
+ {
41
+ name: 'Wrapped Tabs',
42
+ context: {
43
+ wrapped: true
44
+ }
45
+ }
46
+ ]
32
47
  }
@@ -1,5 +1,8 @@
1
1
  window.a11yTabs = (function tabsComponentIIFE(global, document) {
2
2
  const tabInstances = new WeakMap();
3
+ const className = 'o-tab-list';
4
+ const tablistElement = document.querySelector(`.js-${className}`);
5
+ const updateURLFromHash = tablistElement.getAttribute('data-update-url');
3
6
 
4
7
  /**
5
8
  * Instantiates the component
@@ -11,8 +14,6 @@ window.a11yTabs = (function tabsComponentIIFE(global, document) {
11
14
  return;
12
15
  }
13
16
 
14
- const className = 'o-tab-list';
15
- const tablistElement = document.querySelector(`.js-${className}`);
16
17
  const namespace = getComputedStyle(tablistElement, ':before').content.replace(/["']/g, '');
17
18
 
18
19
  const defaults = {
@@ -50,7 +51,6 @@ window.a11yTabs = (function tabsComponentIIFE(global, document) {
50
51
 
51
52
  this.tabLinks.forEach((item, index) => {
52
53
  item.setAttribute('role', 'tab');
53
- // item.setAttribute('id', `tab${index}`);
54
54
 
55
55
  if (index > 0) {
56
56
  item.setAttribute('tabindex', '-1');
@@ -75,14 +75,10 @@ window.a11yTabs = (function tabsComponentIIFE(global, document) {
75
75
 
76
76
  tabInstances.set(this.element, this);
77
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
78
+ // Select the correct tab based on URL hash
79
+ if (updateURLFromHash) {
80
+ this.selectTabFromHash();
81
+ }
86
82
  };
87
83
 
88
84
  TabComponent.prototype = {
@@ -119,12 +115,19 @@ window.a11yTabs = (function tabsComponentIIFE(global, document) {
119
115
  this.tabLinks[newIndex].setAttribute('aria-selected', 'true');
120
116
  this.tabItems[newIndex].setAttribute('data-tab-active', '');
121
117
  this.tabLinks[newIndex].removeAttribute('tabindex');
122
- this.tabLinks[newIndex].focus();
118
+ this.tabLinks[newIndex].focus(); // Focus the newly selected tab
123
119
 
124
120
  // update tab panels
125
121
  this.tabPanels[currentIndex].setAttribute('hidden', '');
126
122
  this.tabPanels[newIndex].removeAttribute('hidden');
127
123
 
124
+ // Update the browser's URL hash to reflect the current tab's ID
125
+ const selectedTabId = this.tabLinks[newIndex].id;
126
+
127
+ if (updateURLFromHash) {
128
+ window.history.pushState(null, '', `#${selectedTabId}`);
129
+ }
130
+
128
131
  this.currentIndex = newIndex;
129
132
 
130
133
  return this;