2025-06-10 13:37:08 +03:00
|
|
|
import { merge } from 'lodash-es';
|
2025-03-18 18:00:54 +02:00
|
|
|
|
|
|
|
|
import * as jitsiTokens from './jitsiTokens.json';
|
|
|
|
|
import * as tokens from './tokens.json';
|
|
|
|
|
|
2021-05-11 11:01:45 +03:00
|
|
|
/**
|
|
|
|
|
* Creates the color tokens based on the color theme and the association map.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} colorMap - A map between the token name and the actual color value.
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
*/
|
2025-03-18 18:00:54 +02:00
|
|
|
export function createColorTokens(colorMap: Object): any {
|
|
|
|
|
const allTokens = merge({}, tokens, jitsiTokens);
|
|
|
|
|
|
2021-05-11 11:01:45 +03:00
|
|
|
return Object.entries(colorMap)
|
2025-03-18 18:00:54 +02:00
|
|
|
.reduce((result, [ token, value ]: [any, string]) => {
|
2025-04-02 15:12:38 +03:00
|
|
|
const color = allTokens[value as keyof typeof allTokens] || value;
|
2025-03-18 18:00:54 +02:00
|
|
|
|
|
|
|
|
return Object.assign(result, { [token]: color });
|
|
|
|
|
}, {});
|
2021-05-11 11:01:45 +03:00
|
|
|
}
|
2025-05-15 16:16:57 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create the typography tokens based on the typography theme and the association map.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} typography - A map between the token name and the actual typography value.
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
*/
|
|
|
|
|
export function createTypographyTokens(typography: Object): any {
|
|
|
|
|
const allTokens = merge({}, tokens, jitsiTokens);
|
|
|
|
|
|
|
|
|
|
return Object.entries(typography)
|
|
|
|
|
.reduce((result, [ token, value ]: [any, any]) => {
|
|
|
|
|
let typographyValue = value;
|
|
|
|
|
|
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
|
typographyValue = allTokens[value as keyof typeof allTokens] || value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Object.assign(result, { [token]: typographyValue });
|
|
|
|
|
}, {});
|
|
|
|
|
}
|