aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html/Link.kt')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Link.kt55
1 files changed, 49 insertions, 6 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
index 83f03676..ad8897d5 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
@@ -1,30 +1,73 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
package pl.treksoft.kvision.html
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.ResString
-import pl.treksoft.kvision.panel.SimplePanel
import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.panel.SimplePanel
+/**
+ * Link component.
+ *
+ * @constructor
+ * @param label link label
+ * @param url link URL address
+ * @param icon link icon
+ * @param image link image
+ * @param classes a set of CSS class names
+ */
open class Link(
label: String, url: String, icon: String? = null, image: ResString? = null,
classes: Set<String> = setOf()
) : SimplePanel(classes) {
- private var label = label
+ /**
+ * Link label.
+ */
+ var label = label
set(value) {
field = value
refresh()
}
- private var url = url
+ /**
+ * Link URL address.
+ */
+ var url = url
set(value) {
field = value
refresh()
}
- private var icon = icon
+ /**
+ * Link icon.
+ */
+ var icon = icon
set(value) {
field = value
refresh()
}
- private var image = image
+ /**
+ * Link image.
+ */
+ var image = image
set(value) {
field = value
refresh()
@@ -32,7 +75,7 @@ open class Link(
override fun render(): VNode {
val t = createLabelWithIcon(label, icon, image)
- return kvh("a", t + childrenVNodes())
+ return render("a", t + childrenVNodes())
}
override fun getSnAttrs(): List<StringPair> {