aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-09-03 02:40:21 +0200
committerRobert Jaros <rjaros@finn.pl>2017-09-03 02:40:21 +0200
commitc056275c522db3f2f391ce44a405da0cedae60ca (patch)
tree2fe29b341182223b20bc50fd0909e94f6e7641ef /src/main/kotlin/pl/treksoft/kvision/html/Link.kt
parent64e2bca354a1eb6018086427365336c3acb75cb8 (diff)
downloadkvision-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.kt26
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)
+ }
+}