(I'm doing a spike to see if a css-in-js solution ...
# javascript
k
(I'm doing a spike to see if a css-in-js solution with a babel-transform step will work for a Kotlin web app)
f
Which solution do you mean, namely? Currently, KotlinJS can't output anything other than ES5 code
k
Ahh, that would explain why I can't use backticks in my
js()
calls 😞
I'm trying to use Linaria or Emotion which rely on a syntax like:
Copy code
css`
  background: red;
`
and this kotlin line errors at compile because of the backticks:
Copy code
js("css`background: red;`")
f
do you use interpolations inside it?
that is,
${expression}
k
Not always. It is just a syntax needed for the babel transform to strip out the css and create a classname
f
When you don't, you can just call it like a function
Copy code
css(Array("""
  background: red;
"""))
triple double quotes are for multiline strings in Kotlin
k
Hmm, oh, nice!
f
With interpolations, it would be a lot more tricky
k
I'll try that right now. 1 min, please.
f
Oh, it should be an array not a string
k
Ah, yeah, unfortunately, I still need it to output from kotlin to js with the backticks.
See https://github.com/callstack/linaria for the syntax required for the babel transform
f
@bashor is there a plan to support targets other than ES5?
k
Thanks for your help, @Filipp Riabchun!
b
is there a plan to support targets other than ES5?
Yes, but only after we will finish migrating to the new compiler infrastructure. Not very soon.
Feel free to vote or star the related issue to get notification about updates https://youtrack.jetbrains.com/issue/KT-8373
k
Thanks, will do! For now I'll hope to use Kotlinjs to share business logic, but likely not be able to use it in any React/View code 😢
f
Well you can have part of your codebase in js and part in Kotlin
k
Yeah. Hopefully all in Kotlin some day 🙂
b
I think JS css will look strange inside Kotlin code. I think it would be better to implement DSL in Kotlin.