@bonniernews/dn-design-system-web 1.1.0-alpha.8 → 2.0.0-alpha.0

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/README.md +1 -1
  3. package/assets/form-field/form-field.scss +1 -0
  4. package/components/buddy-menu/buddy-menu.scss +3 -1
  5. package/components/button/button.scss +1 -0
  6. package/components/button-toggle/README.md +4 -2
  7. package/components/button-toggle/button-toggle.js +12 -2
  8. package/components/button-toggle/button-toggle.njk +14 -9
  9. package/components/button-toggle/button-toggle.scss +45 -2
  10. package/components/checkbox/checkbox.scss +1 -0
  11. package/components/icon-button/README.md +1 -1
  12. package/components/icon-button/icon-button.scss +35 -11
  13. package/components/icon-button-toggle/README.md +52 -0
  14. package/components/icon-button-toggle/icon-button-toggle.js +19 -0
  15. package/components/icon-button-toggle/icon-button-toggle.njk +63 -0
  16. package/components/icon-button-toggle/icon-button-toggle.scss +161 -0
  17. package/components/list-item/README-accordion.md +3 -3
  18. package/components/list-item/README-toggle.md +56 -0
  19. package/components/list-item/list-item.js +25 -10
  20. package/components/list-item/list-item.njk +25 -1
  21. package/components/list-item/list-item.scss +30 -9
  22. package/components/radio-button/radio-button.scss +1 -0
  23. package/components/spinner/README.md +1 -1
  24. package/components/spinner/spinner.scss +30 -0
  25. package/components/text-button/text-button.scss +1 -0
  26. package/components/text-button-toggle/README.md +3 -2
  27. package/components/text-button-toggle/text-button-toggle.js +12 -2
  28. package/components/text-button-toggle/text-button-toggle.scss +1 -0
  29. package/components/text-input/text-input.scss +1 -0
  30. package/foundations/colors.scss +0 -6
  31. package/foundations/helpers/forward.helpers.scss +12 -0
  32. package/foundations/helpers/hover.scss +13 -0
  33. package/foundations/helpers/links.scss +10 -0
  34. package/foundations/helpers/mediaQueries.scss +24 -9
  35. package/foundations/helpers/opacity.scss +1 -0
  36. package/foundations/helpers/shadows.scss +9 -14
  37. package/foundations/helpers/typography.scss +8 -0
  38. package/foundations/icons/icon-sprite.svg +1 -1
  39. package/foundations/icons/icon.njk +45 -0
  40. package/foundations/icons/icon.scss +1 -0
  41. package/foundations/icons/svg/campaign.svg +3 -0
  42. package/foundations/icons/svg/facebook.svg +3 -0
  43. package/foundations/icons/svg/feed.svg +3 -0
  44. package/foundations/icons/svg/filter_none.svg +3 -0
  45. package/foundations/icons/svg/info.svg +3 -0
  46. package/foundations/icons/svg/instagram.svg +3 -0
  47. package/foundations/icons/svg/play_arrow-filled.svg +3 -0
  48. package/foundations/icons/svg/play_arrow.svg +3 -0
  49. package/foundations/icons/svg/twitter.svg +3 -0
  50. package/foundations/variables/colorsCssVariables.scss +6 -1
  51. package/foundations/variables/colorsDnDarkTokens.scss +6 -0
  52. package/foundations/variables/colorsDnLightTokens.scss +6 -1
  53. package/foundations/variables/opacity.scss +1 -0
  54. package/foundations/variables/shadowsDnDarkTokens.scss +16 -0
  55. package/foundations/variables/shadowsDnLightTokens.scss +16 -0
  56. package/foundations/variables/shadowsTokensList.scss +2 -0
  57. package/foundations/variables/typographyTokensList.scss +3 -1
  58. package/foundations/variables/typographyTokensScreenLarge.scss +15 -1
  59. package/foundations/variables/typographyTokensScreenSmall.scss +14 -0
  60. package/package.json +1 -1
  61. package/tokens/colors-css-variables.json +6 -1
  62. package/tokens/shadows-css-variables.json +5 -0
  63. package/foundations/typography/typography.njk +0 -19
  64. package/foundations/typography/typography.scss +0 -15
package/CHANGELOG.md CHANGED
@@ -3,6 +3,182 @@
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.0.0-alpha.0 (2023-02-14)
7
+
8
+
9
+ ### ⚠ BREAKING CHANGES
10
+
11
+ * **foundations:** update tokens from Figma (#667)
12
+
13
+ ### Miscellaneous Chores
14
+
15
+ * **foundations:** update tokens from Figma ([#667](https://github.com/BonnierNews/dn-design-system/issues/667)) ([b15fac1](https://github.com/BonnierNews/dn-design-system/commit/b15fac100e22a073c3e018ba13d2390c18429177))
16
+
17
+
18
+
19
+ ## 1.1.0-alpha.27 (2023-02-14)
20
+
21
+ **Note:** Version bump only for package @bonniernews/dn-design-system-web
22
+
23
+
24
+
25
+
26
+
27
+ ## 1.1.0-alpha.26 (2023-02-13)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * **web:** add article-body variant to link helper ([#662](https://github.com/BonnierNews/dn-design-system/issues/662)) ([3378bbe](https://github.com/BonnierNews/dn-design-system/commit/3378bbeafffdea56228dc207b9940dcc4e4ffdd2))
33
+
34
+
35
+
36
+ ## 1.1.0-alpha.25 (2023-02-13)
37
+
38
+
39
+ ### Features
40
+
41
+ * **web:** topic variant of list item ([#650](https://github.com/BonnierNews/dn-design-system/issues/650)) ([45f2c02](https://github.com/BonnierNews/dn-design-system/commit/45f2c02f5745e30844caad3df0802195402c4676))
42
+
43
+
44
+
45
+ ## 1.1.0-alpha.24 (2023-02-10)
46
+
47
+ **Note:** Version bump only for package @bonniernews/dn-design-system-web
48
+
49
+
50
+
51
+
52
+
53
+ ## [1.1.0-alpha.23](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.22...@bonniernews/dn-design-system-web@1.1.0-alpha.23) (2023-02-08)
54
+
55
+ **Note:** Version bump only for package @bonniernews/dn-design-system-web
56
+
57
+
58
+
59
+
60
+
61
+ ## [1.1.0-alpha.22](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.21...@bonniernews/dn-design-system-web@1.1.0-alpha.22) (2023-02-08)
62
+
63
+ **Note:** Version bump only for package @bonniernews/dn-design-system-web
64
+
65
+
66
+
67
+
68
+
69
+ ## [1.1.0-alpha.21](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.20...@bonniernews/dn-design-system-web@1.1.0-alpha.21) (2023-02-07)
70
+
71
+
72
+ ### Features
73
+
74
+ * **web:** add on-media icon button variant ([#637](https://github.com/BonnierNews/dn-design-system/issues/637)) ([f556c6b](https://github.com/BonnierNews/dn-design-system/commit/f556c6bdd6496007aeaf688ebe09781113d6dc9e))
75
+
76
+
77
+
78
+ ## [1.1.0-alpha.20](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.19...@bonniernews/dn-design-system-web@1.1.0-alpha.20) (2023-02-07)
79
+
80
+
81
+ ### Features
82
+
83
+ * **web:** update toggle buttons and spinners ([#633](https://github.com/BonnierNews/dn-design-system/issues/633)) ([b20911d](https://github.com/BonnierNews/dn-design-system/commit/b20911db947901edff357a1c9fa470eaf294f11a))
84
+
85
+
86
+
87
+ ## 1.1.0-alpha.19 (2023-02-07)
88
+
89
+ **Note:** Version bump only for package @bonniernews/dn-design-system-web
90
+
91
+
92
+
93
+
94
+
95
+ ## [1.1.0-alpha.18](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.17...@bonniernews/dn-design-system-web@1.1.0-alpha.18) (2023-02-06)
96
+
97
+
98
+ ### Bug Fixes
99
+
100
+ * **web:** fix broken media query ([#638](https://github.com/BonnierNews/dn-design-system/issues/638)) ([85ff24c](https://github.com/BonnierNews/dn-design-system/commit/85ff24c5e6119133ded11ba86c2ee09cf1d25a47))
101
+
102
+
103
+
104
+ ## [1.1.0-alpha.17](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.16...@bonniernews/dn-design-system-web@1.1.0-alpha.17) (2023-02-06)
105
+
106
+
107
+ ### Features
108
+
109
+ * **web:** add support for textCase in typography tokens ([#636](https://github.com/BonnierNews/dn-design-system/issues/636)) ([e0b9327](https://github.com/BonnierNews/dn-design-system/commit/e0b93276dbd574ee0f7718b757ce6eb31c998425))
110
+
111
+
112
+
113
+ ## [1.1.0-alpha.16](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.15...@bonniernews/dn-design-system-web@1.1.0-alpha.16) (2023-02-03)
114
+
115
+
116
+ ### Bug Fixes
117
+
118
+ * **web:** remove excessive css from src package ([#632](https://github.com/BonnierNews/dn-design-system/issues/632)) ([c322bdb](https://github.com/BonnierNews/dn-design-system/commit/c322bdb7e764c5e619270bbabab9da25e96bb8ad))
119
+
120
+
121
+
122
+ ## [1.1.0-alpha.15](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.14...@bonniernews/dn-design-system-web@1.1.0-alpha.15) (2023-02-03)
123
+
124
+ **Note:** Version bump only for package @bonniernews/dn-design-system-web
125
+
126
+
127
+
128
+
129
+
130
+ ## [1.1.0-alpha.14](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.13...@bonniernews/dn-design-system-web@1.1.0-alpha.14) (2023-02-03)
131
+
132
+
133
+ ### Bug Fixes
134
+
135
+ * **web:** remove hover styling from list item on small devices ([#630](https://github.com/BonnierNews/dn-design-system/issues/630)) ([6a13dbd](https://github.com/BonnierNews/dn-design-system/commit/6a13dbd065dcf6ee430e46134b45385151e35c17))
136
+
137
+
138
+
139
+ ## 1.1.0-alpha.13 (2023-02-02)
140
+
141
+
142
+ ### Bug Fixes
143
+
144
+ * **web:** add opsz to prevent ios bug ([#628](https://github.com/BonnierNews/dn-design-system/issues/628)) ([0c206b6](https://github.com/BonnierNews/dn-design-system/commit/0c206b6c82ef85f8193d31be44e323ad15448bc2))
145
+
146
+
147
+
148
+ ## [1.1.0-alpha.12](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.11...@bonniernews/dn-design-system-web@1.1.0-alpha.12) (2023-02-01)
149
+
150
+ **Note:** Version bump only for package @bonniernews/dn-design-system-web
151
+
152
+
153
+
154
+
155
+
156
+ ## 1.1.0-alpha.11 (2023-02-01)
157
+
158
+
159
+ ### Bug Fixes
160
+
161
+ * **web:** add support for combined shadows ([#624](https://github.com/BonnierNews/dn-design-system/issues/624)) ([c5a9bb8](https://github.com/BonnierNews/dn-design-system/commit/c5a9bb8f2b9c156d2d39f984834ed9327e2950b5))
162
+
163
+
164
+
165
+ ## [1.1.0-alpha.10](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.9...@bonniernews/dn-design-system-web@1.1.0-alpha.10) (2023-02-01)
166
+
167
+ **Note:** Version bump only for package @bonniernews/dn-design-system-web
168
+
169
+
170
+
171
+
172
+
173
+ ## [1.1.0-alpha.9](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.8...@bonniernews/dn-design-system-web@1.1.0-alpha.9) (2023-01-31)
174
+
175
+
176
+ ### Bug Fixes
177
+
178
+ * **web:** always set width on icons ([#619](https://github.com/BonnierNews/dn-design-system/issues/619)) ([69f60b1](https://github.com/BonnierNews/dn-design-system/commit/69f60b152846fdffbe00207479e9ae0cc6e1d7d7))
179
+
180
+
181
+
6
182
  ## [1.1.0-alpha.8](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.1.0-alpha.7...@bonniernews/dn-design-system-web@1.1.0-alpha.8) (2023-01-30)
7
183
 
8
184
  **Note:** Version bump only for package @bonniernews/dn-design-system-web
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @bonniernews/dn-design-system-web
2
2
 
3
- Components and foundations of DN design system for web
3
+ Foundations, components and helpers of DN design system for web
4
4
 
5
5
  ## Useful links
6
6
 
@@ -3,6 +3,7 @@
3
3
  @use "../../foundations/helpers/utilities.scss" as *;
4
4
  @use "../../foundations/helpers/typography.scss" as *;
5
5
  @use "../../foundations/helpers/colors.scss" as *;
6
+ @use "../../foundations/icons/icon.scss" as *;
6
7
 
7
8
  $ds-form-field__error-icon-size: 20px;
8
9
 
@@ -5,6 +5,7 @@
5
5
  @use "../../foundations/helpers/utilities.scss" as *;
6
6
  @use "../../foundations/helpers/colors.scss" as *;
7
7
  @use "../../foundations/helpers/links.scss" as *;
8
+ @use "../../foundations/helpers/shadows.scss" as *;
8
9
  @use "../button/button.scss" as *;
9
10
  @use "../icon-button/icon-button.scss" as *;
10
11
  @use "../list-item/list-item.scss" as *;
@@ -32,7 +33,8 @@
32
33
  .ds-buddy-menu__inner {
33
34
  background-color: $ds-color-surface-elevated;
34
35
  border-radius: ds-metrics-border-radius(x2);
35
- box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.15);
36
+ box-shadow: ds-shadow-get-box-shadow($ds-shadow-drop-shadow-a),
37
+ ds-shadow-get-box-shadow($ds-shadow-drop-shadow-b);
36
38
  position: relative;
37
39
  z-index: 1;
38
40
  }
@@ -6,6 +6,7 @@
6
6
  @use "../../foundations/helpers/utilities.scss" as *;
7
7
  @use "../../foundations/helpers/colors.scss" as *;
8
8
  @use "../../foundations/helpers/loading.scss" as *;
9
+ @use "../../foundations/icons/icon.scss" as *;
9
10
  @use "../spinner/spinner.scss" as *;
10
11
 
11
12
  $ds-btn-outlined__border-width: ds-metrics-border-width(x1);
@@ -16,6 +16,7 @@
16
16
  |variant | String | no | brand, SecondaryFilled | brand | Design variant |
17
17
  |size| String | no | default, small | default | |
18
18
  |fullWidth | bool | no | true, false | false | Button will be full width on both desktop and mobile |
19
+ |condensed | bool | no | true, false | false | Condensed reduces spacing to a bare minimum, use with care since this might make touch target area smaller than recommended size |
19
20
  |mobile.fullWidth | bool | no | true, false | false | Ex mobile: { fullWidth: true } |
20
21
  |loading | bool | no | true, false | false | |
21
22
  |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
@@ -49,6 +50,7 @@ These are copy paste friendly examples to quickliy get started using a component
49
50
  ### Javascript
50
51
 
51
52
  ```javascript
52
- import textInput from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.js'
53
- DsButtonToggle();
53
+ import dsButtonToggle from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.js'
54
+ const toggleElements = Array.from(document.getElementsByClassName("ds-btn-toggle"));
55
+ dsButtonToggle(toggleElements);
54
56
  ```
@@ -1,5 +1,10 @@
1
- export function DsButtonToggle() {
2
- const toggleElements = Array.from(document.getElementsByClassName("ds-btn-toggle"));
1
+ export {
2
+ dsButtonToggle,
3
+ dsButtonToggleAll
4
+ };
5
+
6
+ function dsButtonToggle(toggleElements = []) {
7
+ if (!toggleElements.length) return;
3
8
  toggleElements.forEach((toggleEl) => {
4
9
  toggleEl.addEventListener("click", () => {
5
10
  if (toggleEl.classList.contains("ds-btn-toggle--disabled")) return;
@@ -7,3 +12,8 @@ export function DsButtonToggle() {
7
12
  });
8
13
  });
9
14
  }
15
+
16
+ function dsButtonToggleAll() {
17
+ const toggleElements = Array.from(document.getElementsByClassName("ds-btn-toggle"));
18
+ dsButtonToggle(toggleElements);
19
+ }
@@ -20,9 +20,10 @@
20
20
 
21
21
  {% set spinnerMap = { primary: "secondary", brand: "onBrand", business: "onBusiness" } %}
22
22
  {% set spinnerVariant = spinnerMap[buttonVariant] | default("primary") %}
23
+ {% set spinnerSize = "xsmall" if params.size == "xsmall" else "small" %}
23
24
 
24
25
  {% set loadingHtml %}
25
- {{ Spinner({ size: 'small', variant: spinnerVariant, forcePx: params.forcePx }) }}
26
+ {{ Spinner({ size: spinnerSize, variant: spinnerVariant, forcePx: params.forcePx }) }}
26
27
  {% endset %}
27
28
 
28
29
  {% if params.loading %}
@@ -41,6 +42,10 @@
41
42
  {% set variant = (variant.push(classNamePrefix + "full-width"), variant) %}
42
43
  {% endif %}
43
44
 
45
+ {% if params.condensed %}
46
+ {% set variant = (variant.push(classNamePrefix + "condensed"), variant) %}
47
+ {% endif %}
48
+
44
49
  {% if params.mobile and params.mobile.fullWidth %}
45
50
  {% set variant = (variant.push(classNamePrefix + "mobile-full-width"), variant) %}
46
51
  {% endif %}
@@ -51,13 +56,13 @@
51
56
 
52
57
  {% set classes = componentClassName + " " + variant | join(" ") %}
53
58
 
54
- <button type="button'" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe}}>
55
- <div class="{{ componentClassName + '__inner'}}">
56
- <div class="{{ componentClassName + '__off'}}"><span>{{ params.text }}</span></div>
57
- <div class="{{ componentClassName + '__on'}}">
58
- {{ Icon({ icon: "check" }) }} <span>{{ params.selectedText }}</span>
59
- </div>
60
- {{ loadingHtml | safe }}
59
+ <button type="button" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe}}>
60
+ <div class="{{ componentClassName + '__inner'}}">
61
+ <div class="{{ componentClassName + '__off'}}"><span>{{ params.text }}</span></div>
62
+ <div class="{{ componentClassName + '__on'}}">
63
+ {{ Icon({ icon: "check" }) }} <span>{{ params.selectedText }}</span>
61
64
  </div>
62
- </button>
65
+ {{ loadingHtml | safe }}
66
+ </div>
67
+ </button>
63
68
  {% endmacro %}
@@ -6,24 +6,31 @@
6
6
  @use "../../foundations/helpers/utilities.scss" as *;
7
7
  @use "../../foundations/helpers/colors.scss" as *;
8
8
  @use "../../foundations/helpers/loading.scss" as *;
9
+ @use "../../foundations/icons/icon.scss" as *;
9
10
  @use "../spinner/spinner.scss" as *;
10
11
 
11
12
  $ds-btn-toggle-outlined__border-width: ds-metrics-border-width(x1);
12
13
  $ds-btn-toggle__min-clickable-area: 48px;
13
14
  $ds-btn-toggle__icon-size: 24px;
15
+ $ds-btn-toggle__icon-size-xsmall: 20px;
14
16
 
15
17
  .ds-btn-toggle {
16
18
  cursor: pointer;
17
19
  background-color: transparent;
18
20
  border: none;
19
- min-width: $ds-btn-toggle__min-clickable-area;
20
- min-height: $ds-btn-toggle__min-clickable-area;
21
+ min-width: 0;
22
+ min-height: 0;
21
23
  display: inline-flex;
22
24
  align-items: center;
23
25
  justify-content: center;
24
26
  padding: 0;
25
27
  position: relative;
26
28
 
29
+ &:not(.ds-btn-toggle--condensed) {
30
+ min-width: $ds-btn-toggle__min-clickable-area;
31
+ min-height: $ds-btn-toggle__min-clickable-area;
32
+ }
33
+
27
34
  &:focus-visible {
28
35
  outline: none;
29
36
  .ds-btn-toggle__inner {
@@ -90,6 +97,16 @@ $ds-btn-toggle__icon-size: 24px;
90
97
  );
91
98
  }
92
99
 
100
+ .ds-btn-toggle--xsmall .ds-btn-toggle__inner {
101
+ @include ds-typography($ds-typography-detailstandard-button-small);
102
+ padding: ds-px-to-rem(
103
+ ds-spacing-component(x1) - $ds-btn-toggle-outlined__border-width
104
+ )
105
+ ds-px-to-rem(
106
+ ds-spacing-component(x3) - $ds-btn-toggle-outlined__border-width
107
+ );
108
+ }
109
+
93
110
  @include ds-mq-only-breakpoint(mobile) {
94
111
  .ds-btn-toggle--mobile-full-width {
95
112
  &,
@@ -178,6 +195,17 @@ $ds-btn-toggle__icon-size: 24px;
178
195
  );
179
196
  }
180
197
 
198
+ &.ds-btn-toggle--xsmall .ds-btn-toggle__inner {
199
+ padding-left: ds-px-to-rem(
200
+ ds-spacing-component(x2) - $ds-btn-toggle-outlined__border-width
201
+ );
202
+ .ds-icon {
203
+ height: ds-px-to-rem($ds-btn-toggle__icon-size-xsmall);
204
+ width: ds-px-to-rem($ds-btn-toggle__icon-size-xsmall);
205
+ margin: ds-spacing-component(0 x1 0 0, rem);
206
+ }
207
+ }
208
+
181
209
  &:focus-visible .ds-btn-toggle__inner {
182
210
  outline-color: $ds-color-border-focus-02;
183
211
  }
@@ -216,4 +244,19 @@ $ds-btn-toggle__icon-size: 24px;
216
244
  padding-left: ds-spacing-component(x4)-$ds-btn-toggle-outlined__border-width;
217
245
  }
218
246
  }
247
+ &.ds-btn-toggle--xsmall {
248
+ .ds-btn-toggle__inner {
249
+ @include ds-typography($ds-typography-detailstandard-button-small, true);
250
+ padding: ds-spacing-component(x1)-$ds-btn-toggle-outlined__border-width
251
+ ds-spacing-component(x3)-$ds-btn-toggle-outlined__border-width;
252
+ .ds-icon {
253
+ margin: ds-spacing-component(0 x1 0 0);
254
+ height: $ds-btn-toggle__icon-size-xsmall;
255
+ width: $ds-btn-toggle__icon-size-xsmall;
256
+ }
257
+ }
258
+ &.ds-btn-toggle--selected .ds-btn-toggle__inner {
259
+ padding-left: ds-spacing-component(x2)-$ds-btn-toggle-outlined__border-width;
260
+ }
261
+ }
219
262
  }
@@ -4,6 +4,7 @@
4
4
  @use "../../foundations/helpers/utilities.scss" as *;
5
5
  @use "../../foundations/helpers/colors.scss" as *;
6
6
  @use "../../assets/form-field/form-field.scss" as *;
7
+ @use "../../foundations/icons/icon.scss" as *;
7
8
 
8
9
  $ds-checkbox__icon-size: 24px;
9
10
 
@@ -1,5 +1,5 @@
1
1
  - GitHub: [BonnierNews/dn-design-system/../web/src/components/icon-button](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-button)
2
- - Storybook: [IconButton > Web](https://designsystem.dn.se/?path=/story/components-app-web-iconbutton-web)
2
+ - Storybook: [IconButton > Web](https://designsystem.dn.se/?path=/story/components-app-web-iconbutton-iconbutton-web)
3
3
 
4
4
  ----
5
5
 
@@ -1,10 +1,5 @@
1
- @use "../../foundations/helpers/spacing.scss" as *;
2
- @use "../../foundations/helpers/typography.scss" as *;
3
- @use "../../foundations/helpers/metrics.scss" as *;
4
- @use "../../foundations/helpers/utilities.scss" as *;
5
- @use "../../foundations/helpers/colors.scss" as *;
6
- @use "../../foundations/helpers/shadows.scss" as *;
7
- @use "../../foundations/helpers/loading.scss" as *;
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
2
+ @use "../../foundations/icons/icon.scss" as *;
8
3
  @use "../spinner/spinner.scss" as *;
9
4
 
10
5
  $ds-icon-btn__border-radius: 50%;
@@ -62,9 +57,10 @@ $ds-btn-outlined__border-width: ds-metrics-border-width(x1);
62
57
  }
63
58
  }
64
59
  }
65
-
66
- &:hover:not(.ds-loading) .ds-icon-btn__inner::before {
67
- background-color: $ds-color-component-primary-overlay;
60
+ @include ds-hover() {
61
+ &:hover:not(.ds-loading) .ds-icon-btn__inner::before {
62
+ background-color: $ds-color-component-primary-overlay;
63
+ }
68
64
  }
69
65
  &:active:not(.ds-loading) .ds-icon-btn__inner::before {
70
66
  background-color: $ds-color-component-primary-overlay-02;
@@ -125,7 +121,7 @@ $ds-btn-outlined__border-width: ds-metrics-border-width(x1);
125
121
 
126
122
  .ds-icon-btn--elevated {
127
123
  .ds-icon-btn__inner {
128
- @include ds-shadow-get-drop-shadow($ds-shadow-drop-shadow-02);
124
+ box-shadow: ds-shadow-get-box-shadow($ds-shadow-drop-shadow-02);
129
125
  background-color: $ds-color-component-secondary;
130
126
  border-color: $ds-color-border-primary-02;
131
127
  color: $ds-color-icon-primary;
@@ -134,3 +130,31 @@ $ds-btn-outlined__border-width: ds-metrics-border-width(x1);
134
130
  border-color: $ds-color-border-primary;
135
131
  }
136
132
  }
133
+
134
+ .ds-icon-btn--on-media {
135
+ .ds-icon-btn__inner {
136
+ background-color: $ds-color-static-transparent-black;
137
+ border-color: transparent;
138
+ color: $ds-color-static-white;
139
+ }
140
+ &:disabled .ds-icon-btn__inner {
141
+ border-color: $ds-color-border-primary;
142
+ }
143
+ @include ds-hover() {
144
+ &:hover:not(.ds-loading) .ds-icon-btn__inner::before {
145
+ background-color: $ds-color-static-transparent-white-10;
146
+ }
147
+ }
148
+ &:active:not(.ds-loading) .ds-icon-btn__inner::before {
149
+ background-color: $ds-color-static-transparent-white-10;
150
+ }
151
+ &:disabled:not(.ds-loading) .ds-icon-btn__inner {
152
+ color: $ds-color-static-white;
153
+ &::before {
154
+ background-color: transparent;
155
+ }
156
+ }
157
+ &:focus-visible .ds-icon-btn__inner {
158
+ outline-color: $ds-color-static-white;
159
+ }
160
+ }
@@ -0,0 +1,52 @@
1
+ - GitHub: [BonnierNews/dn-design-system/../web/src/components/icon-button-toggle](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-button-toggle)
2
+ - Storybook: [IconButton > Web](https://designsystem.dn.se/?path=/story/components-app-web-iconbutton-toggleiconbutton-web)
3
+
4
+ ----
5
+
6
+ # Icon button toggle
7
+
8
+ ## Parameters
9
+
10
+ |parameter | type | required | options | default | description |
11
+ |:--- | :--- | :--- | :--- | :--- | :--- |
12
+ |selected | bool | no | true, false | false | |
13
+ |iconName | String | yes | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icon-web--all |
14
+ |selectedIconName | String | yes | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icon-web--all |v
15
+ |disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
16
+ |variant | String | no | outlined, transparent | outlined | Design variant |
17
+ |size| String | no | default, small, large | default | |
18
+ |loading | bool | no | true, false | false | |
19
+ |a11y.visuallyHidden | Object | no | | | Ex. a11y: { visuallyHidden: "Dela på TikTok" } |
20
+ |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
21
+ |classNames | String | no | | | Ex. "my-special-class" |
22
+ |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
23
+
24
+ ## Minimum requirement example
25
+
26
+ ### Nunjucks
27
+
28
+ These are copy paste friendly examples to quickliy get started using a component.
29
+
30
+ ```html
31
+ {% from '@bonniernews/dn-design-system-web/components/icon-button-toggle/icon-button-toggle.njk' import IconButtonToggle %}
32
+
33
+ {{ IconButtonToggle({
34
+ variant: 'outlined',
35
+ size: 'default',
36
+ iconName: 'bookmarked',
37
+ selectedIconName: 'bookmark-fill'
38
+ })}}
39
+ ```
40
+
41
+ ### SCSS
42
+ ```scss
43
+ @use "@bonniernews/dn-design-system-web/components/icon-button-toggle/icon-button-toggle";
44
+ ```
45
+
46
+ ### Javascript
47
+
48
+ ```javascript
49
+ import dsIconButtonToggle from '@bonniernews/dn-design-system-web/components/icon-button-toggle/icon-button-toggle.js'
50
+ const toggleElements = Array.from(document.getElementsByClassName("ds-icon-btn-toggle"));
51
+ dsIconButtonToggle(toggleElements);
52
+ ```
@@ -0,0 +1,19 @@
1
+ export {
2
+ dsIconButtonToggle,
3
+ dsIconButtonToggleAll
4
+ };
5
+
6
+ function dsIconButtonToggle(toggleElements = []) {
7
+ if (!toggleElements.length) return;
8
+ toggleElements.forEach((toggleEl) => {
9
+ toggleEl.addEventListener("click", () => {
10
+ if (toggleEl.classList.contains("ds-icon-btn-toggle--disabled")) return;
11
+ toggleEl.classList.toggle("ds-icon-btn-toggle--selected");
12
+ });
13
+ });
14
+ }
15
+
16
+ function dsIconButtonToggleAll() {
17
+ const toggleElements = Array.from(document.getElementsByClassName("ds-icon-btn-toggle"));
18
+ dsIconButtonToggle(toggleElements);
19
+ }
@@ -0,0 +1,63 @@
1
+ {% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
2
+ {% from '@bonniernews/dn-design-system-web/foundations/a11y/visually-hidden.njk' import VisuallyHidden %}
3
+ {% from '@bonniernews/dn-design-system-web/components/spinner/spinner.njk' import Spinner %}
4
+
5
+ {% macro IconButtonToggle(params) %}
6
+ {% set componentClassName = "ds-icon-btn-toggle" %}
7
+ {% set classNamePrefix = componentClassName + "--" %}
8
+ {% set variant = [] %}
9
+ {% set attributes %}
10
+ {% for attribute, value in params.attributes %}
11
+ {{attribute}}="{{value}}"
12
+ {% endfor %}
13
+ {% endset %}
14
+
15
+ {% if params.selected %}
16
+ {% set variant = (variant.push(classNamePrefix + "selected"), variant) %}
17
+ {% endif %}
18
+
19
+ {% if params.forcePx %}
20
+ {% set variant = (variant.push("ds-force-px"), variant) %}
21
+ {% endif %}
22
+
23
+ {% if params.variant %}
24
+ {% set variant = (variant.push(classNamePrefix + params.variant), variant) %}
25
+ {% else %}
26
+ {% set variant = (variant.push(classNamePrefix + "outlined"), variant) %}
27
+ {% endif %}
28
+
29
+ {% if params.size and params.size != "default" %}
30
+ {% set variant = (variant.push(classNamePrefix + params.size), variant) %}
31
+ {% endif %}
32
+
33
+ {% set loadingHtml %}
34
+ {{ Spinner({ size: "small", variant: "primary", forcePx: params.forcePx }) }}
35
+ {% endset %}
36
+
37
+ {% if params.loading %}
38
+ {% set variant = (variant.push("ds-loading"), variant) %}
39
+ {% endif %}
40
+
41
+ {% if params.a11y and params.a11y.visuallyHidden %}
42
+ {% set visuallyHidden = VisuallyHidden({ text: params.a11y.visuallyHidden }) %}
43
+ {% endif %}
44
+
45
+ {% if params.classNames %}
46
+ {% set variant = (variant.push(params.classNames), variant) %}
47
+ {% endif%}
48
+
49
+ {% set classes = componentClassName + " " + variant | join(" ") %}
50
+
51
+ <button type="button" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe }}>
52
+ {{- visuallyHidden | safe if visuallyHidden -}}
53
+ <div class="{{ componentClassName + '__inner'}}">
54
+ <div class="{{ componentClassName + '__off'}}">
55
+ {{ Icon({ icon: params.iconName }) }}
56
+ </div>
57
+ <div class="{{ componentClassName + '__on'}}">
58
+ {{ Icon({ icon: params.selectedIconName }) }}
59
+ </div>
60
+ {{ loadingHtml | safe }}
61
+ </div>
62
+ </button>
63
+ {% endmacro %}