Skip to content

Commit 92ec3c1

Browse files
authored
Merge pull request #14 from huanshankeji/use-kobweb-silk
Refactor the project to depend on Kobweb Silk on Kotlin/JS (Compose HTML) and provide a universal multiplatform interface for `Modifier`, scopes, etc. akin to those in `androidx.compose`
2 parents cca2836 + d3b37ff commit 92ec3c1

File tree

138 files changed

+2455
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+2455
-516
lines changed

README.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Maven Central](https://img.shields.io/maven-central/v/com.huanshankeji/compose-multiplatform-material)](https://search.maven.org/search?q=g:com.huanshankeji%20AND%20a:compose-multiplatform-*)
44
![Kotlin version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=com.huanshankeji&name=compose-multiplatform-material)
55

6-
Some simple unified Compose Multiplatform wrappers of common components, layouts, and Material Design components for `androidx.compose.material` (officially supported on Android, desktop (JVM), iOS, web (Kotlin/Wasm)) and Compose HTML (mainly based on [KMDC](https://github.com/mpetuska/kmdc))
6+
Some simple unified Compose Multiplatform wrappers of common components, layouts, and Material Design components for `androidx.compose.material` (officially supported on Android, desktop (JVM), iOS, web (Kotlin/Wasm)) and Compose HTML (mainly based on [Kobweb Silk](https://github.com/varabyte/kobweb?tab=readme-ov-file#silk) and [KMDC](https://github.com/mpetuska/kmdc))
77

88
<!-- a set of APIs for Compose HTML similar to those in `androidx.compose.material` -->
99

@@ -20,7 +20,10 @@ This project is prototype and there is no documentation yet. Check out [the demo
2020
#### Common (Foundation) components
2121

2222
- `BasicText`
23-
- `RawText`
23+
24+
##### `ext` components
25+
26+
- `InlineBasicText`
2427

2528
##### Layouts
2629

@@ -39,7 +42,11 @@ This project is prototype and there is no documentation yet. Check out [the demo
3942
- `TextField`
4043
- `TopAppBarScaffold`
4144

42-
### Styles
45+
#### Components in the `ext` packages
46+
47+
The components in the `ext` packages don't follow the `androidx.compose` APIs exactly, but rather provide wrappers are idiomatic and conventional on both kinds of targets, wrapping different APIs which can't be unified following the `androidx.compose` APIs.
48+
49+
### Styles (obsolete in the legacy module, for removal)
4350

4451
The `ModifierOrAttrsScope.styles` function and the `StyleScope` class provide a universal interface for `Modifier`s and CSS styles.
4552

@@ -51,3 +58,46 @@ The functions in `StyleScope`:
5158
- `backgroundColor`
5259
- `platformBorder`
5360
- `outerBorder`
61+
62+
### Modifiers
63+
64+
- size modifiers
65+
- `size`, `sizeIn`, `fillMaxSize`
66+
- `width`, `widthIn`, `fillMaxWidth`
67+
- `height`, `heightIn`, `fillMaxHeight`
68+
- `padding`
69+
- `background`
70+
- `border` (visually inconsistent)
71+
72+
#### `ext` modifiers
73+
74+
- `outerBorder`
75+
- `roundedCornerBackgroundAndOuterBorder`
76+
77+
## Add the libraries to your dependency
78+
79+
Maven coordinate:
80+
81+
```kotlin
82+
"com.huanshankeji:compose-multiplatform-$module:$version"
83+
```
84+
85+
View [all the artifacts on Maven Central](https://search.maven.org/search?q=g:com.huanshankeji%20AND%20a:compose-multiplatform-*).
86+
87+
This project depends on [Kobweb](https://github.com/varabyte/kobweb) which is not published to Maven Central yet, so you have to add the following Maven repository:
88+
89+
```kotlin
90+
repositories {
91+
maven("https://us-central1-maven.pkg.dev/varabyte-repos/public")
92+
}
93+
```
94+
95+
## About Kobweb Silk
96+
97+
The Kotlin/JS (Compose HTML) portion of this project depends on [Kobweb Compose](https://github.com/varabyte/kobweb/blob/main/frontend/kobweb-compose/README.md) of [Kobweb Silk](https://github.com/varabyte/kobweb?tab=readme-ov-file#silk) which is a UI layer built upon Compose HTML that provides `Modifier` APIs (type-safe CSS API wrappers) and layouts. Here is a list of topics in their README.md that should be helpful when you use this library in Compose HTML:
98+
99+
1. [Silk](https://github.com/varabyte/kobweb?tab=readme-ov-file#silk)
100+
1. [Modifier](https://github.com/varabyte/kobweb?tab=readme-ov-file#modifier)
101+
1. [attrsModifier and styleModifier](https://github.com/varabyte/kobweb?tab=readme-ov-file#attrsmodifier-and-stylemodifier)
102+
1. [General purpose improvements on top of Compose HTML and Kotlin/JS](https://github.com/varabyte/kobweb?tab=readme-ov-file#general-purpose-improvements-on-top-of-compose-html-and-kotlinjs)
103+
1. [What about Compose Multiplatform for Web?](https://github.com/varabyte/kobweb?tab=readme-ov-file#what-about-compose-multiplatform-for-web)

buildSrc/src/main/kotlin/VersionsAndDependencies.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
object DependencyVersions {
2+
val composeMultiplatform = "1.6.1" // manually specified for "ui-unit"
3+
val kobweb = "0.17.1"
24
val huanshankejiComposeWeb = "0.2.2"
35
val kmdc = "0.1.2"
46
val materialIcons = "1.13.12"

buildSrc/src/main/kotlin/common-conventions.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ repositories {
1010
mavenCentral()
1111
google()
1212
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
13+
maven("https://us-central1-maven.pkg.dev/varabyte-repos/public") // for Kobweb
1314
}
1415

1516
group = "com.huanshankeji"

compose-multiplatform-common/build.gradle.kts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,37 @@ plugins {
77

88
kotlin {
99
sourceSets {
10+
/*
11+
Use `api`. See:
12+
https://github.com/JetBrains/compose-multiplatform-core/blob/jb-main/compose/foundation/foundation/build.gradle
13+
https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/compose/foundation/foundation/build.gradle
14+
*/
1015
commonMain {
1116
dependencies {
12-
implementation(compose.runtime)
17+
api(compose.runtime)
1318
//compileOnly(compose.foundation) // for KDoc element links only
19+
/*
20+
The units from Compose are used directly.
21+
This is an ideal dependency whose APIs should be exposed and shared on all platforms including JS
22+
therefore we don't need to create wrappers for them,
23+
because a depending `ui-graphics` module would be too much as it depends on `skiko`,
24+
and more such as `ui` and `ui-text` depend on `ui-graphics`.
25+
A dependency of `ui-unit` is `ui-geometry` which might be useful too.
26+
*/
27+
api("org.jetbrains.compose.ui:ui-unit:${DependencyVersions.composeMultiplatform}")
28+
implementation("org.jetbrains.compose.annotation-internal:annotation:${DependencyVersions.composeMultiplatform}")
1429
}
1530
}
1631
androidxCommonMain {
1732
dependencies {
18-
implementation(compose.foundation)
33+
api(compose.foundation)
1934
}
2035
}
2136
jsMain {
2237
dependencies {
23-
implementation(compose.html.core)
24-
25-
api("com.huanshankeji:compose-web-common:${DependencyVersions.huanshankejiComposeWeb}")
38+
api(compose.html.core)
39+
// see: https://github.com/varabyte/kobweb/blob/main/frontend/kobweb-compose/build.gradle.kts
40+
api("com.varabyte.kobweb:kobweb-compose:${DependencyVersions.kobweb}")
2641
}
2742
}
2843
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import com.huanshankeji.team.`Shreck Ye`
2+
import com.huanshankeji.team.pomForTeamDefaultOpenSource
3+
4+
plugins {
5+
`lib-conventions`
6+
}
7+
8+
kotlin {
9+
sourceSets {
10+
commonMain {
11+
dependencies {
12+
implementation(compose.runtime)
13+
//compileOnly(compose.foundation) // for KDoc element links only
14+
}
15+
}
16+
androidxCommonMain {
17+
dependencies {
18+
api(compose.foundation)
19+
}
20+
}
21+
jsMain {
22+
dependencies {
23+
implementation(compose.html.core)
24+
25+
api("com.huanshankeji:compose-web-common:${DependencyVersions.huanshankejiComposeWeb}")
26+
}
27+
}
28+
}
29+
}
30+
31+
publishing.publications.withType<MavenPublication> {
32+
pomForTeamDefaultOpenSource(
33+
project,
34+
"Legacy Compose Multiplatform common wrappers",
35+
"Legacy common wrappers of components (including layouts) and styles for Compose Multiplatform on (desktop/Android and web)\n" +
36+
"This legacy module depends on `com.huanshankeji:compose-web-common` instead of Kobweb Silk " +
37+
"and its components use the `ModifierOrAttrsScope` class to configure styles."
38+
) {
39+
`Shreck Ye`()
40+
}
41+
}

0 commit comments

Comments
 (0)