Skip to content

refactor: remove badge component token values from theme #31099

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 1 commit into from
May 13, 2025

Conversation

andrewseguin
Copy link
Contributor

@andrewseguin andrewseguin commented May 12, 2025

Refactors the M3 theme config so that it contains system-level values (colors, typography, density, shape, motion, state, elevation) so that component M3 token files can be given the theme config to derive its values.

Previously, M3 token files were used to insert values into the theme config directly when the theme config was created. When a component's theme mixin was called, those values were used. This indirection is difficult to follow in the code, making it unclear when values were created and how they are pulled, because the theme files were not actually calling the m3 token files.

mat.define-theme() -> m3-badge.get-tokens($system) -> $theme
...
mat.badge-theme($theme) -> map.get($theme, tokens) -> token-utils.create-token-values($tokens)

This change makes the flow very clear: a theme config is created with some system values, and then the token file is directly called from the theme config.

mat.define-theme() -> $theme
...
mat.badge-theme($theme) -> m3-badge.get-tokens($theme) -> token-utils.create-token-values($tokens)

This also clears up the mapping with variant colors, which were also inserted in the theme config in an unintuitive way. Instead, we can just perform a simple string replacement, e.g. secondary instead of primary.

The change is performed for badge to show how it will be done with the remaining components. Once that is complete, a lot of cleanup can occur to remove unnecessary flows and mixins.

@andrewseguin andrewseguin added the target: patch This PR is targeted for the next patch release label May 12, 2025
@andrewseguin andrewseguin marked this pull request as ready for review May 12, 2025 19:54
@andrewseguin andrewseguin requested review from a team as code owners May 12, 2025 19:54
@andrewseguin andrewseguin added target: rc This PR is targeted for the next release-candidate and removed target: patch This PR is targeted for the next patch release labels May 12, 2025
@andrewseguin andrewseguin added the action: merge The PR is ready for merge by the caretaker label May 13, 2025
@andrewseguin andrewseguin force-pushed the direct-m3-tokens-pt1 branch from 4cbb5a3 to c5cb560 Compare May 13, 2025 03:26
@andrewseguin andrewseguin force-pushed the direct-m3-tokens-pt1 branch from c5cb560 to 128b2e0 Compare May 13, 2025 03:29
@andrewseguin andrewseguin merged commit 936d179 into angular:main May 13, 2025
20 of 22 checks passed
@andrewseguin
Copy link
Contributor Author

The changes were merged into the following branches: main, 20.0.x

andrewseguin added a commit that referenced this pull request May 13, 2025
Co-authored-by: Andrew Seguin <andrewseguin@google.com>
(cherry picked from commit 936d179)
@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 Jun 13, 2025
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 target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants