generated from mpetuska/template-kmp-library
-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMDCCard.kt
85 lines (82 loc) · 2.43 KB
/
MDCCard.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package showcases
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import dev.petuska.katalog.runtime.Showcase
import dev.petuska.katalog.runtime.layout.InteractiveShowcase
import dev.petuska.katalog.runtime.util.LoremIpsum
import dev.petuska.katalog.runtime.util.RickRollUrl
import dev.petuska.katalog.runtime.util.randomImageUrl
import dev.petuska.kmdc.button.Label
import dev.petuska.kmdc.card.*
import dev.petuska.kmdc.typography.MDCBody1
import dev.petuska.kmdc.typography.MDCH4
import dev.petuska.kmdc.typography.MDCSubtitle1
import dev.petuska.kmdcx.icons.MDCIcon
import dev.petuska.kmdcx.icons.mdcIcon
import org.jetbrains.compose.web.css.backgroundImage
import org.jetbrains.compose.web.dom.Text
import sandbox.control.BooleanControl
import sandbox.control.ChoiceControl
import sandbox.util.NamedGroup
private class MDCCardVM {
var type by mutableStateOf(MDCCardType.Outlined)
var mediaType by mutableStateOf(MDCCardMediaType.Cinema)
var fullBleed by mutableStateOf(false)
}
@Composable
@Showcase(id = "MDCCard")
fun MDCCard() = InteractiveShowcase(
viewModel = { MDCCardVM() },
controls = {
ChoiceControl("Type", MDCCardType.values().associateBy(MDCCardType::name), ::type)
NamedGroup("Media") {
ChoiceControl("Type", MDCCardMediaType.values().associateBy(MDCCardMediaType::name), ::mediaType)
}
NamedGroup("Actions") {
BooleanControl("Full Bleed", ::fullBleed)
}
},
) {
MDCCard(
type = type,
) {
PrimaryAction {
Media(
type = mediaType,
attrs = {
style {
backgroundImage("url(\"${randomImageUrl()}\")")
}
}
) {
MediaContent {
MDCH4("Title")
MDCSubtitle1("Subtitle")
}
}
MDCBody1(LoremIpsum)
}
Actions(fullBleed = fullBleed) {
if (fullBleed) {
ActionButtonLink(href = RickRollUrl) { Label("Action 1") }
} else {
ActionButtons {
ActionButton { Label("Action 1") }
ActionButton { Label("Action 2") }
}
ActionIcons {
ActionIconButton(attrs = {
mdcIcon()
title("Share")
}) { Text(MDCIcon.Share.type) }
ActionIconButton(attrs = {
mdcIcon()
title("More options")
}) { Text(MDCIcon.MoreVert.type) }
}
}
}
}
}