key handler (except the nostr part).

This commit is contained in:
fiatjaf 2022-02-23 16:30:40 -03:00
parent eadc8ca5a3
commit 892b2122b8
4 changed files with 77 additions and 3 deletions

View File

@ -6,10 +6,10 @@ import slinky.core.FunctionalComponent
import slinky.web.html._ import slinky.web.html._
import slinky.core.facade.Hooks._ import slinky.core.facade.Hooks._
import app.handlers.{Handler, Nothing} import app.handlers.{Handler, Nothing, KeyHandling}
object Base { object Base {
val handlers: List[Handler] = List(Nothing) val handlers: List[Handler] = List(KeyHandling, Nothing)
val component = FunctionalComponent[Unit] { props => val component = FunctionalComponent[Unit] { props =>
val (typedValue, setTypedValue) = useState("") val (typedValue, setTypedValue) = useState("")
@ -17,7 +17,6 @@ object Base {
useEffect( useEffect(
() => { () => {
val saved = dom.window.localStorage.getItem("value") val saved = dom.window.localStorage.getItem("value")
println(s"saved: ${saved}")
setTypedValue(saved match { case _: String => saved; case _ => "" }) setTypedValue(saved match { case _: String => saved; case _ => "" })
}, },
Seq() Seq()

View File

@ -0,0 +1,29 @@
package app.components
import scala.scalajs.js
import slinky.core.{FunctionalComponent, CustomAttribute}
import slinky.web.html._
object Item {
val wenkValue = CustomAttribute[String]("data-wenk")
val wenkPos = CustomAttribute[String]("data-wenk-pos")
case class props(label: String, hint: String, content: String)
val component = FunctionalComponent[props] { props =>
div(
style := js.Dynamic.literal(
marginBottom = "9px",
whiteSpace = "pre-wrap",
wordWrap = "break-word",
wordBreak = "break-all"
)
)(
b(wenkValue := props.hint, wenkPos := "right")(
span(props.label)
),
span(" "),
span(props.content)
)
}
}

View File

@ -0,0 +1,21 @@
package app.handlers
import scala.scalajs.js
import slinky.core.FunctionalComponent
import slinky.web.html._
import slinky.core.facade.Hooks._
import slinky.core.facade.Fragment
import io.circe._
import io.circe.parser._
import app.handlers.{Handler}
object EventSignatures extends Handler {
override def handles(value: String): Boolean = false
override val component = FunctionalComponent[String] { props =>
Fragment(
"nada"
)
}
}

View File

@ -0,0 +1,25 @@
package app.handlers
import scala.util.matching.Regex
import scala.scalajs.js
import slinky.core.{FunctionalComponent}
import slinky.web.html._
import slinky.core.facade.Hooks._
import slinky.core.facade.Fragment
import app.handlers.{Handler}
import app.components.{Item}
object KeyHandling extends Handler {
val keymatcher = "^[a-f0-9]{64}$".r
override def handles(value: String): Boolean =
keymatcher.matches(value.toLowerCase())
override val component = FunctionalComponent[String] { props =>
Fragment(
Item.component(Item.props("private key", "", props)),
Item.component(Item.props("public key", "", "soon to be shown here"))
)
}
}