diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-10-08 00:16:18 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-10-08 00:16:18 +0200 |
commit | ce691e9b1409324af359afc721b8561c298d7b71 (patch) | |
tree | 7961490919e788f4c3d2026bbe9b79b08f4c5b15 /src/main/kotlin/pl/treksoft/kvision/html | |
parent | 381f872a4daab133ed53e85526281b6e29873007 (diff) | |
download | kvision-ce691e9b1409324af359afc721b8561c298d7b71.tar.gz kvision-ce691e9b1409324af359afc721b8561c298d7b71.tar.bz2 kvision-ce691e9b1409324af359afc721b8561c298d7b71.zip |
Refactoring
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Button.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Image.kt | 8 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Tag.kt | 7 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt index 74822401..d10cb8cd 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt @@ -70,8 +70,8 @@ open class Button(text: String, icon: String? = null, style: BUTTONSTYLE = BUTTO val cl = super.getSnClass().toMutableList() cl.add("btn" to true) cl.add(style.className to true) - if (size != null) { - cl.add(size?.className.orEmpty() to true) + size?.let { + cl.add(it.className to true) } if (block) { cl.add("btn-block" to true) diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt index c9566531..50840f71 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt @@ -47,7 +47,9 @@ open class Image(src: ResString, alt: String? = null, responsive: Boolean = fals override fun getSnAttrs(): List<StringPair> { val pr = super.getSnAttrs().toMutableList() pr.add("src" to src) - if (alt != null) pr.add("alt" to alt.orEmpty()) + alt?.let { + pr.add("alt" to it) + } return pr } @@ -59,8 +61,8 @@ open class Image(src: ResString, alt: String? = null, responsive: Boolean = fals if (centered) { cl.add("center-block" to true) } - if (shape != null) { - cl.add(shape?.className.orEmpty() to true) + shape?.let { + cl.add(it.className to true) } return cl } diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt index cb8330ac..da964f6e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt @@ -41,7 +41,6 @@ enum class TAG(val tagName: String) { } enum class ALIGN(val className: String) { - NONE(""), LEFT("text-left"), CENTER("text-center"), RIGHT("text-right"), @@ -49,7 +48,7 @@ enum class ALIGN(val className: String) { NOWRAP("text-nowrap") } -open class Tag(type: TAG, text: String? = null, rich: Boolean = false, align: ALIGN = ALIGN.NONE, +open class Tag(type: TAG, text: String? = null, rich: Boolean = false, align: ALIGN? = null, classes: Set<String> = setOf()) : Container(classes) { var type = type set(value) { @@ -86,8 +85,8 @@ open class Tag(type: TAG, text: String? = null, rich: Boolean = false, align: AL override fun getSnClass(): List<StringBoolPair> { val cl = super.getSnClass().toMutableList() - if (align != ALIGN.NONE) { - cl.add(align.className to true) + align?.let { + cl.add(it.className to true) } return cl } |