Skip to content

Commit 4905737

Browse files
committed
Add the card composables
1 parent 8746b57 commit 4905737

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.huanshankeji.compose.html.material3
2+
3+
@RequiresOptIn(
4+
"This API depends on components in the Material Web labs directory, which contains experimental features that are not recommended for production. " +
5+
"See https://github.com/material-components/material-web/tree/main/labs for more details.",
6+
RequiresOptIn.Level.WARNING
7+
)
8+
@Retention(AnnotationRetention.BINARY)
9+
annotation class MaterialWebLabsApi
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.huanshankeji.compose.html.material3
2+
3+
import androidx.compose.runtime.Composable
4+
import com.huanshankeji.compose.web.attributes.Attrs
5+
import org.jetbrains.compose.web.dom.ElementScope
6+
import org.jetbrains.compose.web.dom.TagElement
7+
import org.w3c.dom.HTMLElement
8+
9+
/*
10+
https://github.com/material-components/material-web/blob/main/labs/card/internal/card.ts
11+
https://github.com/material-components/material-web/blob/main/labs/card/demo/stories.ts
12+
*/
13+
14+
@MaterialWebLabsApi
15+
@Composable
16+
fun MdElevatedCard(
17+
attrs: Attrs<HTMLElement>? = null,
18+
content: @Composable (ElementScope<HTMLElement>.() -> Unit)?
19+
) {
20+
require("@material/web/labs/card/elevated-card.js")
21+
22+
TagElement("md-elevated-card", attrs, content)
23+
}
24+
25+
@MaterialWebLabsApi
26+
@Composable
27+
fun MdFilledCard(
28+
attrs: Attrs<HTMLElement>? = null,
29+
content: @Composable (ElementScope<HTMLElement>.() -> Unit)?
30+
) {
31+
require("@material/web/labs/card/filled-card.js")
32+
33+
TagElement("md-filled-card", attrs, content)
34+
}
35+
36+
@MaterialWebLabsApi
37+
@Composable
38+
fun MdOutlinedCard(
39+
attrs: Attrs<HTMLElement>? = null,
40+
content: @Composable (ElementScope<HTMLElement>.() -> Unit)?
41+
) {
42+
require("@material/web/labs/card/outlined-card.js")
43+
44+
TagElement("md-outlined-card", attrs, content)
45+
}

0 commit comments

Comments
 (0)