6 #internals Internals

Helper functions that query the internal data structure in $chroma. These are not part of the public API and are subject to change at any time.

6.1 #internals._chroma-add-name _chroma-add-name()

Private function that adds a color to the data structure of the $chroma variable.

6.2 #internals._chroma-init _chroma-init()

Private function that sets up the initial data structure of the $chroma variable. Can be called repeatedly without damaging existing data.

6.3 #internals._is-keyword-string _is-keyword-string($name)

Normally, type-of() can be used to tell if a given value is a string. But LibSass versions before 3.3.0 think that color keywords in strings are still colors and not strings. This function works, regardless of LibSass bugs.

@TODO: Remove when LibSass 3.2.5 support is dropped.

6.4 #internals._is-old-libsass is-old-libsass()

libsass before 3.3.0 is funky, making it very hard for Chroma to do its job.

  • inspect([color]) returns the original value instead of returning the string equivalent, so you can't cast a color to a string.
  • type-of('[color keyword]') thinks that these strings are colors.
  • map-has-key() works properly, thankfully. So:
    • map-has-key((white: ''), white) correctly returns true
    • map-has-key(('white': ''), 'white') correctly returns true
    • map-has-key((white: ''), 'white') correctly returns false
    • map-has-key(('white': ''), white) correctly returns false This means we can cobble together a replacement for type-of(). And a partial replacement for inspect() that works for everything except dangerous color keywords.

@TODO: Remove when LibSass 3.2.5 support is dropped.

6.5 #internals.chroma-has-color chroma-has-color($name [, $scheme])

Checks if the named color exists in the given scheme or its parent schemes. Returns false or a string of the scheme name that contains the color.

6.6 #internals.chroma-has-scheme chroma-has-scheme($scheme)

Checks if the named color scheme exists.

6.7 #internals.chroma-schemes chroma-schemes()

Returns a list of all color schemes in $chroma.