Files
SimpleNotes/app/src/main/kotlin/views/components/Navbar.kt
T
2020-08-22 00:14:10 +02:00

38 lines
1.1 KiB
Kotlin

package be.simplenotes.app.views.components
import be.simplenotes.domain.security.JwtPayload
import kotlinx.html.*
fun BODY.navbar(jwtPayload: JwtPayload?) {
nav {
id = "navbar"
a("/") {
id = "home"
+"SimpleNotes"
}
ul("space-x-2") {
id = "navigation"
if (jwtPayload != null) {
val links = listOf(
"/notes" to "Notes",
"/settings" to "Settings",
)
links.forEach { (href, name) ->
li("txt") {
a(href = href) { +name }
}
}
li {
form(action = "/logout", method = FormMethod.post) {
button(type = ButtonType.submit, classes = "btn btn-green") { +"Logout" }
}
}
} else {
li {
a(href = "/login", classes = "btn btn-green") { +"Sign In" }
}
}
}
}
}