@bonniernews/dn-design-system-web 2.1.0-alpha.3 → 2.1.0-alpha.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.1.0-alpha.4](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@2.1.0-alpha.3...@bonniernews/dn-design-system-web@2.1.0-alpha.4) (2023-02-20)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **web:** add element attributes to list items ([#676](https://github.com/BonnierNews/dn-design-system/issues/676)) ([5858f74](https://github.com/BonnierNews/dn-design-system/commit/5858f74d99d24bec38b4d404b4b4dcbfacfab9d1))
12
+
13
+
14
+
6
15
  ## [2.1.0-alpha.3](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@2.1.0-alpha.2...@bonniernews/dn-design-system-web@2.1.0-alpha.3) (2023-02-17)
7
16
 
8
17
 
@@ -280,7 +280,7 @@ $ds-btn__icon-size: 24px;
280
280
  .ds-btn--primary,
281
281
  .ds-btn--staticWhiteFilled {
282
282
  &:not(.ds-loading):disabled {
283
- opacity: 0.6; // @todo replace with opacity token if/when available
283
+ opacity: $ds-opacity-component-disabled;
284
284
  .ds-btn__inner {
285
285
  cursor: not-allowed;
286
286
  }
@@ -1,15 +1,12 @@
1
1
  {% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
2
2
  {% from '@bonniernews/dn-design-system-web/components/spinner/spinner.njk' import Spinner %}
3
+ {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
3
4
 
4
5
  {% macro ButtonToggle(params) %}
5
6
  {% set componentClassName = "ds-btn-toggle" %}
6
7
  {% set classNamePrefix = componentClassName + "--" %}
7
8
  {% set variant = [] %}
8
- {% set attributes %}
9
- {% for attribute, value in params.attributes %}
10
- {{attribute}}="{{value}}"
11
- {% endfor %}
12
- {% endset %}
9
+ {% set attributes = getAttributes(params.attributes) %}
13
10
 
14
11
  {% if params.selected %}
15
12
  {% set variant = (variant.push(classNamePrefix + "selected"), variant) %}
@@ -1,11 +1,5 @@
1
1
  @use "sass:math";
2
- @use "../../foundations/helpers/spacing.scss" as *;
3
- @use "../../foundations/helpers/typography.scss" as *;
4
- @use "../../foundations/helpers/mediaQueries.scss" as *;
5
- @use "../../foundations/helpers/metrics.scss" as *;
6
- @use "../../foundations/helpers/utilities.scss" as *;
7
- @use "../../foundations/helpers/colors.scss" as *;
8
- @use "../../foundations/helpers/loading.scss" as *;
2
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
9
3
  @use "../../foundations/icons/icon.scss" as *;
10
4
  @use "../spinner/spinner.scss" as *;
11
5
 
@@ -71,8 +65,10 @@ $ds-btn-toggle__icon-size-xsmall: 20px;
71
65
  }
72
66
  }
73
67
 
74
- &:hover:not(:disabled):not(.ds-loading) .ds-btn-toggle__inner::before {
75
- background-color: $ds-color-component-primary-overlay;
68
+ @include ds-hover() {
69
+ &:hover:not(:disabled):not(.ds-loading) .ds-btn-toggle__inner::before {
70
+ background-color: $ds-color-component-primary-overlay;
71
+ }
76
72
  }
77
73
  &:active:not(:disabled):not(.ds-loading) .ds-btn-toggle__inner::before {
78
74
  background-color: $ds-color-component-primary-overlay-02;
@@ -127,7 +123,7 @@ $ds-btn-toggle__icon-size-xsmall: 20px;
127
123
  }
128
124
  &:not(.ds-btn-toggle--selected) {
129
125
  &:not(.ds-loading):disabled {
130
- opacity: 0.6; // @todo replace with opacity token if/when available
126
+ opacity: $ds-opacity-component-disabled;
131
127
  .ds-btn-toggle__inner {
132
128
  cursor: not-allowed;
133
129
  }
@@ -1,10 +1,6 @@
1
- {% macro Footer(params) %}
2
- {% macro _getAttributes(attributes) %}
3
- {% for attribute, value in attributes %}
4
- {{attribute}}="{{value}}"
5
- {% endfor %}
6
- {% endmacro %}
1
+ {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
7
2
 
3
+ {% macro Footer(params) %}
8
4
  {% set componentClassName = "ds-footer" %}
9
5
  {% set classNamePrefix = componentClassName + "--" %}
10
6
  {% set variant = [] %}
@@ -23,11 +19,11 @@
23
19
  <div class="{{ componentClassName + '__inner'}}">
24
20
  <div class="{{ componentClassName + '__link-grid'}}">
25
21
  {% for group in params.linkGroups %}
26
- <div class="{{ componentClassName + '__link-group'}}" {{- _getAttributes(group.attributes) | safe }}>
22
+ <div class="{{ componentClassName + '__link-group'}}" {{- getAttributes(group.attributes) | safe }}>
27
23
  <h2>{{ group.title }}</h2>
28
24
  <ul>
29
25
  {% for link in group.links %}
30
- <li><a href="{{ link.href }}" class="ds-footer__link {{ link.classNames }}" {{- _getAttributes(link.attributes) | safe }}>{{ link.text }}</a></li>
26
+ <li><a href="{{ link.href }}" class="ds-footer__link {{ link.classNames }}" {{- getAttributes(link.attributes) | safe }}>{{ link.text }}</a></li>
31
27
  {% endfor %}
32
28
  </ul>
33
29
  </div>
@@ -51,11 +47,10 @@
51
47
  {% if params.channels %}
52
48
  <div class="{{ componentClassName + '__channels'}}">
53
49
  {% for link in params.channels %}
54
- <a href="{{ link.href }}" class="ds-footer__channel-link {{ link.classNames }}" {{- _getAttributes(link.attributes) | safe }}>{{ link.text }}</a>
50
+ <a href="{{ link.href }}" class="ds-footer__channel-link {{ link.classNames }}" {{- getAttributes(link.attributes) | safe }}>{{ link.text }}</a>
55
51
  {% endfor %}
56
52
  </div>
57
53
  {% endif %}
58
54
  </div>
59
55
  </footer>
60
56
  {% endmacro %}
61
-
@@ -18,6 +18,7 @@
18
18
  |disabled | bool | no | true, false | false | |
19
19
  |border | bool | no | true, false | false | |
20
20
  |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
21
+ |elementAttributes | Object | no | | | Sets attributes on actual checkbox element and not list item. Same structure as attributes above |
21
22
  |classNames | String | no | | | Ex. "my-special-class" |
22
23
  |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
23
24
 
@@ -19,6 +19,7 @@
19
19
  |disabled | bool | no | true, false | false | |
20
20
  |border | bool | no | true, false | false | |
21
21
  |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
22
+ |elementAttributes | Object | no | | | Sets attributes on actual radio element and not list item. Same structure as attributes above |
22
23
  |classNames | String | no | | | Ex. "my-special-class" |
23
24
  |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
24
25
 
@@ -18,6 +18,7 @@
18
18
  |border | bool | no | true, false | false | |
19
19
  |leadingIcon | String | no | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icon-web--all |
20
20
  |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
21
+ |elementAttributes | Object | no | | | Sets attributes on actual switch element and not list item. Same structure as attributes above |
21
22
  |classNames | String | no | | | Ex. "my-special-class" |
22
23
  |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
23
24
 
@@ -19,6 +19,7 @@
19
19
  |disabled | bool | no | true, false | false | |
20
20
  |border | bool | no | true, false | false | |
21
21
  |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
22
+ |elementAttributes | Object | no | | | Sets attributes on actual toggle element and not list item. Same structure as attributes above |
22
23
  |classNames | String | no | | | Ex. "my-special-class" |
23
24
  |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
24
25
 
@@ -34,7 +35,7 @@ These are copy paste friendly examples to quickliy get started using a component
34
35
  {{ ListItem({
35
36
  listItemType: 'toggle',
36
37
  title: 'My toggle list item',
37
- titleHref: '#',
38
+ titleHref: 'dn.se',
38
39
  toggleText: 'Följ',
39
40
  toggleSelectedText: 'Följer'
40
41
  })}}
@@ -3,6 +3,7 @@
3
3
  {% from '@bonniernews/dn-design-system-web/components/checkbox/checkbox.njk' import Checkbox %}
4
4
  {% from '@bonniernews/dn-design-system-web/components/radio-button/radio-button.njk' import RadioButton %}
5
5
  {% from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.njk' import ButtonToggle %}
6
+ {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
6
7
 
7
8
  {% macro ListItem(params) %}
8
9
  {% set componentClassName = "ds-list-item" %}
@@ -16,7 +17,7 @@
16
17
  {% if params.title %}
17
18
  <div class="{{ componentClassName + '__titles'}}">
18
19
  {% if params.titleHref and not params.disabled %}
19
- <a class="{{ componentClassName + '__title'}}" href="{{ params.href }}">{{ params.title }}</a>
20
+ <a class="{{ componentClassName + '__title'}}" href="{{ params.titleHref }}">{{ params.title }}</a>
20
21
  {% else %}
21
22
  <span class="{{ componentClassName + '__title'}}">{{ params.title }}</span>
22
23
  {% endif %}
@@ -43,11 +44,7 @@
43
44
  {% macro ListItemInner(params, componentClassName) %}
44
45
  {% set classNamePrefix = componentClassName + "--" %}
45
46
  {% set variant = [] %}
46
- {% set attributes %}
47
- {% for attribute, value in params.attributes %}
48
- {{attribute}}="{{value}}"
49
- {% endfor %}
50
- {% endset %}
47
+ {% set attributes = getAttributes(params.attributes) %}
51
48
 
52
49
  {% if params.forcePx %}
53
50
  {% set variant = (variant.push("ds-force-px"), variant) %}
@@ -101,7 +98,8 @@
101
98
  condensed: true,
102
99
  disabled: params.disabled,
103
100
  forcePx: params.forcePx,
104
- stripLabel: true
101
+ stripLabel: true,
102
+ attributes: params.elementAttributes
105
103
  })}}
106
104
  {% endset %}
107
105
  {{ caller() if caller }}
@@ -115,7 +113,7 @@
115
113
  condensed: true,
116
114
  disabled: params.disabled,
117
115
  forcePx: params.forcePx,
118
- buttons: [{ id: params.id, checked: params.selected }]
116
+ buttons: [{ id: params.id, checked: params.selected, attributes: params.elementAttributes }]
119
117
  })}}
120
118
  {% endset %}
121
119
  {{ caller() if caller }}
@@ -131,7 +129,8 @@
131
129
  condensed: true,
132
130
  disabled: params.disabled,
133
131
  forcePx: params.forcePx,
134
- stripLabel: true
132
+ stripLabel: true,
133
+ attributes: params.elementAttributes
135
134
  })}}
136
135
  {% endset %}
137
136
  {{ caller() if caller }}
@@ -158,7 +157,8 @@
158
157
  condensed: false,
159
158
  disabled: params.disabled,
160
159
  forcePx: params.forcePx,
161
- size: "xsmall"
160
+ size: "xsmall",
161
+ attributes: params.elementAttributes
162
162
  })}}
163
163
  {% endset %}
164
164
  {{ caller() if caller }}
@@ -210,8 +210,7 @@ $ds-list-item__padding: ds-spacing-component(x4);
210
210
 
211
211
  .ds-list-item--accordion .ds-checkbox__accordion,
212
212
  .ds-list-item--radio .ds-radio-btn__inner,
213
- .ds-list-item--checkbox .ds-checkbox__inner,
214
- .ds-list-item--switch .ds-switch__inner {
213
+ .ds-list-item--checkbox .ds-checkbox__inner {
215
214
  &::before {
216
215
  display: none;
217
216
  }
@@ -1,9 +1,4 @@
1
- @use "../../foundations/helpers/spacing.scss" as *;
2
- @use "../../foundations/helpers/typography.scss" as *;
3
- @use "../../foundations/helpers/mediaQueries.scss" as *;
4
- @use "../../foundations/helpers/metrics.scss" as *;
5
- @use "../../foundations/helpers/utilities.scss" as *;
6
- @use "../../foundations/helpers/colors.scss" as *;
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
7
2
 
8
3
  $ds-switch__knob-size: 16px;
9
4
  $ds-switch__knob-padding: 4px;
@@ -108,18 +103,30 @@ $ds-switch__container-width: 44px;
108
103
  outline-color: $ds-color-border-focus;
109
104
  }
110
105
  }
106
+ }
111
107
 
112
- &:hover {
113
- input:not(:disabled) + .ds-switch__box::before {
114
- background-color: $ds-color-component-primary-overlay;
115
- }
116
- }
117
- &:active {
118
- input:not(:disabled) + .ds-switch__box::before {
119
- background-color: $ds-color-component-primary-overlay-02;
120
- }
108
+ @include ds-hover() {
109
+ .ds-switch
110
+ input:not(:disabled)
111
+ + .ds-switch__inner:hover
112
+ .ds-switch__box::before,
113
+ .ds-list-item--switch:hover
114
+ input:not(:disabled)
115
+ + .ds-switch__inner
116
+ .ds-switch__box::before {
117
+ background-color: $ds-color-component-primary-overlay;
121
118
  }
122
119
  }
120
+ .ds-switch
121
+ input:not(:disabled)
122
+ + .ds-switch__inner:active
123
+ .ds-switch__box::before,
124
+ .ds-list-item--switch:active
125
+ input:not(:disabled)
126
+ + .ds-switch__inner
127
+ .ds-switch__box::before {
128
+ background-color: $ds-color-component-primary-overlay-02;
129
+ }
123
130
 
124
131
  .ds-switch--condensed .ds-switch__inner {
125
132
  padding: 0;
@@ -0,0 +1,5 @@
1
+ {% macro getAttributes(attributes) %}
2
+ {% for attribute, value in attributes %}
3
+ {{attribute}}="{{value}}"
4
+ {% endfor %}
5
+ {% endmacro %}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "2.1.0-alpha.3",
3
+ "version": "2.1.0-alpha.4",
4
4
  "description": "DN design system for web.",
5
5
  "main": "index.js",
6
6
  "homepage": "https://github.com/BonnierNews/dn-design-system/tree/main/web/src#readme",