heybourn / headwind

An opinionated Tailwind CSS class sorter built for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=heybourn.headwind
MIT License
1.38k stars 46 forks source link

Support `class` tag while using a JS string #101

Closed deadcoder0904 closed 3 years ago

deadcoder0904 commented 3 years ago

Is your feature request related to a problem? Please describe. I'm using Remark to style a table in Tailwind. I can't style it directly as my table is in markdown so I have to use Remark as an intermediary step to do it.

I have an array which contains table tag & I keep pushing tr, th, etc... onto it like:

const str = []
str.push(`<table class="table-fixed max-w-7xl full-bleed md:mx-12 divide-y divide-gray-200">`)
str.push(`<thead class="">`)
str.push(`<tr class="">`)
str.push(`<th class="px-6 py-3 bg-gray-50 text-left text-2xl font-semibold text-blue-gray-700 tracking-wider">${k}</th>`)

Describe the solution you'd like I'd love for Headwind to sort classes in JS files too where a string uses class tag.

petertriho commented 3 years ago

@deadcoder0904 this can be done by adding this to your settings.json

"headwind.classRegex": {
        "javascript": "(?:\\bclass(?:Name)?\\s*=\\s*[\\\"\\']([_a-zA-Z0-9\\s\\-\\:\\/]+)[\\\"\\'])|(?:\\btw\\s*`([_a-zA-Z0-9\\s\\-\\:\\/]*)`)"
    }
deadcoder0904 commented 3 years ago

Good to know :)

petertriho commented 3 years ago

Fixed in https://github.com/heybourn/headwind/pull/109