All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jsMain.styled.dynamicCss.DynamicCssHolder.kt Maven / Gradle / Ivy

There is a newer version: 1.2.4-pre.855
Show newest version
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