Problem: difficult to match an arbitary number of strings e.g. className={clsx("flex items-center", error ? "bg-color-red-500 flex-col" : "bg-color-gray-100 flex-row")}. Current solution can only match the first string flex items-center
Solution: Adds the ability for headwind.classRegex values to be either a string regex (like it is currently, remains backwards compatible) or arrays of string regexes.
With arrays of regexes + recursion, we can use 2 regexes (1st regex matches className value and 2nd regex matches strings value inside the 1st regex values) e.g. 1st regex matches {clsx("flex items-center", error ? "bg-color-red-500 flex-col" : "bg-color-gray-100 flex-row")} and 2nd regex matches flex items-center, bg-color-red-500 flex-col and bg-color-gray-100 flex-row. The solution uses recursion so it theoretically could work any sized regex array.
Regex probably needs some work so that it'll work with more twin.macro scenarios but I believe I've covered most className scenarios
Problem: difficult to match an arbitary number of strings e.g.
className={clsx("flex items-center", error ? "bg-color-red-500 flex-col" : "bg-color-gray-100 flex-row")}
. Current solution can only match the first stringflex items-center
Solution: Adds the ability for
headwind.classRegex
values to be either a string regex (like it is currently, remains backwards compatible) or arrays of string regexes.With arrays of regexes + recursion, we can use 2 regexes (1st regex matches className value and 2nd regex matches strings value inside the 1st regex values) e.g. 1st regex matches
{clsx("flex items-center", error ? "bg-color-red-500 flex-col" : "bg-color-gray-100 flex-row")}
and 2nd regex matchesflex items-center
,bg-color-red-500 flex-col
andbg-color-gray-100 flex-row
. The solution uses recursion so it theoretically could work any sized regex array.Regex probably needs some work so that it'll work with more twin.macro scenarios but I believe I've covered most className scenarios