-
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
Fix color object closures with gradients #2185
Fix color object closures with gradients #2185
Conversation
Have to figure out the best way to handle the If the user's color is configured as |
Currently regretting not passing in the whole alpha value as that would have let us just pass in |
I don't really understand this. I mean, I'd prefer to use the user's color instead of an arbitrary one for the transparent color too... but whatever value is given from the user won't change the result, right? It's going to be transparent, and the user has no way to change the opacity anyway? So, is it really a big deal? Either way, I can think of a solution to fix that. How about giving a new parameter, return value({
opacityVariable: `--gradient-${type}-opacity`,
opacityValue
})
The user should now configure it that way: primary: ({ opacityVariable, opacityValue }) => `rgba(var(--primary), var(${opacityVariable}, ${opacityValue}))` That would require a change in every place where And for what it's worth to you, I still think it was better to give only the variable name. I think it's more flexible that way. 👍 |
The problem is that this would generate the wrong output:
Check out the actual CSS for one of the
The So the only way I can think to fix this is to pass
|
I made some changes and merged, which you can see here: The summary is:
Thanks again for your help getting this working, going to publish this as a patch release as long as you don't see any remaining issues. |
I'm fine with your changes, it's a bit more complicated that what I was imagining, but the functionality is there so not gonna complain 👍 Thank you for your time! |
The problem is we'd have to invoke it like:
...because there is no variable for |
Yes, I edited out when I finally understood. I'm a bit slow. Thanks again 😅 |
This PR applies two fixes, both related to #1676.
Color object flatening
#1676 actually won't work at all (my bad 😢) until this is fixed, because
lodash
'sisObject
will return true if it is given a function. So, the condition had to be changed according to this information.New gradient stop plugin
This one won't just not work, but will crash if it encounters a closure. This is because the CSS is given the actual closure, so PostCSS will complain. Like, it will complain by crashing.
To fix that, the
value
variable needs to be checked. If it is a function, it needs to be executed. But that function will take an object with anopacityVariable
key as a parameter, and I thought it would be confusing to give it an empty value.So I also introduced new opacity variables. I'm not sure how useful it can be, nor if it should be only one variable, though.
.from-<color>
utilities, it is given--gradient-from-opacity
.via-<color>
utilities, it is given--gradient-via-opacity
.to-<color>
utilities, it is given--gradient-to-opacity
The variable name has been copied from the ones you used already, like
--gradient-from-color
.