-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Let's hack <style>
#3
Comments
I love it |
or maybe interpolation like <style scoped>
h1 {
color: {{ color }};
font-size: {{ fontSize * 2 }};
}
</style> ? Edit: Not friendly for editors since it is invalid css |
@IniZio I thought about that, but that's invalid CSS so editor may report errors. |
Guess eval is the way to go then 🤔 |
I like this concept. I'm way more willing to adopt this method if I can continue using the style block in my SFCs. Perhaps setting a new type will help make it more obvious to fresh eyes on the project what's going on too. Like |
What do you think about auto-injection of css variables? In: <template>
<h1>hello</h1>
</template>
<script>
export default {
props: ['color', 'size'],
data: () => ({ bgColor: 'red' }),
computed: { fontSize() { return this.size + 'px'; } },
}
</script>
<style scoped>
h1 {
color: var(--vm-color);
font-size: var(--vm-fontSize);
background-color: var(--vm-bgColor);
}
</style> Out: <template>
<h1 :style="{'--vm-color': color, '--vm-fontSize': fontSize, '--vm-bgColor': bgColor}">hello</h1>
</template>
<script>
export default {
props: ['color', 'size'],
data: () => ({ bgColor: 'red' }),
computed: { fontSize() { return this.size + 'px'; } },
}
</script>
<style scoped>
h1 {
color: var(--vm-color);
font-size: var(--vm-fontSize);
background-color: var(--vm-bgColor);
}
</style> |
In:
Out:
The text was updated successfully, but these errors were encountered: