timothy.paetz
09/10/2022, 11:35 PMimplementation("app.softwork:routing-compose:0.2.8")
Thanks!timothy.paetz
09/10/2022, 11:35 PMimport org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
}
repositories {
mavenCentral()
maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
google()
}
kotlin {
js(IR) {
browser()
binaries.executable()
}
sourceSets {
val jsMain by getting {
kotlin.srcDir("src/main/kotlin")
resources.srcDir("src/main/resources")
dependencies {
implementation(compose.web.core)
implementation(compose.runtime)
}
}
}
}
// a temporary workaround for a bug in jsRun invocation - see <https://youtrack.jetbrains.com/issue/KT-48273>
afterEvaluate {
rootProject.extensions.configure<NodeJsRootExtension> {
nodeVersion = "16.0.0"
versions.webpackDevServer.version = "4.0.0"
versions.webpackCli.version = "4.10.0"
}
}
Thomas
09/10/2022, 11:38 PMdependencies
block next to the other implementation lines, if I understand your question correctly.Thomas
09/10/2022, 11:39 PMtimothy.paetz
09/10/2022, 11:52 PM\src\main\kotlin\main.kt: (2, 12): Unresolved reference: jetbrains
\src\main\kotlin\main.kt: (3, 12): Unresolved reference: jetbrains
\src\main\kotlin\main.kt: (4, 12): Unresolved reference: jetbrains
\src\main\kotlin\main.kt: (5, 12): Unresolved reference: jetbrains
\src\main\kotlin\main.kt: (8, 5): Unresolved reference: renderComposable
\src\main\kotlin\main.kt: (9, 9): @Composable invocations can only happen from the context of a @Composable function
\src\main\kotlin\main.kt: (21, 5): Unresolved reference: Div
\src\main\kotlin\main.kt: (22, 9): Unresolved reference: Text
\src\main\kotlin\main.kt: (24, 5): Unresolved reference: Button
\src\main\kotlin\main.kt: (26, 13): Unresolved reference: onClick
\src\main\kotlin\main.kt: (26, 23): Cannot infer a type for this parameter. Please specify it explicitly.
\src\main\kotlin\main.kt: (31, 9): Unresolved reference: Text
timothy.paetz
09/10/2022, 11:55 PMval commonMain by getting {
dependencies {
implementation("app.softwork:routing-compose:0.2.8")
}
}
Thomas
09/11/2022, 12:12 AMtimothy.paetz
09/11/2022, 12:28 AMtimothy.paetz
09/11/2022, 12:28 AMimport androidx.compose.runtime.*
import org.jetbrains.compose.web.dom.Button
import org.jetbrains.compose.web.dom.Div
import org.jetbrains.compose.web.dom.Text
import org.jetbrains.compose.web.renderComposable
fun main() {
renderComposable(rootElementId = "root") {
Body()
// HashRouter(initPath = "/") {
// route("/blogs") {
// Text("Hello World")
// }
// }
}
}
@Composable
fun Body() {
var counter by remember { mutableStateOf(0) }
Div {
Text("Clicked: ${counter}")
}
Button(
attrs = {
onClick { _ ->
counter++
}
}
) {
Text("Click")
}
}
timothy.paetz
09/11/2022, 1:07 AMhfhbd
09/11/2022, 8:10 AMkotlin("multiplatform") version "1.7.10"
id("org.jetbrains.compose") version "1.2.0-alpha01-dev770"
implementation("app.softwork:routing-compose:0.2.8")
And if you only want to have a web project, you could also use kotlin("js") version "1.7.10"
, this makes the config a little bit easier imho.timothy.paetz
09/11/2022, 4:01 PM