twenty/packages/twenty-ui/.storybook/preview.tsx
Lucas Bordeau a0178478d4
Feat/performance-refactor-styled-component (#5516)
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
2024-05-24 18:53:37 +02:00

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;