kjsuikit/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitTooltipModifier.kt

48 lines
1.2 KiB
Kotlin
Raw Normal View History

2022-01-12 13:58:52 +00:00
package dev.inmo.jsuikit.modifiers
2021-12-22 08:38:12 +00:00
import dev.inmo.jsuikit.utils.buildAttribute
2021-12-22 08:38:12 +00:00
class UIKitTooltipModifier(
text: String,
align: Align? = null,
delay: Int? = null,
offset: Int? = null,
duration: Int? = null,
animation: UIKitAnimation? = null
) : UIKitModifier {
override val otherAttrs: Map<String, String> = mapOf(
buildAttribute("uk-tooltip") {
"title" to text
align ?.let { it.k to it.v }
delay ?.let { "delay" to it.toString() }
offset ?.let { "offset" to it.toString() }
duration ?.let { "duration" to it.toString() }
animation ?.let { "animation" to it.name }
}
2021-12-22 08:38:12 +00:00
)
sealed class Align(name: String) {
val k = "pos"
val v = name
sealed class Top(suffix: String) : Align("top$suffix") {
object Center : Top("")
object Left : Top("-left")
object Right : Top("-right")
}
sealed class Bottom(suffix: String) : Align("bottom$suffix") {
object Center : Bottom("")
object Left : Bottom("-left")
object Right : Bottom("-right")
}
object Left : Align("left")
object Right : Align("right")
}
}