diff options
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/core/Style.kt | 9 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/panel/Root.kt | 3 |
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() |