You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JitsiThemeProvider.web.tsx 1.2KB

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