-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(material/core): special-case icon button color token #31625
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
@use '../style/elevation'; | ||
@use '../theming/config-validation'; | ||
@use '../theming/definition'; | ||
@use '../theming/inspection'; | ||
@use '../theming/m2-inspection'; | ||
@use '../theming/palettes'; | ||
@use '../style/sass-utils'; | ||
|
@@ -322,6 +323,11 @@ | |
// Unlike M3's `mat.theme()`, this mixin does not replace the need to call | ||
// individual component theme mixins for Angular Material components. | ||
@mixin m2-theme($theme-config, $overrides: ()) { | ||
@if inspection.get-theme-version($theme-config) == 1 { | ||
@error '`m2-theme` mixin should only be called for M2 theme ' + | ||
'configs created with define-light-theme or define-dark-theme'; | ||
} | ||
|
||
$config: m2-inspection.get-m2-config($theme-config); | ||
|
||
$color: map.get($config, color); | ||
|
@@ -350,6 +356,18 @@ | |
|
||
@include _define-m2-system-vars(m2.md-sys-shape-values(), $overrides); | ||
@include _define-m2-system-vars(m2.md-sys-state-values(), $overrides); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the icon button? Yeah unfortunately. I thought about adding a modification in icon-button's theme mixin but that introduces the same sort of issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we at least have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh this is specifically an M2-only mixin, different entirely from the implementation for This mixin explicitly takes an M2 theme config and is meant to convert that to system CSS vars. I don't expect M3 apps to ever call this |
||
// The icon button's color token is set to `inherit` for M2 and intended to display | ||
// the color inherited from its parent element. This is crucial because it's unknown | ||
// whether the icon button sits on a container with background like "surface" or "primary", | ||
// where both may have different contrast colors like white or black. | ||
// However, variables set to inherit AND define a fallback will always use the fallback, | ||
// which is "on-surface-variant". This mixin now defines this value. | ||
// To avoid this, and continue using `inherit` for the icon button color, set the color explicitly | ||
// to the token without a fallback. | ||
.mat-mdc-button-base.mat-mdc-icon-button:not(.mat-mdc-button-disabled) { | ||
color: var(--mat-icon-button-icon-color); | ||
} | ||
} | ||
|
||
@mixin _define-m2-system-vars($vars, $overrides) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have this if there's also another theme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only defines the system vars - I'd like to make a dev-app page that shows all the variables and this makes that work for both M2 and M3. This mixin, unlike M3, isn't meant to be a replacement for the individual component mixins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus this helps validate that nothing changes on the site if it's included. This is how I found the issue with the icon button's styles.
Part of this is to encourage people to use this mixin and use systems vars instead of our m2 APIs to pull from the theme config. If we find an issue in the dev-app from this, we should fix it