aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/snabbdom
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/snabbdom')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt b/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt
index 789417e6..3bf68003 100644
--- a/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt
@@ -1,6 +1,11 @@
package pl.treksoft.kvision.snabbdom
-import com.github.snabbdom.*
+import com.github.snabbdom.Attrs
+import com.github.snabbdom.Classes
+import com.github.snabbdom.On
+import com.github.snabbdom.Props
+import com.github.snabbdom.VNodeData
+import com.github.snabbdom.VNodeStyle
import pl.treksoft.kvision.core.Widget
external class Object
@@ -10,16 +15,16 @@ fun obj(init: dynamic.() -> Unit): dynamic {
}
@Suppress("UnsafeCastFromDynamic")
-private fun VNodeData(): VNodeData = js("({})")
+private fun vNodeData(): VNodeData = js("({})")
interface SnOn<T> : On {
var self: T
}
-fun snOpt(block: VNodeData.() -> Unit) = (VNodeData()::apply)(block)
+fun snOpt(block: VNodeData.() -> Unit) = (vNodeData()::apply)(block)
@Suppress("UnsafeCastFromDynamic")
-internal fun On(widget: Widget): SnOn<Widget> {
+internal fun on(widget: Widget): SnOn<Widget> {
val obj = js("({})")
obj["self"] = widget
return obj
@@ -29,28 +34,28 @@ typealias StringPair = Pair<String, String>
typealias StringBoolPair = Pair<String, Boolean>
@Suppress("UnsafeCastFromDynamic")
-fun snStyle(vararg pairs: StringPair): VNodeStyle {
+fun snStyle(pairs: List<StringPair>): VNodeStyle {
return obj {
pairs.forEach { (key, value) -> this[key] = value }
}
}
@Suppress("UnsafeCastFromDynamic")
-fun snProps(vararg pairs: StringPair): Props {
+fun snProps(pairs: List<StringPair>): Props {
return obj {
pairs.forEach { (key, value) -> this[key] = value }
}
}
@Suppress("UnsafeCastFromDynamic")
-fun snClasses(vararg pairs: StringBoolPair): Classes {
+fun snClasses(pairs: List<StringBoolPair>): Classes {
return obj {
pairs.forEach { (key, value) -> this[key] = value }
}
}
@Suppress("UnsafeCastFromDynamic")
-fun snAttrs(vararg pairs: StringPair): Attrs {
+fun snAttrs(pairs: List<StringPair>): Attrs {
return obj {
pairs.forEach { (key, value) -> this[key] = value }
}