diff options
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html/Link.kt')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Link.kt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt new file mode 100644 index 00000000..e201da48 --- /dev/null +++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt @@ -0,0 +1,26 @@ +package pl.treksoft.kvision.html + +import com.github.snabbdom.VNode +import pl.treksoft.kvision.core.Container +import pl.treksoft.kvision.snabbdom.StringPair + +open class Link(label: String, url: String, classes: Set<String> = setOf()) : Container(classes) { + var label = label + set(value) { + field = value + refresh() + } + var url = url + set(value) { + field = value + refresh() + } + + override fun render(): VNode { + return kvh("a", arrayOf(label) + childrenVNodes()) + } + + override fun getSnAttrs(): List<StringPair> { + return super.getSnAttrs() + ("href" to url) + } +} |