What is the css DSL counter part of the following ...
# ktor
a
What is the css DSL counter part of the following css?
Copy code
@font-face {
    src: url("/fonts/Urbanist.ttf");
    font-family: urbanist;
}
So far I got:
Copy code
call.respondCss {
    fontFace {
        fontFamily = "urbanist"
    }
}
but I cannot find a way to populate the src value. (also, please let me know if this is not the right place to ask this)
🙏 1
Couldn’t find a way to do it so I created (copy-pasted) my own CssProperty. Seems to be working
Copy code
var StyledElement.src: String by CssProperty()

// copy pasted in my file to be accessible
private class CssProperty<T>(private val default: (() -> T)? = null) {
    operator fun getValue(thisRef: StyledElement, property: KProperty<*>): T {
        default?.let { default ->
            if (!thisRef.declarations.containsKey(property.name)) {
                thisRef.declarations[property.name] = default() as Any
            }
        }

        @Suppress("UNCHECKED_CAST")
        return thisRef.declarations[property.name] as T
    }

    operator fun setValue(thisRef: StyledElement, property: KProperty<*>, value: T) {
        thisRef.declarations[property.name] = value as Any
    }
}
m
wow, so you had to copy CssProperty, which is private in Ktor, and modify it to your needs? If you think this is a missing feature you should open a PR to Ktor.
a
I suggest filing an issue to the kotlin-wrappers repository.
💯 1
a
Fixed already