format button only when there is a JSON element.

This commit is contained in:
fiatjaf 2023-03-24 22:14:45 -03:00
parent 8961eddc43
commit 4d23a4c6af
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

View File

@ -35,17 +35,21 @@ object Main extends IOWebApp {
def actions(store: Store): Resource[IO, HtmlDivElement[IO]] =
div(
cls := "flex flex-col space-y-1 my-3",
button(
Styles.button,
"format",
onClick --> (_.foreach(_ =>
store.input.update(original =>
parse(original).toOption
.map(_.printWith(jsonPrinter))
.getOrElse(original)
store.result.map {
case Right(_: Event) =>
button(
Styles.button,
"format",
onClick --> (_.foreach(_ =>
store.input.update(original =>
parse(original).toOption
.map(_.printWith(jsonPrinter))
.getOrElse(original)
)
))
)
))
),
case _ => div("")
},
button(
Styles.button,
"generate event",