Skip to content

Instantly share code, notes, and snippets.

@zlangbert
Last active August 29, 2015 14:21
Show Gist options
  • Save zlangbert/76ed8a0382054a29e5d7 to your computer and use it in GitHub Desktop.
Save zlangbert/76ed8a0382054a29e5d7 to your computer and use it in GitHub Desktop.
case class Props(color: String, onClick: Unit => Unit)
class Backend($: BackendScope[Props, _]) {
def onClick(e: ReactEventI) = {
println("clicked!")
$.props.onClick()
}
val circ = ReactComponentB[Props]("CircleComponent")
.stateless
.backend(new Backend(_))
.render((props, _, b) =>
div(
svg(width := 800, height := 100,
g(transform := "translate(100, 0)",
onKeyPress ==> b.onClick,
circle(
cx := "25", cy := "25", r := "25", fill := props.color)
)
)
)
)
.build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment