File tree Expand file tree Collapse file tree 4 files changed +21
-0
lines changed
compose-multiplatform-common/src
commonMain/kotlin/com/huanshankeji/compose/ui
jsMain/kotlin/com/huanshankeji/compose/ui
jvmMain/kotlin/com/huanshankeji/compose/ui
demo/src/commonMain/kotlin/com/huanshankeji/compose/material/demo Expand file tree Collapse file tree 4 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ expect class ModifierOrAttrsScope<out TElement : Element> {
1313
1414expect class StyleScope {
1515 fun margin (value : SizeValue )
16+ fun height (value : SizeValue )
17+ fun width (value : SizeValue )
1618}
1719
1820private const val PADDING_MESSAGE =
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ package com.huanshankeji.compose.ui
22
33import com.huanshankeji.compose.ui.unit.SizeValue
44import org.jetbrains.compose.web.attributes.AttrsScope
5+ import org.jetbrains.compose.web.css.height
56import org.jetbrains.compose.web.css.margin
7+ import org.jetbrains.compose.web.css.width
68import org.jetbrains.compose.web.dom.AttrBuilderContext
79import org.w3c.dom.HTMLElement
810
@@ -22,4 +24,10 @@ actual class ModifierOrAttrsScope<out TElement : Element>(val attrsScope: AttrsS
2224actual class StyleScope (val styleScope : org.jetbrains.compose.web.css.StyleScope ) {
2325 actual fun margin (value : SizeValue ) =
2426 styleScope.margin(value.platformValue)
27+
28+ actual fun height (value : SizeValue ) =
29+ styleScope.height(value.platformValue)
30+
31+ actual fun width (value : SizeValue ) =
32+ styleScope.width(value.platformValue)
2533}
Original file line number Diff line number Diff line change 11package com.huanshankeji.compose.ui
22
3+ import androidx.compose.foundation.layout.height
34import androidx.compose.foundation.layout.padding
5+ import androidx.compose.foundation.layout.width
46import androidx.compose.ui.Modifier
57import com.huanshankeji.compose.ui.unit.SizeValue
68
@@ -33,4 +35,12 @@ actual class StyleScope(val modifierOrAttrsScope: ModifierOrAttrsScope<*>) {
3335 actual fun margin (value : SizeValue ) = modifierOrAttrsScope.modify {
3436 padding(value.platformValue)
3537 }
38+
39+ actual fun height (value : SizeValue ) = modifierOrAttrsScope.modify {
40+ height(value.platformValue)
41+ }
42+
43+ actual fun width (value : SizeValue ) = modifierOrAttrsScope.modify {
44+ width(value.platformValue)
45+ }
3646}
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ fun App() {
2222 Card ({
2323 style {
2424 margin(16 .dpOrPx)
25+ height(400 .dpOrPx)
2526 }
2627 }) {
2728 Column ({
You can’t perform that action at this time.
0 commit comments