Browse Source

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
pull/932/head
Shagen Ogandzhanian 3 years ago
parent
commit
d363211110
  1. 2
      web/benchmark-core/src/jsMain/kotlin/com/sample/content/CodeSamplesSwitcher.kt
  2. 4
      web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleBuilder.kt
  3. 2
      web/core/src/jsTest/kotlin/CSSStylesheetTests.kt
  4. 2
      web/core/src/jsTest/kotlin/CSSUnitApiTests.kt

2
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<CSSpxValue>()
val labelPadding by variable<CSSpxValue>()
}

4
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 <TValue> CSSStyleVariable<TValue>.value(fallback: TValue? = null)
)
)
fun <TValue: StylePropertyValue> CSSVariables.variable() =
fun <TValue: StylePropertyValue> variable() =
ReadOnlyProperty<Any?, CSSStyleVariable<TValue>> { _, property ->
CSSStyleVariable(property.name)
}

2
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<CSSUnitValue>()
val height by variable<CSSUnitValue>()

2
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<CSSSizeValue<CSSUnit.px>>()
}
val typedResultLength: CSSNumericValue<CSSUnitLength> = 4.pt + variables.pxVar.value()

Loading…
Cancel
Save