From a6fbe1ff944e2e9b8d51c3e97d70952c0c1b57e7 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Sun, 6 Jun 2021 00:09:44 +0200 Subject: [PATCH] BREAKING: CSSUnitValue working in Chrome --- web/core/build.gradle.kts | 2 +- .../kotlin/androidx/compose/web/css/CSS.kt | 8 +- .../androidx/compose/web/css/CSSUnits.kt | 76 +++++++++---------- 3 files changed, 40 insertions(+), 46 deletions(-) diff --git a/web/core/build.gradle.kts b/web/core/build.gradle.kts index 31ea84286c..7c058691c8 100644 --- a/web/core/build.gradle.kts +++ b/web/core/build.gradle.kts @@ -13,7 +13,7 @@ kotlin { testLogging.showStandardStreams = true useKarma { useChromeHeadless() - useFirefox() +// useFirefox() } } } diff --git a/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSS.kt b/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSS.kt index 7086459b9f..b69932271d 100644 --- a/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSS.kt +++ b/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSS.kt @@ -142,15 +142,9 @@ external interface CSSNumericValue : CSSStyleValue { } } -external interface CSSUnitValue : CSSNumericValue, StylePropertyValue { +open external class CSSUnitValue(value: Number, unit: String) : CSSNumericValue, StylePropertyValue { val value: Number val unit: String -} - -@JsName("CSSUnitValue") -external class CSSUnitValueJS(value: Number, unit: String) : CSSNumericValue, CSSUnitValue { - override val value: Number - override val unit: String override fun add(vararg values: CSSNumberish): CSSNumericValue = definedExternally override fun sub(vararg values: CSSNumberish): CSSNumericValue = definedExternally override fun mul(vararg values: CSSNumberish): CSSNumericValue = definedExternally diff --git a/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSUnits.kt b/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSUnits.kt index a2cc78eac2..1d267451b9 100644 --- a/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSUnits.kt +++ b/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSUnits.kt @@ -8,44 +8,44 @@ interface CSSFrequencyValue interface CSSResolutionValue interface CSSFlexValue -interface CSSpercentValue : CSSUnitValue, CSSRelValue -interface CSSemValue : CSSUnitValue, CSSRelValue -interface CSSexValue : CSSUnitValue, CSSRelValue -interface CSSchValue : CSSUnitValue, CSSRelValue -interface CSSicValue : CSSUnitValue, CSSRelValue -interface CSSremValue : CSSUnitValue, CSSRelValue -interface CSSlhValue : CSSUnitValue, CSSRelValue -interface CSSrlhValue : CSSUnitValue, CSSRelValue -interface CSSvwValue : CSSUnitValue, CSSRelValue -interface CSSvhValue : CSSUnitValue, CSSRelValue -interface CSSviValue : CSSUnitValue, CSSRelValue -interface CSSvbValue : CSSUnitValue, CSSRelValue -interface CSSvminValue : CSSUnitValue, CSSRelValue -interface CSSvmaxValue : CSSUnitValue, CSSRelValue -interface CSScmValue : CSSUnitValue, CSSRelValue -interface CSSmmValue : CSSUnitValue, CSSRelValue -interface CSSQValue : CSSUnitValue, CSSRelValue - -interface CSSptValue : CSSUnitValue, CSSAbsValue -interface CSSpcValue : CSSUnitValue, CSSAbsValue -interface CSSpxValue : CSSUnitValue, CSSAbsValue - -interface CSSdegValue : CSSUnitValue, CSSAngleValue -interface CSSgradValue : CSSUnitValue, CSSAngleValue -interface CSSradValue : CSSUnitValue, CSSAngleValue -interface CSSturnValue : CSSUnitValue, CSSAngleValue - -interface CSSsValue : CSSUnitValue, CSSTimeValue -interface CSSmsValue : CSSUnitValue, CSSTimeValue - -interface CSSHzValue : CSSUnitValue, CSSFrequencyValue -interface CSSkHzValue : CSSUnitValue, CSSFrequencyValue - -interface CSSdpiValue : CSSUnitValue, CSSResolutionValue -interface CSSdpcmValue : CSSUnitValue, CSSResolutionValue -interface CSSdppxValue : CSSUnitValue, CSSResolutionValue - -interface CSSfrValue : CSSUnitValue, CSSFlexValue +class CSSpercentValue(value: Number) : CSSUnitValue(value, "percent"), CSSRelValue +class CSSemValue(value: Number) : CSSUnitValue(value, "em"), CSSRelValue +class CSSexValue(value: Number) : CSSUnitValue(value, "ex"), CSSRelValue +class CSSchValue(value: Number) : CSSUnitValue(value, "ch"), CSSRelValue +class CSSicValue(value: Number) : CSSUnitValue(value, "ic"), CSSRelValue +class CSSremValue(value: Number) : CSSUnitValue(value, "rem"), CSSRelValue +class CSSlhValue(value: Number) : CSSUnitValue(value, "lh"), CSSRelValue +class CSSrlhValue(value: Number) : CSSUnitValue(value, "rlh"), CSSRelValue +class CSSvwValue(value: Number) : CSSUnitValue(value, "vw"), CSSRelValue +class CSSvhValue(value: Number) : CSSUnitValue(value, "vh"), CSSRelValue +class CSSviValue(value: Number) : CSSUnitValue(value, "vi"), CSSRelValue +class CSSvbValue(value: Number) : CSSUnitValue(value, "vb"), CSSRelValue +class CSSvminValue(value: Number) : CSSUnitValue(value, "vmin"), CSSRelValue +class CSSvmaxValue(value: Number) : CSSUnitValue(value, "vmax"), CSSRelValue +class CSScmValue(value: Number) : CSSUnitValue(value, "cm"), CSSRelValue +class CSSmmValue(value: Number) : CSSUnitValue(value, "mm"), CSSRelValue +class CSSQValue(value: Number) : CSSUnitValue(value, "q"), CSSRelValue + +class CSSptValue(value: Number) : CSSUnitValue(value, "pt"), CSSAbsValue +class CSSpcValue(value: Number) : CSSUnitValue(value, "pc"), CSSAbsValue +class CSSpxValue(value: Number) : CSSUnitValue(value, "px"), CSSAbsValue + +class CSSdegValue(value: Number) : CSSUnitValue(value, "deg"), CSSAngleValue +class CSSgradValue(value: Number) : CSSUnitValue(value, "grad"), CSSAngleValue +class CSSradValue(value: Number) : CSSUnitValue(value, "rad"), CSSAngleValue +class CSSturnValue(value: Number) : CSSUnitValue(value, "turn"), CSSAngleValue + +class CSSsValue(value: Number) : CSSUnitValue(value, "s"), CSSTimeValue +class CSSmsValue(value: Number) : CSSUnitValue(value, "ms"), CSSTimeValue + +class CSSHzValue(value: Number) : CSSUnitValue(value, "hz"), CSSFrequencyValue +class CSSkHzValue(value: Number) : CSSUnitValue(value, "khz"), CSSFrequencyValue + +class CSSdpiValue(value: Number) : CSSUnitValue(value, "dpi"), CSSResolutionValue +class CSSdpcmValue(value: Number) : CSSUnitValue(value, "dpcm"), CSSResolutionValue +class CSSdppxValue(value: Number) : CSSUnitValue(value, "dppx"), CSSResolutionValue + +class CSSfrValue(value: Number) : CSSUnitValue(value, "fr"), CSSFlexValue val Number.number get(): CSSUnitValue = CSS.number(this)