From d363211110584486b33018add67a9288d42be021 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Fri, 23 Jul 2021 01:01:40 +0200 Subject: [PATCH] Remove CSSVariables context One can define CSS variables anywhere This is actually the only thing we want to do right now in framework of #894 Resolves #894 --- .../jsMain/kotlin/com/sample/content/CodeSamplesSwitcher.kt | 2 +- .../kotlin/org/jetbrains/compose/web/css/StyleBuilder.kt | 4 +--- web/core/src/jsTest/kotlin/CSSStylesheetTests.kt | 2 +- web/core/src/jsTest/kotlin/CSSUnitApiTests.kt | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/web/benchmark-core/src/jsMain/kotlin/com/sample/content/CodeSamplesSwitcher.kt b/web/benchmark-core/src/jsMain/kotlin/com/sample/content/CodeSamplesSwitcher.kt index e3a9a2984a..bd829264f9 100644 --- a/web/benchmark-core/src/jsMain/kotlin/com/sample/content/CodeSamplesSwitcher.kt +++ b/web/benchmark-core/src/jsMain/kotlin/com/sample/content/CodeSamplesSwitcher.kt @@ -7,7 +7,7 @@ import org.jetbrains.compose.web.attributes.* import org.jetbrains.compose.web.dom.* import com.sample.style.AppStylesheet -private object SwitcherVariables : CSSVariables { +private object SwitcherVariables { val labelWidth by variable() val labelPadding by variable() } diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleBuilder.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleBuilder.kt index 8a7d1a4512..43466c4f33 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleBuilder.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleBuilder.kt @@ -52,8 +52,6 @@ fun StyleBuilder.add( value: StylePropertyValue ) = property(propertyName, value) -interface CSSVariables - interface CSSVariable { val name: String } @@ -79,7 +77,7 @@ fun CSSStyleVariable.value(fallback: TValue? = null) ) ) -fun CSSVariables.variable() = +fun variable() = ReadOnlyProperty> { _, property -> CSSStyleVariable(property.name) } diff --git a/web/core/src/jsTest/kotlin/CSSStylesheetTests.kt b/web/core/src/jsTest/kotlin/CSSStylesheetTests.kt index 1debabe2ec..8874c35d08 100644 --- a/web/core/src/jsTest/kotlin/CSSStylesheetTests.kt +++ b/web/core/src/jsTest/kotlin/CSSStylesheetTests.kt @@ -13,7 +13,7 @@ import org.w3c.dom.get import kotlin.test.Test import kotlin.test.assertEquals -object AppCSSVariables : CSSVariables { +object AppCSSVariables { val width by variable() val height by variable() diff --git a/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt b/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt index 7e6553584c..20e2788a47 100644 --- a/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt +++ b/web/core/src/jsTest/kotlin/CSSUnitApiTests.kt @@ -491,7 +491,7 @@ class CSSUnitApiTests { @Test fun calcVaraiables() { - val variables = object : CSSVariables { + val variables = object { val pxVar by variable>() } val typedResultLength: CSSNumericValue = 4.pt + variables.pxVar.value()