jsMain.styled.dynamicCss.DynamicCssHolder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-styled-next-js
Show all versions of kotlin-styled-next-js
Kotlin implementation of styled-components
package styled.dynamicCss
import kotlinx.css.RuleSet
import styled.AbstractCssHolder
import styled.StyleSheet
/**
* An implementation of the [AbstractCssHolder] to inject and provide styles without delegation features.
* */
internal class DynamicCssHolder(sheet: StyleSheet, cssSuffix: String, vararg ruleSets: RuleSet) : AbstractCssHolder(sheet, *ruleSets) {
private val className = "${sheet.name}-$cssSuffix"
/**
* Contains the initialization part of the delegate from [AbstractCssHolder].
* */
internal fun markToInject() {
classNamesToInject.add(className)
}
/**
* Contains the property providing the part from [AbstractCssHolder].
* */
internal fun provideRuleSet(): RuleSet = {
sheet.scheduleImports()
if (sheet.isStatic) {
scheduleToInject(className)
+className
}
if (!sheet.isStatic || !allowClasses || isHolder) {
styleName.add(className)
ruleSets.forEach { it() }
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy