slinky-bridge-react-konva

react-konva bridge for slinky

License

License

MIT
Categories

Categories

React User Interface Web Frameworks
GroupId

GroupId

com.github.oen9
ArtifactId

ArtifactId

slinky-bridge-react-konva_sjs1_2.13
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

slinky-bridge-react-konva
react-konva bridge for slinky
Project URL

Project URL

https://github.com/oen9/slinky-bridge-react-konva
Project Organization

Project Organization

oen9
Source Code Management

Source Code Management

https://github.com/oen9/slinky-bridge-react-konva

Download slinky-bridge-react-konva_sjs1_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.oen9/slinky-bridge-react-konva_sjs1_2.13/ -->
<dependency>
    <groupId>com.github.oen9</groupId>
    <artifactId>slinky-bridge-react-konva_sjs1_2.13</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.oen9/slinky-bridge-react-konva_sjs1_2.13/
implementation 'com.github.oen9:slinky-bridge-react-konva_sjs1_2.13:0.1.1'
// https://jarcasting.com/artifacts/com.github.oen9/slinky-bridge-react-konva_sjs1_2.13/
implementation ("com.github.oen9:slinky-bridge-react-konva_sjs1_2.13:0.1.1")
'com.github.oen9:slinky-bridge-react-konva_sjs1_2.13:jar:0.1.1'
<dependency org="com.github.oen9" name="slinky-bridge-react-konva_sjs1_2.13" rev="0.1.1">
  <artifact name="slinky-bridge-react-konva_sjs1_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.oen9', module='slinky-bridge-react-konva_sjs1_2.13', version='0.1.1')
)
libraryDependencies += "com.github.oen9" % "slinky-bridge-react-konva_sjs1_2.13" % "0.1.1"
[com.github.oen9/slinky-bridge-react-konva_sjs1_2.13 "0.1.1"]

Dependencies

compile (4)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.1
org.scala-js : scalajs-library_2.13 jar 1.0.1
me.shadaj : slinky-core_sjs1_2.13 jar 0.6.4
org.scala-js : scalajs-dom_sjs1_2.13 jar 1.0.0

test (1)

Group / Artifact Type Version
org.scala-js : scalajs-test-bridge_2.13 jar 1.0.1

Project Modules

There are no modules declared in this project.

slinky-bridge-react-konva

Build Status CircleCI

react-konva bridge for slinky

This bridge is developed for my own purpose. There is a lot of missing but I'm doing my best. If you need something special contact me.

showcase / demo

See the showcase here: react-konva-showcase (live app on heroku)

what do we have

supported

  • all tutorial's shapes
  • all events
  • animations

missing

  • filters
  • Transformer
  • probably more (contact me)

chunk of example build.sbt

lazy val jsSettings = Seq(
  libraryDependencies ++= Seq(
    "me.shadaj" %%% "slinky-web" % "0.6.4",
    "com.github.oen9" %%% "slinky-bridge-react-konva" % "0.1.1"
  ),
  npmDependencies in Compile ++= Seq(
    "react" -> "16.13.0",
    "react-dom" -> "16.13.0",
    "konva" -> "4.2.2",
    "react-konva" -> "16.12.0-0"
  ),
  scalaJSUseMainModuleInitializer := true,
  version.in(webpack) := "4.42.1",
  webpackBundlingMode := BundlingMode.Application,
  webpackBundlingMode.in(fastOptJS) := BundlingMode.LibraryOnly(),
)

tested with

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.1")
scalaVersion := "2.13.1

how to use

import com.github.oen9.slinky.bridge.reactkonva._

div(className := "card-body",
  Stage(width = 800, height = 600)(
    Layer(
      Text(text = "Hello world!"),
      Text(text = "try drag and drop --> ", x = 50, y = 260, fontSize = 18),
      Circle(x = 290, y = 290, radius = 50, stroke = "blue", strokeWidth = 5, draggable = true)
    )
  )
)
import com.github.oen9.slinky.bridge.konva.Konva
import com.github.oen9.slinky.bridge.konva.Konva.KonvaEventObject
import com.github.oen9.slinky.bridge.reactkonva.Rect
import org.scalajs.dom.raw.MouseEvent
import slinky.core.annotations.react
import slinky.core.facade.Hooks._
import slinky.core.FunctionalComponent
import slinky.web.html._

@react object ColoredRect {
  type Props = Unit
  val component = FunctionalComponent[Props] { _ =>
    val (color, setColor) = useState("navy")

    def handleClick(e: KonvaEventObject[MouseEvent]): Unit = {
      setColor(Konva.Util.getRandomColor())
    }

    Rect(
      x = 20,
      y = 20,
      width = 50,
      height = 50,
      fill = color,
      shadowBlur = 5,
      onClick = handleClick _
    )
  }
}

Versions

Version
0.1.1
0.1.0
0.0.5
0.0.4
0.0.3