Hello people! I’ll go straight to the point :smile...
# compose-web
t
Hello people! I’ll go straight to the point 😄 I use the following code for CSS variables.
Copy code
object BoardCssVariable {
    val translateOrigin by variable<StylePropertyString>()
}
The current examples are use it in something like
Copy code
object BoardSheet : StyleSheet() {
    val container by style {
        BoardCssVariable.translateOrigin("translateY(-150%)")
        property("transform", BoardCssVariable.translateOrigin.value())
    }
}
But that’s not really useful. I want to change its value depending on some logic. So I ended up doing
Copy code
Div({
    style {
        if (myCondition) {
          property(BoardCssVariable.translateOrigin.name, "translateY(-150%)")
        }
    }
}) {}
Is there some ideas to make it more pleasant? Maybe Compose for web could get some handy features via the compiler, some kind of CSS runtime like Emotion? Of course, it is not blocking. Just curious to know what will be the team’s take on that 🙂 Maybe I could have done something like
Copy code
Div({
    classes(BoardSheet.container("translateY(-150%)"))
}) {}
and under the wood, the compiler would have done what I manually did. I don’t know 🤷
a
Yes, we have plans to improve this experience. I think it will be much more handy.
🙏 1