Skip to content

Commit 7738f31

Browse files
committed
feat(typography): add letter-spacing configuration to typography configs.
1 parent 4c3e385 commit 7738f31

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/lib/core/typography/_typography-utils.scss

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
@return _mat-get-type-value($config, $level, font-weight);
1919
}
2020

21+
// Gets the letter spacing for a level inside a typography config.
22+
@function mat-letter-spacing($config, $level) {
23+
@return _mat-get-type-value($config, $level, letter-spacing);
24+
}
25+
2126
// Gets the font-family from a typography config and removes the quotes around it.
2227
@function mat-font-family($config, $level: null) {
2328
$font-family: map-get($config, font-family);
@@ -31,7 +36,8 @@
3136

3237
// Outputs the shorthand `font` CSS property, based on a set of typography values. Falls back to
3338
// the individual properties if a value that isn't allowed in the shorthand is passed in.
34-
@mixin mat-typography-font-shorthand($font-size, $font-weight, $line-height, $font-family) {
39+
@mixin mat-typography-font-shorthand(
40+
$font-size, $font-weight, $line-height, $font-family, $letter-spacing) {
3541
// If any of the values are set to `inherit`, we can't use the shorthand
3642
// so we fall back to passing in the individual properties.
3743
@if ($font-size == inherit or
@@ -54,6 +60,8 @@
5460
// Sass from dividing the two values.
5561
font: $font-weight #{$font-size}/#{$line-height} $font-family;
5662
}
63+
// Set the letter spacing regardless of method for setting font values.
64+
letter-spacing: $letter-spacing;
5765
}
5866

5967
// Converts a typography level into CSS styles.
@@ -62,6 +70,8 @@
6270
$font-weight: mat-font-weight($config, $level);
6371
$line-height: mat-line-height($config, $level);
6472
$font-family: mat-font-family($config, $level);
73+
$letter-spacing: mat-letter-spacing($config, $level);
6574

66-
@include mat-typography-font-shorthand($font-size, $font-weight, $line-height, $font-family);
75+
@include mat-typography-font-shorthand(
76+
$font-size, $font-weight, $line-height, $font-family, $letter-spacing);
6777
}

src/lib/core/typography/_typography.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
$font-size,
66
$line-height: $font-size,
77
$font-weight: 400,
8-
$font-family: null) {
8+
$font-family: null,
9+
$letter-spacing: null) {
910

1011
@return (
1112
font-size: $font-size,
1213
line-height: $line-height,
1314
font-weight: $font-weight,
14-
font-family: $font-family
15+
font-family: $font-family,
16+
letter-spacing: $letter-spacing
1517
);
1618
}
1719

0 commit comments

Comments
 (0)