Skip to content

Commit 680dbe3

Browse files
authored
Merge pull request #67 from yogeshVU/main
Adds the kotlin/js target
2 parents 9347a96 + 93ad242 commit 680dbe3

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ Running on
66
* Android
77
* Desktop
88
* Web (Wasm)
9+
* Web (Kotlin/JS)
910
* Kotlin Notebook
1011

1112

13+
1214
Code is very minimal right now with Compose code using remote apis directly. Will choose/add persistence library once those libraries support Wasm along
1315
with associated Repository. Also need to add some sort of shared view model/state holder. Have started using Voyager for navigation in the Android client
1416
and need to evaulate whether this could/should be used for other clients (again needs Wasm support first).
@@ -37,6 +39,10 @@ and need to evaulate whether this could/should be used for other clients (again
3739

3840
<img width="1141" alt="Screenshot 2023-12-14 at 17 16 17" src="https://github.com/joreilly/ClimateTraceKMP/assets/6302/70e02dc8-f82b-4ed2-b940-495e513ce3b1">
3941

42+
### Compose for Web (Kotlin/JS)
43+
44+
<img width="1141" alt="Screenshot 2023-12-14 at 17 16 17" src="https://github.com/joreilly/ClimateTraceKMP/assets/6302/70e02dc8-f82b-4ed2-b940-495e513ce3b1">
45+
4046
### Kotlin Notebook
4147

4248
<img width="694" alt="Screenshot 2023-12-14 at 20 33 45" src="https://github.com/joreilly/ClimateTraceKMP/assets/6302/82ed364a-0284-4e5c-b81e-40fdfc58f312">

composeApp/build.gradle.kts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ kotlin {
2323
}
2424
binaries.executable()
2525
}
26-
26+
27+
28+
js(){
29+
browser()
30+
binaries.executable()
31+
}
32+
33+
2734
androidTarget()
2835
jvm("desktop")
2936

@@ -74,6 +81,10 @@ kotlin {
7481
api(libs.compose.window.size)
7582
}
7683

84+
jsMain.dependencies {
85+
implementation(compose.html.core)
86+
}
87+
7788
androidMain.dependencies {
7889
implementation(libs.compose.ui.tooling.preview)
7990
implementation(libs.androidx.activity.compose)

composeApp/src/jsMain/kotlin/main.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import androidx.compose.ui.ExperimentalComposeUiApi
2+
import androidx.compose.ui.window.CanvasBasedWindow
3+
import org.jetbrains.skiko.wasm.onWasmReady
4+
5+
@OptIn(ExperimentalComposeUiApi::class)
6+
fun main() {
7+
onWasmReady {
8+
CanvasBasedWindow("KotlinBrowser") {
9+
App()
10+
}
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>ClimateTraceKMP</title>
6+
<script type="application/javascript" src="skiko.js"></script>
7+
<script type="application/javascript" src="composeApp.js"></script>
8+
</head>
9+
<body>
10+
<canvas id="ComposeTarget"></canvas>
11+
</body>
12+
</html>

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ android.useAndroidX=true
1010

1111
#Compose
1212
org.jetbrains.compose.experimental.wasm.enabled=true
13+
org.jetbrains.compose.experimental.jscanvas.enabled=true
14+
1315

1416
#MPP
1517
kotlin.mpp.androidSourceSetLayoutVersion=2

0 commit comments

Comments
 (0)