Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(all): Mixins for changing component color #30241

Open
martinboue opened this issue Dec 27, 2024 · 0 comments
Open

feat(all): Mixins for changing component color #30241

martinboue opened this issue Dec 27, 2024 · 0 comments
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team

Comments

@martinboue
Copy link

martinboue commented Dec 27, 2024

Feature Description

What I want

To easily change the color of a material component.

Context

It is a very common use case to change a material component default color, and migrating from v18 to v19 this was a pain point for me.

Before in v18, I could change the component color to one in my theme palette like this:

@include mat.chips-color(theme.$theme, $color-variant: tertiary);

And now in v19, I need to specify every tokens:

@include mat.chips-overrides((
   elevated-selected-container-color: map.get(theme.$palettes, tertiary, 90),
   selected-label-text-color: map.get(theme.$palettes, tertiary, 10),
   selected-trailing-icon-color: map.get(theme.$palettes, tertiary, 10),
   selected-hover-state-layer-color: map.get(theme.$palettes, tertiary, 10),
   selected-trailing-action-state-layer-color: map.get(theme.$palettes, tertiary, 10),
   selected-focus-state-layer-color: map.get(theme.$palettes, tertiary, 10),
   with-icon-selected-icon-color: map.get(theme.$palettes, tertiary, 10)
));

It's much more complicated now, and if we want to keep the same level of contrast (here tones 10 and 90) we have to inspect the generated code and find the equivalent in the new color.

Proposed solution

In v18 we had to pick a color from our theme, which wasn't very flexible. An ideal solution would be:

@include mat.chips-color(#FF0000); // <== We could pass any color here and the mixin would compute the tones

If not doable, then the same behavior as v18 would be good enough:

@include mat.chips-color(theme.$palettes, tertiary);
// or
$tertiary-palette: map.get(theme.$palettes, tertiary);
@include mat.chips-color($tertiary-palette);

There should be one mat.<component>-color mixin for each material component.

Use Case

No response

@martinboue martinboue added feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team labels Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

1 participant