aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-04-03 17:22:17 +0200
committerRobert Jaros <rjaros@finn.pl>2018-04-03 17:22:17 +0200
commit870fd9ba525d117b1e9cc1227ea8ddc33204e747 (patch)
tree5102a750ec399078cdd366c7a08755d1d25dddcd /src/main/kotlin
parent01c1d306b8df6f552949b04e88829f6730e537c7 (diff)
downloadkvision-870fd9ba525d117b1e9cc1227ea8ddc33204e747.tar.gz
kvision-870fd9ba525d117b1e9cc1227ea8ddc33204e747.tar.bz2
kvision-870fd9ba525d117b1e9cc1227ea8ddc33204e747.zip
Navigation bar fix.
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt b/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt
index 7e83c764..b2ab58da 100644
--- a/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt
@@ -33,7 +33,7 @@ enum class NavbarType(internal val navbarType: String) {
* @param init an initializer extension function
*/
open class Navbar(
- label: String = "",
+ label: String? = null,
type: NavbarType? = null,
inverted: Boolean = false,
classes: Set<String> = setOf(), init: (Navbar.() -> Unit)? = null
@@ -43,9 +43,14 @@ open class Navbar(
* The navbar header label.
*/
var label
- get() = brandLink.label
+ get() = if (brandLink.visible) brandLink.label else null
set(value) {
- brandLink.label = value
+ if (value != null) {
+ brandLink.label = value
+ brandLink.show()
+ } else {
+ brandLink.hide()
+ }
}
/**
@@ -59,7 +64,7 @@ open class Navbar(
private val idc = "kv_navbar_$counter"
- private val brandLink = Link(label, "#", classes = setOf("navbar-brand"))
+ private val brandLink = Link(label ?: "", "#", classes = setOf("navbar-brand"))
internal val container = SimplePanel(setOf("collapse", "navbar-collapse")) {
id = idc
}
@@ -73,6 +78,7 @@ open class Navbar(
add(container)
}
addInternal(c)
+ if (label == null) brandLink.hide()
counter++
@Suppress("LeakingThis")
init?.invoke(this)
@@ -128,15 +134,15 @@ open class Navbar(
*
* It takes the same parameters as the constructor of the built component.
*/
- fun Container.navbarPanel(
- text: String = "",
+ fun Container.navbar(
+ label: String? = null,
type: NavbarType? = null,
inverted: Boolean = false,
classes: Set<String> = setOf(), init: (Navbar.() -> Unit)? = null
): Navbar {
- val navbarPanel = Navbar(text, type, inverted, classes, init)
- this.add(navbarPanel)
- return navbarPanel
+ val navbar = Navbar(label, type, inverted, classes, init)
+ this.add(navbar)
+ return navbar
}
}
}