diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSBuilder.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSBuilder.kt index ba5943fd41..f2ecdb8bba 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSBuilder.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSBuilder.kt @@ -2,7 +2,7 @@ package org.jetbrains.compose.web.css import org.jetbrains.compose.web.css.selectors.CSSSelector -interface CSSBuilder : CSSStyleRuleBuilder, GenericStyleSheetBuilder { +interface CSSBuilder : StyleBuilder, GenericStyleSheetBuilder { val root: CSSSelector val self: CSSSelector } diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSKeyframeRule.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSKeyframeRule.kt index 37ef76fcef..0ccb549e74 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSKeyframeRule.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSKeyframeRule.kt @@ -50,19 +50,19 @@ class CSSKeyframesBuilder() { } val frames: MutableList = mutableListOf() - fun from(style: CSSStyleRuleBuilder.() -> Unit) { + fun from(style: StyleBuilder.() -> Unit) { frames += CSSKeyframeRuleDeclaration(CSSKeyframe.From, buildCSSStyleRule(style)) } - fun to(style: CSSStyleRuleBuilder.() -> Unit) { + fun to(style: StyleBuilder.() -> Unit) { frames += CSSKeyframeRuleDeclaration(CSSKeyframe.To, buildCSSStyleRule(style)) } - fun each(vararg keys: CSSSizeValue, style: CSSStyleRuleBuilder.() -> Unit) { + fun each(vararg keys: CSSSizeValue, style: StyleBuilder.() -> Unit) { frames += CSSKeyframeRuleDeclaration(CSSKeyframe.Combine(keys.toList()), buildCSSStyleRule(style)) } - operator fun CSSSizeValue.invoke(style: CSSStyleRuleBuilder.() -> Unit) { + operator fun CSSSizeValue.invoke(style: StyleBuilder.() -> Unit) { frames += CSSKeyframeRuleDeclaration(CSSKeyframe.Percentage(this), buildCSSStyleRule(style)) } } diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSRules.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSRules.kt index c591ec511a..7fe9b6cc4b 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSRules.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSRules.kt @@ -2,9 +2,8 @@ package org.jetbrains.compose.web.css import org.jetbrains.compose.web.css.selectors.CSSSelector - interface CSSStyleRuleBuilder : StylePropertyBuilder, StyleVariableBuilder -open class CSSRuleBuilderImpl : CSSStyleRuleBuilder, StyleBuilderImpl() +open class CSSRuleBuilderImpl : StyleBuilderImpl() @Suppress("EqualsOrHashCode") interface CSSRuleDeclaration { @@ -32,7 +31,7 @@ interface CSSGroupingRuleDeclaration: CSSRuleDeclaration { typealias CSSRuleDeclarationList = List typealias MutableCSSRuleDeclarationList = MutableList -fun buildCSSStyleRule(cssRule: CSSStyleRuleBuilder.() -> Unit): StyleHolder { +fun buildCSSStyleRule(cssRule: StyleBuilder.() -> Unit): StyleHolder { val builder = CSSRuleBuilderImpl() builder.cssRule() return builder diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StylePropertyBuilder.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StylePropertyBuilder.kt index 78d6776843..cd84f2b883 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StylePropertyBuilder.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StylePropertyBuilder.kt @@ -34,6 +34,7 @@ interface StyleVariableBuilder { } } +interface StyleBuilder : StylePropertyBuilder, StyleVariableBuilder inline fun variableValue(variableName: String, fallback: StylePropertyValue? = null) = "var(--$variableName${fallback?.let { ", $it" } ?: ""})" @@ -91,7 +92,7 @@ interface StyleHolder { } @Suppress("EqualsOrHashCode") -open class StyleBuilderImpl : StylePropertyBuilder, CSSStyleRuleBuilder, StyleHolder { +open class StyleBuilderImpl : StyleBuilder, StyleHolder { override val properties: MutableStylePropertyList = mutableListOf() override val variables: MutableStylePropertyList = mutableListOf() diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleSheet.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleSheet.kt index 2cce399fff..a698f2f991 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleSheet.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleSheet.kt @@ -115,7 +115,7 @@ open class StyleSheet( } } - override fun buildRules(rulesBuild: GenericStyleSheetBuilder.() -> Unit) = + override fun buildRules(rulesBuild: GenericStyleSheetBuilder.() -> Unit) = StyleSheet().apply(rulesBuild).cssRules } diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleSheetBuilder.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleSheetBuilder.kt index 5c20d03bec..b46cb3f235 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleSheetBuilder.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/StyleSheetBuilder.kt @@ -34,8 +34,8 @@ interface GenericStyleSheetBuilder : CSSRulesHolder { } } -interface StyleSheetBuilder : CSSRulesHolder, GenericStyleSheetBuilder { - override fun style(selector: CSSSelector, cssRule: CSSStyleRuleBuilder.() -> Unit) { +interface StyleSheetBuilder : CSSRulesHolder, GenericStyleSheetBuilder { + override fun style(selector: CSSSelector, cssRule: StyleBuilder.() -> Unit) { add(selector, buildCSSStyleRule(cssRule)) } } @@ -47,6 +47,6 @@ open class StyleSheetBuilderImpl : StyleSheetBuilder { cssRules.add(cssRule) } - override fun buildRules(rulesBuild: GenericStyleSheetBuilder.() -> Unit) = + override fun buildRules(rulesBuild: GenericStyleSheetBuilder.() -> Unit) = StyleSheetBuilderImpl().apply(rulesBuild).cssRules }