-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Resolve values in functional utilities based on @theme
options
#15623
Resolve values in functional utilities based on @theme
options
#15623
Conversation
line-height: var(--text-xs--line-height); | ||
line-height: 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this change, we also generated 2 line-height
declarations, but Lightning CSS collapsed it. However, now that one is generating a variable, Lightning CSS is not optimizing it.
E.g.:
- Before: https://lightningcss.dev/playground/index.html#%7B%22minify%22%3Afalse%2C%22customMedia%22%3Atrue%2C%22cssModules%22%3Afalse%2C%22analyzeDependencies%22%3Afalse%2C%22targets%22%3A%7B%22chrome%22%3A6225920%7D%2C%22include%22%3A0%2C%22exclude%22%3A0%2C%22source%22%3A%22.foo%20%7B%5Cn%20%20font-size%3A%20.75rem%3B%5Cn%20%20line-height%3A%208%3B%5Cn%20%20line-height%3A%206%3B%5Cn%7D%22%2C%22visitorEnabled%22%3Afalse%2C%22visitor%22%3A%22%7B%5Cn%20%20Color(color)%20%7B%5Cn%20%20%20%20if%20(color.type%20%3D%3D%3D%20'rgb')%20%7B%5Cn%20%20%20%20%20%20color.g%20%3D%200%3B%5Cn%20%20%20%20%20%20return%20color%3B%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%22%2C%22unusedSymbols%22%3A%5B%5D%2C%22version%22%3A%22local%22%7D
- After: https://lightningcss.dev/playground/index.html#%7B%22minify%22%3Afalse%2C%22customMedia%22%3Atrue%2C%22cssModules%22%3Afalse%2C%22analyzeDependencies%22%3Afalse%2C%22targets%22%3A%7B%22chrome%22%3A6225920%7D%2C%22include%22%3A0%2C%22exclude%22%3A0%2C%22source%22%3A%22.foo%20%7B%5Cn%20%20font-size%3A%20.75rem%3B%5Cn%20%20line-height%3A%20var(--foo)%3B%5Cn%20%20line-height%3A%206%3B%5Cn%7D%22%2C%22visitorEnabled%22%3Afalse%2C%22visitor%22%3A%22%7B%5Cn%20%20Color(color)%20%7B%5Cn%20%20%20%20if%20(color.type%20%3D%3D%3D%20'rgb')%20%7B%5Cn%20%20%20%20%20%20color.g%20%3D%200%3B%5Cn%20%20%20%20%20%20return%20color%3B%5Cn%20%20%20%20%7D%5Cn%20%20%7D%5Cn%7D%22%2C%22unusedSymbols%22%3A%5B%5D%2C%22version%22%3A%22local%22%7D
@@ -4854,8 +4854,35 @@ function resolveValueFunction( | |||
arg.value[0] === '-' && | |||
arg.value[1] === '-' | |||
) { | |||
let resolved = designSystem.resolveThemeValue(arg.value.replace('*', value.value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolveThemeValue
is fully resolving the value because we passed it a value like --text-sm--line-height
.
Instead, we should use the resolveWith
in case of nested keys.
@theme
options
This PR fixes an issue where functional utilities configured via CSS don't resolve the values correctly.
We always fully resolved the values as-if a
@theme inline
was used.We used to compile the following code:
Into:
But it should be referencing the variable instead:
However, if you used
@theme inline reference
, it should inline the value:This will now correctly compile to: