Skip to content

Commit

Permalink
Merge pull request #984 from mikepenz/feature/enhance_wasm_example
Browse files Browse the repository at this point in the history
Enhanced wasm sample app | CI to publish to GitHub pages
  • Loading branch information
mikepenz authored May 9, 2024
2 parents b966ed3 + cebd1d5 commit f71987f
Show file tree
Hide file tree
Showing 7 changed files with 624 additions and 332 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
push:
tags:
- '*'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: |
11
17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build Page
run: |
./gradlew app-wasm:wasmJsBrowserDistribution --no-configuration-cache
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'app-wasm/build/dist/wasmJs/productionExecutable'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion app-wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Generate Dependency Information

```bash
./gradlew app-wasm:exportLibraryDefinitions -PaboutLibraries.exportPath=src/commonMain/composeResources/files/
./gradlew :app-wasm:exportLibraryDefinitions -PaboutLibraries.exportPath=src/commonMain/composeResources/files/
```

### Run Wasm app
Expand Down

Large diffs are not rendered by default.

38 changes: 36 additions & 2 deletions app-wasm/src/wasmJsMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.window.CanvasBasedWindow
import com.mikepenz.aboutlibraries.Libs
import com.mikepenz.aboutlibraries.entity.Library
import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer
import com.mikepenz.`app-wasm`.generated.resources.Res
import com.mikepenz.aboutlibraries.ui.compose.LicenseDialog
import com.mikepenz.aboutlibraries.ui.compose.util.htmlReadyLicenseContent
import com.mikepenz.app_wasm.generated.resources.Res
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.jetbrains.compose.resources.ExperimentalResourceApi
Expand All @@ -28,10 +34,38 @@ fun main() {
}
}

val uriHandler = LocalUriHandler.current
val openDialog = remember { mutableStateOf<Library?>(null) }

LibrariesContainer(
libraries.value,
Modifier.fillMaxSize()
Modifier.fillMaxSize(),
onLibraryClick = { library ->
val license = library.licenses.firstOrNull()
if (!license?.url.isNullOrBlank()) {
license?.url?.also {
try {
uriHandler.openUri(it)
} catch (t: Throwable) {
println("Failed to open url: ${it}")
}
}
} else if (!license?.htmlReadyLicenseContent.isNullOrBlank()) {
openDialog.value = library
}
},
)


val library = openDialog.value
if (library != null) {
// TODO use https://android-review.googlesource.com/c/platform/frameworks/support/+/3024604
LicenseDialog(library, body = {
Text(library.licenses.firstOrNull()?.htmlReadyLicenseContent ?: "")
}) {
openDialog.value = null
}
}
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions app-wasm/webpack.config.d/boilerplate.js

This file was deleted.

31 changes: 0 additions & 31 deletions app-wasm/webpack.config.d/cleanupSourcemap.js

This file was deleted.

Loading

0 comments on commit f71987f

Please sign in to comment.