1 import { StyledEngineProvider, ThemeProvider } from '@mui/material/styles'; 2 import * as React from 'react'; 3 import { connect } from 'react-redux'; 4 5 import { IReduxState } from '../../../app/types'; 6 7 import BaseTheme from './BaseTheme.web'; 8 9 interface IProps { 10 11 /** 12 * The default theme or theme set through advanced branding. 13 */ 14 _theme: Object; 15 16 /** 17 * The children of the component. 18 */ 19 children: React.ReactNode; 20 } 21 22 /** 23 * The theme provider for the web app. 24 * 25 * @param {Object} props - The props of the component. 26 * @returns {React.ReactNode} 27 */ 28 function JitsiThemeProvider(props: IProps) { 29 return ( 30 <StyledEngineProvider injectFirst = { true }> 31 <ThemeProvider theme = { props._theme }>{ props.children }</ThemeProvider> 32 </StyledEngineProvider> 33 ); 34 } 35 36 /** 37 * Maps part of the Redux state to the props of this component. 38 * 39 * @param {Object} state - The Redux state. 40 * @returns {IProps} 41 */ 42 function _mapStateToProps(state: IReduxState) { 43 const { muiBrandedTheme } = state['features/dynamic-branding']; 44 45 return { 46 _theme: muiBrandedTheme || BaseTheme 47 }; 48 } 49 50 export default connect(_mapStateToProps)(JitsiThemeProvider);