@internetstiftelsen/styleguide 3.0.11 → 3.0.12

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetstiftelsen/styleguide",
3
- "version": "3.0.11",
3
+ "version": "3.0.12",
4
4
  "main": "dist/components.js",
5
5
  "ports": {
6
6
  "fractal": "3000"
@@ -18,6 +18,10 @@
18
18
  @include m(discreet) {
19
19
  @extend %discreet;
20
20
  }
21
+ @include m(small) {
22
+ font-size: $size-medium;
23
+ padding: rhythm(0.5);
24
+ }
21
25
  }
22
26
 
23
27
  @include b(input-icon) {
@@ -6,6 +6,7 @@
6
6
  background: transparent;
7
7
  cursor: pointer;
8
8
  width: 100%;
9
+ position: relative;
9
10
 
10
11
  &::-webkit-slider-runnable-track {
11
12
  background-color: $color-concrete;
@@ -76,6 +77,12 @@
76
77
  box-shadow: 0 0 0 inset rgba($color-cyberspace, 0.2), 0 1px 2px rgba($color-cyberspace, 0.2), 0 0 0 3px $color-ocean-light;
77
78
  }
78
79
 
80
+ @include m(no-preview) {
81
+ & + output {
82
+ display: none;
83
+ }
84
+ }
85
+
79
86
  @include e(value){
80
87
  background-color: $color-concrete;
81
88
  padding: rhythm(0.5) rhythm(1);
@@ -102,3 +109,11 @@
102
109
  }
103
110
  }
104
111
 
112
+ @include atom(range-input) {
113
+ position: absolute;
114
+ top: 0;
115
+ right: 0;
116
+ z-index: 0;
117
+ width: rhythm(5);
118
+ }
119
+
@@ -41,5 +41,26 @@ module.exports = {
41
41
  step: '1',
42
42
  }
43
43
  },
44
+ {
45
+ name: 'Text input',
46
+ context: {
47
+ input: true,
48
+ value: '0',
49
+ min: '0',
50
+ max: '100',
51
+ step: '1',
52
+ }
53
+ },
54
+ {
55
+ name: 'No preview',
56
+ context: {
57
+ no_preview: true,
58
+ input: true,
59
+ value: '0',
60
+ min: '0',
61
+ max: '100',
62
+ step: '1',
63
+ }
64
+ }
44
65
  ]
45
66
  }
@@ -1,11 +1,15 @@
1
1
  const ranges = document.querySelectorAll('.js-range-wrapper');
2
- function setValue(range, rangeValue) {
2
+ function setValue(range, rangeValue, rangeInput) {
3
3
  const val = range.value;
4
4
  const min = range.min ? range.min : 0;
5
5
  const max = range.max ? range.max : 100;
6
6
  const newVal = Number(((val - min) * 100) / (max - min));
7
7
  rangeValue.innerHTML = val;
8
8
 
9
+ if (rangeInput) {
10
+ rangeInput.value = val;
11
+ }
12
+
9
13
  // Sorta magic numbers based on size of the native UI thumb
10
14
  rangeValue.style.left = `calc(${newVal}% + (${8 - newVal * 0.15}px))`;
11
15
  }
@@ -13,11 +17,23 @@ function setValue(range, rangeValue) {
13
17
  ranges.forEach((wrap) => {
14
18
  const range = wrap.querySelector('.js-range');
15
19
  const rangeValue = wrap.querySelector('.js-range-value');
20
+ const rangeInput = wrap.querySelector('.js-range-input');
16
21
 
17
22
  range.addEventListener('input', () => {
18
- setValue(range, rangeValue);
23
+ setValue(range, rangeValue, rangeInput);
19
24
  range.focus();
20
25
  });
21
26
 
22
- setValue(range, rangeValue);
27
+ if (rangeInput) {
28
+ rangeInput.addEventListener('input', () => {
29
+ if (rangeInput.value !== '') {
30
+ range.value = rangeInput.value;
31
+ rangeValue.innerHTML = rangeInput.value;
32
+ setValue(range, rangeValue, rangeInput);
33
+ }
34
+ rangeInput.focus();
35
+ });
36
+ }
37
+
38
+ setValue(range, rangeValue, rangeInput);
23
39
  });
@@ -2,7 +2,11 @@ window.a11yTabs = (function tabsComponentIIFE(global, document) {
2
2
  const tabInstances = new WeakMap();
3
3
  const className = 'o-tab-list';
4
4
  const tablistElement = document.querySelector(`.js-${className}`);
5
- const updateURLFromHash = tablistElement.getAttribute('data-update-url');
5
+ let updateURLFromHash;
6
+
7
+ if (tablistElement) {
8
+ updateURLFromHash = tablistElement.getAttribute('data-update-url');
9
+ }
6
10
 
7
11
  /**
8
12
  * Instantiates the component