mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Change prettier rules
This commit is contained in:
@@ -5,7 +5,7 @@ import storyDecorator from './storyDecorator';
|
||||
const req = require.context('../packages/app', true, /\.story\.[tj]sx?$/);
|
||||
|
||||
function loadStories() {
|
||||
req.keys().forEach((filename) => req(filename));
|
||||
req.keys().forEach((filename) => req(filename));
|
||||
}
|
||||
|
||||
addDecorator(storyDecorator);
|
||||
|
@@ -2,40 +2,37 @@ import React from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { Channel } from '@storybook/channels';
|
||||
import { setIntlConfig } from 'storybook-addon-intl';
|
||||
import {
|
||||
EVENT_SET_LOCALE_ID,
|
||||
EVENT_GET_LOCALE_ID,
|
||||
} from 'storybook-addon-intl/dist/shared';
|
||||
import { EVENT_SET_LOCALE_ID, EVENT_GET_LOCALE_ID } from 'storybook-addon-intl/dist/shared';
|
||||
import { SUPPORTED_LANGUAGES, DEFAULT_LANGUAGE } from 'app/services/i18n';
|
||||
import { setLocale } from 'app/components/i18n/actions';
|
||||
|
||||
setIntlConfig({
|
||||
locales: SUPPORTED_LANGUAGES,
|
||||
defaultLocale: DEFAULT_LANGUAGE,
|
||||
locales: SUPPORTED_LANGUAGES,
|
||||
defaultLocale: DEFAULT_LANGUAGE,
|
||||
});
|
||||
|
||||
const IntlDecorator: React.ComponentType<{
|
||||
channel: Channel;
|
||||
channel: Channel;
|
||||
}> = ({ channel, children }) => {
|
||||
const dispatch = useDispatch();
|
||||
const dispatch = useDispatch();
|
||||
|
||||
React.useEffect(() => {
|
||||
const onLocaleChange = (locale: string) => {
|
||||
dispatch(setLocale(locale));
|
||||
};
|
||||
React.useEffect(() => {
|
||||
const onLocaleChange = (locale: string) => {
|
||||
dispatch(setLocale(locale));
|
||||
};
|
||||
|
||||
// Listen for change of locale
|
||||
channel.on(EVENT_SET_LOCALE_ID, onLocaleChange);
|
||||
// Listen for change of locale
|
||||
channel.on(EVENT_SET_LOCALE_ID, onLocaleChange);
|
||||
|
||||
// Request the current locale
|
||||
channel.emit(EVENT_GET_LOCALE_ID);
|
||||
// Request the current locale
|
||||
channel.emit(EVENT_GET_LOCALE_ID);
|
||||
|
||||
return () => {
|
||||
channel.removeListener(EVENT_SET_LOCALE_ID, onLocaleChange);
|
||||
};
|
||||
}, [channel]);
|
||||
return () => {
|
||||
channel.removeListener(EVENT_SET_LOCALE_ID, onLocaleChange);
|
||||
};
|
||||
}, [channel]);
|
||||
|
||||
return children as React.ReactElement;
|
||||
return children as React.ReactElement;
|
||||
};
|
||||
|
||||
export default IntlDecorator;
|
||||
|
@@ -10,11 +10,11 @@ import { IntlDecorator } from './decorators';
|
||||
const store = storeFactory();
|
||||
|
||||
export default ((story) => {
|
||||
const channel = addons.getChannel();
|
||||
const channel = addons.getChannel();
|
||||
|
||||
return (
|
||||
<ContextProvider store={store} history={browserHistory}>
|
||||
<IntlDecorator channel={channel}>{story()}</IntlDecorator>
|
||||
</ContextProvider>
|
||||
);
|
||||
return (
|
||||
<ContextProvider store={store} history={browserHistory}>
|
||||
<IntlDecorator channel={channel}>{story()}</IntlDecorator>
|
||||
</ContextProvider>
|
||||
);
|
||||
}) as DecoratorFunction<React.ReactElement>;
|
||||
|
@@ -1,14 +1,14 @@
|
||||
const rootConfig = require('../webpack.config');
|
||||
|
||||
module.exports = async ({ config }) => ({
|
||||
...config,
|
||||
resolve: rootConfig.resolve,
|
||||
module: {
|
||||
...config.module,
|
||||
// our rules should satisfy all storybook needs,
|
||||
// so replace all storybook defaults with our rules
|
||||
rules: rootConfig.module.rules,
|
||||
},
|
||||
...config,
|
||||
resolve: rootConfig.resolve,
|
||||
module: {
|
||||
...config.module,
|
||||
// our rules should satisfy all storybook needs,
|
||||
// so replace all storybook defaults with our rules
|
||||
rules: rootConfig.module.rules,
|
||||
},
|
||||
|
||||
resolveLoader: rootConfig.resolveLoader,
|
||||
resolveLoader: rootConfig.resolveLoader,
|
||||
});
|
||||
|
Reference in New Issue
Block a user