aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/panel
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/panel')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/Root.kt60
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt2
4 files changed, 63 insertions, 3 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt
index 66f2d422..ad3522ea 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt
@@ -3,7 +3,7 @@ package pl.treksoft.kvision.panel
import pl.treksoft.kvision.core.Component
import pl.treksoft.kvision.core.StyledComponent
import pl.treksoft.kvision.core.WidgetWrapper
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
import pl.treksoft.kvision.utils.px
enum class FLEXDIR(val dir: String) {
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt
index 3b226102..549f7631 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt
@@ -2,7 +2,7 @@ package pl.treksoft.kvision.panel
import pl.treksoft.kvision.core.Component
import pl.treksoft.kvision.core.WidgetWrapper
-import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.core.StringPair
enum class GRIDJUSTIFY(val justify: String) {
START("start"),
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt b/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt
new file mode 100644
index 00000000..88634bea
--- /dev/null
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/Root.kt
@@ -0,0 +1,60 @@
+package pl.treksoft.kvision.panel
+
+import com.github.snabbdom.VNode
+import pl.treksoft.kvision.KVManager
+import pl.treksoft.kvision.modal.Modal
+import pl.treksoft.kvision.core.StringBoolPair
+
+class Root(id: String, private val fixed: Boolean = false) : SimplePanel() {
+ private val modals: MutableList<Modal> = mutableListOf()
+ private var rootVnode: VNode = renderVNode()
+
+ internal var renderDisabled = false
+
+ init {
+ rootVnode = KVManager.patch(id, this.renderVNode())
+ this.id = id
+ roots.add(this)
+ }
+
+ override fun render(): VNode {
+ return kvh("div#" + id, childrenVNodes() + modalsVNodes())
+ }
+
+ internal fun addModal(modal: Modal) {
+ modals.add(modal)
+ modal.parent = this
+ refresh()
+ }
+
+ private fun modalsVNodes(): Array<VNode> {
+ return modals.filter { it.visible }.map { it.renderVNode() }.toTypedArray()
+ }
+
+ override fun getSnClass(): List<StringBoolPair> {
+ val css = if (!fixed) "container-fluid" else "container"
+ return super.getSnClass() + (css to true)
+ }
+
+ internal fun reRender(): Root {
+ if (!renderDisabled) {
+ rootVnode = KVManager.patch(rootVnode, renderVNode())
+ }
+ return this
+ }
+
+ override fun getRoot(): Root? {
+ return this
+ }
+
+ companion object {
+ private val roots: MutableList<Root> = mutableListOf()
+
+ internal fun getLastRoot(): Root? {
+ return if (roots.size > 0)
+ roots[roots.size - 1]
+ else
+ null
+ }
+ }
+}
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt
index 722f60e6..10595a37 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt
@@ -7,7 +7,7 @@ import pl.treksoft.kvision.core.StyledComponent
import pl.treksoft.kvision.core.UNIT
import pl.treksoft.kvision.html.TAG
import pl.treksoft.kvision.html.Tag
-import pl.treksoft.kvision.snabbdom.obj
+import pl.treksoft.kvision.utils.obj
enum class DIRECTION(val dir: String) {
HORIZONTAL("horizontal"),