Remove named opacity support for color opacity modifiers#14278
Merged
Conversation
RobinMalfait
approved these changes
Sep 2, 2024
adamwathan
approved these changes
Sep 2, 2024
thecrypticace
added a commit
that referenced
this pull request
Sep 4, 2024
We removed named opacity modifier support in #14278 but we (read: me lol) totally forgot about the suggestions in intellisense. So we need to make sure that we don't suggest those either.
|
Is there any chance we could see support for named alpha values, maybe under a different theme key like |
philipp-spiess
added a commit
that referenced
this pull request
Nov 15, 2024
This PR reverts #14278 to bring back support for using named opacity values in color opacity modifiers: ```css @theme { --opacity-myOpacity: 50%; } ``` ```html <div class="bg-red-500/myOpacity"></div> ``` We briefly discuss to restructure the code so that we avoid adding a `theme` argument to the call sites but I do still prefer the current approach for the following reasons: The way to avoid this is to a) put something in either the `Theme` class scope, where it feels grossly out of place, or b) put it into the shared closure in the utilities file which is already very large and hard to reason. Furthermore, there's a second call site in the compile function where we would need to duplicate the namespace lookup. Every caller of the current `asColor` value already has access to the `Theme` so passing that as an argument seems like the least intrusive way. ## Test Plan Brought back the unit tests but I also tested it with the Vite extension: <img width="744" alt="Screenshot 2024-11-15 at 11 15 05" src="https://github.com/user-attachments/assets/63923b80-767e-4104-b7eb-f71fc815b51e"> --------- Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Right now if you have a custom opacity theme value configured like this…
…then you can use that named opacity value as a color opacity modifier like this:
We think this behavior is confusing. The color opacity modifier is not setting opacity but the alpha value of a color. Opacity is for setting the opacity of an element, so the custom names you'd come up with are named after those situations, which makes them not seem appropriate for color modifiers.