diff --git a/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSOperations.kt b/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSOperations.kt index 7eea1eca41..f9a0a20208 100644 --- a/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSOperations.kt +++ b/web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSOperations.kt @@ -61,4 +61,9 @@ operator fun CSSNumericValue.minus(b: CSSCalcValue): operator fun CSSCalcValue.times(b: Number): CSSCalcValue = CSSCalcValue(CSSTimes(this.op, b)) operator fun Number.times(b: CSSCalcValue): CSSCalcValue = CSSCalcValue(CSSTimes(b.op, this, false)) +operator fun CSSNumericValue.div(b: Number): CSSCalcValue = CSSCalcValue(CSSDiv(this, b)) operator fun CSSCalcValue.div(b: Number): CSSCalcValue = CSSCalcValue(CSSDiv(this.op, b)) + +operator fun CSSNumericValue.times(b: Number): CSSCalcValue = CSSCalcValue(CSSTimes(this, b)) +operator fun Number.times(b: CSSNumericValue): CSSCalcValue = CSSCalcValue(CSSTimes(b, this, false)) + diff --git a/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt b/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt index 1a9d559031..ef78e2b58f 100644 --- a/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt +++ b/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt @@ -427,6 +427,12 @@ class CSSUnitApiTests { val typedResultLengthFallback: CSSNumericValue = 4.pt + variables.pxVar.value(4.px) assertEquals("calc(4pt + var(--pxVar, 4px))", typedResultLengthFallback.toString()) + + val typedResultLengthMultiplyLeft: CSSNumericValue = variables.pxVar.value(4.px) * 4 + assertEquals("calc(var(--pxVar, 4px) * 4)", typedResultLengthMultiplyLeft.toString()) + + val typedResultLengthMultiplyRight: CSSNumericValue = 4 * variables.pxVar.value(4.px) + assertEquals("calc(4 * var(--pxVar, 4px))", typedResultLengthMultiplyRight.toString()) } @Test