diff options
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Button.kt | 13 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Link.kt | 17 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Tag.kt | 2 |
3 files changed, 18 insertions, 14 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt index 0fe2f559..74822401 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt @@ -1,7 +1,6 @@ package pl.treksoft.kvision.html import com.github.snabbdom.VNode -import pl.treksoft.kvision.core.KVManager import pl.treksoft.kvision.core.ResString import pl.treksoft.kvision.core.Widget import pl.treksoft.kvision.snabbdom.StringBoolPair @@ -63,17 +62,7 @@ open class Button(text: String, icon: String? = null, style: BUTTONSTYLE = BUTTO } override fun render(): VNode { - val t = if (icon != null) { - if (icon?.startsWith("fa-") == true) { - arrayOf(KVManager.virtualize("<i class='fa $icon fa-lg'></i>"), " " + text) - } else { - arrayOf(KVManager.virtualize("<span class='glyphicon glyphicon-$icon'></span>"), " " + text) - } - } else if (image != null) { - arrayOf(KVManager.virtualize("<img src='$image' alt='' />"), " " + text) - } else { - arrayOf(text) - } + val t = createLabelWithIcon(text, icon, image) return kvh("button", t) } diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt index e201da48..4f333482 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt @@ -2,9 +2,11 @@ package pl.treksoft.kvision.html import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Container +import pl.treksoft.kvision.core.ResString import pl.treksoft.kvision.snabbdom.StringPair -open class Link(label: String, url: String, classes: Set<String> = setOf()) : Container(classes) { +open class Link(label: String, url: String, icon: String? = null, image: ResString? = null, + classes: Set<String> = setOf()) : Container(classes) { var label = label set(value) { field = value @@ -15,9 +17,20 @@ open class Link(label: String, url: String, classes: Set<String> = setOf()) : Co field = value refresh() } + var icon = icon + set(value) { + field = value + refresh() + } + var image = image + set(value) { + field = value + refresh() + } override fun render(): VNode { - return kvh("a", arrayOf(label) + childrenVNodes()) + val t = createLabelWithIcon(label, icon, image) + return kvh("a", t + childrenVNodes()) } override fun getSnAttrs(): List<StringPair> { diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt index febee81b..109e5509 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt @@ -19,6 +19,8 @@ enum class TAG(val tagName: String) { BLOCKQUOTE("blockquote"), FOOTER("footer"), PRE("pre"), + UL("ul"), + OL("ol"), DIV("div"), MARK("mark"), |