Separate views into a maven module

This commit is contained in:
2020-10-24 01:25:25 +02:00
parent 536c6e7b79
commit 8b8dbd6fe5
37 changed files with 255 additions and 227 deletions
@@ -0,0 +1,37 @@
package be.simplenotes.views.components
import be.simplenotes.types.LoggedInUser
import kotlinx.html.*
internal fun BODY.navbar(loggedInUser: LoggedInUser?) {
nav {
id = "navbar"
a("/") {
id = "home"
+"SimpleNotes"
}
ul("space-x-2") {
id = "navigation"
if (loggedInUser != 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" }
}
}
}
}
}