You can add a new class and extension method like this
Copy code
class ThemeColorValue(private val colorKey: String): CSSColorValue {
override fun toString(): String = "var(--$colorKey)"
}
fun CSSBuilder.borderColor(color: CSSColorValue) {
property("border-color", color)
}
m
Morten Minke
04/29/2023, 10:33 AM
Good one, I can give that a shot. It does however implicitly expect the users to the the toString to evaluate the correct value.
Would be nice if the CSS properties somehow have a generic way of dealing with the var functionality.
Something like
Copy code
color(var("--some-var"))
This would make it more 'supported' by Compose
t
Tuna
04/29/2023, 10:46 AM
I prefer small support and easy to extend rather than having everything.
thx Christian that was exactly what I was looking for!!!
d
David Herman
04/30/2023, 1:24 PM
@Morten Minke If you haven't gotten too far in your project, you might be interested in my project Kobweb. It's a layer built on top of Compose HTML and the css variable stuff came out clean I think: https://github.com/varabyte/kobweb#css-variables