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

bug(theme): promlem with css var calculation #28621

Closed
1 task
feichin-noreja opened this issue Feb 20, 2024 · 4 comments
Closed
1 task

bug(theme): promlem with css var calculation #28621

feichin-noreja opened this issue Feb 20, 2024 · 4 comments
Labels
needs triage This issue needs to be triaged by the team

Comments

@feichin-noreja
Copy link

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

If i define a css var with the value of a css var like in the code snippet below some material css variables are not defined correctly.
E.g. --mdc-linear-progress-track-color is set to var(--primary-500) but should be converted to a rgba color with 0,25 opacity.

That causes the theme to have some bad behaviour.

`:root{
--primary-500: #FF0000
}

$primary:(
500: var(--primary-500)
)
`

Reproduction

StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-d9ccxk

Expected Behavior

The css var should be handled like a hex value

Actual Behavior

The css var is copied

Environment

  • Angular: 17.2
  • CDK/Material: 17.2
  • Browser(s): Edge
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 11
@feichin-noreja feichin-noreja added the needs triage This issue needs to be triaged by the team label Feb 20, 2024
@Blafasel3
Copy link

Upvote, I experienced this today when updating to material v16 as well. Really annoying in combination with #26056 (comment), because of this bug I have to hard copy values out of my custom palette in order to fix the aforementioned bug. Workaround inception which gets really hard to maintain.

@crisbeto
Copy link
Member

Palettes based on CSS variables were never supported, see #25981 (comment). Instead of creating a palette with CSS variables that are initialized to colors, you can pass those colors directly to the palette and it'll create variables for you. This specific case can also be worked around with .mdc-linear-progress__buffer-bar { opacity: 0.25 }, but there's no guarantee other places won't have a similar issue.

@feichin-noreja
Copy link
Author

@crisbeto can you update the https://material.angular.io/guide/theming page so that is clear that the Palettes dont "understand" css vars?

The better solution for us would be if the material theme supported css variables.

@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 Mar 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

3 participants