mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-04 05:32:38 +03:00
a0178478d4
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
29 lines
692 B
TypeScript
29 lines
692 B
TypeScript
import { useEffect } from 'react';
|
|
import { ThemeProvider } from '@emotion/react';
|
|
import { Preview } from '@storybook/react';
|
|
import { useDarkMode } from 'storybook-dark-mode';
|
|
|
|
import { THEME_DARK, THEME_LIGHT } from '../src/theme/index';
|
|
|
|
const preview: Preview = {
|
|
decorators: [
|
|
(Story) => {
|
|
const mode = useDarkMode() ? 'Dark' : 'Light';
|
|
|
|
const theme = mode === 'Dark' ? THEME_DARK : THEME_LIGHT;
|
|
|
|
useEffect(() => {
|
|
document.documentElement.className = mode === 'Dark' ? 'dark' : 'light';
|
|
}, [mode]);
|
|
|
|
return (
|
|
<ThemeProvider theme={theme}>
|
|
<Story />
|
|
</ThemeProvider>
|
|
);
|
|
},
|
|
],
|
|
};
|
|
|
|
export default preview;
|