diff options
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/panel')
9 files changed, 67 insertions, 18 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt index 59c61637..52239032 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt @@ -24,6 +24,7 @@ package pl.treksoft.kvision.panel import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.utils.perc +import pl.treksoft.kvision.utils.set /** * Dock layout directions. @@ -50,21 +51,25 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit * Internal property. */ protected var leftComponent: Component? = null + /** * @suppress * Internal property. */ protected var centerComponent: Component? = null + /** * @suppress * Internal property. */ protected var rightComponent: Component? = null + /** * @suppress * Internal property. */ protected var upComponent: Component? = null + /** * @suppress * Internal property. @@ -83,6 +88,7 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit @Suppress("MagicNumber") height = 100.perc } + /** * @suppress * Internal property. @@ -204,8 +210,12 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit * * It takes the same parameters as the constructor of the built component. */ -fun Container.dockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit)? = null): DockPanel { - val dockPanel = DockPanel(classes, init) +fun Container.dockPanel( + classes: Set<String>? = null, + className: String? = null, + init: (DockPanel.() -> Unit)? = null +): DockPanel { + val dockPanel = DockPanel(classes ?: className.set, init) this.add(dockPanel) return dockPanel } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/FieldsetPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/FieldsetPanel.kt index 14310ffc..b6998556 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/FieldsetPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/FieldsetPanel.kt @@ -25,6 +25,7 @@ import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag +import pl.treksoft.kvision.utils.set /** * The HTML fieldset container. @@ -74,10 +75,11 @@ open class FieldsetPanel( */ fun Container.fieldsetPanel( legend: String? = null, - classes: Set<String> = setOf(), + classes: Set<String>? = null, + className: String? = null, init: (FieldsetPanel.() -> Unit)? = null ): FieldsetPanel { - val fieldsetPanel = FieldsetPanel(legend, classes, init) + val fieldsetPanel = FieldsetPanel(legend, classes ?: className.set, init) this.add(fieldsetPanel) return fieldsetPanel } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt index 4cdbfa01..13deaeb0 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt @@ -27,6 +27,7 @@ import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.core.Widget import pl.treksoft.kvision.core.WidgetWrapper import pl.treksoft.kvision.utils.px +import pl.treksoft.kvision.utils.set /** * CSS flexbox directions. @@ -237,9 +238,13 @@ open class FlexPanel( fun Container.flexPanel( direction: FlexDir? = null, wrap: FlexWrap? = null, justify: FlexJustify? = null, alignItems: FlexAlignItems? = null, alignContent: FlexAlignContent? = null, - spacing: Int? = null, classes: Set<String> = setOf(), init: (FlexPanel.() -> Unit)? = null + spacing: Int? = null, + classes: Set<String>? = null, + className: String? = null, + init: (FlexPanel.() -> Unit)? = null ): FlexPanel { - val flexPanel = FlexPanel(direction, wrap, justify, alignItems, alignContent, spacing, classes, init) + val flexPanel = + FlexPanel(direction, wrap, justify, alignItems, alignContent, spacing, classes ?: className.set, init) this.add(flexPanel) return flexPanel } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt index 1598753b..daf5c92b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt @@ -25,6 +25,7 @@ import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.StringPair import pl.treksoft.kvision.core.WidgetWrapper +import pl.treksoft.kvision.utils.set /** * CSS grid justification options. @@ -113,46 +114,57 @@ open class GridPanel( * CSS grid auto columns. */ var autoColumns by refreshOnUpdate(autoColumns) + /** * CSS grid auto rows. */ var autoRows by refreshOnUpdate(autoRows) + /** * CSS grid auto flow. */ var autoFlow by refreshOnUpdate(autoFlow) + /** * CSS grid columns template. */ var templateColumns by refreshOnUpdate(templateColumns) + /** * CSS grid rows template. */ var templateRows by refreshOnUpdate(templateRows) + /** * CSS grid areas template. */ var templateAreas by refreshOnUpdate(templateAreas) + /** * CSS grid column gap. */ var columnGap by refreshOnUpdate(columnGap) + /** * CSS grid row gap. */ var rowGap by refreshOnUpdate(rowGap) + /** * CSS grid items justification. */ var justifyItems by refreshOnUpdate(justifyItems) + /** * CSS grid items alignment. */ var alignItems by refreshOnUpdate(alignItems) + /** * CSS grid content justification. */ var justifyContent by refreshOnUpdate(justifyContent) + /** * CSS grid content alignment. */ @@ -267,11 +279,14 @@ fun Container.gridPanel( templateColumns: String? = null, templateRows: String? = null, templateAreas: List<String>? = null, columnGap: Int? = null, rowGap: Int? = null, justifyItems: GridJustify? = null, alignItems: GridAlign? = null, justifyContent: GridJustifyContent? = null, - alignContent: GridAlignContent? = null, classes: Set<String> = setOf(), init: (GridPanel.() -> Unit)? = null + alignContent: GridAlignContent? = null, + classes: Set<String>? = null, + className: String? = null, + init: (GridPanel.() -> Unit)? = null ): GridPanel { val gridPanel = GridPanel( autoColumns, autoRows, autoFlow, templateColumns, templateRows, templateAreas, - columnGap, rowGap, justifyItems, alignItems, justifyContent, alignContent, classes, init + columnGap, rowGap, justifyItems, alignItems, justifyContent, alignContent, classes ?: className.set, init ) this.add(gridPanel) return gridPanel diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt index ccc77b0f..88c95b92 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt @@ -22,6 +22,7 @@ package pl.treksoft.kvision.panel import pl.treksoft.kvision.core.Container +import pl.treksoft.kvision.utils.set /** * The container with horizontal layout. @@ -59,10 +60,11 @@ fun Container.hPanel( justify: FlexJustify? = null, alignItems: FlexAlignItems? = null, spacing: Int? = null, - classes: Set<String> = setOf(), + classes: Set<String>? = null, + className: String? = null, init: (HPanel.() -> Unit)? = null ): HPanel { - val hpanel = HPanel(wrap, justify, alignItems, spacing, classes, init) + val hpanel = HPanel(wrap, justify, alignItems, spacing, classes ?: className.set, init) this.add(hpanel) return hpanel } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SimplePanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SimplePanel.kt index 915fa6a7..f2210550 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/SimplePanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/SimplePanel.kt @@ -25,6 +25,7 @@ import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.Widget +import pl.treksoft.kvision.utils.set /** * Basic container class, rendered as a DIV element with all children directly within. @@ -108,8 +109,12 @@ open class SimplePanel(classes: Set<String> = setOf(), init: (SimplePanel.() -> * * It takes the same parameters as the constructor of the built component. */ -fun Container.simplePanel(classes: Set<String> = setOf(), init: (SimplePanel.() -> Unit)? = null): SimplePanel { - val simplePanel = SimplePanel(classes, init) +fun Container.simplePanel( + classes: Set<String>? = null, + className: String? = null, + init: (SimplePanel.() -> Unit)? = null +): SimplePanel { + val simplePanel = SimplePanel(classes ?: className.set, init) this.add(simplePanel) return simplePanel } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt index c7f4b3ac..f838e85c 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt @@ -30,6 +30,7 @@ import pl.treksoft.kvision.core.UNIT import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag import pl.treksoft.kvision.utils.obj +import pl.treksoft.kvision.utils.set /** * Split panel direction. @@ -107,9 +108,11 @@ open class SplitPanel( */ fun Container.splitPanel( direction: Direction = Direction.VERTICAL, - classes: Set<String> = setOf(), init: (SplitPanel.() -> Unit)? = null + classes: Set<String>? = null, + className: String? = null, + init: (SplitPanel.() -> Unit)? = null ): SplitPanel { - val splitPanel = SplitPanel(direction, classes, init) + val splitPanel = SplitPanel(direction, classes ?: className.set, init) this.add(splitPanel) return splitPanel } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt index 84fb6174..02a77b55 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt @@ -25,6 +25,7 @@ import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.routing.routing +import pl.treksoft.kvision.utils.set import kotlin.browser.window /** @@ -130,9 +131,12 @@ open class StackPanel( * It takes the same parameters as the constructor of the built component. */ fun Container.stackPanel( - activateLast: Boolean = true, classes: Set<String> = setOf(), init: (StackPanel.() -> Unit)? = null + activateLast: Boolean = true, + classes: Set<String>? = null, + className: String? = null, + init: (StackPanel.() -> Unit)? = null ): StackPanel { - val stackPanel = StackPanel(activateLast, classes, init) + val stackPanel = StackPanel(activateLast, classes ?: className.set, init) this.add(stackPanel) return stackPanel } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt index e5d275d4..42471994 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt @@ -22,6 +22,7 @@ package pl.treksoft.kvision.panel import pl.treksoft.kvision.core.Container +import pl.treksoft.kvision.utils.set /** * The container with vertical layout. @@ -55,9 +56,11 @@ open class VPanel( */ fun Container.vPanel( justify: FlexJustify? = null, alignItems: FlexAlignItems? = null, spacing: Int? = null, - classes: Set<String> = setOf(), init: (VPanel.() -> Unit)? = null + classes: Set<String>? = null, + className: String? = null, + init: (VPanel.() -> Unit)? = null ): VPanel { - val vpanel = VPanel(justify, alignItems, spacing, classes, init) + val vpanel = VPanel(justify, alignItems, spacing, classes ?: className.set, init) this.add(vpanel) return vpanel } |