You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.js 599B

123456789101112131415
  1. // @flow
  2. /**
  3. * Creates the color tokens based on the color theme and the association map.
  4. * If a key is not found in the association map it defaults to the current value.
  5. *
  6. * @param {Object} colorMap - A map between the token name and the actual color value.
  7. * @param {Object} colors - An object containing all the theme colors.
  8. * @returns {Object}
  9. */
  10. export function createColorTokens(colorMap: Object, colors: Object): Object {
  11. return Object.entries(colorMap)
  12. .reduce((result, [ token, value ]) =>
  13. Object.assign(result, { [token]: colors[value] || value }), {});
  14. }