@bonniernews/dn-design-system-web 11.3.1 → 11.4.0-beta.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
4
4
 
5
5
 
6
6
 
7
+ ## [11.4.0-beta.0](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@11.3.1...@bonniernews/dn-design-system-web@11.4.0-beta.0) (2024-02-12)
8
+
9
+
10
+ ### Features
11
+
12
+ * **core:** handle new token types ([e766b43](https://github.com/BonnierNews/dn-design-system/commit/e766b43f723bd7e0c6a3327d1d8508594b6d64a9))
13
+
7
14
  ## [11.3.1](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@11.3.0...@bonniernews/dn-design-system-web@11.3.1) (2024-02-09)
8
15
 
9
16
 
@@ -11,6 +11,7 @@
11
11
  @use "fontFamily.scss" as *;
12
12
  @forward "../variables/typographyTokensList.scss";
13
13
  @forward "../variables/decorations.scss";
14
+ @forward "../variables/typographyAddons.scss";
14
15
 
15
16
  $dsTypographyKeys: (
16
17
  fontFamily: "font-family",
@@ -46,16 +47,23 @@ $dsSerifWeights: (
46
47
 
47
48
  // Serif variation changes, text 18px, headline 26px, display 34px. As fallback we will always use headline
48
49
 
49
- @mixin ds-typography($component, $forcePx: false) {
50
- $tmpMap: map.get($typographyTokensScreenSmall, $component);
51
- $tmpMapScreenLarge: map.get($typographyTokensScreenLarge, $component);
52
- $tmpMapScreenExtraLarge: map.get($typographyTokensScreenExtraLarge, $component);
50
+ @mixin ds-typography($component, $forcePx: false, $fontWeight: null, $letterSpacing: null, $lineHeight: null) {
51
+ // making sure override values have matching keys in typography object
52
+ $addons: (
53
+ "letterSpacing": $letterSpacing,
54
+ "fontWeight": null,
55
+ "lineHeight": null,
56
+ );
57
+ $tmpMap: map.merge($addons, map.get($typographyTokensScreenSmall, $component));
58
+ $tmpMapScreenLarge: map.merge($addons, map.get($typographyTokensScreenLarge, $component));
59
+ $tmpMapScreenExtraLarge: map.merge($addons, map.get($typographyTokensScreenExtraLarge, $component));
53
60
 
54
61
  @if $tmpMap {
55
62
  @include ds-mq-largest-breakpoint(mobile) {
56
63
  @include _ds-normalize-letter-spacing($tmpMap);
57
64
  @each $key in map-keys($tmpMap) {
58
- @include _ds-typography-get-property($tmpMap, $key, $forcePx);
65
+ $value: _ds-get-override-value($key, $fontWeight, $letterSpacing, $lineHeight);
66
+ @include _ds-typography-get-property($tmpMap, $key, $forcePx, "small", $value);
59
67
  }
60
68
  }
61
69
  }
@@ -64,7 +72,8 @@ $dsSerifWeights: (
64
72
  @include ds-mq-only-breakpoint(tablet) {
65
73
  @include _ds-normalize-letter-spacing($tmpMapScreenLarge);
66
74
  @each $key in map-keys($tmpMapScreenLarge) {
67
- @include _ds-typography-get-property($tmpMapScreenLarge, $key, $forcePx, "large");
75
+ $value: _ds-get-override-value($key, $fontWeight, $letterSpacing, $lineHeight);
76
+ @include _ds-typography-get-property($tmpMapScreenLarge, $key, $forcePx, "large", $value);
68
77
  }
69
78
  }
70
79
  }
@@ -73,27 +82,45 @@ $dsSerifWeights: (
73
82
  @include ds-mq-smallest-breakpoint(desktop) {
74
83
  @include _ds-normalize-letter-spacing($tmpMapScreenExtraLarge);
75
84
  @each $key in map-keys($tmpMapScreenExtraLarge) {
76
- @include _ds-typography-get-property($tmpMapScreenExtraLarge, $key, $forcePx, "extraLarge");
85
+ $value: _ds-get-override-value($key, $fontWeight, $letterSpacing, $lineHeight);
86
+ @include _ds-typography-get-property($tmpMapScreenExtraLarge, $key, $forcePx, "extraLarge", $value);
77
87
  }
78
88
  }
79
89
  }
80
90
  }
81
91
 
82
- @mixin ds-typography-without-mq($component, $screen: false, $forcePx: false) {
92
+ @mixin ds-typography-without-mq(
93
+ $component,
94
+ $screen: mobile,
95
+ $forcePx: false,
96
+ $fontWeight: null,
97
+ $letterSpacing: null,
98
+ $lineHeight: null
99
+ ) {
83
100
  $tmpMap: false;
101
+ $scaling: "small";
102
+ // making sure override values have matching keys in typography object
103
+ $addons: (
104
+ "letterSpacing": $letterSpacing,
105
+ "fontWeight": null,
106
+ "lineHeight": null,
107
+ );
84
108
 
85
109
  @if $screen == mobile {
86
- $tmpMap: map.get($typographyTokensScreenSmall, $component);
110
+ $tmpMap: map.merge($addons, map.get($typographyTokensScreenSmall, $component));
87
111
  } @else if $screen == tablet {
88
- $tmpMap: map.get($typographyTokensScreenLarge, $component);
112
+ $tmpMap: map.merge($addons, map.get($typographyTokensScreenLarge, $component));
113
+ $scaling: "large";
89
114
  } @else if $screen == desktop {
90
- $tmpMap: map.get($typographyTokensScreenExtraLarge, $component);
115
+ $tmpMap: map.merge($addons, map.get($typographyTokensScreenExtraLarge, $component));
116
+ $scaling: "extraLarge";
91
117
  }
92
118
 
93
119
  @if $tmpMap {
94
120
  @include _ds-normalize-letter-spacing($tmpMap);
95
121
  @each $key in map-keys($tmpMap) {
96
- @include _ds-typography-get-property($tmpMap, $key, $forcePx);
122
+ $value: _ds-get-override-value($key, $fontWeight, $letterSpacing, $lineHeight);
123
+ @include _ds-typography-get-property($tmpMap, $key, $forcePx, $scaling, $value);
97
124
  }
98
125
  }
99
126
  }
@@ -122,13 +149,15 @@ $dsSerifWeights: (
122
149
  }
123
150
  }
124
151
 
125
- @mixin _ds-typography-get-property($map, $key, $forcePx, $screen: "small") {
152
+ @mixin _ds-typography-get-property($map, $key, $forcePx, $screen: "small", $value: null) {
153
+ @if not $value {
154
+ $value: map.get($map, $key);
155
+ }
126
156
  $unit: "";
127
- $value: map.get($map, $key);
128
157
  $fontFamilyType: _ds-get-font-family-type($map);
129
158
  $fontWeights: if($fontFamilyType == "serif", $dsSerifWeights, $dsSansWeights);
130
159
 
131
- @if $value != "" {
160
+ @if $value and $value != "" {
132
161
  @if $key == "fontFamily" {
133
162
  @if $fontFamilyType == "serif" {
134
163
  font-family: $ds-font--serif;
@@ -152,19 +181,17 @@ $dsSerifWeights: (
152
181
  }
153
182
  font-variation-settings: "opsz" $value;
154
183
  } @else if $key == "lineHeight" {
155
- @if $forcePx {
156
- line-height: $value * 1px;
157
- } @else {
158
- line-height: ds-px-to-rem($value);
159
- line-height: clamp($value * 1px, ds-px-to-rem($value), _ds-get-max-scaled-size($value, $screen));
160
- }
184
+ line-height: $value;
161
185
  } @else if $key == "letterSpacing" {
162
- @if $forcePx {
163
- $value: $value * 1px;
186
+ @if $value == 0 {
187
+ letter-spacing: normal;
164
188
  } @else {
165
- $value: ds-px-to-rem($value);
189
+ @if $forcePx {
190
+ letter-spacing: $value * 1px;
191
+ } @else {
192
+ letter-spacing: ds-px-to-rem($value);
193
+ }
166
194
  }
167
- #{map.get($dsTypographyKeys, $key)}: $value;
168
195
  } @else if index(map-keys($dsTypographyKeys), $key) {
169
196
  #{map.get($dsTypographyKeys, $key)}: $value;
170
197
  }
@@ -211,3 +238,14 @@ $dsSerifWeights: (
211
238
  @include ds-typography($token, true);
212
239
  }
213
240
  }
241
+
242
+ @function _ds-get-override-value($key, $fontWeight, $letterSpacing, $lineHeight) {
243
+ @if $key == "fontWeight" {
244
+ @return $fontWeight;
245
+ } @else if $key == "letterSpacing" {
246
+ @return $letterSpacing;
247
+ } @else if $key == "lineHeight" {
248
+ @return $lineHeight;
249
+ }
250
+ @return null;
251
+ }
@@ -8,8 +8,11 @@
8
8
 
9
9
  |parameter | type | required | options | default | description |
10
10
  |:--- | :--- | :--- | :--- | :--- | :--- |
11
- |token | Sass variable | yes | | | Ex. $ds-typography-functional-body01regular, all typography variables starts with prefix $ds-typography- |
11
+ |token | Sass variable | yes | | | Ex. $ds-typography-expressiveheading03, all typography variables starts with prefix $ds-typography- |
12
12
  |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
13
+ |fontWeight | Sass variable | no | | null | Ex: $ds-fontweight-medium, all font-weight variables starts with prefix $ds-fontweight- |
14
+ |letterSpacing | Sass variable | no | | null | Ex: $ds-letterspacing-xs, all letter-spacing variables starts with prefix $ds-letterspacing- |
15
+ |lineHeight | Sass variable | no | | null | Ex: $ds-lineheight-tight, all line-height variables starts with prefix $ds-lineheight- |
13
16
 
14
17
  These are copy paste friendly examples to quickliy get started using a component.
15
18
 
@@ -17,12 +20,34 @@ These are copy paste friendly examples to quickliy get started using a component
17
20
  ```scss
18
21
  @use "@bonniernews/dn-design-system-web/foundations/helpers/forward.helpers" as *;
19
22
 
20
- @include ds-typography($ds-typography-functional-body01regular);
23
+ @include ds-typography($ds-typography-expressiveheading03);
24
+ ````
25
+
26
+ **With overriding addons**
27
+ ```scss
28
+ @include ds-typography(
29
+ $component: $ds-typography-expressiveheading03,
30
+ $fontWeight: $ds-fontweight-medium,
31
+ $lineHeight: $ds-lineheight-tight,
32
+ $letterSpacing: $ds-letterspacing-none
33
+ );
34
+ ```
35
+
36
+ **Without media queries**
37
+ All devices get the same sizes based on $screen parameter (defaults to mobile)
38
+ ```scss
39
+ @include ds-typography-without-mq(
40
+ $component: $ds-typography-expressiveheading03,
41
+ $screen: desktop,
42
+ $fontWeight: $ds-fontweight-medium,
43
+ $lineHeight: $ds-lineheight-tight,
44
+ $letterSpacing: $ds-letterspacing-xs
45
+ );
21
46
  ```
22
47
 
23
- With forcePX parameter:
48
+ **With forcePX parameter**
24
49
  ```scss
25
- @include ds-typography($ds-typography-functional-body01regular, true);
50
+ @include ds-typography($ds-typography-expressiveheading03, true);
26
51
  ```
27
52
 
28
53
  ## ⚠️ Manual typography (only for use in special circumstances)
@@ -0,0 +1,10 @@
1
+ $ds-fontweight-regular: Regular;
2
+ $ds-lineheight-none: 1;
3
+ $ds-lineheight-tight: 1.12;
4
+ $ds-lineheight-regular: 1.5;
5
+ $ds-fontweight-medium: Medium;
6
+ $ds-fontweight-semibold: SemiBold;
7
+ $ds-fontweight-bold: Bold;
8
+ $ds-letterspacing-none: 0;
9
+ $ds-letterspacing-xs: 0.2;
10
+ $ds-letterspacing-s: 0.5;
@@ -102,3 +102,29 @@ $ds-typography-detailteaser-standard-opinion: 'detailteaser-standard-opinion';
102
102
  $ds-typography-detailteaser-twin: 'detailteaser-twin';
103
103
  $ds-typography-detailteaser-large-compact: 'detailteaser-large-compact';
104
104
  $ds-typography-detailteaser-large-compact-opinion: 'detailteaser-large-compact-opinion';
105
+ $ds-typography-expressiveheading01: 'expressiveheading01';
106
+ $ds-typography-expressiveheading02: 'expressiveheading02';
107
+ $ds-typography-expressiveheading03: 'expressiveheading03';
108
+ $ds-typography-expressiveheading04: 'expressiveheading04';
109
+ $ds-typography-expressiveheading05: 'expressiveheading05';
110
+ $ds-typography-expressiveheading06: 'expressiveheading06';
111
+ $ds-typography-expressiveheading07: 'expressiveheading07';
112
+ $ds-typography-expressivebody01: 'expressivebody01';
113
+ $ds-typography-expressivebody02: 'expressivebody02';
114
+ $ds-typography-expressivebody03: 'expressivebody03';
115
+ $ds-typography-expressiveingress01: 'expressiveingress01';
116
+ $ds-typography-expressiveingress02: 'expressiveingress02';
117
+ $ds-typography-functionalmeta01: 'functionalmeta01';
118
+ $ds-typography-functionalmeta02: 'functionalmeta02';
119
+ $ds-typography-functionallabel01: 'functionallabel01';
120
+ $ds-typography-functionallabel02: 'functionallabel02';
121
+ $ds-typography-functionalbody01: 'functionalbody01';
122
+ $ds-typography-functionalbody02: 'functionalbody02';
123
+ $ds-typography-functionalingress01: 'functionalingress01';
124
+ $ds-typography-functionalingress02: 'functionalingress02';
125
+ $ds-typography-functionalheading01: 'functionalheading01';
126
+ $ds-typography-functionalheading02: 'functionalheading02';
127
+ $ds-typography-functionalheading03: 'functionalheading03';
128
+ $ds-typography-functionalheading04: 'functionalheading04';
129
+ $ds-typography-functionalheading05: 'functionalheading05';
130
+ $ds-typography-functionalheading06: 'functionalheading06';