aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-03-23 21:57:14 +0100
committerRobert Jaros <rjaros@finn.pl>2019-03-23 21:57:14 +0100
commitc56ddc135c7caa9a9b62ced9425544d599e9eb69 (patch)
tree64b1264c9bda8c9df975944a18997a84713449bd /src/main/kotlin
parent514d95a8f3f16b11b406bcfc9028cbf8d662227e (diff)
downloadkvision-c56ddc135c7caa9a9b62ced9425544d599e9eb69.tar.gz
kvision-c56ddc135c7caa9a9b62ced9425544d599e9eb69.tar.bz2
kvision-c56ddc135c7caa9a9b62ced9425544d599e9eb69.zip
Code style fixes.
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/Style.kt9
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/Root.kt3
2 files changed, 7 insertions, 5 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Style.kt b/src/main/kotlin/pl/treksoft/kvision/core/Style.kt
index 7510a650..c2858fa0 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/Style.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/Style.kt
@@ -36,6 +36,7 @@ import pl.treksoft.kvision.panel.Root
* @param parentStyle parent CSS style object
* @param init an initializer extension function
*/
+@Suppress("TooManyFunctions")
open class Style(className: String? = null, parentStyle: Style? = null, init: (Style.() -> Unit)? = null) :
StyledComponent() {
@@ -54,6 +55,7 @@ open class Style(className: String? = null, parentStyle: Style? = null, init: (S
init {
val root = Root.getLastRoot()
+ @Suppress("LeakingThis")
parent = root
if (root != null) {
@Suppress("LeakingThis")
@@ -112,9 +114,9 @@ open class Style(className: String? = null, parentStyle: Style? = null, init: (S
internal fun generateStyle(): String {
val styles = getSnStyle()
- return ".${className} {\n" + styles.map {
+ return ".$className {\n" + styles.joinToString("\n") {
"${it.first}: ${it.second};"
- }.joinToString("\n") + "\n}"
+ } + "\n}"
}
override fun getElement(): Node? {
@@ -161,8 +163,7 @@ open class Style(className: String? = null, parentStyle: Style? = null, init: (S
* It takes the same parameters as the constructor of the built component.
*/
fun Style.style(className: String? = null, init: (Style.() -> Unit)? = null): Style {
- val style = Style(className, this, init)
- return style
+ return Style(className, this, init)
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt b/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt
index e069dd4c..1a90f7fc 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt
@@ -44,6 +44,7 @@ import pl.treksoft.kvision.utils.snOpt
* otherwise it's rendered with "container" class (default is false)
* @param init an initializer extension function
*/
+@Suppress("TooManyFunctions")
class Root(id: String, private val fixed: Boolean = false, init: (Root.() -> Unit)? = null) : SimplePanel() {
private val styles: MutableList<Style> = mutableListOf()
private val modals: MutableList<Modal> = mutableListOf()
@@ -97,7 +98,7 @@ class Root(id: String, private val fixed: Boolean = false, init: (Root.() -> Uni
private fun stylesVNodes(): Array<VNode> {
val visibleStyles = styles.filter { it.visible }
return if (visibleStyles.isNotEmpty()) {
- val stylesDesc = visibleStyles.map { it.generateStyle() }.joinToString("\n")
+ val stylesDesc = visibleStyles.joinToString("\n") { it.generateStyle() }
arrayOf(h("style", arrayOf(stylesDesc)))
} else {
arrayOf()