Skip to content

fix(material/checkbox): refactor to depend on @angular/material/core/tokens #26744

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

Merged
merged 7 commits into from
Mar 20, 2023

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Mar 7, 2023

No description provided.

@mmalerba mmalerba added the target: minor This PR is targeted for the next minor release label Mar 7, 2023
@mmalerba mmalerba requested a review from devversion as a code owner March 7, 2023 22:04
@mmalerba mmalerba force-pushed the mdc-checkbox-tokens branch 3 times, most recently from 3fc744e to 11be168 Compare March 7, 2023 22:21
@mmalerba mmalerba requested a review from andrewseguin as a code owner March 7, 2023 22:21
@mmalerba mmalerba force-pushed the mdc-checkbox-tokens branch 3 times, most recently from 2f3019c to 77d5150 Compare March 8, 2023 21:44
@include _selected-ripple-colors($primary, primary);
}
&.mat-primary {
$primary-config: map.merge($config, (accent: $primary));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand why we're passing in a primary palette into a key called accent here and in the warn theme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our .mat-primary, .mat-accent, .mat-warn classes don't really fit well with the token-based theming. There aren't separate tokens for e.g. checkbox-color-when-primary, checkbox-color-when-accent. Instead I set up the tokens to draw their values from the default flavor of checkbox (accent). In order to still support the .mat-primary and .mat-warn, I just call get-color-tokens passing the desired palette as the accent palette to get the styles we want.

Ultimately I think we'll want to deprecate and remove the class based theming, but this seemed like a decent solution for now

@include mdc-helpers.disable-mdc-fallback-declarations {
@include mdc-checkbox-theme.theme-styles(checkbox-private.$private-checkbox-theme-config);
}
.mdc-checkbox__native-control:focus {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it seems like the & ~ .mdc-checkbox__ripple and & ~ .mat-mdc-checkbox-ripple .mat-ripple-element are repeated a few times. Maybe we can clean this up a bit with a mixin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try to extract it, but I felt like it just made the code harder to reason about. I'll give it another try to see if I can come up with something that actually simplifies it instead of just making it harder to follow.

I think the real solution to this is to just do what MDC exepcts w.r.t. the state layer and stop trying to do our own thing. Then we can remove all this code and rely on the MDC mixin

@wagnermaciel wagnermaciel added the action: merge The PR is ready for merge by the caretaker label Mar 19, 2023
@crisbeto crisbeto added the merge: fix commit message When the PR is merged, rewrites/fixups of the commit messages are needed label Mar 20, 2023
@crisbeto
Copy link
Member

Merging this one in as discussed over DM.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker merge: fix commit message When the PR is merged, rewrites/fixups of the commit messages are needed target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants