diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-09-03 02:40:21 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-09-03 02:40:21 +0200 |
commit | c056275c522db3f2f391ce44a405da0cedae60ca (patch) | |
tree | 2fe29b341182223b20bc50fd0909e94f6e7641ef /src/main/kotlin/pl/treksoft/kvision/html/Link.kt | |
parent | 64e2bca354a1eb6018086427365336c3acb75cb8 (diff) | |
download | kvision-c056275c522db3f2f391ce44a405da0cedae60ca.tar.gz kvision-c056275c522db3f2f391ce44a405da0cedae60ca.tar.bz2 kvision-c056275c522db3f2f391ce44a405da0cedae60ca.zip |
Link widget
Tag, List, DropDown widget refactoring
Unit tests
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) + } +} |