Skip to content

Commit 4476e34

Browse files
committed
Add the progress composables and fix the name of the md menu file BTW
1 parent 0ee7ce2 commit 4476e34

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

compose-html-material3/src/jsMain/kotlin/com/huanshankeji/compose/html/material3/MdCheckbox.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.huanshankeji.compose.html.material3
22

33
import androidx.compose.runtime.Composable
4+
import com.huanshankeji.compose.html.material3.attributes.indeterminate
45
import com.huanshankeji.compose.web.attributes.Attrs
56
import com.huanshankeji.compose.web.attributes.attr
67
import com.huanshankeji.compose.web.attributes.ext.*
@@ -29,7 +30,7 @@ fun MdCheckbox(
2930
attr("touch-target", "wrapper")
3031
checked?.let { attr("checked", it) }
3132
disabled(disabled)
32-
indeterminate?.let { attr("indeterminate", it) }
33+
indeterminate(indeterminate)
3334
required(required)
3435
value(value)
3536
name(name)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.huanshankeji.compose.html.material3
2+
3+
import androidx.compose.runtime.Composable
4+
import com.huanshankeji.compose.html.material3.attributes.indeterminate
5+
import com.huanshankeji.compose.web.attributes.Attrs
6+
import com.huanshankeji.compose.web.attributes.attrIfNotNull
7+
import org.jetbrains.compose.web.dom.ElementScope
8+
import org.jetbrains.compose.web.dom.TagElement
9+
import org.w3c.dom.HTMLElement
10+
11+
/*
12+
https://github.com/material-components/material-web/blob/main/docs/components/progress.md
13+
https://material-web.dev/components/progress/
14+
https://material-web.dev/components/progress/stories/
15+
*/
16+
17+
@Composable
18+
private fun CommonMdProgress(
19+
tagName: String,
20+
attrsBefore: Attrs<HTMLElement>?,
21+
value: Number?,
22+
max: Number?,
23+
indeterminate: Boolean?,
24+
fourColor: Boolean?,
25+
attrs: Attrs<HTMLElement>?,
26+
content: @Composable (ElementScope<HTMLElement>.() -> Unit)?
27+
) =
28+
TagElement(tagName, {
29+
attrsBefore?.invoke(this)
30+
31+
attrIfNotNull("value", value)
32+
attrIfNotNull("max", max)
33+
indeterminate(indeterminate)
34+
attrIfNotNull("four-color", fourColor)
35+
36+
attrs?.invoke(this)
37+
}, content)
38+
39+
@Composable
40+
fun MdLinearProgress(
41+
buffer: Number? = null,
42+
value: Number? = null,
43+
max: Number? = null,
44+
indeterminate: Boolean? = null,
45+
fourColor: Boolean? = null,
46+
attrs: Attrs<HTMLElement>? = null,
47+
content: @Composable (ElementScope<HTMLElement>.() -> Unit)? = null
48+
) {
49+
require("@material/web/progress/linear-progress.js")
50+
51+
CommonMdProgress(
52+
"md-linear-progress",
53+
{ attrIfNotNull("buffer", buffer) },
54+
value, max, indeterminate, fourColor, attrs, content
55+
)
56+
}
57+
58+
@Composable
59+
fun MdCircularProgress(
60+
value: Number? = null,
61+
max: Number? = null,
62+
indeterminate: Boolean? = null,
63+
fourColor: Boolean? = null,
64+
attrs: Attrs<HTMLElement>? = null,
65+
content: @Composable (ElementScope<HTMLElement>.() -> Unit)? = null
66+
) {
67+
require("@material/web/progress/circular-progress.js")
68+
69+
CommonMdProgress(
70+
"md-circular-progress",
71+
null,
72+
value, max, indeterminate, fourColor, attrs, content
73+
)
74+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.huanshankeji.compose.html.material3.attributes
2+
3+
import com.huanshankeji.compose.web.attributes.attr
4+
import org.jetbrains.compose.web.attributes.AttrsScope
5+
6+
fun AttrsScope<*>.indeterminate(indeterminate: Boolean?) {
7+
indeterminate?.let { attr("indeterminate", it) }
8+
}

0 commit comments

Comments
 (0)