Skip to content

Commit d31c163

Browse files
committed
Add the StyleScope extension functions width and height, each of which takes a string argument, and a const string value FIT_CONTENT
1 parent 40d1f5d commit d31c163

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

compose-web-common/src/jsMain/kotlin/com/huanshankeji/compose/web/Layouts.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package com.huanshankeji.compose.web
33
import androidx.compose.runtime.Composable
44
import com.huanshankeji.compose.web.attributes.attrs
55
import com.huanshankeji.compose.web.attributes.plus
6+
import com.huanshankeji.compose.web.css.FIT_CONTENT
67
import com.huanshankeji.compose.web.css.Styles
8+
import com.huanshankeji.compose.web.css.width
79
import com.huanshankeji.compose.web.css.wrapInAttrs
810
import org.jetbrains.compose.web.css.*
911
import org.jetbrains.compose.web.dom.AttrBuilderContext
@@ -37,7 +39,7 @@ fun Column(
3739
Flexbox(attrs<HTMLDivElement> {
3840
style {
3941
flexDirection(FlexDirection.Column)
40-
if (fitContent) property("width", "fit-content")
42+
if (fitContent) width(FIT_CONTENT)
4143
}
4244
} + attrs, content)
4345

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.huanshankeji.compose.web.css
2+
3+
import org.jetbrains.compose.web.css.StyleScope
4+
5+
fun StyleScope.width(value: String) =
6+
property("width", value)
7+
8+
fun StyleScope.height(value: String) =
9+
property("height", value)
10+
11+
const val FIT_CONTENT = "fit-content"

0 commit comments

Comments
 (0)