@bonniernews/dn-design-system-web 7.1.0 → 7.2.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
@@ -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
+ ## 7.2.0 (2023-10-23)
7
+
8
+
9
+ ### Features
10
+
11
+ * **web:** limit scaling for large fonts ([#1063](https://github.com/BonnierNews/dn-design-system/issues/1063)) ([213a9b9](https://github.com/BonnierNews/dn-design-system/commit/213a9b93fcb46ea459519f83a1a2af28fe665045))
12
+
13
+
14
+
6
15
  ## 7.1.0 (2023-10-20)
7
16
 
8
17
 
@@ -70,7 +70,8 @@ $dsSerifWeights: (
70
70
  @include _ds-typography-get-property(
71
71
  $tmpMapScreenLarge,
72
72
  $key,
73
- $forcePx
73
+ $forcePx,
74
+ "large"
74
75
  );
75
76
  }
76
77
  }
@@ -83,7 +84,8 @@ $dsSerifWeights: (
83
84
  @include _ds-typography-get-property(
84
85
  $tmpMapScreenExtraLarge,
85
86
  $key,
86
- $forcePx
87
+ $forcePx,
88
+ "extraLarge"
87
89
  );
88
90
  }
89
91
  }
@@ -109,46 +111,70 @@ $dsSerifWeights: (
109
111
  }
110
112
  }
111
113
 
112
- @mixin _ds-typography-get-property($map, $key, $forcePx) {
114
+ @mixin _ds-typography-get-property($map, $key, $forcePx, $screen: "small") {
113
115
  $unit: "";
114
116
  $value: map.get($map, $key);
115
117
  $fontFamilyType: _ds-get-font-family-type($map);
116
118
  $fontWeights: if($fontFamilyType == "serif", $dsSerifWeights, $dsSansWeights);
117
- $canForcePx: list.index((fontSize, lineHeight, letterSpacing), $key);
118
119
 
119
- @if $key == "fontFamily" {
120
- @if $fontFamilyType == "serif" {
121
- font-family: $ds-font--serif;
122
- } @else if $fontFamilyType == "sans" {
123
- font-family: $ds-font--sans;
124
- }
125
- } @else if $key == "fontWeight" {
126
- $value: string.to-lower-case($value);
127
- @if map-has-key($fontWeights, $value) {
128
- $value: map.get($fontWeights, $value);
129
- }
130
- font-weight: #{$value};
131
- } @else if $key == "fontStyle" {
132
- font-style: string.to-lower-case($value);
133
- } @else if $key == "fontSize" {
134
- @if $forcePx {
135
- font-size: $value * 1px;
136
- } @else {
137
- font-size: ds-px-to-rem($value);
138
- }
139
- font-variation-settings: "opsz" $value;
140
- } @else if $canForcePx and $value != "" {
141
- @if $forcePx {
142
- $value: $value * 1px;
143
- } @else {
144
- $value: ds-px-to-rem($value);
120
+ @if $value != "" {
121
+ @if $key == "fontFamily" {
122
+ @if $fontFamilyType == "serif" {
123
+ font-family: $ds-font--serif;
124
+ } @else if $fontFamilyType == "sans" {
125
+ font-family: $ds-font--sans;
126
+ }
127
+ } @else if $key == "fontWeight" {
128
+ $value: string.to-lower-case($value);
129
+ @if map-has-key($fontWeights, $value) {
130
+ $value: map.get($fontWeights, $value);
131
+ }
132
+ font-weight: #{$value};
133
+ } @else if $key == "fontStyle" {
134
+ font-style: string.to-lower-case($value);
135
+ } @else if $key == "fontSize" {
136
+ @if $forcePx {
137
+ font-size: $value * 1px;
138
+ } @else {
139
+ font-size: ds-px-to-rem($value);
140
+ font-size: clamp($value * 1px, ds-px-to-rem($value), _ds-get-max-scaled-size($value, $screen));
141
+ }
142
+ font-variation-settings: "opsz" $value;
143
+ } @else if $key == "lineHeight" {
144
+ @if $forcePx {
145
+ line-height: $value * 1px;
146
+ } @else {
147
+ line-height: ds-px-to-rem($value);
148
+ line-height: clamp($value * 1px, ds-px-to-rem($value), _ds-get-max-scaled-size($value, $screen));
149
+ }
150
+ } @else if $key == "letterSpacing" {
151
+ @if $forcePx {
152
+ $value: $value * 1px;
153
+ } @else {
154
+ $value: ds-px-to-rem($value);
155
+ }
156
+ #{map.get($dsTypographyKeys, $key)}: $value;
157
+ } @else if index(map-keys($dsTypographyKeys), $key) {
158
+ #{map.get($dsTypographyKeys, $key)}: $value;
145
159
  }
146
- #{map.get($dsTypographyKeys, $key)}: $value;
147
- } @else if index(map-keys($dsTypographyKeys), $key) and $value != "" {
148
- #{map.get($dsTypographyKeys, $key)}: $value;
149
160
  }
150
161
  }
151
162
 
163
+ @function _ds-get-max-scaled-size($size, $screen: "small") {
164
+ $midPoint: 26;
165
+ $scalingFactor: 0.33;
166
+ @if ($screen == "large") {
167
+ $midPoint: 30;
168
+ $scalingFactor: 0.2;
169
+ } @else if ($screen == "extraLarge") {
170
+ $midPoint: 32;
171
+ $scalingFactor: 0.166;
172
+ }
173
+
174
+ $calculatedScalingFactor: 2 - math.div(1, (1 + math.pow(math.$e, $scalingFactor * ($midPoint - $size))));
175
+ @return math.round($calculatedScalingFactor * $size * 1px);
176
+ }
177
+
152
178
  @function _ds-get-font-family-type($map) {
153
179
  $fontFamily: map.get($map, "fontFamily");
154
180
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
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",