stivoat / tailwind-fold

Visual Studio Code extension that improves code readability by folding long class attributes
https://marketplace.visualstudio.com/items?itemName=stivo.tailwind-fold
MIT License
121 stars 23 forks source link

Ability to hide classes defined using curly braces #30

Closed milindgoel15 closed 8 months ago

milindgoel15 commented 10 months ago

Sometimes we have to define classes using curly braces instead of just quotes when we have to merge some classes that are conditionally rendered. For example:


className={`some class here ${some condition based class here}`}
OR
className={cn(
               "some class here",
               some condition based class here
            )}

The first one works randomly. I think if there are lots of classes and the prettier has moved the ending bracket to next line, the extension fails to fold.

example: image

Etsi0 commented 9 months ago

+1 it would be nice if they could make it fold into something like this:

className={...}
Etsi0 commented 9 months ago

i think this would fix it:

/(class|className)=(['"`]|{)(.*?)(\2|})/g