In this PR I'm optimizing a whole RecordTableCell in real conditions with a complex RelationFieldDisplay component : - Broke down getObjectRecordIdentifier into multiple utils - Precompute memoized function for getting chip data per field with useRecordChipDataGenerator() - Refactored RelationFieldDisplay - Use CSS modules where performance is needed instead of styled components - Create a CSS theme with global CSS variables to be used by CSS modules
23 lines
558 B
TypeScript
23 lines
558 B
TypeScript
import { ReactNode, useEffect } from 'react';
|
|
import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
|
|
|
|
import { ThemeType } from '..';
|
|
|
|
import './theme.css';
|
|
|
|
type ThemeProviderProps = {
|
|
theme: ThemeType;
|
|
children: ReactNode;
|
|
};
|
|
|
|
const ThemeProvider = ({ theme, children }: ThemeProviderProps) => {
|
|
useEffect(() => {
|
|
document.documentElement.className =
|
|
theme.name === 'dark' ? 'dark' : 'light';
|
|
}, [theme]);
|
|
|
|
return <EmotionThemeProvider theme={theme}>{children}</EmotionThemeProvider>;
|
|
};
|
|
|
|
export default ThemeProvider;
|