We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This must not be resolved before the initial release.
Twind recommends using template literal syntax as it allows advanced caching. Is it possible to transform arrays to a template literal call of tw?
<div tw={['bg-gray-200', true && 'rounded', { hover: ['bg-red-500', 'p-3'] }, 'underline']}></div> // => tw`bg-blue-500 ${true && 'rounded'} ${{ hover: ['bg-red-500', 'p-3'] }} underline`
That would mean all strings are converted to template elements and non-strings are interpolations values (see astexplorer).
This would should work for static strings as well:
<div tw="bg-gray-200 rounded"></div> // => tw`bg-gray-200 rounded`
If the tw attribute value is already a template literal that could be used as is:
<div tw={`bg-blue-500 ${true && 'rounded'} ${{ hover: ['bg-red-500', 'p-3'] }} underline`}></div> // => tw`bg-blue-500 ${true && 'rounded'} ${{ hover: ['bg-red-500', 'p-3'] }} underline`
For non-array and non-string tw attribute values i would recommend to call tw with the value as is.
<div tw={{ 'bg-gray-200': true, rounded: false, underline: isTrue() }}></div> // => tw({ 'bg-gray-200': true, rounded: false, underline: isTrue() })
What to you think @itsMapleLeaf ?
The text was updated successfully, but these errors were encountered:
Yep, this can be done. Anyone else is welcome to pick this up before I do. I'll say if/when I can get to it
Sorry, something went wrong.
Most of this is done as of v1.0.1, only missing this case:
v1.0.1
<div tw={['bg-gray-200', true && 'rounded', { hover: ['bg-red-500', 'p-3'] }, 'underline']}></div> // currently: // => tw`${'bg-blue-500'} ${true && 'rounded'} ${{ hover: ['bg-red-500', 'p-3'] }} ${'underline'}` // desired: // => tw`bg-blue-500 ${true && 'rounded'} ${{ hover: ['bg-red-500', 'p-3'] }} underline`
itsMapleLeaf
No branches or pull requests
Twind recommends using template literal syntax as it allows advanced caching. Is it possible to transform arrays to a template literal call of tw?
That would mean all strings are converted to template elements and non-strings are interpolations values (see astexplorer).
This would should work for static strings as well:
If the tw attribute value is already a template literal that could be used as is:
For non-array and non-string tw attribute values i would recommend to call tw with the value as is.
What to you think @itsMapleLeaf ?
The text was updated successfully, but these errors were encountered: