@bonniernews/dn-design-system-web 3.0.0-alpha.9 → 3.0.0-alpha.90

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 (128) hide show
  1. package/CHANGELOG.md +720 -0
  2. package/assets/article-image/article-image.njk +11 -10
  3. package/assets/article-image/article-image.scss +1 -15
  4. package/assets/form-field/form-field.njk +2 -2
  5. package/assets/form-field/form-field.scss +2 -6
  6. package/assets/teaser/dot-or-grade.njk +7 -0
  7. package/assets/teaser/teaser.scss +96 -0
  8. package/components/article-body-image/README.md +2 -2
  9. package/components/article-body-image/article-body-image.njk +1 -5
  10. package/components/article-top-image/README.md +2 -2
  11. package/components/article-top-image/article-top-image.njk +1 -5
  12. package/components/article-top-image/article-top-image.scss +1 -1
  13. package/components/badge/badge.scss +1 -5
  14. package/components/buddy-menu/buddy-menu.scss +1 -8
  15. package/components/button/button.njk +38 -43
  16. package/components/button/button.scss +6 -1
  17. package/components/button-toggle/button-toggle.js +2 -0
  18. package/components/button-toggle/button-toggle.njk +36 -36
  19. package/components/button-toggle/button-toggle.scss +6 -1
  20. package/components/byline/byline.njk +2 -2
  21. package/components/byline/byline.scss +1 -3
  22. package/components/checkbox/checkbox.njk +3 -3
  23. package/components/checkbox/checkbox.scss +8 -9
  24. package/components/disclaimer/disclaimer.njk +2 -2
  25. package/components/disclaimer/disclaimer.scss +23 -10
  26. package/components/factbox/README.md +2 -2
  27. package/components/factbox/factbox.njk +12 -24
  28. package/components/factbox/factbox.scss +16 -51
  29. package/components/footer/footer.scss +2 -8
  30. package/components/icon-button/README.md +2 -1
  31. package/components/icon-button/icon-button.njk +4 -4
  32. package/components/icon-button/icon-button.scss +5 -2
  33. package/components/icon-button-toggle/icon-button-toggle.js +2 -0
  34. package/components/icon-button-toggle/icon-button-toggle.njk +28 -36
  35. package/components/icon-button-toggle/icon-button-toggle.scss +5 -2
  36. package/components/icon-sprite/README.md +51 -0
  37. package/components/icon-sprite/icon-sprite.njk +12 -0
  38. package/components/icon-sprite/icon-sprite.scss +12 -0
  39. package/components/icon-with-wrapper/README.md +9 -2
  40. package/components/icon-with-wrapper/icon-with-wrapper.njk +2 -2
  41. package/components/icon-with-wrapper/icon-with-wrapper.scss +2 -1
  42. package/components/image-caption/README.md +38 -0
  43. package/components/image-caption/image-caption.njk +36 -0
  44. package/components/image-caption/image-caption.scss +25 -0
  45. package/components/list-item/list-item.njk +5 -5
  46. package/components/list-item/list-item.scss +1 -3
  47. package/components/pictogram/README.md +39 -0
  48. package/components/pictogram/pictogram.njk +30 -0
  49. package/components/pictogram/pictogram.scss +54 -0
  50. package/components/quote/README.md +1 -2
  51. package/components/quote/quote.njk +6 -8
  52. package/components/quote/quote.scss +1 -14
  53. package/components/radio-button/radio-button.njk +3 -3
  54. package/components/radio-button/radio-button.scss +8 -10
  55. package/components/spinner/spinner.njk +19 -23
  56. package/components/spinner/spinner.scss +4 -1
  57. package/components/teaser-dot/README.md +34 -0
  58. package/components/teaser-dot/teaser-dot.njk +24 -0
  59. package/components/teaser-dot/teaser-dot.scss +39 -0
  60. package/components/teaser-image/README.md +40 -0
  61. package/components/teaser-image/teaser-image.njk +21 -0
  62. package/components/teaser-image/teaser-image.scss +21 -0
  63. package/components/teaser-large/README.md +52 -0
  64. package/components/teaser-large/teaser-large.njk +96 -0
  65. package/components/teaser-large/teaser-large.scss +139 -0
  66. package/components/teaser-onsite/README.md +45 -0
  67. package/components/teaser-onsite/teaser-onsite.njk +45 -0
  68. package/components/teaser-onsite/teaser-onsite.scss +33 -0
  69. package/components/teaser-package/README.md +42 -0
  70. package/components/teaser-package/teaser-package.njk +39 -0
  71. package/components/teaser-package/teaser-package.scss +114 -0
  72. package/components/teaser-right-now/README.md +37 -0
  73. package/components/teaser-right-now/teaser-right-now.njk +29 -0
  74. package/components/teaser-right-now/teaser-right-now.scss +57 -0
  75. package/components/teaser-slideshow/README.md +42 -0
  76. package/components/teaser-slideshow/teaser-slideshow.njk +38 -0
  77. package/components/teaser-slideshow/teaser-slideshow.scss +37 -0
  78. package/components/teaser-split/README-container.md +40 -0
  79. package/components/teaser-split/README.md +49 -0
  80. package/components/teaser-split/teaser-split.njk +93 -0
  81. package/components/teaser-split/teaser-split.scss +85 -0
  82. package/components/teaser-standard/README.md +50 -0
  83. package/components/teaser-standard/teaser-standard.njk +81 -0
  84. package/components/teaser-standard/teaser-standard.scss +38 -0
  85. package/components/teaser-tipsa/README.md +41 -0
  86. package/components/teaser-tipsa/teaser-tipsa.njk +31 -0
  87. package/components/teaser-tipsa/teaser-tipsa.scss +22 -0
  88. package/components/text-button/text-button.njk +34 -37
  89. package/components/text-button/text-button.scss +12 -10
  90. package/components/text-button-toggle/text-button-toggle.js +2 -0
  91. package/components/text-button-toggle/text-button-toggle.njk +30 -33
  92. package/components/text-button-toggle/text-button-toggle.scss +10 -10
  93. package/components/text-input/text-input.scss +3 -8
  94. package/components/video-caption/README.md +1 -1
  95. package/components/video-caption/video-caption.njk +12 -6
  96. package/components/vip-badge/README.md +35 -0
  97. package/components/vip-badge/vip-badge.njk +23 -0
  98. package/components/vip-badge/vip-badge.scss +54 -0
  99. package/foundations/colors.scss +31 -0
  100. package/foundations/helpers/README-links.md +1 -1
  101. package/foundations/helpers/colors.scss +2 -0
  102. package/foundations/helpers/hover.scss +14 -0
  103. package/foundations/helpers/links.scss +15 -7
  104. package/foundations/helpers/typography.scss +22 -2
  105. package/foundations/icons/grade-icon.njk +50 -11
  106. package/foundations/icons/icon.njk +172 -143
  107. package/foundations/icons/sprite.njk +1 -0
  108. package/foundations/icons/sprite.svg +1 -0
  109. package/foundations/icons/svg/download.svg +3 -0
  110. package/foundations/icons/svg/filter_list.svg +3 -0
  111. package/foundations/icons/svg/pause.svg +3 -0
  112. package/foundations/icons/svg/system_update.svg +3 -0
  113. package/foundations/icons/svg/vip.svg +3 -0
  114. package/foundations/typography/fontDefinitions.scss +82 -67
  115. package/foundations/variables/colorsCssVariables.scss +6 -0
  116. package/foundations/variables/colorsDnDarkTokens.scss +7 -1
  117. package/foundations/variables/colorsDnLightTokens.scss +8 -2
  118. package/foundations/variables/spacingLayout.scss +6 -1
  119. package/foundations/variables/spacingLayoutLargeScreen.scss +5 -0
  120. package/foundations/variables/spacingLayoutList.scss +5 -0
  121. package/foundations/variables/typographyTokensList.scss +5 -0
  122. package/foundations/variables/typographyTokensScreenExtraLarge.scss +571 -0
  123. package/foundations/variables/typographyTokensScreenLarge.scss +133 -100
  124. package/foundations/variables/typographyTokensScreenSmall.scss +147 -114
  125. package/package.json +2 -2
  126. package/tokens/colors-css-variables.json +6 -0
  127. package/tokens/spacing-layout-list.json +6 -1
  128. package/foundations/icons/icon-sprite.svg +0 -2
@@ -1,10 +1,6 @@
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 *;
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
6
2
  @use "../../assets/form-field/form-field.scss" as *;
7
- @use "../../foundations/icons/icon.scss" as *;
3
+ @use "../icon-sprite/icon-sprite.scss";
8
4
 
9
5
  $ds-checkbox__icon-size: 24px;
10
6
 
@@ -85,9 +81,12 @@ $ds-checkbox__icon-size: 24px;
85
81
  }
86
82
  }
87
83
 
88
- &:hover,
89
- &:active {
90
- .ds-checkbox__inner::before {
84
+ &:active .ds-checkbox__inner::before {
85
+ background-color: $ds-color-component-primary-overlay;
86
+ }
87
+
88
+ @include ds-hover() {
89
+ &:hover .ds-checkbox__inner::before {
91
90
  background-color: $ds-color-component-primary-overlay;
92
91
  }
93
92
  }
@@ -1,4 +1,4 @@
1
- {% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
1
+ {% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
2
2
  {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
3
3
 
4
4
  {% macro Disclaimer(params) %}
@@ -16,7 +16,7 @@
16
16
  {% endif %}
17
17
 
18
18
  {% if params.iconName %}
19
- {% set iconSvg = Icon({ icon: params.iconName }) %}
19
+ {% set iconSvg = IconUse({ icon: params.iconName }) %}
20
20
  {% set additionalClasses = (additionalClasses.push(classNamePrefix + "with-icon"), additionalClasses) %}
21
21
  {% endif %}
22
22
 
@@ -1,28 +1,29 @@
1
1
  @use "../../foundations/helpers/forward.helpers.scss" as *;
2
- @use "../../foundations/icons/icon.scss" as *;
2
+ @use "../icon-sprite/icon-sprite.scss";
3
3
 
4
4
  $ds-disclaimer__icon-size: 20px;
5
5
  $ds-btn-outlined__border-width: ds-metrics-border-width(x1);
6
6
 
7
7
  .ds-disclaimer {
8
- padding: ds-spacing-component($ds-sc-x3 $ds-sc-x4);
9
- margin-bottom: ds-spacing-component($ds-sc-x4);
10
- background-color: $ds-color-surface-raised;
8
+ @include ds-spacing-layout($ds-sl-gap-vertical-static-medium, padding-bottom);
11
9
  box-sizing: border-box;
12
10
 
13
- &--with-icon {
14
- display: flex;
15
- flex-direction: row;
11
+ .ds-disclaimer__body-html,
12
+ .ds-disclaimer__icon-wrapper {
13
+ background-color: $ds-color-surface-raised;
14
+ padding: ds-spacing-component($ds-sc-x3 $ds-sc-x4);
16
15
  }
17
16
 
18
17
  .ds-disclaimer__icon-wrapper {
19
- margin-right: ds-spacing-component($ds-sc-x2);
18
+ // instead of margin to keep background color
19
+ padding-right: ds-spacing-component($ds-sc-x2);
20
20
  }
21
21
 
22
22
  .ds-disclaimer__body-html {
23
23
  @include ds-typography($ds-typography-functional-body01regular);
24
24
  margin: 0;
25
25
  color: $ds-color-text-primary-02;
26
+ flex-grow: 1;
26
27
 
27
28
  @at-root .ds-force-px#{&} {
28
29
  @include ds-typography($ds-typography-functional-body01regular, true);
@@ -57,8 +58,20 @@ $ds-btn-outlined__border-width: ds-metrics-border-width(x1);
57
58
  }
58
59
  }
59
60
 
60
- &--native {
61
- background-color: $ds-color-static-ad-yellow;
61
+ &.ds-disclaimer--with-icon {
62
+ display: flex;
63
+ flex-direction: row;
64
+
65
+ .ds-disclaimer__body-html {
66
+ padding-left: 0;
67
+ }
68
+ }
69
+
70
+ &.ds-disclaimer--native {
71
+ .ds-disclaimer__body-html,
72
+ .ds-disclaimer__icon-wrapper {
73
+ background-color: $ds-color-static-ad-yellow;
74
+ }
62
75
 
63
76
  .ds-icon,
64
77
  .ds-disclaimer__body-html,
@@ -13,7 +13,7 @@
13
13
  |vignetteHtml | HTML String | no | | | |
14
14
  |titleHtml | HTML String | yes | | | |
15
15
  |bodyHtml | HTML String | yes | | | |
16
- |variant | String | yes | standard, culture, sport, economy | standard | Design variant |
16
+ |theme | String | no | default, kultur, nyheter, sport, ekonomi | | Design theme |
17
17
  |grade | String | no | | | zero, one, two, three, four, five, none |
18
18
  |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
19
19
  |classNames | String | no | | | Ex. "my-special-class" |
@@ -33,7 +33,7 @@ These are copy paste friendly examples to quickliy get started using a component
33
33
  vignetteHtml: "",
34
34
  titleHtml: "Drama",
35
35
  bodyHtml: "<p>”Irrational man”<br />Regi och manus: Woody Allen<br />I rollerna: Joaquin Phoenix, Emma Stone, Parker Posey m fl.<br />Längd: 1 tim 35 min (från 11 år.)</p>",
36
- variant: "culture",
36
+ theme: "kultur",
37
37
  grade: "two",
38
38
  forcePx: true
39
39
  })}}
@@ -1,35 +1,31 @@
1
- {% from '@bonniernews/dn-design-system-web/foundations/icons/grade-icon.njk' import GradeIcon %}
1
+ {% from '@bonniernews/dn-design-system-web/foundations/icons/grade-icon.njk' import GetGrade %}
2
2
  {% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
3
3
  {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
4
4
 
5
5
  {% macro Factbox(params) %}
6
6
  {% set componentClassName = "ds-factbox" %}
7
7
  {% set classNamePrefix = componentClassName + "--" %}
8
- {% set variant = [] %}
9
- {% set grades = ["zero", "one", "two", "three", "four", "five"] %}
10
- {% set gradesNumeric = ["0", "1", "2", "3", "4", "5"] %}
11
- {% set activeGrade = params.grade | default("") | string %}
8
+ {% set additionalClasses = [] %}
9
+ {% set grade = params.grade | default("") | string %}
12
10
  {% set attributes = getAttributes(params.attributes) %}
13
11
 
14
- {% if params.variant %}
15
- {% set variant = (variant.push(classNamePrefix + params.variant), variant) %}
16
- {% else %}
17
- {% set variant = (variant.push(classNamePrefix + "standard"), variant) %}
12
+ {% if params.theme %}
13
+ {% set additionalClasses = (additionalClasses.push('ds-theme--' + params.theme), additionalClasses) %}
18
14
  {% endif %}
19
15
 
20
16
  {% if params.forcePx %}
21
- {% set variant = (variant.push("ds-force-px"), variant) %}
17
+ {% set additionalClasses = (additionalClasses.push("ds-force-px"), additionalClasses) %}
22
18
  {% endif %}
23
19
 
24
20
  {% if params.forceExpand %}
25
- {% set variant = (variant.push(classNamePrefix + "expanded"), variant) %}
21
+ {% set additionalClasses = (additionalClasses.push(classNamePrefix + "expanded"), additionalClasses) %}
26
22
  {% endif %}
27
23
 
28
24
  {% if params.classNames %}
29
- {% set variant = (variant.push(params.classNames), variant) %}
25
+ {% set additionalClasses = (additionalClasses.push(params.classNames), additionalClasses) %}
30
26
  {% endif%}
31
27
 
32
- {% set classes = componentClassName + " " + variant | join(" ") %}
28
+ {% set classes = componentClassName + " " + additionalClasses | join(" ") %}
33
29
 
34
30
  <div class="{{ classes }}" {{- attributes | safe }}>
35
31
  <div class="{{ componentClassName + '__inner'}}">
@@ -38,15 +34,7 @@
38
34
  {%- if params.vignetteHtml %}<span class="{{ componentClassName + '__vignette'}}">{{ params.vignetteHtml | safe }}</span>{%- endif %}
39
35
  {{- params.titleHtml | safe -}}
40
36
  </h2>
41
- {% if activeGrade and activeGrade in grades %}
42
- {% for grade in grades %}
43
- {% if grade == activeGrade %}
44
- {% set gradeTitle = "Betyg: " + gradesNumeric[loop.index0] + "." %}
45
- {% set gradeDesc = "Betygsskala: " + gradesNumeric | first + " till " + gradesNumeric | last + "." %}
46
- <div class="{{ componentClassName + '__grade'}}">{{- GradeIcon({ icon: activeGrade, title: gradeTitle, desc: gradeDesc }) | safe }}</div>
47
- {% endif %}
48
- {% endfor %}
49
- {% endif%}
37
+ {{ GetGrade({ grade: grade, type: "scale" }) if grade }}
50
38
  <div class="{{ componentClassName + '__body'}}">{{ params.bodyHtml | safe }}</div>
51
39
  </div>
52
40
  <div class="{{ componentClassName + '__show-more'}}">
@@ -57,7 +45,7 @@
57
45
  iconPosition: 'right',
58
46
  iconName: 'expand_more',
59
47
  classNames: 'ds-factbox__expand-more',
60
- fullWidth: true,
48
+ mobile: { fullWidth: true },
61
49
  forcePx: params.forcePx,
62
50
  condensed: true
63
51
  })}}
@@ -68,7 +56,7 @@
68
56
  iconPosition: 'right',
69
57
  iconName: 'expand_less',
70
58
  classNames: 'ds-factbox__expand-less',
71
- fullWidth: true,
59
+ mobile: { fullWidth: true },
72
60
  forcePx: params.forcePx,
73
61
  condensed: true
74
62
  })}}
@@ -1,11 +1,12 @@
1
1
  @use "../../foundations/helpers/forward.helpers.scss" as *;
2
2
  @use "../button/button.scss" as *;
3
3
 
4
- $ds-factbox__grade-size: 40px + (ds-metrics-border-width(x2) * 2);
4
+ $ds-factbox__grade-size: 40px;
5
5
  $ds-factbox__show-more-fade-height: 48px;
6
6
  $ds-factbox__padding: ds-spacing-component($ds-sc-x4);
7
7
  /* stylelint-disable-next-line */
8
- $ds-factbox__padding-left: $ds-factbox__padding - ds-metrics-border-width(x2);
8
+ $ds-factbox-border-width: 4px;
9
+ $ds-factbox__padding-left: $ds-factbox__padding - $ds-factbox-border-width;
9
10
  $ds-factbox__max-height: 500px; // includes top/bottom spacing
10
11
 
11
12
  .ds-factbox {
@@ -18,7 +19,7 @@ $ds-factbox__max-height: 500px; // includes top/bottom spacing
18
19
 
19
20
  .ds-factbox__inner {
20
21
  border-top: ds-metrics-border-width(x1) solid $ds-color-border-primary;
21
- border-left: ds-metrics-border-width(x2) solid $ds-color-component-brand;
22
+ border-left: $ds-factbox-border-width solid $ds-theme-color;
22
23
  max-height: ds-px-to-rem($ds-factbox__max-height);
23
24
  overflow: hidden;
24
25
  position: relative;
@@ -72,27 +73,24 @@ $ds-factbox__max-height: 500px; // includes top/bottom spacing
72
73
  }
73
74
  }
74
75
  .ds-factbox__vignette {
75
- color: $ds-color-component-brand;
76
+ color: $ds-theme-color;
76
77
  margin-right: ds-spacing-component($ds-sc-x1);
77
78
  }
78
- .ds-factbox__grade {
79
+ .ds-icon--grade {
79
80
  color: $ds-color-icon-primary;
80
81
  margin: 0 0 ds-spacing-component($ds-sc-x4);
81
-
82
- .ds-icon {
83
- display: block;
84
- height: ds-px-to-rem($ds-factbox__grade-size);
85
- svg {
86
- height: 100%;
87
- width: auto;
88
- circle {
89
- stroke: currentColor;
90
- }
91
- }
92
- @at-root .ds-force-px#{&} {
93
- height: $ds-factbox__grade-size;
82
+ display: block;
83
+ height: ds-px-to-rem($ds-factbox__grade-size);
84
+ svg {
85
+ height: 100%;
86
+ width: auto;
87
+ circle {
88
+ stroke: currentColor;
94
89
  }
95
90
  }
91
+ @at-root .ds-force-px#{&} {
92
+ height: $ds-factbox__grade-size;
93
+ }
96
94
  }
97
95
  .ds-factbox__show-more--collapsable::before {
98
96
  content: "";
@@ -139,37 +137,4 @@ $ds-factbox__max-height: 500px; // includes top/bottom spacing
139
137
  }
140
138
  }
141
139
  }
142
-
143
- &--culture {
144
- .ds-factbox__inner {
145
- border-left-color: $ds-color-static-kultur;
146
- }
147
- .ds-factbox__vignette {
148
- color: $ds-color-static-kultur;
149
- }
150
- }
151
- &--sport {
152
- .ds-factbox__inner {
153
- border-left-color: $ds-color-static-sport;
154
- }
155
- .ds-factbox__vignette {
156
- color: $ds-color-static-sport;
157
- }
158
- }
159
- &--economy {
160
- .ds-factbox__inner {
161
- border-left-color: $ds-color-static-economy;
162
- }
163
- .ds-factbox__vignette {
164
- color: $ds-color-static-economy;
165
- }
166
- }
167
- &--sthlm {
168
- .ds-factbox__inner {
169
- border-left-color: $ds-color-static-sthlm;
170
- }
171
- .ds-factbox__vignette {
172
- color: $ds-color-static-sthlm;
173
- }
174
- }
175
140
  }
@@ -1,10 +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 *;
7
- @use "../../foundations/helpers/links.scss" as *;
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
8
2
 
9
3
  $ds-footer-row-gap-spacing-token: $ds-sc-x8;
10
4
  $ds-footer-row-padding-spacing-token: $ds-sc-x4;
@@ -133,7 +127,7 @@ $ds-footer-column-gap: ds-spacing-component($ds-sc-x8) * 2; // @todo change to t
133
127
  margin-top: ds-spacing-component($ds-footer-row-gap-spacing-token);
134
128
 
135
129
  a {
136
- @include ds-link();
130
+ @include ds-link($ds-link-list);
137
131
  margin: ds-spacing-component($ds-sc-x4 $ds-sc-x4 0 0);
138
132
  display: inline-block;
139
133
 
@@ -32,7 +32,8 @@ These are copy paste friendly examples to quickliy get started using a component
32
32
  {{ IconButton({
33
33
  variant: 'outlined',
34
34
  size: 'default',
35
- iconName: 'home-filled'
35
+ iconName: 'arrow_forward',
36
+ attributes: { 'aria-label': 'Nästa' }
36
37
  })}}
37
38
  ```
38
39
 
@@ -1,4 +1,4 @@
1
- {% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
1
+ {% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
2
2
  {% from '@bonniernews/dn-design-system-web/foundations/a11y/visually-hidden.njk' import VisuallyHidden %}
3
3
  {% from '@bonniernews/dn-design-system-web/components/spinner/spinner.njk' import Spinner %}
4
4
 
@@ -27,7 +27,7 @@
27
27
  {% endif %}
28
28
 
29
29
  {% if params.iconName %}
30
- {% set iconSvg = Icon({ icon: params.iconName }) %}
30
+ {% set iconSvg = IconUse({ icon: params.iconName, attributes: { "aria-hidden": "true" } }) %}
31
31
  {% endif %}
32
32
 
33
33
  {% set loadingHtml %}
@@ -51,13 +51,13 @@
51
51
  {% if params.href %}
52
52
  <a href="{{ params.href | default('#', true) }}" class="{{ classes }}" {{- attributes | safe }}>
53
53
  {{- visuallyHidden | safe if visuallyHidden -}}
54
- <span class="{{ componentClassName + '__inner'}}">{{- iconSvg | safe if iconSvg -}}</span>
54
+ <span class="{{ componentClassName + '__inner' }}">{{- iconSvg | safe if iconSvg -}}</span>
55
55
  {{ loadingHtml | safe }}
56
56
  </a>
57
57
  {% else %}
58
58
  <button type="button" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe }}>
59
59
  {{- visuallyHidden | safe if visuallyHidden -}}
60
- <span class="{{ componentClassName + '__inner'}}">{{- iconSvg | safe if iconSvg -}}</span>
60
+ <span class="{{ componentClassName + '__inner' }}">{{- iconSvg | safe if iconSvg -}}</span>
61
61
  {{ loadingHtml | safe }}
62
62
  </button>
63
63
  {% endif %}
@@ -1,5 +1,5 @@
1
1
  @use "../../foundations/helpers/forward.helpers.scss" as *;
2
- @use "../../foundations/icons/icon.scss" as *;
2
+ @use "../icon-sprite/icon-sprite.scss";
3
3
  @use "../spinner/spinner.scss" as *;
4
4
 
5
5
  $ds-icon-btn__border-radius: 50%;
@@ -19,11 +19,14 @@ $ds-btn-outlined__border-width: ds-metrics-border-width(x1);
19
19
  padding: 0;
20
20
  position: relative;
21
21
 
22
+ span {
23
+ pointer-events: none;
24
+ }
25
+
22
26
  .ds-icon-btn__inner {
23
27
  box-sizing: border-box;
24
28
  border-radius: $ds-icon-btn__border-radius;
25
29
  border: $ds-btn-outlined__border-width solid;
26
- transition: background-color 50ms ease-out;
27
30
  margin: 0;
28
31
  display: inline-flex;
29
32
  align-items: center;
@@ -9,6 +9,8 @@ function dsIconButtonToggle(toggleElements = []) {
9
9
  toggleEl.addEventListener("click", () => {
10
10
  if (toggleEl.classList.contains("ds-icon-btn-toggle--disabled")) return;
11
11
  toggleEl.classList.toggle("ds-icon-btn-toggle--selected");
12
+ const ariaChecked = toggleEl.getAttribute("aria-checked") === "true" ? "false" : "true";
13
+ toggleEl.setAttribute("aria-checked", ariaChecked);
12
14
  });
13
15
  });
14
16
  }
@@ -1,63 +1,55 @@
1
- {% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
1
+ {% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
2
2
  {% from '@bonniernews/dn-design-system-web/foundations/a11y/visually-hidden.njk' import VisuallyHidden %}
3
3
  {% from '@bonniernews/dn-design-system-web/components/spinner/spinner.njk' import Spinner %}
4
+ {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
4
5
 
5
6
  {% 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 %}
7
+ {%- set componentClassName = "ds-icon-btn-toggle" %}
8
+ {%- set classNamePrefix = componentClassName + "--" %}
9
+ {%- set additionalClasses = [] %}
10
+ {%- set attributes = getAttributes(params.attributes) %}
14
11
 
15
- {% if params.selected %}
16
- {% set variant = (variant.push(classNamePrefix + "selected"), variant) %}
12
+ {%- if params.selected %}
13
+ {% set additionalClasses = (additionalClasses.push(classNamePrefix + "selected"), additionalClasses) %}
17
14
  {% endif %}
18
15
 
19
- {% if params.forcePx %}
20
- {% set variant = (variant.push("ds-force-px"), variant) %}
16
+ {%- if params.forcePx %}
17
+ {% set additionalClasses = (additionalClasses.push("ds-force-px"), additionalClasses) %}
21
18
  {% endif %}
22
19
 
23
- {% if params.variant %}
24
- {% set variant = (variant.push(classNamePrefix + params.variant), variant) %}
20
+ {%- if params.variant %}
21
+ {% set additionalClasses = (additionalClasses.push(classNamePrefix + params.variant), additionalClasses) %}
25
22
  {% else %}
26
- {% set variant = (variant.push(classNamePrefix + "outlined"), variant) %}
23
+ {% set additionalClasses = (additionalClasses.push(classNamePrefix + "outlined"), additionalClasses) %}
27
24
  {% endif %}
28
25
 
29
- {% if params.size and params.size != "default" %}
30
- {% set variant = (variant.push(classNamePrefix + params.size), variant) %}
26
+ {%- if params.size and params.size != "default" %}
27
+ {% set additionalClasses = (additionalClasses.push(classNamePrefix + params.size), additionalClasses) %}
31
28
  {% endif %}
32
29
 
33
- {% set loadingHtml %}
34
- {{ Spinner({ size: "small", variant: "primary", forcePx: params.forcePx }) }}
30
+ {%- set loadingHtml %}
31
+ {{ Spinner({ size: "small", additionalClasses: "primary", forcePx: params.forcePx }) }}
35
32
  {% endset %}
36
33
 
37
- {% if params.loading %}
38
- {% set variant = (variant.push("ds-loading"), variant) %}
34
+ {%- if params.loading %}
35
+ {% set additionalClasses = (additionalClasses.push("ds-loading"), additionalClasses) %}
39
36
  {% endif %}
40
37
 
41
- {% if params.a11y and params.a11y.visuallyHidden %}
38
+ {%- if params.a11y and params.a11y.visuallyHidden %}
42
39
  {% set visuallyHidden = VisuallyHidden({ text: params.a11y.visuallyHidden }) %}
43
40
  {% endif %}
44
41
 
45
- {% if params.classNames %}
46
- {% set variant = (variant.push(params.classNames), variant) %}
42
+ {%- if params.classNames %}
43
+ {% set additionalClasses = (additionalClasses.push(params.classNames), additionalClasses) %}
47
44
  {% endif%}
48
45
 
49
- {% set classes = componentClassName + " " + variant | join(" ") %}
50
-
51
- <button type="button" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe }}>
46
+ {%- set classes = componentClassName + " " + additionalClasses | join(" ") %}
47
+ <button type="button" role="switch" aria-checked="{{ "true" if params.selected else "false" }}" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe }}>
52
48
  {{- 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>
49
+ <span class="{{ componentClassName + '__inner' }}" aria-hidden="true">
50
+ <span class="{{ componentClassName + '__off' }}">{{ IconUse({ icon: params.iconName }) }}</span>
51
+ <span class="{{ componentClassName + '__on' }}">{{ IconUse({ icon: params.selectedIconName }) }}</span>
60
52
  {{ loadingHtml | safe }}
61
- </div>
53
+ </span>
62
54
  </button>
63
55
  {% endmacro %}
@@ -1,5 +1,5 @@
1
1
  @use "../../foundations/helpers/forward.helpers.scss" as *;
2
- @use "../../foundations/icons/icon.scss" as *;
2
+ @use "../icon-sprite/icon-sprite.scss";
3
3
  @use "../spinner/spinner.scss" as *;
4
4
 
5
5
  $ds-icon-btn-toggle__border-radius: 50%;
@@ -19,11 +19,14 @@ $ds-btn-toggle-outlined__border-width: ds-metrics-border-width(x1);
19
19
  padding: 0;
20
20
  position: relative;
21
21
 
22
+ span {
23
+ pointer-events: none;
24
+ }
25
+
22
26
  .ds-icon-btn-toggle__inner {
23
27
  box-sizing: border-box;
24
28
  border-radius: $ds-icon-btn-toggle__border-radius;
25
29
  border: $ds-btn-toggle-outlined__border-width solid;
26
- transition: background-color 50ms ease-out;
27
30
  margin: 0;
28
31
  display: inline-flex;
29
32
  align-items: center;
@@ -0,0 +1,51 @@
1
+ - GitHub: [BonnierNews/dn-design-system/../web/src/components/icon-sprite](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-sprite)
2
+ - Storybook: [Icon > Web](https://designsystem.dn.se/?path=/story/foundations-icon-web--all)
3
+
4
+ ----
5
+ # Icons
6
+
7
+ There are three ways to use icons from DS:
8
+ * Use Icon from sprite: `IconUse({})`, this is the **recomended** way since this reduces the html output.
9
+ * Use Icon with wrapper: `IconWithWrapper({})`, the component itself uses the icons from the sprite but wraps it with a div and takes properties like size and color
10
+ * Use Icon from foundations: `Icon({})`, only use this if you need an inline icon, this will output the entire svg wherever it is used.
11
+
12
+
13
+ # Icon Sprite
14
+
15
+ ## Parameters
16
+
17
+ |parameter | type | required | options | default | description |
18
+ |:--- | :--- | :--- | :--- | :--- | :--- |
19
+ |icon | String | yes | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icon-web--all |
20
+ |classNames | String | no | | | Ex. "my-special-class" |
21
+ |attributes | Object | no | | | Ex. { "data-test": "lorem ipsum" } |
22
+ |~forcePx~ | | | | | Not supported |
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-sprite/icon-sprite.njk' import IconUse %}
32
+
33
+ {{ IconUse({
34
+ icon: 'arrow_back',
35
+ classNames: 'my-special-class',
36
+ attributes: { width: '16px' }
37
+ }) | safe }}
38
+ ```
39
+
40
+ ### SCSS
41
+ ```scss
42
+ @use "@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite";
43
+ ```
44
+
45
+ ℹ️ The sprite has to be included **somewhere** on the rendered page
46
+
47
+ ```html
48
+ {% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconSprite %}
49
+
50
+ {{ IconSprite() | safe }}
51
+ ```
@@ -0,0 +1,12 @@
1
+ {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
2
+
3
+ {% macro IconUse(params) %}
4
+ {%- set attributes = getAttributes(params.attributes) %}
5
+ <i class="ds-icon ds-icon--sprite ds-icon--{{ params.icon }} {{ params.classNames }}" {{- attributes | safe }}>
6
+ <svg><use xlink:href="#ds-{{ params.icon }}"></use></svg>
7
+ </i>
8
+ {% endmacro %}
9
+
10
+ {% macro IconSprite() %}
11
+ {% include "@bonniernews/dn-design-system-web/foundations/icons/sprite.njk" %}
12
+ {% endmacro %}
@@ -0,0 +1,12 @@
1
+ @use "../../foundations/icons/icon.scss" as *;
2
+
3
+ .ds-icon--sprite {
4
+ display: block;
5
+ width: 100%;
6
+ height: 100%;
7
+
8
+ svg {
9
+ width: 100%;
10
+ height: 100%;
11
+ }
12
+ }
@@ -44,7 +44,14 @@ These are copy paste friendly examples to quickliy get started using a component
44
44
 
45
45
  These are copy paste friendly examples to quickliy get started using a component.
46
46
 
47
- ℹ️ Note that the only available parameter for icon without wrapper is `icon`
47
+ ## Parameters
48
+
49
+ |parameter | type | required | options | default | description |
50
+ |:--- | :--- | :--- | :--- | :--- | :--- |
51
+ |icon | String | yes | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icon-web--all |
52
+ |classNames | String | no | | | Ex. "my-special-class" |
53
+ |attributes | Object | no | | | Ex. { "data-test": "lorem ipsum" } |
54
+ |~forcePx~ | | | | | Not supported |
48
55
 
49
56
  ```html
50
57
  {% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
@@ -55,4 +62,4 @@ These are copy paste friendly examples to quickliy get started using a component
55
62
  ### SCSS
56
63
  ```scss
57
64
  @use "@bonniernews/dn-design-system-web/foundations/icons/icon";
58
- ```
65
+ ```
@@ -1,4 +1,4 @@
1
- {% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
1
+ {% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
2
2
 
3
3
  {% macro IconWithWrapper(params) %}
4
4
  {% set componentClassName = "ds-icon-wrapper" %}
@@ -29,6 +29,6 @@
29
29
  {% set styleIcon = "width: " + iconSize + "; height: " + iconSize + ";" %}
30
30
 
31
31
  <div class="{{ classes }}" style="{{ styleIcon }} {{ styleColor }}" {{- attributes | safe}}>
32
- {{ Icon({ icon: params.icon }) | safe }}
32
+ {{ IconUse({ icon: params.icon }) | safe }}
33
33
  </div>
34
34
  {% endmacro %}
@@ -1,4 +1,5 @@
1
- @use "../../foundations/icons/icon.scss" as *;
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
2
+ @use "../icon-sprite/icon-sprite.scss";
2
3
 
3
4
  .ds-icon-wrapper {
4
5
  .ds-icon {