Update kotlin libs

This commit is contained in:
2023-05-09 22:40:10 +02:00
parent 5aa2e80c5f
commit f2bdc8d6c7
66 changed files with 261 additions and 264 deletions
+3 -4
View File
@@ -3,15 +3,15 @@ package be.simplenotes.views
import be.simplenotes.types.LoggedInUser
import kotlinx.html.*
import kotlinx.html.ThScope.col
import javax.inject.Named
import javax.inject.Singleton
import jakarta.inject.Named
import jakarta.inject.Singleton
@Singleton
class BaseView(@Named("styles") styles: String) : View(styles) {
fun renderHome(loggedInUser: LoggedInUser?) = renderPage(
title = "Home",
description = "A fast and simple note taking website",
loggedInUser = loggedInUser
loggedInUser = loggedInUser,
) {
section("text-center my-2 p-2") {
h1("text-5xl casual") {
@@ -21,7 +21,6 @@ class BaseView(@Named("styles") styles: String) : View(styles) {
}
div("container mx-auto flex flex-wrap justify-center content-center") {
div("md:order-1 order-2 flipped p-4 my-10 w-full md:w-1/2") {
attributes["aria-label"] = "demo"
div("flex justify-between mb-4") {
+3 -3
View File
@@ -4,8 +4,8 @@ import be.simplenotes.views.components.Alert
import be.simplenotes.views.components.alert
import kotlinx.html.a
import kotlinx.html.div
import javax.inject.Named
import javax.inject.Singleton
import jakarta.inject.Named
import jakarta.inject.Singleton
@Singleton
class ErrorView(@Named("styles") styles: String) : View(styles) {
@@ -23,7 +23,7 @@ class ErrorView(@Named("styles") styles: String) : View(styles) {
Alert.Warning,
errorType.title,
"Please try again later",
multiline = true
multiline = true,
)
Type.NotFound -> alert(Alert.Warning, errorType.title, "Page not found", multiline = true)
Type.Other -> alert(Alert.Warning, errorType.title)
+8 -9
View File
@@ -6,8 +6,8 @@ import be.simplenotes.types.PersistedNoteMetadata
import be.simplenotes.views.components.*
import io.konform.validation.ValidationError
import kotlinx.html.*
import javax.inject.Named
import javax.inject.Singleton
import jakarta.inject.Named
import jakarta.inject.Singleton
@Singleton
class NoteView(@Named("styles") styles: String) : View(styles) {
@@ -41,7 +41,7 @@ class NoteView(@Named("styles") styles: String) : View(styles) {
|---
|
""".trimMargin(
"|"
"|",
)
}
submitButton("Save")
@@ -123,10 +123,9 @@ class NoteView(@Named("styles") styles: String) : View(styles) {
fun renderedNote(loggedInUser: LoggedInUser?, note: PersistedNote, shared: Boolean) = renderPage(
note.title,
loggedInUser = loggedInUser,
scripts = listOf("/highlight.10.1.2.js", "/init-highlight.0.0.1.js")
scripts = listOf("/highlight.10.1.2.js", "/init-highlight.0.0.1.js"),
) {
div("container mx-auto p-4") {
if (shared) {
p("p-4 bg-gray-800") {
+"You are viewing a public note "
@@ -172,14 +171,14 @@ class NoteView(@Named("styles") styles: String) : View(styles) {
form(method = FormMethod.post, classes = "inline flex space-x-2 justify-end mb-4") {
a(
href = "/notes/${note.uuid}/edit",
classes = "btn btn-green"
classes = "btn btn-green",
) { +"Edit" }
span {
button(
type = ButtonType.submit,
name = if (note.public) "private" else "public",
classes = "font-semibold border-b-4 ${if (note.public) "border-teal-200" else "border-green-500"}" +
" p-2 rounded-l bg-teal-200 text-gray-800"
" p-2 rounded-l bg-teal-200 text-gray-800",
) {
+"Private"
}
@@ -188,7 +187,7 @@ class NoteView(@Named("styles") styles: String) : View(styles) {
name = if (note.public) "private" else "public",
classes = "font-semibold border-b-4 " +
(if (!note.public) "border-teal-200" else "border-green-500") +
" p-2 rounded-r bg-teal-200 text-gray-800"
" p-2 rounded-r bg-teal-200 text-gray-800",
) {
+"Public"
}
@@ -196,7 +195,7 @@ class NoteView(@Named("styles") styles: String) : View(styles) {
button(
type = ButtonType.submit,
name = "delete",
classes = "btn btn-red"
classes = "btn btn-red",
) { +"Delete" }
}
}
+5 -9
View File
@@ -8,8 +8,8 @@ import be.simplenotes.views.extensions.summary
import io.konform.validation.ValidationError
import kotlinx.html.*
import kotlinx.html.ButtonType.submit
import javax.inject.Named
import javax.inject.Singleton
import jakarta.inject.Named
import jakarta.inject.Singleton
@Singleton
class SettingView(@Named("styles") styles: String) : View(styles) {
@@ -20,7 +20,6 @@ class SettingView(@Named("styles") styles: String) : View(styles) {
validationErrors: List<ValidationError> = emptyList(),
) = renderPage("Settings", loggedInUser = loggedInUser) {
div("container mx-auto") {
section("m-4 p-4 bg-gray-800 rounded") {
h1("text-xl") {
+"Welcome "
@@ -29,17 +28,15 @@ class SettingView(@Named("styles") styles: String) : View(styles) {
}
section("m-4 p-2 bg-gray-800 rounded flex flex-wrap justify-around items-end") {
form(classes = "m-2", method = FormMethod.post, action = "/export") {
button(
name = "display",
classes = "inline btn btn-teal block",
type = submit
type = submit,
) { +"Display my data" }
}
form(classes = "m-2", method = FormMethod.post, action = "/export") {
div {
listOf("json", "zip").forEach { format ->
radioInput(name = "format") {
@@ -69,7 +66,6 @@ class SettingView(@Named("styles") styles: String) : View(styles) {
error?.let { alert(Alert.Warning, error) }
details {
if (error != null || validationErrors.isNotEmpty()) {
attributes["open"] = ""
}
@@ -87,7 +83,7 @@ class SettingView(@Named("styles") styles: String) : View(styles) {
placeholder = "Password",
autoComplete = "off",
type = InputType.password,
error = validationErrors.find { it.dataPath == ".password" }?.message
error = validationErrors.find { it.dataPath == ".password" }?.message,
)
checkBoxInput(name = "checked") {
id = "checked"
@@ -100,7 +96,7 @@ class SettingView(@Named("styles") styles: String) : View(styles) {
button(
type = submit,
classes = "block mt-4 btn btn-red",
name = "delete"
name = "delete",
) { +"I'm sure" }
}
}
+5 -5
View File
@@ -7,8 +7,8 @@ import be.simplenotes.views.components.input
import be.simplenotes.views.components.submitButton
import io.konform.validation.ValidationError
import kotlinx.html.*
import javax.inject.Named
import javax.inject.Singleton
import jakarta.inject.Named
import jakarta.inject.Singleton
@Singleton
class UserView(@Named("styles") styles: String) : View(styles) {
@@ -23,7 +23,7 @@ class UserView(@Named("styles") styles: String) : View(styles) {
error,
validationErrors,
"Create an account",
"Register"
"Register",
) {
+"Already have an account? "
a(href = "/login", classes = "no-underline text-blue-500 hover:text-blue-400 font-bold") { +"Sign In" }
@@ -63,14 +63,14 @@ class UserView(@Named("styles") styles: String) : View(styles) {
id = "username",
placeholder = "Username",
autoComplete = "username",
error = validationErrors.find { it.dataPath == ".username" }?.message
error = validationErrors.find { it.dataPath == ".username" }?.message,
)
input(
id = "password",
placeholder = "Password",
autoComplete = "new-password",
type = InputType.password,
error = validationErrors.find { it.dataPath == ".password" }?.message
error = validationErrors.find { it.dataPath == ".password" }?.message,
)
submitButton(submit)
}
+3 -3
View File
@@ -8,13 +8,13 @@ internal fun FlowContent.input(
placeholder: String,
id: String,
autoComplete: String? = null,
error: String? = null
error: String? = null,
) {
val colors = "bg-gray-800 border-gray-700 focus:border-teal-500 text-white"
div("mb-8") {
input(
type = type,
classes = "$colors rounded w-full border appearance-none focus:outline-none text-base p-2"
classes = "$colors rounded w-full border appearance-none focus:outline-none text-base p-2",
) {
attributes["placeholder"] = placeholder
attributes["aria-label"] = placeholder
@@ -30,7 +30,7 @@ internal fun FlowContent.submitButton(text: String) {
div("flex items-center mt-6") {
button(
type = submit,
classes = "btn btn-teal w-full"
classes = "btn btn-teal w-full",
) { +text }
}
}
+2 -2
View File
@@ -10,11 +10,11 @@ internal fun DIV.noteListHeader(numberOfDeletedNotes: Int, query: String = "") {
span {
a(
href = "/notes/trash",
classes = "btn btn-teal"
classes = "btn btn-teal",
) { +"Trash ($numberOfDeletedNotes)" }
a(
href = "/notes/new",
classes = "ml-2 btn btn-green"
classes = "ml-2 btn btn-green",
) { +"New" }
}
}
@@ -8,7 +8,7 @@ internal class SUMMARY(consumer: TagConsumer<*>) :
consumer,
emptyMap(),
inlineTag = true,
emptyTag = false
emptyTag = false,
),
HtmlInlineTag
+1 -1
View File
@@ -8,5 +8,5 @@ import java.util.*
private val prettyTime = PrettyTime()
internal fun LocalDateTime.toTimeAgo(): String = prettyTime.format(
Date.from(atZone(ZoneId.systemDefault()).toInstant())
Date.from(atZone(ZoneId.systemDefault()).toInstant()),
)