christophsturm
06/08/2020, 3:32 PMRobert Jaros
06/08/2020, 4:05 PMchristophsturm
06/08/2020, 4:12 PMchristophsturm
06/08/2020, 4:15 PMRobert Jaros
06/08/2020, 4:36 PMRobert Jaros
06/08/2020, 4:37 PMRobert Jaros
06/08/2020, 5:01 PMpackage com.example
import pl.treksoft.kvision.Application
import pl.treksoft.kvision.panel.root
import pl.treksoft.kvision.react.react
import pl.treksoft.kvision.require
import pl.treksoft.kvision.startApplication
import pl.treksoft.kvision.utils.obj
import react.RClass
import react.RProps
external interface RechartsProps : RProps {
var width: Number
var height: Number
var data: Array<dynamic>
}
external interface DataKeyProps : RProps {
var dataKey: String
}
val LineChart: RClass<RechartsProps> = require("recharts").LineChart
val Legend: RClass<RProps> = require("recharts").Legend
val Line: RClass<DataKeyProps> = require("recharts").Line
val XAxis: RClass<DataKeyProps> = require("recharts").XAxis
val YAxis: RClass<RProps> = require("recharts").YAxis
class App : Application() {
override fun start() {
val data = arrayOf(obj {
name = "Page A"
uv = 4000
pv = 2400
}, obj {
name = "Page B"
uv = 3000
pv = 1398
}, obj {
name = "Page C"
uv = 2000
pv = 9800
}, obj {
name = "Page D"
uv = 2780
pv = 3908
})
root("kvapp") {
react {
LineChart {
attrs.width = 400
attrs.height = 300
attrs.data = data
Line {
attrs.dataKey = "uv"
}
Line {
attrs.dataKey = "pv"
}
XAxis {
attrs.dataKey = "name"
}
YAxis {}
Legend {}
}
}
}
}
}
fun main() {
startApplication(::App)
}
Robert Jaros
06/08/2020, 5:02 PMchristophsturm
06/08/2020, 5:06 PMchristophsturm
06/08/2020, 5:08 PMchristophsturm
06/08/2020, 5:09 PMRobert Jaros
06/08/2020, 5:11 PMchristophsturm
06/08/2020, 5:12 PMRobert Jaros
06/08/2020, 5:14 PMchristophsturm
06/08/2020, 5:15 PMRobert Jaros
06/08/2020, 5:15 PMinclude("css/**")
include("img/**")
include("js/**")
fragments to get the resources copied in the right placeschristophsturm
06/08/2020, 5:16 PMchristophsturm
06/08/2020, 5:16 PM$buildDir/tmp/expandedArchives/
? what task expands to that location?Robert Jaros
06/08/2020, 5:17 PMRobert Jaros
06/08/2020, 5:17 PMRobert Jaros
06/08/2020, 5:19 PMkvision-
prefix and copies css, img and js files into directory where DCE and webpack can find themRobert Jaros
06/08/2020, 5:20 PMRobert Jaros
06/08/2020, 5:21 PMRobert Jaros
06/08/2020, 5:21 PMRobert Jaros
06/08/2020, 5:22 PMchristophsturm
06/09/2020, 10:04 AMchristophsturm
06/09/2020, 10:22 AMimplementation("pl.treksoft:kvision-react:$kvisionVersion")
to the kvision template project i can no longer import the gradle file and the error message is cryptic:
Warning:<i><b>root project 'template': Unable to build Kotlin project configuration</b>
Details: org.gradle.internal.operations.BuildOperationQueueFailure: There was a failure while populating the build operation queue: Process 'Resolving NPM dependencies using yarn' returns 1
yarn install v1.21.1
[1/4] Resolving packages...
info Visit <https://yarnpkg.com/en/docs/cli/install> for documentation about this command.
Caused by: java.lang.IllegalStateException: Process 'Resolving NPM dependencies using yarn' returns 1
yarn install v1.21.1
[1/4] Resolving packages...
info Visit <https://yarnpkg.com/en/docs/cli/install> for documentation about this command.
</i>
Robert Jaros
06/09/2020, 11:12 AMRobert Jaros
06/09/2020, 11:14 AMRobert Jaros
06/09/2020, 11:16 AMchristophsturm
06/09/2020, 11:17 AMRobert Jaros
06/09/2020, 11:18 AMchristophsturm
06/09/2020, 11:19 AMchristophsturm
06/09/2020, 11:20 AMsourceSets["main"].dependencies {
+ val kotlinWrappersVersion = "-pre.107-kotlin-1.3.72"
+ val reactVersion = "16.13.1"
+ implementation("org.jetbrains:kotlin-react:$reactVersion$kotlinWrappersVersion")
+ implementation("org.jetbrains:kotlin-react-dom:$reactVersion$kotlinWrappersVersion")
+
implementation(kotlin("stdlib-js"))
implementation(npm("po2json"))
implementation(npm("grunt"))
@@ -97,6 +102,9 @@ kotlin {
implementation("pl.treksoft:kvision-pace:$kvisionVersion")
implementation("pl.treksoft:kvision-moment:$kvisionVersion")
implementation("pl.treksoft:kvision-toast:$kvisionVersion")
+// implementation("pl.treksoft:kvision-react:$kvisionVersion")
+
+
}
christophsturm
06/09/2020, 11:20 AMRobert Jaros
06/09/2020, 11:24 AMRobert Jaros
06/09/2020, 11:24 AMchristophsturm
06/09/2020, 11:25 AMerror Couldn't find any versions for "kotlinx-html-js" that matches "0.7.1"
Robert Jaros
06/09/2020, 11:25 AMRobert Jaros
06/09/2020, 11:25 AMchristophsturm
06/09/2020, 11:26 AMchristophsturm
06/09/2020, 12:05 PMchristophsturm
06/09/2020, 12:30 PMobj
helper methodchristophsturm
06/09/2020, 12:55 PM<Line dataKey="value" dot={{ stroke: 'red', strokeWidth: 2 }} />
Robert Jaros
06/09/2020, 1:03 PMRobert Jaros
06/09/2020, 1:03 PMDataKeyProps
create a new one, with additional dot: dynamic
property.Robert Jaros
06/09/2020, 1:05 PMLineProps
and declare Line
as RClass<LineProps>
Robert Jaros
06/09/2020, 1:05 PMattrs.dot
inside Line { }
Robert Jaros
06/09/2020, 1:06 PMDataKeyProps
in my example code for simplicity - you will probably need dedicated interface for every react component.christophsturm
06/09/2020, 1:07 PMchristophsturm
06/09/2020, 1:32 PMchristophsturm
06/09/2020, 1:34 PMexternal interface Dot {
var stroke: String
var strokeWidth: Number
}
but now i have to set it like this:
Line {
attrs.dot = obj {
}
attrs.dot.stroke = "#8884d8"
attrs.dataKey = "uv"
}
Robert Jaros
06/09/2020, 2:51 PMRobert Jaros
06/09/2020, 2:53 PMRobert Jaros
06/09/2020, 2:57 PMchristophsturm
06/09/2020, 5:27 PMobj
method, but with generics
inline fun <T> iobj(init: T.() -> Unit): dynamic
Robert Jaros
06/09/2020, 5:46 PMinline fun <T> iobj(init: T.() -> Unit): T {
val o = js("{}")
(o as T).init()
return o
}
Robert Jaros
06/09/2020, 5:47 PMval dot = iobj<Dot> {
stroke = "5"
strokeWidth = 5
}
Robert Jaros
06/09/2020, 5:54 PMobj
without conflictRobert Jaros
06/09/2020, 5:56 PMchristophsturm
06/09/2020, 5:57 PMchristophsturm
06/09/2020, 5:58 PM