aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules
diff options
context:
space:
mode:
Diffstat (limited to 'kvision-modules')
-rw-r--r--kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt2
-rw-r--r--kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt17
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt10
-rw-r--r--kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt2
4 files changed, 21 insertions, 10 deletions
diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
index 891cd226..3fa6cd36 100644
--- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
+++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
@@ -392,7 +392,7 @@ internal class DropDownButton(
inherited
} + listOf(
"data-toggle" to "dropdown", "aria-haspopup" to "true",
- "aria-expanded" to "false", "href" to "#"
+ "aria-expanded" to "false", "href" to "javascript:void(0)"
)
}
}
diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt
index 68975f8d..c6f6fe3f 100644
--- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt
+++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt
@@ -64,7 +64,8 @@ enum class NavbarExpand(internal val navbarExpand: String) {
* The Bootstrap Navbar container.
*
* @constructor
- * @param label the navbar label
+ * @param label the navbar header label
+ * @param link the navbar header link
* @param type the navbar type
* @param expand the navbar responsive behavior
* @param nColor the navbar color
@@ -74,6 +75,7 @@ enum class NavbarExpand(internal val navbarExpand: String) {
*/
open class Navbar(
label: String? = null,
+ link: String? = null,
type: NavbarType? = null,
expand: NavbarExpand? = NavbarExpand.LG,
nColor: NavbarColor = NavbarColor.LIGHT,
@@ -94,6 +96,14 @@ open class Navbar(
brandLink.hide()
}
}
+ /**
+ * The navbar header link.
+ */
+ var link
+ get() = brandLink.url
+ set(value) {
+ brandLink.url = value
+ }
/**
* The navbar type.
@@ -114,7 +124,7 @@ open class Navbar(
private val idc = "kv_navbar_$counter"
- private val brandLink = Link(label ?: "", "#", classes = setOf("navbar-brand"))
+ private val brandLink = Link(label ?: "", link, classes = setOf("navbar-brand"))
internal val container = SimplePanel(setOf("collapse", "navbar-collapse")) {
id = idc
}
@@ -183,13 +193,14 @@ open class Navbar(
*/
fun Container.navbar(
label: String? = null,
+ link: String? = null,
type: NavbarType? = null,
expand: NavbarExpand? = NavbarExpand.LG,
nColor: NavbarColor = NavbarColor.LIGHT,
bgColor: BsBgColor = BsBgColor.LIGHT,
classes: Set<String> = setOf(), init: (Navbar.() -> Unit)? = null
): Navbar {
- val navbar = Navbar(label, type, expand, nColor, bgColor, classes, init)
+ val navbar = Navbar(label, link, type, expand, nColor, bgColor, classes, init)
this.add(navbar)
return navbar
}
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
index f75331f3..5efdeb20 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/dropdown/DropDownSpec.kt
@@ -42,7 +42,7 @@ class DropDownSpec : DomSpec {
val element = document.getElementById("test")
val id = dd.buttonId()
assertEqualsHtml(
- "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"#\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><a class=\"dropdown-item\" href=\"#!/x\">abc</a><a class=\"dropdown-item\" href=\"#!/y\">def</a></div></div>",
+ "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"javascript:void(0)\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><a class=\"dropdown-item\" href=\"#!/x\">abc</a><a class=\"dropdown-item\" href=\"#!/y\">def</a></div></div>",
element?.innerHTML,
"Should render correct drop down"
)
@@ -59,7 +59,7 @@ class DropDownSpec : DomSpec {
val element = document.getElementById("test")
val id = dd.buttonId()
assertEqualsHtml(
- "<div class=\"dropup show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"#\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"top-start\" aria-expanded=\"true\" style=\"position: ;\"><a class=\"dropdown-item\" href=\"#!/x\">abc</a><a class=\"dropdown-item\" href=\"#!/y\">def</a></div></div>",
+ "<div class=\"dropup show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"javascript:void(0)\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"top-start\" aria-expanded=\"true\" style=\"position: ;\"><a class=\"dropdown-item\" href=\"#!/x\">abc</a><a class=\"dropdown-item\" href=\"#!/y\">def</a></div></div>",
element?.innerHTML,
"Should render correct drop down"
)
@@ -76,7 +76,7 @@ class DropDownSpec : DomSpec {
val element = document.getElementById("test")
val id = dd.buttonId()
assertEqualsHtml(
- "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"#\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><h6 class=\"dropdown-header\">abc</h6></div></div>",
+ "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"javascript:void(0)\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><h6 class=\"dropdown-header\">abc</h6></div></div>",
element?.innerHTML,
"Should render correct drop down"
)
@@ -93,7 +93,7 @@ class DropDownSpec : DomSpec {
val element = document.getElementById("test")
val id = dd.buttonId()
assertEqualsHtml(
- "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"#\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><div class=\"dropdown-divider\"></div></div></div>",
+ "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"javascript:void(0)\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><div class=\"dropdown-divider\"></div></div></div>",
element?.innerHTML,
"Should render correct drop down"
)
@@ -110,7 +110,7 @@ class DropDownSpec : DomSpec {
val element = document.getElementById("test")
val id = dd.buttonId()
assertEqualsHtml(
- "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"#\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><a class=\"dropdown-item disabled\" tabindex=\"-1\" aria-disabled=\"true\" href=\"javascript:void(0)\">abc</a></div></div>",
+ "<div class=\"dropdown show\"><button class=\"btn btn-primary dropdown-toggle\" id=\"$id\" role=\"button\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" href=\"javascript:void(0)\"><i class=\"flag\"></i> Dropdown</button><div class=\"dropdown-menu show\" aria-labelledby=\"$id\" x-placement=\"bottom-start\" aria-expanded=\"true\" style=\"position: ;\"><a class=\"dropdown-item disabled\" tabindex=\"-1\" aria-disabled=\"true\" href=\"javascript:void(0)\">abc</a></div></div>",
element?.innerHTML,
"Should render correct drop down"
)
diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt
index 8cbc0af6..e7fd6e40 100644
--- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt
+++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/navbar/NavbarSpec.kt
@@ -39,7 +39,7 @@ class NavbarSpec : DomSpec {
fun render() {
run {
val root = Root("test", fixed = true)
- val navbar = Navbar("TEST", NavbarType.FIXEDTOP)
+ val navbar = Navbar("TEST", "#", NavbarType.FIXEDTOP)
root.add(navbar)
val element = document.getElementById("test")
val id = navbar.container.id