@internetstiftelsen/styleguide 2.21.14-beta.0.9 → 2.21.16

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-beta.0.9",
3
+ "version": "2.21.16",
4
4
  "main": "dist/components.js",
5
5
  "ports": {
6
6
  "fractal": "3000"
@@ -1,12 +1,12 @@
1
1
  <{{getelement el "a"}}
2
- {{#if id}}id="{{id}}""{{/if}}
2
+ {{#if id}}id="{{id}}"{{/if}}
3
3
  {{#if button_type}}type="{{button_type}}"{{/if}}
4
4
  {{#if url}}href="{{ url }}"{{/if}}
5
5
  class="a-button{{#if modifiers}} {{getmodifiers modifiers "a-button"}}{{/if}}{{#if icon }} a-button--icon{{/if}}{{#if additional_classes}} {{ additional_classes}}{{/if}}"
6
6
  {{{attr attributes}}}
7
7
  {{#if aria_controls}}aria-controls="{{ aria_controls }}"{{/if}}
8
8
  >
9
- <span class="a-button__text"{{#if alternative_text}} data-alternative-text="{{alternative_text}}{{/if}}">{{ text }}</span>
9
+ <span class="a-button__text"{{#if alternative_text}} data-alternative-text="{{alternative_text}}"{{/if}}>{{ text }}</span>
10
10
  {{#if icon}}
11
11
  {{> @icon id=icon additional_classes="a-button__icon"}}
12
12
  {{/if}}
package/src/components.js CHANGED
@@ -24,3 +24,4 @@ import './molecules/glider/glider-single';
24
24
  import './atoms/timeline/anchorScroll';
25
25
  import './molecules/timeline-navigation/timeline-navigation';
26
26
  import './molecules/context-menu/context-menu';
27
+ import './molecules/alert/alert';
@@ -86,8 +86,7 @@ th a:not([class*='tag']) {
86
86
  }
87
87
 
88
88
  ul:not([class]),
89
- ol:not([class]),
90
- ul.checklist {
89
+ ol:not([class]) {
91
90
  li > a {
92
91
  @extend %break-long-links;
93
92
  @extend %link-styles;
@@ -70,7 +70,7 @@
70
70
  <div class="grid-18 grid-md-14">
71
71
  <ul class="checklist">
72
72
  <li>Lorem ipsum dolor sit amet</li>
73
- <li>Sed nisl justo, <a href="#">pharetra non scelerisque</a></li>
73
+ <li>Sed nisl justo, pharetra non scelerisque</li>
74
74
  <li> Vestibulum ullamcorper</li>
75
75
  <li>
76
76
  Nam vitae mauris blandit
@@ -45,6 +45,10 @@ $alert-text: $color-cyberspace;
45
45
  top: rhythm(1);
46
46
  right: rhythm(1);
47
47
  }
48
+
49
+ &[aria-hidden="true"] {
50
+ display: none;
51
+ }
48
52
  }
49
53
 
50
54
  // Alternate styles
@@ -38,7 +38,7 @@ module.exports = {
38
38
  name: 'dismissable',
39
39
  context: {
40
40
  name: 'Avfärda',
41
- type: 'success',
41
+ type: 'warning',
42
42
  role: 'alert',
43
43
  text: 'Meddelanderuta med som användaren kan välja att klicka bort.',
44
44
  js_class: 'js-dismiss-alert',
@@ -1,6 +1,11 @@
1
- <div{{#if role}} role="{{role}}"{{/if}} class="m-alert m-alert--{{type}}{{#if is_dismissable}} m-alert--dismissable{{/if}}{{#if js_class}} {{js_class}}{{/if}}">
1
+ <div{{#if role}} id="alert-1" role="{{role}}"{{/if}} class="m-alert m-alert--{{type}}{{#if is_dismissable}} m-alert--dismissable{{/if}}{{#if js_class}} {{js_class}}{{/if}}" {{#if is_dismissable}} aria-hidden="true"{{/if}}>
2
2
  {{#if is_dismissable}}
3
- {{> @button el="button" modifiers="icon, standalone-icon" icon="close"}}
3
+ <button class="a-button a-button--icon a-button--standalone-icon a-button--icon" data-a11y-toggle="alert-1">
4
+ <span class="a-button__text">Stäng</span>
5
+ <svg class="icon a-button__icon">
6
+ <use xlink:href="#icon-close"></use>
7
+ </svg>
8
+ </button>
4
9
  {{/if}}
5
10
  <h2 class="u-m-b-1">{{name}}</h2>
6
11
  <p>{{{text}}}</p>
@@ -0,0 +1,21 @@
1
+ const alerts = document.querySelectorAll('.js-dismiss-alert');
2
+
3
+ function dismiss(alert) {
4
+ const target = alert.querySelector('[data-a11y-toggle]');
5
+ const id = target.closest('[role]').getAttribute('id');
6
+ const idElement = document.getElementById(id);
7
+
8
+ if (sessionStorage.getItem(id) !== 'is-dismissed') {
9
+ window.addEventListener('DOMContentLoaded', () => {
10
+ idElement.setAttribute('aria-hidden', 'false');
11
+ });
12
+
13
+ target.addEventListener('click', () => {
14
+ sessionStorage.setItem(id, 'is-dismissed');
15
+ });
16
+ }
17
+ }
18
+
19
+ if (alerts) {
20
+ [].forEach.call(alerts, dismiss);
21
+ }
@@ -132,18 +132,21 @@
132
132
  position: relative;
133
133
 
134
134
  &::after {
135
- content: '';
136
- padding: rhythm(1);
135
+ content: 'Förstora bilden';
136
+ color: $color-snow;
137
+ padding: rhythm(1) rhythm(2) rhythm(1) rhythm(4);
137
138
  display: block;
138
139
  position: absolute;
139
140
  top: 0;
140
141
  left: 0;
141
- border-radius: $border-radius;
142
- width: $icon-size-large * 1.4;
142
+ border-top-left-radius: $border-radius;
143
+ border-bottom-right-radius: $border-radius;
144
+ width: auto;
145
+ line-height: 1;
143
146
  height: $icon-size-large * 1.4;
144
147
  background-color: rgba($color-cyberspace, 0.8);
145
148
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' id='icon-search' viewbox='0 0 32 32' width='32' height='32' fill='%23ffffff'%3E%3Cpath d='M24,21.8l8,8L29.9,32l-8-8c-5.9,4.6-14.3,3.6-19-2.2S-0.7,7.6,5.1,2.9S19.3-0.7,24,5.1C27.9,10,27.9,16.9,24,21.8L24,21.8z M13.4,23.9c5.8,0,10.5-4.7,10.5-10.5S19.2,3,13.4,3S3,7.7,3,13.4S7.7,23.9,13.4,23.9z'/%3E%3C/svg%3E");
146
- background-position: center center;
149
+ background-position: rhythm(1) center;
147
150
  background-size: $icon-size-medium $icon-size-medium;
148
151
  background-repeat: no-repeat;
149
152
 
@@ -181,9 +184,13 @@
181
184
  }
182
185
 
183
186
  figcaption {
187
+ max-width: rem(612px);
188
+ text-align: center;
184
189
  color: $color-snow;
185
- padding-left: rhythm(1);
186
- padding-right: rhythm(1);
190
+ padding-left: rhythm(2);
191
+ padding-right: rhythm(2);
192
+ margin-bottom: 0 !important;
193
+ padding-bottom: 0 !important;
187
194
  }
188
195
  }
189
196
  }