From b1d9c9d5bfaae4661c400f7824b2c90a55b2193f Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 25 Apr 2023 22:06:04 -0300 Subject: [PATCH] add "clear" button. --- src/main/scala/Main.scala | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala index 71cdef2..950b8b6 100644 --- a/src/main/scala/Main.scala +++ b/src/main/scala/Main.scala @@ -45,6 +45,15 @@ object Main extends IOWebApp { def actions(store: Store): Resource[IO, HtmlDivElement[IO]] = div( cls := "flex flex-col space-y-1 my-3", + store.input.map { + case "" => div("") + case _ => + button( + Styles.button, + "clear", + onClick --> (_.foreach(_ => store.input.set(""))) + ) + }, store.result.map { case Right(_: Event) => button(