-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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 ?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request