From c1fd4bd25901cbee54712daadb15e4c2fcc98fc9 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Thu, 8 Jul 2021 23:18:31 +0200 Subject: [PATCH] Move relevant properties from CSSProperties to box.kt, position.kt and flex.kt --- .../compose/web/css/CSSProperties.kt | 99 ------------------- .../compose/web/css/properties/box.kt | 24 +++++ .../compose/web/css/properties/flex.kt | 49 +++++++++ .../compose/web/css/properties/position.kt | 48 +++++++++ 4 files changed, 121 insertions(+), 99 deletions(-) create mode 100644 web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/box.kt create mode 100644 web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/flex.kt create mode 100644 web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/position.kt diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSProperties.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSProperties.kt index 7c17abd3..6d4613ce 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSProperties.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSProperties.kt @@ -2,8 +2,6 @@ package org.jetbrains.compose.web.css -import org.jetbrains.compose.web.css.keywords.CSSAutoKeyword - fun StyleBuilder.opacity(value: Number) { property("opacity", value) } @@ -65,101 +63,4 @@ inline fun CSSBorder.color(color: CSSColorValue) { fun StyleBuilder.display(displayStyle: DisplayStyle) { property("display", displayStyle.value) -} - -fun StyleBuilder.flexDirection(flexDirection: FlexDirection) { - property("flex-direction", flexDirection.value) -} - -fun StyleBuilder.flexWrap(flexWrap: FlexWrap) { - property("flex-wrap", flexWrap.value) -} - -fun StyleBuilder.flexFlow(flexDirection: FlexDirection, flexWrap: FlexWrap) { - property( - "flex-flow", - "${flexDirection.value} ${flexWrap.value}" - ) -} - -fun StyleBuilder.justifyContent(justifyContent: JustifyContent) { - property( - "justify-content", - justifyContent.value - ) -} -fun StyleBuilder.alignSelf(alignSelf: AlignSelf) { - property( - "align-self", - alignSelf.value - ) -} - -fun StyleBuilder.alignItems(alignItems: AlignItems) { - property( - "align-items", - alignItems.value - ) -} - -fun StyleBuilder.alignContent(alignContent: AlignContent) { - property( - "align-content", - alignContent.value - ) -} - -fun StyleBuilder.position(position: Position) { - property( - "position", - position.value - ) -} - -fun StyleBuilder.width(value: CSSNumeric) { - property("width", value) -} - -fun StyleBuilder.width(value: CSSAutoKeyword) { - property("width", value) -} - -fun StyleBuilder.height(value: CSSNumeric) { - property("height", value) -} - -fun StyleBuilder.height(value: CSSAutoKeyword) { - property("height", value) -} - -fun StyleBuilder.top(value: CSSLengthOrPercentageValue) { - property("top", value) -} - -fun StyleBuilder.top(value: CSSAutoKeyword) { - property("top", value) -} - -fun StyleBuilder.bottom(value: CSSLengthOrPercentageValue) { - property("bottom", value) -} - -fun StyleBuilder.bottom(value: CSSAutoKeyword) { - property("bottom", value) -} - -fun StyleBuilder.left(value: CSSLengthOrPercentageValue) { - property("left", value) -} - -fun StyleBuilder.left(value: CSSAutoKeyword) { - property("left", value) -} - -fun StyleBuilder.right(value: CSSLengthOrPercentageValue) { - property("right", value) -} - -fun StyleBuilder.right(value: CSSAutoKeyword) { - property("right", value) } \ No newline at end of file diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/box.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/box.kt new file mode 100644 index 00000000..c235e101 --- /dev/null +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/box.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. + */ + +package org.jetbrains.compose.web.css + +import org.jetbrains.compose.web.css.keywords.CSSAutoKeyword + +fun StyleBuilder.width(value: CSSNumeric) { + property("width", value) +} + +fun StyleBuilder.width(value: CSSAutoKeyword) { + property("width", value) +} + +fun StyleBuilder.height(value: CSSNumeric) { + property("height", value) +} + +fun StyleBuilder.height(value: CSSAutoKeyword) { + property("height", value) +} \ No newline at end of file diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/flex.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/flex.kt new file mode 100644 index 00000000..60ab3768 --- /dev/null +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/flex.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. + */ + +package org.jetbrains.compose.web.css + +fun StyleBuilder.flexDirection(flexDirection: FlexDirection) { + property("flex-direction", flexDirection.value) +} + +fun StyleBuilder.flexWrap(flexWrap: FlexWrap) { + property("flex-wrap", flexWrap.value) +} + +fun StyleBuilder.flexFlow(flexDirection: FlexDirection, flexWrap: FlexWrap) { + property( + "flex-flow", + "${flexDirection.value} ${flexWrap.value}" + ) +} + +fun StyleBuilder.justifyContent(justifyContent: JustifyContent) { + property( + "justify-content", + justifyContent.value + ) +} +fun StyleBuilder.alignSelf(alignSelf: AlignSelf) { + property( + "align-self", + alignSelf.value + ) +} + +fun StyleBuilder.alignItems(alignItems: AlignItems) { + property( + "align-items", + alignItems.value + ) +} + +fun StyleBuilder.alignContent(alignContent: AlignContent) { + property( + "align-content", + alignContent.value + ) +} + diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/position.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/position.kt new file mode 100644 index 00000000..7005b983 --- /dev/null +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/position.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. + */ + +package org.jetbrains.compose.web.css + +import org.jetbrains.compose.web.css.keywords.CSSAutoKeyword + +fun StyleBuilder.position(position: Position) { + property( + "position", + position.value + ) +} + +fun StyleBuilder.top(value: CSSLengthOrPercentageValue) { + property("top", value) +} + +fun StyleBuilder.top(value: CSSAutoKeyword) { + property("top", value) +} + +fun StyleBuilder.bottom(value: CSSLengthOrPercentageValue) { + property("bottom", value) +} + +fun StyleBuilder.bottom(value: CSSAutoKeyword) { + property("bottom", value) +} + +fun StyleBuilder.left(value: CSSLengthOrPercentageValue) { + property("left", value) +} + +fun StyleBuilder.left(value: CSSAutoKeyword) { + property("left", value) +} + +fun StyleBuilder.right(value: CSSLengthOrPercentageValue) { + property("right", value) +} + +fun StyleBuilder.right(value: CSSAutoKeyword) { + property("right", value) +} +