mirror of
https://github.com/fiatjaf/nak.git
synced 2024-10-30 09:09:08 -04:00
key handler (except the nostr part).
This commit is contained in:
parent
eadc8ca5a3
commit
892b2122b8
|
@ -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()
|
||||||
|
|
29
src/main/scala/app/components/Item.scala
Normal file
29
src/main/scala/app/components/Item.scala
Normal 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)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
21
src/main/scala/app/handlers/EventSignatures.scala
Normal file
21
src/main/scala/app/handlers/EventSignatures.scala
Normal 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"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
25
src/main/scala/app/handlers/KeyHandling.scala
Normal file
25
src/main/scala/app/handlers/KeyHandling.scala
Normal 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"))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user