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(COMPONENT): Global Color Specific CSS Generation using Design Tokens #30022

Open
fireflysemantics opened this issue Nov 14, 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

@fireflysemantics
Copy link

fireflysemantics commented Nov 14, 2024

Feature Description

Currently when we want to generate different themes we scope the classes to the specific themes by nesting the theme css generation within a scope block.

.dark-theme {
   /// Dark theme CSS generation
}

html {
   /// Light theme (Default) CSS generation
}

And this will duplicate the generation of classes that change color, and with the old way of doing it this made sense because we used SASS getters to retrieve color from the theme palette.

When using the Material Design Tokens (CSS Variables) this becomes unnecessary, because the selector context ( .light {}, .dark {}` and so on ... ) decides what CSS are applicable.

And so any CSS that depends on color design tokens only needs to be generated once.

So Angular Material can split of structural classes and generate those within a specific scope block if necessary ( If a different theme implies a different structure), while only generating color specific CSS one time.

Use Case

Application Size Optimization. The CSS Bundles will be smaller.

Notes

This is a slightly tricky concept, so for anyone curious about this here's a minimal demo.

https://stackblitz.com/edit/stackblitz-starters-j3ncju?file=package.json

When the .dark class is applied to the main element it changes the background of the div.

@fireflysemantics fireflysemantics 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 Nov 14, 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