Browse Source

[web] Color is used exclusively as a namespace, all data classes a derived from CSSColorValue

pull/889/head
Shagen Ogandzhanian 3 years ago
parent
commit
30c5510111
  1. 13
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/Color.kt

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

@ -5,30 +5,29 @@ package org.jetbrains.compose.web.css
external interface CSSColorValue: StylePropertyValue, CSSVariableValueAs<CSSColorValue>
abstract class Color : CSSStyleValue, CSSColorValue {
data class Named(val value: String) : Color() {
data class Named(val value: String) : CSSColorValue {
override fun toString(): String = value
}
data class RGB(val r: Number, val g: Number, val b: Number) : Color() {
data class RGB(val r: Number, val g: Number, val b: Number) : CSSColorValue {
override fun toString(): String = "rgb($r, $g, $b)"
}
data class RGBA(val r: Number, val g: Number, val b: Number, val a: Number) : Color() {
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)"
}
data class HSL(val h: CSSAngleValue, val s: Number, val l: Number) : Color() {
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%)"
}
data class HSLA(val h: CSSAngleValue, val s: Number, val l: Number, val a: Number) : Color() {
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)
override fun toString(): String = "hsla($h, $s%, $l%, $a)"
}
}
fun Color(name: String): Color = Color.Named(name)
fun Color(name: String): CSSColorValue = Color.Named(name)
Loading…
Cancel
Save