Skip to content

Commit 88fa4ac

Browse files
committed
Add a preliminary Card composable which doesn't produce consistent results on desktop and web
1 parent c66c304 commit 88fa4ac

File tree

4 files changed

+21
-3
lines changed
  • compose-multiplatform-material/src
  • demo/src/commonMain/kotlin/com/huanshankeji/compose/material/demo

4 files changed

+21
-3
lines changed

compose-multiplatform-material/src/commonMain/kotlin/com/huanshankeji/compose/material/Components.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ expect /*value*/ class ButtonScope {
1212
expect fun Button(onClick: () -> Unit, content: @Composable ButtonScope.() -> Unit)
1313

1414

15+
@Composable
16+
expect fun Card(content: @Composable () -> Unit)
17+
18+
1519
@Composable
1620
expect fun Icon(materialIcon: MaterialIcon)
1721

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.huanshankeji.compose.material.icon.MaterialIcon
55
import dev.petuska.kmdc.button.Label
66
import dev.petuska.kmdc.button.MDCButton
77
import dev.petuska.kmdc.button.MDCButtonScope
8+
import dev.petuska.kmdc.card.MDCCard
89
import dev.petuska.kmdc.icon.button.MDCIconButton
910
import dev.petuska.kmdc.top.app.bar.*
1011
import dev.petuska.kmdcx.icons.MDCIconSpan
@@ -23,6 +24,11 @@ actual fun Button(onClick: () -> Unit, content: @Composable ButtonScope.() -> Un
2324
MDCButton(attrs = { onClick { onClick() } }) { ButtonScope(this).content() }
2425

2526

27+
@Composable
28+
actual fun Card(content: @Composable () -> Unit) =
29+
MDCCard { content() }
30+
31+
2632
/**
2733
* There is often a better alternative of adding the CSS rule to the parent element to using this composable directly.
2834
*/

compose-multiplatform-material/src/jvmMain/kotlin/com/huanshankeji/compose/material/Components.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ actual fun Button(onClick: () -> Unit, content: @Composable ButtonScope.() -> Un
1818
androidx.compose.material.Button(onClick) { ButtonScope(this).content() }
1919

2020

21+
@Composable
22+
actual fun Card(content: @Composable () -> Unit) =
23+
androidx.compose.material.Card { content() }
24+
25+
2126
@Composable
2227
actual fun Icon(materialIcon: MaterialIcon) =
2328
androidx.compose.material.Icon(materialIcon, null)

demo/src/commonMain/kotlin/com/huanshankeji/compose/material/demo/Composables.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.huanshankeji.compose.material.demo
33
import androidx.compose.runtime.*
44
import com.huanshankeji.compose.Text
55
import com.huanshankeji.compose.material.Button
6+
import com.huanshankeji.compose.material.Card
67
import com.huanshankeji.compose.material.TopAppBarScaffold
78
import com.huanshankeji.compose.material.icon.MaterialIcons
89

@@ -15,9 +16,11 @@ fun App() {
1516
}, {
1617
MaterialIconActionButton({}, MaterialIcons.Search)
1718
}) {
18-
var count by remember { mutableStateOf(0) }
19-
Button({ count++ }) {
20-
Label(count.toString())
19+
Card {
20+
var count by remember { mutableStateOf(0) }
21+
Button({ count++ }) {
22+
Label(count.toString())
23+
}
2124
}
2225
}
2326
}

0 commit comments

Comments
 (0)