Class StyleMap

The style map containing all the css variables defined in the parsed identity css files

Hierarchy
  • StyleMap
Index
Methods

forEach

  • forEach(callbackFn: function): void
  • Runs a callbackFn on each of the properties contained in the style map

    Parameters
    • callbackFn: function

      The callback to run against each property

    Returns void

get

  • Gets the CSSStyleValue given the corresponding property name

    const primaryColor: CSSColorValue = styleMap.get('primary-color');
    
    Parameters
    • property: string

      The name of the property (prepending -- is not necessary but allowed)

    Returns CSSStyleValue

    The corresponding style value

getAll

  • getAll(properties: string[]): object
  • Gets the CSSStyleValues corresponding to the given array of property names

    const values = styleMap.getAll(['primary-color', 'accent-color']);
    
    // In the values Object the keys correspond to the names of the variables
    // found in the styleMap. These are converted from hyphen-case to camel-case
    // so you don't have to use the bracket notation to access values and can
    // use destructuring declarations:
    
    const {primaryColor, secondaryColor} = styleMap.getAll(['primary-color', 'accent-color']);
    
    Parameters
    • properties: string[]

      The array of property names

    Returns object

    The Object of found properties

getByType

  • Gets the CSSStyleValues of the properties extending types

    const values = styleMap.getByType(CSSHexColor, CSSRgbaColor);
    
    Type parameters Parameters
    • Rest ...types: T[]

      The instances of CSSStyleValue

    Returns StyleMapEntry[]

    An array of StyleMapEntries

getSimilar

  • Gets the CSSStyleValues of the properties matching the given regex

    const values = styleMap.getSimilar(/color$/);
    
    // All the variables with names ending with "color"
    
    Parameters
    • regExp: RegExp

      A regular expression to ls against property names

    Returns StyleMapEntry[]

    An array of StyleMapEntries

print

  • print(): void

set

  • Sets (or overwrites) a property in the style map

    Parameters
    • property: string

      The name of the property

    • The value of the property

    Returns void