generated from mpetuska/template-kmp-library
-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
MDCIcon.kt
65 lines (62 loc) · 1.82 KB
/
MDCIcon.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
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.kmdc.typography.MDCCaption
import dev.petuska.kmdcx.icons.MDCIcon
import dev.petuska.kmdcx.icons.MDCIconBase
import dev.petuska.kmdcx.icons.MDCIconType
import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.dom.Div
import sandbox.control.ChoiceControl
import sandbox.control.RangeControl
private class MDCIconVM {
var base by mutableStateOf(MDCIconBase.I)
var type by mutableStateOf(MDCIconType.Filled)
var size by mutableStateOf(24)
}
@Composable
@Showcase(id = "MDCIcon")
fun MDCIcon() = InteractiveShowcase(
viewModel = { MDCIconVM() },
controls = {
ChoiceControl("Base", MDCIconBase.values().associateBy(MDCIconBase::name), ::base)
ChoiceControl("Type", MDCIconType.values().associateBy(MDCIconType::name), ::type)
RangeControl("Size", size, min = 12, max = 240, step = 12) { size = it.toInt() }
},
) {
Div(attrs = {
style {
display(DisplayStyle.Flex)
flexFlow(FlexDirection.Row, FlexWrap.Wrap)
}
}) {
MDCIcon.values().forEach { icon ->
Div(attrs = {
style {
padding(0.5.em)
display(DisplayStyle.Flex)
flexDirection(FlexDirection.Column)
alignItems(AlignItems.Center)
justifyContent(JustifyContent.Center)
}
}) {
MDCIcon(
base = base,
type = type,
icon = icon,
attrs = {
style {
fontSize(size.px)
}
}
)
MDCCaption(icon.name)
MDCCaption("(${icon.type})")
}
}
}
}