From c56ddc135c7caa9a9b62ced9425544d599e9eb69 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 23 Mar 2019 21:57:14 +0100 Subject: Code style fixes. --- src/main/kotlin/pl/treksoft/kvision/core/Style.kt | 9 +++++---- src/main/kotlin/pl/treksoft/kvision/panel/Root.kt | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/main/kotlin') 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