Skip to content

Commit 2258956

Browse files
committed
🌟 add chrome ext support
1 parent 9dea301 commit 2258956

File tree

3 files changed

+47
-11
lines changed

3 files changed

+47
-11
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
![](demo_web.gif)
1919

20+
#### Compose Web
21+
22+
![](demo_chrome.gif)
23+
2024
#### Mobile
2125

2226
- TODO
@@ -34,14 +38,11 @@
3438
Choose platform
3539
1) Desktop
3640
2) Web
41+
3) Chrome extension
3742
```
3843

3944
## 📦 What's included?
4045

41-
### Web
42-
43-
- A basic counter example
44-
4546
### Desktop
4647

4748
- Architecture (MVVM) with Android-ish structure (SingleActivity)
@@ -54,6 +55,14 @@ Choose platform
5455
- Logging (Arbor)
5556
- Font (GoogleSans)
5657

58+
### Web
59+
60+
- A basic counter example
61+
62+
### Chrome extension
63+
64+
- A simple popup window
65+
5766
## ✍️ Author
5867

5968
👤 **theapache64**

demo_chrome.gif

453 KB
Loading

src/main/kotlin/com/theapache64/createcomposeapp/Main.kt

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import com.github.theapache64.corvetee.util.println
77

88
private const val PLATFORM_DESKTOP = "Desktop"
99
private const val PLATFORM_WEB = "Web"
10+
private const val PLATFORM_CHROME_EXT = "Chrome"
1011
private const val IS_DEBUG = false
1112

1213
private val platforms = listOf(
1314
PLATFORM_DESKTOP,
14-
PLATFORM_WEB
15+
PLATFORM_WEB,
16+
PLATFORM_CHROME_EXT,
1517
)
1618

1719
fun main(args: Array<String>) {
@@ -35,12 +37,9 @@ fun main(args: Array<String>) {
3537
println(Color.CYAN, "Platform: $platform")
3638

3739
when (platform) {
38-
PLATFORM_DESKTOP -> {
39-
createDesktopApp()
40-
}
41-
PLATFORM_WEB -> {
42-
createComposeWebApp()
43-
}
40+
PLATFORM_DESKTOP -> createDesktopApp()
41+
PLATFORM_WEB -> createComposeWebApp()
42+
PLATFORM_CHROME_EXT -> createChromeExtensionApp()
4443
}
4544
}
4645

@@ -71,6 +70,34 @@ fun createComposeWebApp() {
7170
println(Color.YELLOW, "Run `./gradlew jsBrowserRun` from project root to run the app in your browser")
7271
}
7372

73+
fun createChromeExtensionApp() {
74+
val corvette = Corvette(
75+
githubRepoUrl = "https://github.com/theapache64/compose-chrome-extension-template",
76+
isDebug = IS_DEBUG
77+
)
78+
79+
val replaceMap = mapOf(
80+
"rootProject.name = \"compose-chrome-extension-template\"" to "rootProject.name = \"${
81+
corvette.projectName.replace(
82+
" ",
83+
"_"
84+
)
85+
}\"", // settings.gradle.kt
86+
"com.composeweb.chrome" to corvette.packageName, // app kt files
87+
"<script src=\"compose-chrome-extension-template.js\"></script>" to "<script src=\"${
88+
corvette.projectName.replace(
89+
" ",
90+
"_"
91+
)
92+
}.js\"></script>", // index.html
93+
"Compose Chrome Extension Template" to corvette.projectName, // index.html
94+
"platform = \"Chrome Extension!\"" to "platform = \"${corvette.projectName}!\"",
95+
)
96+
97+
corvette.start(replaceMap)
98+
println(Color.YELLOW, "Run `./gradlew jsBrowserRun` from project root to run the extension directly in your browser")
99+
}
100+
74101
private fun createDesktopApp() {
75102

76103
val corvette = Corvette(

0 commit comments

Comments
 (0)