Add API for custom component theming with M3 #27617
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A new API for this is necessary because the existing APIs (e.g.
mat.get-color-from-palette
) require the user to have some knowledge of how the theme object is structured. With the M3 theme objects, we made he decision that the theme object structure should be opaque to the user.I will do a followup PR to add support for using the same API to access values from M2 theme objects. This will allow users to move their custom components on to the new API before updating to use an M3 theme.
With the new theming APIs, I'm focusing on trying to catch common errors a user might make and report helpful error messages rather than the
$map: null is not a map
errors that our previous APIs often threw. I've added tests to cover these error cases as well as the expected cases.I'm introducing the APIs as private in this PR, but will do a followup once they have M2 theme support to make them public.