Browse Source

CSSProperties is no more, use properties.kt in case of doubts

pull/869/head
Shagen Ogandzhanian 3 years ago
parent
commit
0baeeca8c4
  1. 66
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSProperties.kt
  2. 30
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/border.kt
  3. 15
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/color.kt
  4. 13
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/flex.kt
  5. 19
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/properties.kt

66
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSProperties.kt

@ -1,66 +0,0 @@
@file:Suppress("Unused", "NOTHING_TO_INLINE")
package org.jetbrains.compose.web.css
fun StyleBuilder.opacity(value: Number) {
property("opacity", value)
}
fun StyleBuilder.order(value: Int) {
property("order", value)
}
fun StyleBuilder.flexGrow(value: Number) {
property("flex-grow", value)
}
fun StyleBuilder.flexShrink(value: Number) {
property("flex-shrink", value)
}
fun StyleBuilder.opacity(value: CSSSizeValue<CSSUnit.percent>) {
property("opacity", (value.value / 100))
}
fun StyleBuilder.color(value: String) {
property("color", value)
}
fun StyleBuilder.color(value: CSSColorValue) {
// color hasn't Typed OM yet
property("color", value)
}
@Suppress("EqualsOrHashCode")
class CSSBorder : CSSStyleValue {
var width: CSSNumeric? = null
var style: LineStyle? = null
var color: CSSColorValue? = null
override fun equals(other: Any?): Boolean {
return if (other is CSSBorder) {
width == other.width && style == other.style && color == other.color
} else false
}
override fun toString(): String {
val values = listOfNotNull(width, style, color)
return values.joinToString(" ")
}
}
inline fun CSSBorder.width(size: CSSNumeric) {
width = size
}
inline fun CSSBorder.style(style: LineStyle) {
this.style = style
}
inline fun CSSBorder.color(color: CSSColorValue) {
this.color = color
}
fun StyleBuilder.display(displayStyle: DisplayStyle) {
property("display", displayStyle.value)
}

30
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/border.kt

@ -5,6 +5,36 @@
package org.jetbrains.compose.web.css
@Suppress("EqualsOrHashCode")
class CSSBorder : CSSStyleValue {
var width: CSSNumeric? = null
var style: LineStyle? = null
var color: CSSColorValue? = null
override fun equals(other: Any?): Boolean {
return if (other is CSSBorder) {
width == other.width && style == other.style && color == other.color
} else false
}
override fun toString(): String {
val values = listOfNotNull(width, style, color)
return values.joinToString(" ")
}
}
inline fun CSSBorder.width(size: CSSNumeric) {
width = size
}
inline fun CSSBorder.style(style: LineStyle) {
this.style = style
}
inline fun CSSBorder.color(color: CSSColorValue) {
this.color = color
}
inline fun StyleBuilder.border(crossinline borderBuild: CSSBorder.() -> Unit) {
property("border", CSSBorder().apply(borderBuild))
}

15
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/color.kt

@ -0,0 +1,15 @@
/*
* 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.color(value: String) {
property("color", value)
}
fun StyleBuilder.color(value: CSSColorValue) {
// color hasn't Typed OM yet
property("color", value)
}

13
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/flex.kt

@ -47,3 +47,16 @@ fun StyleBuilder.alignContent(alignContent: AlignContent) {
)
}
fun StyleBuilder.order(value: Int) {
property("order", value)
}
fun StyleBuilder.flexGrow(value: Number) {
property("flex-grow", value)
}
fun StyleBuilder.flexShrink(value: Number) {
property("flex-shrink", value)
}

19
web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/properties.kt

@ -0,0 +1,19 @@
/*
* 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.opacity(value: Number) {
property("opacity", value)
}
fun StyleBuilder.opacity(value: CSSSizeValue<CSSUnit.percent>) {
property("opacity", (value.value / 100))
}
fun StyleBuilder.display(displayStyle: DisplayStyle) {
property("display", displayStyle.value)
}
Loading…
Cancel
Save