This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
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.
This is a work in progress. I'd like to see if this is a reasonable approach or if there are better ideas.
My first thought was to turn candidates (conditionally) into RegExp objects and match the utilities against them. That would be pretty powerful. Unfortunately the idea that a candidate is a string is pretty pervasive and also core to how matchUtilities, modifiers, and what not all work. For them to be regular expressions we'd have to generate all the classes in the tailwind config up front in memory and then match against the generated list.
My second thought was to add support for wildcards in asValue() but that would require supporting multiple return values — which for a prototype would be a significant change across all plugins just to not break something.
So end the end I settled with giving plugins the ability to explicitly register wildcard support. When you call a plugin you can say
matchWildcards({ px: ['0', '1', '2', '3', …], …})
and when it findsp-{*}
when resolving matches it expands to p-1, p-2, p-3, p-4, etc…Due to implementation it includes duplicate utilities if you do
p-{*}
andp-1
/p-2
/ etc… I need to find a way to clean this up / fix it but I wanted to get the reactions to the general approach first.I've added wildcard support to the padding plugin only in this draft.