Browse Source

Remove CSSKeywordValue from API completely

And subsequently simplify auto invocation
pull/743/head
Shagen Ogandzhanian 4 years ago
parent
commit
15a6b5601e
  1. 13
      web/core/src/jsMain/kotlin/androidx/compose/web/css/CSS.kt
  2. 7
      web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSHelpers.kt

13
web/core/src/jsMain/kotlin/androidx/compose/web/css/CSS.kt

@ -36,9 +36,7 @@ fun StyleSheet.insertRule(cssRule: String, index: Int? = null): Int {
val ElementCSSInlineStyle.attributeStyleMap val ElementCSSInlineStyle.attributeStyleMap
get() = this.asDynamic().attributeStyleMap.unsafeCast<StylePropertyMap>() get() = this.asDynamic().attributeStyleMap.unsafeCast<StylePropertyMap>()
external interface CSSStyleValue { external interface CSSStyleValue
// toString() : string
}
@JsName("CSSStyleValue") @JsName("CSSStyleValue")
open external class CSSStyleValueJS : CSSStyleValue { open external class CSSStyleValueJS : CSSStyleValue {
@ -79,15 +77,6 @@ external class CSSUnparsedValue(members: Array<CSSUnparsedSegment>) : CSSStyleVa
operator fun set(index: Int, value: CSSUnparsedSegment) operator fun set(index: Int, value: CSSUnparsedSegment)
} }
external interface CSSKeywordValue : CSSStyleValue {
val value: String
}
@JsName("CSSKeywordValue")
external class CSSKeywordValueJS(value: String) : CSSKeywordValue {
override val value: String
}
// type CSSNumberish = number | CSSNumericValue // type CSSNumberish = number | CSSNumericValue
interface CSSNumberish { interface CSSNumberish {
companion object { companion object {

7
web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSHelpers.kt

@ -1,11 +1,9 @@
@file:Suppress("UNUSED") @file:Suppress("UNUSED")
package org.jetbrains.compose.web.css package org.jetbrains.compose.web.css
interface CSSAutoValue : CSSKeywordValue interface CSSAutoValue : CSSStyleValue
val auto = CSSKeywordValueJS("auto").unsafeCast<CSSAutoValue>() val auto = StylePropertyValue("auto").unsafeCast<CSSAutoValue>()
fun asCSSAutoValue(value: dynamic) = (value as? CSSKeywordValueJS).unsafeCast<CSSAutoValue>()
// type CSSSizeOrAutoValue = CSSSizeValue | CSSAutoValue // type CSSSizeOrAutoValue = CSSSizeValue | CSSAutoValue
interface CSSSizeOrAutoValue : CSSStyleValue, StylePropertyValue { interface CSSSizeOrAutoValue : CSSStyleValue, StylePropertyValue {
@ -16,7 +14,6 @@ interface CSSSizeOrAutoValue : CSSStyleValue, StylePropertyValue {
} }
fun CSSSizeOrAutoValue.asCSSSizeValue() = this.asDynamic() as? CSSUnitValueJS fun CSSSizeOrAutoValue.asCSSSizeValue() = this.asDynamic() as? CSSUnitValueJS
fun CSSSizeOrAutoValue.asCSSAutoValue(): CSSAutoValue = asCSSAutoValue(this.asDynamic())
enum class Direction { enum class Direction {
rtl, rtl,

Loading…
Cancel
Save