@internetstiftelsen/styleguide 2.21.14 → 2.21.15

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.
@@ -50,4 +50,6 @@ require('./atoms/timeline/anchorScroll');
50
50
 
51
51
  require('./molecules/timeline-navigation/timeline-navigation');
52
52
 
53
- require('./molecules/context-menu/context-menu');
53
+ require('./molecules/context-menu/context-menu');
54
+
55
+ require('./molecules/alert/alert');
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var alerts = document.querySelectorAll('.js-dismiss-alert');
4
+
5
+ function dismiss(alert) {
6
+ var target = alert.querySelector('[data-a11y-toggle]');
7
+ var id = target.closest('[role]').getAttribute('id');
8
+ var idElement = document.getElementById(id);
9
+
10
+ if (sessionStorage.getItem(id) !== 'is-dismissed') {
11
+ window.addEventListener('DOMContentLoaded', function () {
12
+ idElement.setAttribute('aria-hidden', 'false');
13
+ });
14
+
15
+ target.addEventListener('click', function () {
16
+ sessionStorage.setItem(id, 'is-dismissed');
17
+ });
18
+ }
19
+ }
20
+
21
+ if (alerts) {
22
+ [].forEach.call(alerts, dismiss);
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetstiftelsen/styleguide",
3
- "version": "2.21.14",
3
+ "version": "2.21.15",
4
4
  "main": "dist/components.js",
5
5
  "ports": {
6
6
  "fractal": "3000"
@@ -10,15 +10,3 @@
10
10
  <h2 class="u-m-b-1">{{name}}</h2>
11
11
  <p>{{{text}}}</p>
12
12
  </div>
13
- <div{{#if role}} id="alert-2" role="{{role}}"{{/if}} class="m-alert m-alert--error{{#if is_dismissable}} m-alert--dismissable{{/if}}{{#if js_class}} {{js_class}}{{/if}}" {{#if is_dismissable}} aria-hidden="true"{{/if}}>
14
- {{#if is_dismissable}}
15
- <button class="a-button a-button--icon a-button--standalone-icon a-button--icon" data-a11y-toggle="alert-2">
16
- <span class="a-button__text">Stäng</span>
17
- <svg class="icon a-button__icon">
18
- <use xlink:href="#icon-close"></use>
19
- </svg>
20
- </button>
21
- {{/if}}
22
- <h2 class="u-m-b-1">{{name}}</h2>
23
- <p>{{{text}}}</p>
24
- </div>