1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/packages/ui-components/.storybook/preview.js

53 lines
1.4 KiB
JavaScript

import Flags from 'country-flag-icons/react/3x2';
import { Provider } from 'react-redux';
import config from '../../plugins/ui-theme/src/i18n/config';
import {
AppConfigurationProvider,
StyleBaseline,
ThemeProvider,
TranslatorProvider,
store,
} from '../src/';
const DEFAULT_LANGUAGE = 'en-US';
const listLanguages = [
{ lng: DEFAULT_LANGUAGE, icon: Flags.US, menuKey: 'lng.english' },
{ lng: 'cs-CZ', icon: Flags.CZ, menuKey: 'lng.czech' },
{ lng: 'pt-BR', icon: Flags.BR, menuKey: 'lng.portuguese' },
{ lng: 'es-ES', icon: Flags.ES, menuKey: 'lng.spanish' },
{ lng: 'de-DE', icon: Flags.DE, menuKey: 'lng.german' },
];
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
// preview-head file contains the __VERDACCIO_BASENAME_UI_OPTIONS
// required by AppConfigurationProvider
export const withMuiTheme = (Story) => (
<Provider store={store}>
<TranslatorProvider loadDayJSLocale={() => {}} i18n={config} listLanguages={listLanguages}>
<AppConfigurationProvider>
<ThemeProvider>
<StyleBaseline />
<Story />
</ThemeProvider>
</AppConfigurationProvider>
</TranslatorProvider>
</Provider>
);
if (typeof global.process === 'undefined') {
const { worker } = require('../msw/browser');
worker.start();
}
export const decorators = [withMuiTheme];