feat(theming): Add a typesafe like API to get theming tokens CSS var names
- Vorherrschende Sprache
- TypeScript
- Sterne
- 25k
- Forks
- 6.8k
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
### Feature Description
Currently there are Sass mixings that allow to, in a typesafe safe way, override theming tokens:
```
mat.snack-bar-overrides(....)
```
When saying typesafe, I mean that if a token is renamed or removed, the compiler will trigger an error. There are no equivalent to generating the CSS custom properties associated with these tokens.
### Use Case
Why this could help?
I have a component to show temporary messages, much like an snack-bar, but it isn't a snack bar, but it uses the same snack bar theming, same colors, for example. So this uses currently `--mat-snack-bar-` prefixed CSS variables. The problem is that migrating from version 19 up to 21, many of these variables names were renamed from `--mdc`- to `--mat`- prefixes thankfully automatically but it missed that for snack bars, the prefixes changed from snackbar to snack-bar.
If instead of using the var named directly we had some kind of:
```
mat.token-var(snack-bar, container-color, white)
```
to generate `var(--mat-snack-bar-container-color, white)` in a typesafe way, triggering an error if a bad component or token name is used, this could have avoided the missed rename.
Beitragsleitfaden
Rechercherichtung
Es ist keine Datei und kein Test-Einstiegspunkt benannt. Beginne damit, die vorhandenen Sass-Override-Mixins zu untersuchen, einschließlich mat.snack-bar-overrides, sowie die hier beschriebene Benennung der CSS Custom Properties der Snack-Bar. Als abgeschlossen würde eine vereinbarte typesafe API zum Erzeugen von Token-Variablennamen und eine Abdeckung für ungültige Komponenten- oder Tokennamen gelten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, sass
- Bereich
- frontend
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100