https://kotlinlang.org logo
#javascript
Title
# javascript
j

Jon Shemitz

12/13/2023, 11:08 PM
I'm experimenting with Kotlin/JS, building a web toy. All the pure-Kotlin logic works fine (though unit testing is slower than on JVM, and it can't locate the lines that throw exceptions) and the HTML DSL was easy to pick up and extend, so long as I was just using old, old HTML - tables, divs, spans, and the like. But I can't seem to get more 'modern' CSS to work at all! I'm trying to specify a transition. My expectation is that within a
css {}
block, I should either be setting
transition
or be setting
transitionProperty
+
transitionDuration
. But while the
css.transition
property is a
Transition?
, clicking through to the
Transition
source shows it as a
sealed external interface
, not a class with constructor parameters. Similarly, I'd like to set a gradient background. Again, I expect that I should set
backgroundImage
within a
css {}
block, but
BackgroundImage
is also coming up as a
sealed external interface
. Should these features be working as I expect, or are they still works in progress? Is it possible that my project configuration needs some tweaking? (The libraries do include Gradle:
org.jetbrains.kotlin-wrappers:kotlin-csstype:klib:3.1.0-pre.3462
.)
a

Artem Kobzar

12/14/2023, 10:01 AM
@turansky ^^
t

turansky

12/14/2023, 12:24 PM
For complex values we have factory functions. For
Transition
we have 3 factories with same name.
j

Jon Shemitz

12/14/2023, 5:03 PM
Thank you, @turansky, that makes sense. Is there any documentation that would tell me the names of these factory functions? Or is there an
import
I should add that would let IDEA auto-suggest these functions?
t

turansky

12/14/2023, 8:52 PM
Main rule - we have safe factory functions for all.
asDynamic
and
unsafeCast
aren't required.
For complex values, like
Transition
- functions we same name name. For CSS functions, like
url
- functions with same name. For primitives and array like functions we provide:
string
,
integer
,
number
,
array
,
many
Predefined constant:
Auto.auto
None.none
and more. And it's parent types of interface, which you need. For example you can use constants from
PropertyName
for
TransitionProperty
3 Views