您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

utils.ts 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { merge } from 'lodash';
  2. import * as jitsiTokens from './jitsiTokens.json';
  3. import * as tokens from './tokens.json';
  4. /**
  5. * Creates the color tokens based on the color theme and the association map.
  6. *
  7. * @param {Object} colorMap - A map between the token name and the actual color value.
  8. * @returns {Object}
  9. */
  10. export function createColorTokens(colorMap: Object): any {
  11. const allTokens = merge({}, tokens, jitsiTokens);
  12. return Object.entries(colorMap)
  13. .reduce((result, [ token, value ]: [any, string]) => {
  14. const color = allTokens[value as keyof typeof allTokens] || value;
  15. return Object.assign(result, { [token]: color });
  16. }, {});
  17. }
  18. /**
  19. * Create the typography tokens based on the typography theme and the association map.
  20. *
  21. * @param {Object} typography - A map between the token name and the actual typography value.
  22. * @returns {Object}
  23. */
  24. export function createTypographyTokens(typography: Object): any {
  25. const allTokens = merge({}, tokens, jitsiTokens);
  26. return Object.entries(typography)
  27. .reduce((result, [ token, value ]: [any, any]) => {
  28. let typographyValue = value;
  29. if (typeof value === 'string') {
  30. typographyValue = allTokens[value as keyof typeof allTokens] || value;
  31. }
  32. return Object.assign(result, { [token]: typographyValue });
  33. }, {});
  34. }