Skip to content

Commit ef2d4d9

Browse files
committed
Add an isInteractiveJs parameter to ListItemComponents
1 parent 291e6f5 commit ef2d4d9

File tree

2 files changed

+15
-3
lines changed
  • compose-multiplatform-material3/src
    • commonMain/kotlin/com/huanshankeji/compose/material3/lazy/ext
    • jsMain/kotlin/com/huanshankeji/compose/material3/lazy/ext

2 files changed

+15
-3
lines changed

compose-multiplatform-material3/src/commonMain/kotlin/com/huanshankeji/compose/material3/lazy/ext/List.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ expect class ListScope {
3131

3232
expect class ItemScope
3333

34+
/**
35+
* @param isInteractiveJs whether the item is interactive on JS DOM,
36+
* aka whether it shows effects when the mouse pointer hovers above it or when it gets clicked.
37+
* On the `androidx.compose` targets, use `Modifier.clickable` for the same effect.
38+
*/
3439
class ListItemComponents(
3540
val contentModifier: Modifier = Modifier,
41+
val isInteractiveJs: Boolean,
3642
val headline: @Composable (Modifier) -> Unit,
3743
val start: @Composable ((Modifier) -> Unit)? = null,
3844
val end: @Composable ((Modifier) -> Unit)? = null,
@@ -42,6 +48,7 @@ class ListItemComponents(
4248
) {
4349
constructor(
4450
contentModifier: Modifier = Modifier,
51+
isInteractiveJs: Boolean,
4552
headline: String,
4653
start: Icon? = null,
4754
end: Icon? = null,
@@ -50,6 +57,7 @@ class ListItemComponents(
5057
overline: String? = null
5158
) : this(
5259
contentModifier,
60+
isInteractiveJs,
5361
headline.toTextWithModifier(),
5462
start.toNullableContentWithModifier(),
5563
end.toNullableContentWithModifier(),

compose-multiplatform-material3/src/jsMain/kotlin/com/huanshankeji/compose/material3/lazy/ext/List.js.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
44
import com.huanshankeji.compose.foundation.verticalScrollPlatformModifier
55
import com.huanshankeji.compose.html.material3.MdList
66
import com.huanshankeji.compose.html.material3.MdListItemScope
7+
import com.huanshankeji.compose.html.material3.MdListItemType
78
import com.huanshankeji.compose.html.material3.MdListScope
89
import com.huanshankeji.compose.runtime.DeferredComposableRunner
910
import com.huanshankeji.compose.ui.Modifier
@@ -39,9 +40,12 @@ actual class ListScope(val mdListScope: MdListScope) {
3940

4041

4142
@Composable
42-
private fun ListItem(content: ListItemComponents) =
43-
mdListScope.MdListItem(attrs = content.contentModifier.toAttrs()) {
44-
contentFromComponents(content)
43+
private fun ListItem(components: ListItemComponents) =
44+
mdListScope.MdListItem(
45+
type = if (components.isInteractiveJs) MdListItemType.Button else null,
46+
attrs = components.contentModifier.toAttrs()
47+
) {
48+
contentFromComponents(components)
4549
}
4650

4751

0 commit comments

Comments
 (0)