@internetstiftelsen/styleguide 3.0.12 → 3.0.14

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.
@@ -1,13 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  var ranges = document.querySelectorAll('.js-range-wrapper');
4
- function setValue(range, rangeValue) {
4
+ function setValue(range, rangeValue, rangeInput) {
5
5
  var val = range.value;
6
6
  var min = range.min ? range.min : 0;
7
7
  var max = range.max ? range.max : 100;
8
8
  var newVal = Number((val - min) * 100 / (max - min));
9
9
  rangeValue.innerHTML = val;
10
10
 
11
+ if (rangeInput) {
12
+ rangeInput.value = val;
13
+ }
14
+
11
15
  // Sorta magic numbers based on size of the native UI thumb
12
16
  rangeValue.style.left = 'calc(' + newVal + '% + (' + (8 - newVal * 0.15) + 'px))';
13
17
  }
@@ -15,11 +19,23 @@ function setValue(range, rangeValue) {
15
19
  ranges.forEach(function (wrap) {
16
20
  var range = wrap.querySelector('.js-range');
17
21
  var rangeValue = wrap.querySelector('.js-range-value');
22
+ var rangeInput = wrap.querySelector('.js-range-input');
18
23
 
19
24
  range.addEventListener('input', function () {
20
- setValue(range, rangeValue);
25
+ setValue(range, rangeValue, rangeInput);
21
26
  range.focus();
22
27
  });
23
28
 
24
- setValue(range, rangeValue);
29
+ if (rangeInput) {
30
+ rangeInput.addEventListener('input', function () {
31
+ if (rangeInput.value !== '') {
32
+ range.value = rangeInput.value;
33
+ rangeValue.innerHTML = rangeInput.value;
34
+ setValue(range, rangeValue, rangeInput);
35
+ }
36
+ rangeInput.focus();
37
+ });
38
+ }
39
+
40
+ setValue(range, rangeValue, rangeInput);
25
41
  });
@@ -2,6 +2,13 @@
2
2
 
3
3
  window.a11yTabs = function tabsComponentIIFE(global, document) {
4
4
  var tabInstances = new WeakMap();
5
+ var className = 'o-tab-list';
6
+ var tablistElement = document.querySelector('.js-' + className);
7
+ var updateURLFromHash = void 0;
8
+
9
+ if (tablistElement) {
10
+ updateURLFromHash = tablistElement.getAttribute('data-update-url');
11
+ }
5
12
 
6
13
  /**
7
14
  * Instantiates the component
@@ -13,8 +20,6 @@ window.a11yTabs = function tabsComponentIIFE(global, document) {
13
20
  return;
14
21
  }
15
22
 
16
- var className = 'o-tab-list';
17
- var tablistElement = document.querySelector('.js-' + className);
18
23
  var namespace = getComputedStyle(tablistElement, ':before').content.replace(/["']/g, '');
19
24
 
20
25
  var defaults = {
@@ -46,7 +51,6 @@ window.a11yTabs = function tabsComponentIIFE(global, document) {
46
51
 
47
52
  this.tabLinks.forEach(function (item, index) {
48
53
  item.setAttribute('role', 'tab');
49
- // item.setAttribute('id', `tab${index}`);
50
54
 
51
55
  if (index > 0) {
52
56
  item.setAttribute('tabindex', '-1');
@@ -71,14 +75,10 @@ window.a11yTabs = function tabsComponentIIFE(global, document) {
71
75
 
72
76
  tabInstances.set(this.element, this);
73
77
 
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
78
+ // Select the correct tab based on URL hash
79
+ if (updateURLFromHash) {
80
+ this.selectTabFromHash();
81
+ }
82
82
  };
83
83
 
84
84
  TabComponent.prototype = {
@@ -116,16 +116,18 @@ window.a11yTabs = function tabsComponentIIFE(global, document) {
116
116
  this.tabLinks[newIndex].setAttribute('aria-selected', 'true');
117
117
  this.tabItems[newIndex].setAttribute('data-tab-active', '');
118
118
  this.tabLinks[newIndex].removeAttribute('tabindex');
119
- this.tabLinks[newIndex].focus();
119
+ this.tabLinks[newIndex].focus(); // Focus the newly selected tab
120
120
 
121
121
  // update tab panels
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
125
  // Update the browser's URL hash to reflect the current tab's ID
127
126
  var selectedTabId = this.tabLinks[newIndex].id;
128
- global.history.pushState(null, '', '#' + selectedTabId);
127
+
128
+ if (updateURLFromHash) {
129
+ window.history.pushState(null, '', '#' + selectedTabId);
130
+ }
129
131
 
130
132
  this.currentIndex = newIndex;
131
133
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetstiftelsen/styleguide",
3
- "version": "3.0.12",
3
+ "version": "3.0.14",
4
4
  "main": "dist/components.js",
5
5
  "ports": {
6
6
  "fractal": "3000"
@@ -45,6 +45,7 @@
45
45
 
46
46
  &:focus {
47
47
  outline: none;
48
+ box-shadow: none !important;
48
49
 
49
50
  & + output {
50
51
  background-color: $color-ocean-light;
@@ -44,7 +44,7 @@
44
44
  }
45
45
  }
46
46
 
47
- [role='presentation'] {
47
+ @include e(item) {
48
48
  display: flex;
49
49
  flex: 0 0 auto;
50
50
  padding: 0;
@@ -54,7 +54,7 @@
54
54
  }
55
55
  }
56
56
 
57
- [role='tab'] {
57
+ @include e(link) {
58
58
  @extend %normalize-links;
59
59
 
60
60
  display: inline-flex;
@@ -104,3 +104,33 @@
104
104
  }
105
105
  }
106
106
  }
107
+
108
+ .no-js {
109
+ @include organism(tab-list) {
110
+ padding: initial;
111
+ margin: initial;
112
+ list-style-type: disc;
113
+
114
+ @include plumber(
115
+ $leading-bottom: 3
116
+ );
117
+
118
+ @include e(item) {
119
+ display: list-item;
120
+ margin-top: rhythm(1);
121
+ margin-left: rhythm(4);
122
+ padding-top: rhythm(0.25);
123
+ padding-bottom: rhythm(0.25);
124
+ padding-top: 0;
125
+ padding-left: 0;
126
+ }
127
+
128
+ @include e(link) {
129
+ background-color: transparent;
130
+ padding: 0;
131
+ border-radius: 0;
132
+
133
+ @extend %link-styles;
134
+ }
135
+ }
136
+ }
@@ -22,6 +22,14 @@ $color-tab-highlight: $color-ruby !default;
22
22
  box-shadow: 0 0 0 2px inset $color-tab-highlight !important;
23
23
  }
24
24
  }
25
+
26
+ &::-webkit-slider-thumb {
27
+ box-shadow: 0 0 0 inset rgba($color-cyberspace, 0.2), 0 1px 2px rgba($color-cyberspace, 0.2), 0 0 0 3px inset $color-tab-highlight !important;
28
+ }
29
+
30
+ &::-moz-range-thumb {
31
+ box-shadow: 0 0 0 inset rgba($color-cyberspace, 0.2), 0 1px 2px rgba($color-cyberspace, 0.2), 0 0 0 3px inset $color-tab-highlight !important;
32
+ }
25
33
  }
26
34
 
27
35
  // Use when element is on dark background