@internetstiftelsen/styleguide 4.1.0 → 4.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetstiftelsen/styleguide",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "main": "dist/components.js",
5
5
  "ports": {
6
6
  "fractal": "3000"
@@ -49,21 +49,26 @@ class CharCounter {
49
49
 
50
50
  if (this.min && count < this.min) {
51
51
  this.counterEl.textContent = `${count}/${this.min}`;
52
- this.counterEl.className = `color-ruby ${className('a-meta')}`;
52
+ this.counterEl.className = `backgrond-ruby-light ${className('a-meta')}`;
53
+ this.el.setAttribute('aria-invalid', 'true');
54
+ this.counterEl.closest('.field-group').classList.add('is-invalid');
53
55
 
54
56
  return;
55
57
  }
56
58
 
57
59
  if (this.max && count > this.max) {
58
60
  this.counterEl.textContent = `${count}/${this.max}`;
59
- this.counterEl.classList.remove('color-granit');
60
- this.counterEl.className = `color-ruby ${className('a-meta')}`;
61
+ this.counterEl.className = `background-ruby-light ${className('a-meta')}`;
62
+ this.el.setAttribute('aria-invalid', 'true');
63
+ this.counterEl.closest('.field-group').classList.add('is-invalid');
61
64
 
62
65
  return;
63
66
  }
64
67
 
65
68
  this.counterEl.textContent = `${count}/${this.max || this.min}`;
66
- this.counterEl.className = `color-jade ${className('a-meta')}`;
69
+ this.counterEl.className = `background-jade-light ${className('a-meta')}`;
70
+ this.el.removeAttribute('aria-invalid');
71
+ this.counterEl.closest('.field-group').classList.remove('is-invalid');
67
72
  }
68
73
 
69
74
  build() {
@@ -83,8 +88,8 @@ class CharCounter {
83
88
  this.el.style.paddingRight = '3.8333333333rem';
84
89
  }
85
90
 
86
- counter.className = `color-granit ${className('a-meta')}`;
87
- counter.style.cssText = 'position: absolute; top: 5px; right: 10px; z-index: 501;';
91
+ counter.className = `color-cyberspace ${className('a-meta')}`;
92
+ counter.style.cssText = 'position: absolute; top: .5rem; right: .5rem; z-index: 501;background-color: #ff9fb4; border-radius: 0.25rem; padding: .25rem; line-height: 1;margin: 0';
88
93
 
89
94
  wrapper.appendChild(counter);
90
95
 
@@ -6,10 +6,15 @@ function toggleTextOnClick(e) {
6
6
  const target = (el.dataset.toggleTarget) ? document.getElementById(el.dataset.toggleTarget) : el;
7
7
  const i = parseInt(el.dataset.iteration || 0, 10);
8
8
  const options = el.dataset.toggleText.split('|');
9
- const nextIteration = (i + 1) === options.length ? 0 : i + 1;
9
+ const nextIteration = (i + 1) === options.length ? 0 : i + 1;
10
+ const ariaPressed = el.getAttribute('aria-pressed');
10
11
 
11
12
  el.dataset.iteration = nextIteration;
12
13
  target.innerText = options[nextIteration];
14
+
15
+ if (ariaPressed) {
16
+ el.setAttribute('aria-pressed', ariaPressed === 'true' ? 'false' : 'true');
17
+ }
13
18
  }
14
19
 
15
20
  /* eslint-disable */
@@ -1,2 +1,2 @@
1
1
  # Toggle button
2
- This component uses the textToggle.js file located here: `/assets/js/`
2
+ This component uses the textToggle.js and iconToggle.js files located here: `/assets/js/`
@@ -3,7 +3,7 @@ module.exports = {
3
3
  default: 'Toggle text',
4
4
 
5
5
  context: {
6
- target_id: 'boo',
6
+ target_id: 'myToggleTarget',
7
7
  external_target: false,
8
8
  toggle_text: true,
9
9
  toggle_text_primary_value: 'Toggle text',
@@ -13,7 +13,7 @@ module.exports = {
13
13
  {
14
14
  name: 'External target',
15
15
  context: {
16
- target_id: 'boo',
16
+ target_id: 'myToggleTarget',
17
17
  external_target: true,
18
18
  toggle_text_primary_value: 'Toggle text',
19
19
  toggle_text_secondary_value: 'I am an external target',
@@ -24,7 +24,7 @@ module.exports = {
24
24
  {
25
25
  name: 'Toggle icon',
26
26
  context: {
27
- target_id: 'boo',
27
+ target_id: 'myToggleTarget',
28
28
  external_target: false,
29
29
  toggle_text_primary_value: 'Toggle icon',
30
30
  toggle_text: false,
@@ -34,12 +34,35 @@ module.exports = {
34
34
  {
35
35
  name: 'Toggle text and icon',
36
36
  context: {
37
- target_id: 'boo',
37
+ target_id: 'myToggleTarget',
38
38
  external_target: false,
39
39
  toggle_text_primary_value: 'Toggle text and icon ',
40
40
  toggle_text: true,
41
41
  toggle_icon: true,
42
42
  }
43
43
  },
44
+ {
45
+ name: 'Three text toggles',
46
+ context: {
47
+ target_id: 'myToggleTarget',
48
+ external_target: false,
49
+ toggle_text_primary_value: 'Toggle text 3 times',
50
+ toggle_text: true,
51
+ toggle_icon: false,
52
+ toggle_thrice: true,
53
+ aria_pressed: false,
54
+ }
55
+ },
56
+ {
57
+ name: 'Aria-pressed state',
58
+ context: {
59
+ target_id: 'myToggleTarget',
60
+ external_target: false,
61
+ toggle_text_primary_value: 'Toggle text and aria-pressed',
62
+ toggle_text: true,
63
+ toggle_icon: false,
64
+ aria_pressed: true,
65
+ }
66
+ },
44
67
  ]
45
68
  }