Provides a managed dynamic style sheet / element useful in configuring global CSS variables. When creating an instance of StyleManager, you must provide a CSS ID for the style element.

Instances of StyleManager must be versioned by supplying a semver version string via the 'version' option. This version is assigned to the associated style element. When a StyleManager instance is created and there is an existing instance with a version that is lower than the current new instance, all CSS rules are removed, letting the higher version take precedence. This isn't a perfect system and requires thoughtful construction of CSS variables exposed, but allows multiple independently compiled TRL packages to load the latest CSS variables..

Implements

Accessors

  • get isConnected(): boolean
  • Determines if this StyleManager style element is still connected / available.

    Returns boolean

    Is StyleManager connected.

  • get textContent(): string
  • Returns string

    Provides an accessor to get the textContent for the style sheet.

  • get version(): string
  • Returns string

    Returns the version of this instance.

Methods

  • Provides a copy constructor to duplicate an existing StyleManager instance into a new document.

    Parameters

    • options: Clone

      Required clone options.

    Returns StyleManager

    New style manager instance or undefined if not connected.

  • Retrieves an associated RuleManager by name.

    Parameters

    • ruleName: string

      Rule name.

    Returns RuleManager

    Associated rule manager for given name or undefined if the rule name is not defined or manager is unconnected.

  • Returns whether a StyleManager.CSSRuleManger exists for the given name.

    Parameters

    • ruleName: string

      Rule name.

    Returns boolean

    Is there a CSS rule manager with the given name.

  • Connect to an existing dynamic styles managed element by CSS ID with semver check on version range compatibility.

    Parameters

    Returns StyleManager