Skip to content

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

ref: Convert Theme to TS (#11926)

Robert Pintilii2cea6c7b98a5
diff --git a/react/features/app/components/App.web.js b/react/features/app/components/App.web.js
index 43547e824e..950ba7b977 100644
--- a/react/features/app/components/App.web.js
+++ b/react/features/app/components/App.web.js
@@ -5,7 +5,7 @@ import React from 'react';
import { DialogContainer } from '../../base/dialog';
import GlobalStyles from '../../base/ui/components/GlobalStyles';
-import JitsiThemeProvider from '../../base/ui/components/JitsiThemeProvider';
+import JitsiThemeProvider from '../../base/ui/components/JitsiThemeProvider.web';
import { ChromeExtensionBanner } from '../../chrome-extension-banner';
import { AbstractApp } from './AbstractApp';
diff --git a/react/features/base/ui/components/BaseTheme.web.js b/react/features/base/ui/components/BaseTheme.web.ts
similarity index 79%
rename from react/features/base/ui/components/BaseTheme.web.js
rename to react/features/base/ui/components/BaseTheme.web.ts
index 05b0763848..69cfaa0f14 100644
--- a/react/features/base/ui/components/BaseTheme.web.js
+++ b/react/features/base/ui/components/BaseTheme.web.ts
@@ -1,7 +1,5 @@
-// @flow
-
import { font, colors, colorMap, spacing, shape, typography, breakpoints } from '../Tokens';
-import { createWebTheme } from '../functions';
+import { createWebTheme } from '../functions.web';
export default createWebTheme({
font,
diff --git a/react/features/base/ui/components/JitsiThemeProvider.web.js b/react/features/base/ui/components/JitsiThemeProvider.web.tsx
similarity index 83%
rename from react/features/base/ui/components/JitsiThemeProvider.web.js
rename to react/features/base/ui/components/JitsiThemeProvider.web.tsx
index 8923dfef48..89a4896c36 100644
--- a/react/features/base/ui/components/JitsiThemeProvider.web.js
+++ b/react/features/base/ui/components/JitsiThemeProvider.web.tsx
@@ -1,11 +1,8 @@
-// @flow
-
import { ThemeProvider } from '@material-ui/core/styles';
import * as React from 'react';
+import { connect } from 'react-redux';
-import { connect } from '../../../base/redux';
-
-import BaseTheme from './BaseTheme';
+import BaseTheme from './BaseTheme.web';
type Props = {
@@ -14,10 +11,10 @@ type Props = {
*/
_theme: Object,
- /**
+ /**
* The children of the component.
*/
- children: React.ChildrenArray<any>
+ children: React.ReactNode
}
/**
@@ -36,7 +33,7 @@ function JitsiThemeProvider(props: Props) {
* @param {Object} state - The Redux state.
* @returns {Props}
*/
-function _mapStateToProps(state) {
+function _mapStateToProps(state: any) {
const { muiBrandedTheme } = state['features/dynamic-branding'];
return {
diff --git a/react/features/base/ui/functions.web.js b/react/features/base/ui/functions.web.ts
similarity index 76%
rename from react/features/base/ui/functions.web.js
rename to react/features/base/ui/functions.web.ts
index 27813652bd..a3af4459aa 100644
--- a/react/features/base/ui/functions.web.js
+++ b/react/features/base/ui/functions.web.ts
@@ -1,16 +1,25 @@
-// @flow
-
import { createMuiTheme } from '@material-ui/core/styles';
+import { Theme } from './types';
import { createColorTokens } from './utils';
+interface ThemeProps {
+ breakpoints: Object;
+ colorMap: Object;
+ colors: Object;
+ font: Object;
+ shape: Object;
+ spacing: Array<number>;
+ typography: Object;
+}
+
/**
* Creates a MUI theme based on local UI tokens.
*
* @param {Object} arg - The ui tokens.
* @returns {Object}
*/
-export function createWebTheme({ font, colors, colorMap, shape, spacing, typography, breakpoints }: Object) {
+export function createWebTheme({ font, colors, colorMap, shape, spacing, typography, breakpoints }: ThemeProps): Theme {
return createMuiTheme({
props: {
// disable ripple effect on buttons globally
@@ -29,7 +38,7 @@ export function createWebTheme({ font, colors, colorMap, shape, spacing, typogra
...typography
},
breakpoints
- });
+ }) as unknown as Theme;
}
/**
@@ -39,7 +48,7 @@ export function createWebTheme({ font, colors, colorMap, shape, spacing, typogra
* @returns {Object}
*/
export function formatCommonClasses(stylesObj: Object) {
- const formatted = {};
+ const formatted: any = {};
for (const [ key, value ] of Object.entries(stylesObj)) {
formatted[`.${key}`] = value;
diff --git a/react/features/base/ui/utils.js b/react/features/base/ui/utils.ts
similarity index 89%
rename from react/features/base/ui/utils.js
rename to react/features/base/ui/utils.ts
index 717a0d3177..5bc8485aeb 100644
--- a/react/features/base/ui/utils.js
+++ b/react/features/base/ui/utils.ts
@@ -1,5 +1,3 @@
-// @flow
-
/**
* Creates the color tokens based on the color theme and the association map.
* If a key is not found in the association map it defaults to the current value.
@@ -10,6 +8,6 @@
*/
export function createColorTokens(colorMap: Object, colors: Object): Object {
return Object.entries(colorMap)
- .reduce((result, [ token, value ]) =>
+ .reduce((result, [ token, value ]: [any, keyof Object]) =>
Object.assign(result, { [token]: colors[value] || value }), {});
}
diff --git a/react/features/prejoin/components/PrejoinApp.js b/react/features/prejoin/components/PrejoinApp.js
index 58338f516f..622fca1121 100644
--- a/react/features/prejoin/components/PrejoinApp.js
+++ b/react/features/prejoin/components/PrejoinApp.js
@@ -10,7 +10,7 @@ import { setConfig } from '../../base/config';
import { DialogContainer } from '../../base/dialog';
import { createPrejoinTracks } from '../../base/tracks';
import GlobalStyles from '../../base/ui/components/GlobalStyles';
-import JitsiThemeProvider from '../../base/ui/components/JitsiThemeProvider';
+import JitsiThemeProvider from '../../base/ui/components/JitsiThemeProvider.web';
import { initPrejoin, makePrecallTest } from '../actions';
import PrejoinThirdParty from './PrejoinThirdParty';