diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/Color.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/Color.kt index 42d95b6322..04e1242af4 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/Color.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/Color.kt @@ -5,20 +5,25 @@ package org.jetbrains.compose.web.css external interface CSSColorValue : StylePropertyValue, CSSVariableValueAs object Color { + + @Deprecated("use org.jetbrains.compose.web.css.rgb", ReplaceWith("rgb(r, g, b)")) data class RGB(val r: Number, val g: Number, val b: Number) : CSSColorValue { override fun toString(): String = "rgb($r, $g, $b)" } + @Deprecated("use org.jetbrains.compose.web.css.rgba", ReplaceWith("rgba(r, g, b, a)")) data class RGBA(val r: Number, val g: Number, val b: Number, val a: Number) : CSSColorValue { override fun toString(): String = "rgba($r, $g, $b, $a)" } + @Deprecated("use org.jetbrains.compose.web.css.hsl", ReplaceWith("hsl(r, g, b)")) data class HSL(val h: CSSAngleValue, val s: Number, val l: Number) : CSSColorValue { constructor(h: Number, s: Number, l: Number) : this(h.deg, s, l) override fun toString(): String = "hsl($h, $s%, $l%)" } + @Deprecated("use org.jetbrains.compose.web.css.hsla", ReplaceWith("hsla(r, g, b, a)")) data class HSLA(val h: CSSAngleValue, val s: Number, val l: Number, val a: Number) : CSSColorValue { constructor(h: Number, s: Number, l: Number, a: Number) : this(h.deg, s, l, a) diff --git a/web/core/src/jsTest/kotlin/css/ColorTests.kt b/web/core/src/jsTest/kotlin/css/ColorTests.kt index 6186e61e39..6e90e28688 100644 --- a/web/core/src/jsTest/kotlin/css/ColorTests.kt +++ b/web/core/src/jsTest/kotlin/css/ColorTests.kt @@ -16,6 +16,7 @@ import kotlin.test.assertEquals class ColorTests { @Test + @Suppress("DEPRECATION") fun rgbTestDeprecated() = runTest { composition { Div({ style { color(Color.RGB(0, 0, 0)) } }) @@ -39,6 +40,7 @@ class ColorTests { } @Test + @Suppress("DEPRECATION") fun rgbaTestDeprecated() = runTest { composition { Div({ style { color(Color.RGBA(0, 220, 0, 0.2)) } }) @@ -66,49 +68,50 @@ class ColorTests { } @Test - fun hslaTestDeprecated() = runTest { + @Suppress("DEPRECATION") + fun hslTestDeprecated() = runTest { composition { - Div({ style { color(Color.HSLA(100, 100, 50, 1)) } }) - Div({ style { color(Color.HSLA(235, 100, 50, .5)) } }) + Div({ style { color(Color.HSL(100, 120, 50)) } }) + Div({ style { color(Color.HSL(235, 100, 50)) } }) } assertEquals("rgb(85, 255, 0)", (root.children[0] as HTMLElement).style.color) - assertEquals("rgba(0, 21, 255, 0.5)", (root.children[1] as HTMLElement).style.color) + assertEquals("rgb(0, 21, 255)", (root.children[1] as HTMLElement).style.color) } - @Test - fun hslaTest() = runTest { + fun hslTest() = runTest { composition { - Div({ style { color(hsla(100, 100, 50, 1)) } }) - Div({ style { color(hsla(235, 100, 50, .5)) } }) + Div({ style { color(hsl(100, 120, 50)) } }) + Div({ style { color(hsl(235, 100, 50)) } }) } assertEquals("rgb(85, 255, 0)", (root.children[0] as HTMLElement).style.color) - assertEquals("rgba(0, 21, 255, 0.5)", (root.children[1] as HTMLElement).style.color) + assertEquals("rgb(0, 21, 255)", (root.children[1] as HTMLElement).style.color) } @Test - fun hslTestDeprecated() = runTest { + @Suppress("DEPRECATION") + fun hslaTestDeprecated() = runTest { composition { - Div({ style { color(Color.HSL(100, 120, 50)) } }) - Div({ style { color(Color.HSL(235, 100, 50)) } }) + Div({ style { color(Color.HSLA(100, 100, 50, 1)) } }) + Div({ style { color(Color.HSLA(235, 100, 50, .5)) } }) } assertEquals("rgb(85, 255, 0)", (root.children[0] as HTMLElement).style.color) - assertEquals("rgb(0, 21, 255)", (root.children[1] as HTMLElement).style.color) + assertEquals("rgba(0, 21, 255, 0.5)", (root.children[1] as HTMLElement).style.color) } @Test - fun hslTest() = runTest { + fun hslaTest() = runTest { composition { - Div({ style { color(hsl(100, 120, 50)) } }) - Div({ style { color(hsl(235, 100, 50)) } }) + Div({ style { color(hsla(100, 100, 50, 1)) } }) + Div({ style { color(hsla(235, 100, 50, .5)) } }) } assertEquals("rgb(85, 255, 0)", (root.children[0] as HTMLElement).style.color) - assertEquals("rgb(0, 21, 255)", (root.children[1] as HTMLElement).style.color) + assertEquals("rgba(0, 21, 255, 0.5)", (root.children[1] as HTMLElement).style.color) } @@ -394,6 +397,6 @@ class ColorTests { assertEquals("yellowgreen", (root.children[counter++] as HTMLElement).style.color) assertEquals("yellow", (root.children[counter++] as HTMLElement).style.color) assertEquals("transparent", (root.children[counter++] as HTMLElement).style.color) - assertEquals("currentcolor", (root.children[counter++] as HTMLElement).style.color) + assertEquals("currentcolor", (root.children[counter] as HTMLElement).style.color) } }