angular / angular/components

bug(Theming Angular Material): Custom typography not applied to standard typography levels in mat.core-theme() or all-component-themes()

Offen
#24,370 14 Kommentare 6 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/core area: theming docs P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Tried to change the font-family so that e.g. body-1 everywhere has font family Arial.
But it only changed the font-family in mat components, not outside in normal divs.

```
$my-typography: mat.define-typography-config(
$font-family: 'Arial',
);
$my-theme: mat.define-light-theme((
typography: $my-typography,
color: (
primary: $dicey-primary,
accent: $dicey-accent,
warn: $dicey-warn,
))
);
@include mat.all-component-themes($my-theme);
```

Similar problem was reported here, but not solved: https://github.com/angular/components/issues/23683#issue-1015421891

-----------------------

It works when I do it with all-component-typographies:

```
$my-typography: mat.define-typography-config(
$font-family: 'Arial',
);
@include mat.all-component-typographies($my-typography);
```

### Reproduction

Steps to reproduce:
1. Add custom theme with typography
2. See if body tag font-family changes

### Expected Behavior

Bodys font family changes to custom font family

### Actual Behavior

The body font family is standard Roboto

### Environment

- Angular: 13.1.2
- CDK/Material: 13.1.1
- Browser(s): Firefox
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 11

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, den Fall Angular 13.1.2 aus dem Issue zu reproduzieren, und vergleiche mat.all-component-themes($my-theme) mit mat.all-component-typographies($my-typography). Verfolge die von mat.core-theme() und all-component-themes() verwendeten Typografie-Mixins; abgeschlossen ist die Aufgabe, wenn die konfigurierte Arial-Schriftart auf den Body und die standardmäßigen Typografieebenen angewendet wird, nicht nur auf Material-Komponenten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, sass, typescript
Bereich
design, frontend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.