aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Button.kt11
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Image.kt7
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/List.kt9
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Tag.kt15
4 files changed, 25 insertions, 17 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
index 81df4eaf..0fe2f559 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
@@ -7,7 +7,7 @@ import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.snabbdom.StringBoolPair
import pl.treksoft.kvision.snabbdom.StringPair
-enum class BUTTON_STYLE(val className: String) {
+enum class BUTTONSTYLE(val className: String) {
DEFAULT("btn-default"),
PRIMARY("btn-primary"),
SUCCESS("btn-success"),
@@ -17,14 +17,15 @@ enum class BUTTON_STYLE(val className: String) {
LINK("btn-link")
}
-enum class BUTTON_SIZE(val className: String) {
+enum class BUTTONSIZE(val className: String) {
LARGE("btn-lg"),
SMALL("btn-sm"),
XSMALL("btn-xs")
}
-open class Button(text: String, icon: String? = null, style: BUTTON_STYLE = BUTTON_STYLE.DEFAULT, size: BUTTON_SIZE? = null,
- block: Boolean = false, disabled: Boolean = false, image: ResString? = null, classes: Set<String> = setOf()) : Widget(classes) {
+open class Button(text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT,
+ size: BUTTONSIZE? = null, block: Boolean = false, disabled: Boolean = false,
+ image: ResString? = null, classes: Set<String> = setOf()) : Widget(classes) {
var text = text
set(value) {
field = value
@@ -96,4 +97,4 @@ open class Button(text: String, icon: String? = null, style: BUTTON_STYLE = BUTT
return super.getSnAttrs() + ("type" to "button")
}
-} \ No newline at end of file
+}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
index 3e9fe5d6..a03d673a 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt
@@ -6,13 +6,14 @@ import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.snabbdom.StringBoolPair
import pl.treksoft.kvision.snabbdom.StringPair
-enum class IMAGE_SHAPE(val className: String) {
+enum class IMAGESHAPE(val className: String) {
ROUNDED("img-rounded"),
CIRCLE("img-circle"),
THUMBNAIL("img-thumbnail")
}
-open class Image(src: ResString, alt: String? = null, responsive: Boolean = false, shape: IMAGE_SHAPE? = null, centered: Boolean = false, classes: Set<String> = setOf()) : Widget(classes) {
+open class Image(src: ResString, alt: String? = null, responsive: Boolean = false, shape: IMAGESHAPE? = null,
+ centered: Boolean = false, classes: Set<String> = setOf()) : Widget(classes) {
var src = src
set(value) {
field = value
@@ -63,4 +64,4 @@ open class Image(src: ResString, alt: String? = null, responsive: Boolean = fals
}
return cl
}
-} \ No newline at end of file
+}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/List.kt b/src/main/kotlin/pl/treksoft/kvision/html/List.kt
index e525d9a5..24978f8d 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/List.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/List.kt
@@ -15,7 +15,8 @@ enum class LIST(val tagName: String) {
DL_HORIZ("dl")
}
-open class ListTag(type: LIST, elements: List<String>? = null, rich: Boolean = false, classes: Set<String> = setOf()) : Container(classes) {
+open class ListTag(type: LIST, elements: List<String>? = null, rich: Boolean = false,
+ classes: Set<String> = setOf()) : Container(classes) {
var type = type
set(value) {
field = value
@@ -35,7 +36,9 @@ open class ListTag(type: LIST, elements: List<String>? = null, rich: Boolean = f
override fun render(): VNode {
val childrenElements = when (type) {
LIST.UL, LIST.OL, LIST.UNSTYLED, LIST.INLINE -> elements?.map { el -> element("li", el, rich) }
- LIST.DL, LIST.DL_HORIZ -> elements?.mapIndexed { index, el -> element(if (index % 2 == 0) "dt" else "dd", el, rich) }
+ LIST.DL, LIST.DL_HORIZ -> elements?.mapIndexed { index, el ->
+ element(if (index % 2 == 0) "dt" else "dd", el, rich)
+ }
}?.toTypedArray()
if (childrenElements != null) {
return kvh(type.tagName, childrenElements + childrenVNodes())
@@ -84,4 +87,4 @@ open class ListTag(type: LIST, elements: List<String>? = null, rich: Boolean = f
}
return cl
}
-} \ No newline at end of file
+}
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
index 4a3f708f..37a7bf98 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
@@ -5,6 +5,7 @@ import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.KVManager
import pl.treksoft.kvision.snabbdom.StringBoolPair
+@Suppress("EnumNaming")
enum class TAG(val tagName: String) {
H1("h1"),
H2("h2"),
@@ -45,7 +46,8 @@ enum class ALIGN(val className: String) {
NOWRAP("text-nowrap")
}
-open class Tag(type: TAG, text: String? = null, rich: Boolean = false, align: ALIGN = ALIGN.NONE, classes: Set<String> = setOf()) : Container(classes) {
+open class Tag(type: TAG, text: String? = null, rich: Boolean = false, align: ALIGN = ALIGN.NONE,
+ classes: Set<String> = setOf()) : Container(classes) {
var type = type
set(value) {
field = value
@@ -68,15 +70,16 @@ open class Tag(type: TAG, text: String? = null, rich: Boolean = false, align: AL
}
override fun render(): VNode {
- if (text != null) {
+ val ret = if (text != null) {
if (rich) {
- return kvh(type.tagName, arrayOf(KVManager.virtualize("<span>$text</span>")) + childrenVNodes())
+ kvh(type.tagName, arrayOf(KVManager.virtualize("<span>$text</span>")) + childrenVNodes())
} else {
- return kvh(type.tagName, arrayOf(text) + childrenVNodes())
+ kvh(type.tagName, arrayOf(text) + childrenVNodes())
}
} else {
- return kvh(type.tagName, childrenVNodes())
+ kvh(type.tagName, childrenVNodes())
}
+ return ret
}
override fun getSnClass(): List<StringBoolPair> {
@@ -86,4 +89,4 @@ open class Tag(type: TAG, text: String? = null, rich: Boolean = false, align: AL
}
return cl
}
-} \ No newline at end of file
+}