Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(ui) fix parsing typography tokens

Saúl Ibarra Corretgé0c68a1eb51d6
diff --git a/react/features/base/ui/functions.web.ts b/react/features/base/ui/functions.web.ts
index 01774a7412..a3d06c23f6 100644
--- a/react/features/base/ui/functions.web.ts
+++ b/react/features/base/ui/functions.web.ts
@@ -3,7 +3,7 @@ import { Theme, adaptV4Theme, createTheme } from '@mui/material/styles';
import { ITypography, IPalette as Palette1 } from '../ui/types';
-import { createColorTokens } from './utils';
+import { createColorTokens, createTypographyTokens } from './utils';
declare module '@mui/material/styles' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
@@ -36,7 +36,7 @@ export function createWebTheme({ font, colorMap, shape, spacing, typography, bre
typography: {
// @ts-ignore
font,
- ...typography
+ ...createTypographyTokens(typography)
},
breakpoints
}));
diff --git a/react/features/base/ui/utils.ts b/react/features/base/ui/utils.ts
index 547ba086bc..ac27264cbe 100644
--- a/react/features/base/ui/utils.ts
+++ b/react/features/base/ui/utils.ts
@@ -19,3 +19,24 @@ export function createColorTokens(colorMap: Object): any {
return Object.assign(result, { [token]: color });
}, {});
}
+
+/**
+ * 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 });
+ }, {});
+}