Open moisesbites opened 2 years ago
I solved using this:
<script>
import Processor from 'windicss';
const processor = new Processor();
function windi(strings, ...values) {
const str = strings.reduce((query, queryPart, i) => {
const valueExists = i < values.length;
const text = query + queryPart;
return valueExists ? text + values[i] : text;
}, '');
const result = processor.interpret(str);
return result.styleSheet.children
.map((child) => {
return child.property.map((p) => `${p.name}: ${p.value}${p.important ? '!important' : ''};`).join('');
})
.join('');
}
</script>
<span style="{windi`${$$props.class}`}">some text</span>
That is actually the expected behavior.
I can see if i can improve that in an future update, but no promise!
@alexanderniebuhr Thank you very much.
For while, I'm using that function to solve this Issue, but if there was a more elegant way to solve this automatically, it would be much appreciated.
@moisesbites I wrote a preprocessor to overcome this challenge: https://www.npmjs.com/package/svelte-deep-wind-preprocess
@moisesbites I wrote a preprocessor to overcome this challenge: https://www.npmjs.com/package/svelte-deep-wind-preprocess
Thank you. I will try. Please, it would be interesting to correct the github project reference in the https://www.npmjs.com/package/svelte-deep-wind-preprocess.
@moisesbites I wrote a preprocessor to overcome this challenge: https://www.npmjs.com/package/svelte-deep-wind-preprocess
Thank you. I will try. Please, it would be interesting to correct the github project reference in the https://www.npmjs.com/package/svelte-deep-wind-preprocess.
Sorry about that. I had to do some refactoring first - the code now lives at https://github.com/jacob-8/svelte-deep-wind-preprocess
Describe the bug
When using $$props.class in a component, the windicss classes is not working inside the component:
Fo example, in the
page
:In the
SomeComponent
:The text would be blue-700 but is not working. But if I put inside the component the same windicss class I'm passing into in another snippet of page , the classes work correctly in both texts. For example:
In the
SomeComponent
:System Info
Used Package Manager
npm