Skip to content

Commit d3b37ff

Browse files
committed
Remove the dependency on compose-multiplatform-common-legacy in compose-multiplatform-material and improve code
1 parent 047cb82 commit d3b37ff

File tree

4 files changed

+7
-17
lines changed

4 files changed

+7
-17
lines changed

compose-multiplatform-material/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ kotlin {
1616
dependencies {
1717
api(compose.runtime)
1818
implementation("org.jetbrains.compose.annotation-internal:annotation:${DependencyVersions.composeMultiplatform}")
19-
api(project(":compose-multiplatform-common:compose-multiplatform-common-legacy")) // TODO remove
2019
api(project(":compose-multiplatform-common"))
2120
//compileOnly(compose.material) // for KDoc element links only
2221
}

compose-multiplatform-material/src/jsMain/kotlin/com/huanshankeji/compose/material/Button.js.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ import com.huanshankeji.compose.foundation.layout.RowScope
66
import com.huanshankeji.compose.material.ext.ButtonType
77
import com.huanshankeji.compose.material.ext.toMDCButtonType
88
import com.huanshankeji.compose.ui.Modifier
9-
import com.huanshankeji.compose.web.attributes.attrs
10-
import com.huanshankeji.compose.web.attributes.plus
119
import com.varabyte.kobweb.compose.ui.toAttrs
1210
import dev.petuska.kmdc.button.MDCButton
13-
import org.w3c.dom.HTMLButtonElement
1411

1512
@Composable
1613
private fun Button(
@@ -20,9 +17,9 @@ private fun Button(
2017
content: @Composable RowScope.() -> Unit
2118
) =
2219
MDCButton(buttonType.toMDCButtonType(),
23-
attrs = attrs<HTMLButtonElement> {
20+
attrs = modifier.platformModifier.toAttrs {
2421
onClick { onClick() }
25-
} + modifier.platformModifier.toAttrs()) {
22+
}) {
2623
Row(content = content)
2724
}
2825

compose-multiplatform-material/src/jsMain/kotlin/com/huanshankeji/compose/material/Card.js.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@ package com.huanshankeji.compose.material
22

33
import androidx.compose.runtime.Composable
44
import com.huanshankeji.compose.ui.Modifier
5-
import com.huanshankeji.compose.web.css.FIT_CONTENT
6-
import com.huanshankeji.compose.web.css.width
5+
import com.huanshankeji.kobweb.compose.ui.modifiers.sizeFitContent
76
import com.varabyte.kobweb.compose.ui.toAttrs
87
import dev.petuska.kmdc.card.MDCCard
8+
import com.varabyte.kobweb.compose.ui.Modifier as PlatformModifier
99

1010
@Composable
1111
actual fun Card(modifier: Modifier, content: @Composable () -> Unit) =
12-
MDCCard(attrs = modifier.platformModifier.toAttrs {
13-
style {
14-
width(FIT_CONTENT)
15-
}
16-
}) { content() }
12+
MDCCard(attrs = PlatformModifier.sizeFitContent().then(modifier.platformModifier).toAttrs()) { content() }

compose-multiplatform-material/src/jsMain/kotlin/com/huanshankeji/compose/material/ext/Button.js.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package com.huanshankeji.compose.material.ext
33
import androidx.compose.runtime.Composable
44
import com.huanshankeji.compose.material.ext.ButtonType.*
55
import com.huanshankeji.compose.ui.Modifier
6-
import com.huanshankeji.compose.web.attributes.attrs
7-
import com.huanshankeji.compose.web.attributes.plus
86
import com.varabyte.kobweb.compose.ui.toAttrs
97
import dev.petuska.kmdc.button.Label
108
import dev.petuska.kmdc.button.MDCButton
@@ -20,9 +18,9 @@ actual fun Button(
2018
content: @Composable ButtonScope.() -> Unit
2119
) =
2220
MDCButton(buttonType.toMDCButtonType(),
23-
attrs = attrs<HTMLButtonElement> {
21+
attrs = modifier.platformModifier.toAttrs {
2422
onClick { onClick() }
25-
} + modifier.platformModifier.toAttrs()) {
23+
}) {
2624
ButtonScope(this).content()
2725
}
2826

0 commit comments

Comments
 (0)