-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
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
class="$$props.class" is not working, but would be good to have a function to solve this: #422
Comments
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 |
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
The text was updated successfully, but these errors were encountered: