Better error handling

This commit is contained in:
2020-08-21 19:31:24 +02:00
parent b27fd29230
commit 36600bb1f4
6 changed files with 68 additions and 15 deletions
@@ -2,7 +2,7 @@ package be.simplenotes.app.views.components
import kotlinx.html.*
fun FlowContent.alert(type: Alert, title: String, details: String? = null) {
fun FlowContent.alert(type: Alert, title: String, details: String? = null, multiline: Boolean = false) {
val colors = when (type) {
Alert.Success -> "bg-green-500 border border-green-400 text-gray-800"
Alert.Warning -> "bg-red-500 border border-red-400 text-red-200"
@@ -10,7 +10,10 @@ fun FlowContent.alert(type: Alert, title: String, details: String? = null) {
div("$colors px-4 py-3 mb-4 rounded relative") {
attributes["role"] = "alert"
strong("font-bold") { +title }
details?.let { span("block sm:inline") { +details } }
details?.let {
if (multiline) p { +details }
else span("block sm:inline") { +details }
}
}
}