|
3 | 3 | @use '../../../style/sass-utils';
|
4 | 4 | @use '../../../theming/theming';
|
5 | 5 | @use '../../../theming/palette';
|
| 6 | +@use '../../../typography/typography-utils'; |
6 | 7 |
|
7 | 8 | // The prefix used to generate the fully qualified name for tokens in this file.
|
8 | 9 | $prefix: (mat, form-field);
|
@@ -57,7 +58,34 @@ $prefix: (mat, form-field);
|
57 | 58 |
|
58 | 59 | // Tokens that can be configured through Angular Material's typography theming API.
|
59 | 60 | @function get-typography-tokens($config) {
|
60 |
| - @return (); |
| 61 | + $fallback-font-family: typography-utils.font-family($config); |
| 62 | + |
| 63 | + @return ( |
| 64 | + // MDC uses `subtitle1` for the input value, placeholder and floating label. The spec |
| 65 | + // shows `body1` for text fields though, so we manually override the typography. |
| 66 | + // Note: Form controls inherit the typography from the parent form field. |
| 67 | + container-text-font: typography-utils.font-family($config, body-1) or $fallback-font-family, |
| 68 | + container-text-line-height: typography-utils.line-height($config, body-1), |
| 69 | + container-text-size: typography-utils.font-size($config, body-1), |
| 70 | + container-text-tracking: typography-utils.letter-spacing($config, body-1), |
| 71 | + container-text-weight: typography-utils.font-weight($config, body-1), |
| 72 | + |
| 73 | + // In the container styles, we updated the floating label to use the `body-1` typography level. |
| 74 | + // The MDC notched outline overrides this accidentally (only when the label floats) to a |
| 75 | + // `rem`-based value. This results in different label widths when floated/docked and ultimately |
| 76 | + // breaks the notch width as it has been measured in the docked state (where `body-1` is |
| 77 | + // applied). We try to unset these styles set by the `mdc-notched-outline`: |
| 78 | + // https://github.com/material-components/material-components-web/blob/master/packages/mdc-notched-outline/_mixins.scss#L272-L292. |
| 79 | + // This is why we can't use their `label-text-populated-size` token and we have to declare |
| 80 | + // our own version of it. |
| 81 | + outlined-label-text-populated-size: typography-utils.font-size($config, body-1), |
| 82 | + |
| 83 | + subscript-text-font: typography-utils.font-family($config, caption) or $fallback-font-family, |
| 84 | + subscript-text-line-height: typography-utils.line-height($config, caption), |
| 85 | + subscript-text-size: typography-utils.font-size($config, caption), |
| 86 | + subscript-text-tracking: typography-utils.letter-spacing($config, caption), |
| 87 | + subscript-text-weight: typography-utils.font-weight($config, caption), |
| 88 | + ); |
61 | 89 | }
|
62 | 90 |
|
63 | 91 | // Tokens that can be configured through Angular Material's density theming API.
|
|
0 commit comments