Class Theme<TValues>

Creates a theme class for grouping variables and applying them to elements.

Type Parameters

Hierarchy (View Summary)

Constructors

Properties

_dependants: Base[] = []
_lastPropertiesSet: string[] = []
_listeners: Record<string, () => void[]> = ...
css: Record<string, string> = {}
els: HTMLElement[] = []
options: { escapeChar: string } = ...
ready: boolean = false
value: TValues = ...

Methods

  • Parameters

    • res: Record<string, string>
    • key: string
    • sep: string
    • value: ControlVar<any, any> | InterpolatedVars<any>
    • __namedParameters: { remove?: boolean } = {}

    Returns void

  • Parameters

    • dep: any

    Returns void

  • Attach to an element and automatically set and update the theme's properties on it.

    If no element is passed, attaches to document.documentElement.

    Parameters

    • el: HTMLElement = document.documentElement

    Returns void

  • Parameters

    • el: HTMLElement = document.documentElement

    Returns void

  • Parameters

    • __namedParameters: { recompute?: boolean } = {}

    Returns void

  • Parameters

    • type: "change"
    • cb: () => void

    Returns void

  • Parameters

    • type: "change"
    • cb: () => void

    Returns void

  • The theme can force dependencies to recompute.

    This should not be needed unless you want to recompute based of some external state.

    Please file a bug report otherwise.

    Parameters

    • force: boolean = true

    Returns void

  • Parameters

    • key: string

    Returns void

  • Parameters

    • value: Partial<{ escapeChar: string }> = {}

    Returns void

  • Set css variables on an element.

    Careful that the css properties are prefixed with --, otherwise they might conflict with other style properties.

    Can be passed a list of already set properties to remove. Returns a list of properties that were set.

    Parameters

    • el: HTMLElement
    • css: Record<string, string>
    • lastPropertiesSet: string[] = []

    Returns string[]