Function parseAsAttributes

Parses input in the form of: ['elementid-attribute', 'default-value']. Eg, ['indicator-fill', 'gray'] will yield:

{ variable: `indicator-fill`, attribute: `fill`, id: `indicator`, defaultValue: `gray` }

Once parsed, use setFromVariables to apply data.

// Array of arrays is treated as a set of key-value pairs
const options = [ [`indicator-fill`, `gray`], [`backdrop-fill`, `whitesmoke`] ]
const attrs = parseAsAttributes(options);
Yields:
[
{ variable: `indicator-fill`, attribute: `fill`, id: `indicator`, defaultValue: `gray` }
{ variable: `backdrop-fill`, attribute: `fill`, id: `backdrop`, defaultValue: `whitesmoke` }
]

// Assign
setFromCssVariables(document.body, attrs);
  • Parameters

    • options: (string | string[])[]

    Returns (CssVariable & {
        id: string;
    })[]