2021-02-12 18:24:50 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { groupBy } from 'lodash';
|
2021-04-28 21:53:59 +02:00
|
|
|
import en from '../../../../app/_locales/en/messages.json';
|
2021-12-07 23:29:12 +01:00
|
|
|
import README from './README.mdx';
|
2021-02-12 18:24:50 +01:00
|
|
|
import MetaMaskTranslation from './metamask-translation';
|
|
|
|
|
2021-12-07 23:29:12 +01:00
|
|
|
const { keysWithoutSubstitution } = groupBy(Object.keys(en), (key) => {
|
|
|
|
if (en[key].message.includes('$1')) {
|
|
|
|
return 'keysWithSubstitution';
|
|
|
|
}
|
|
|
|
return 'keysWithoutSubstitution';
|
|
|
|
});
|
|
|
|
|
2021-02-12 18:24:50 +01:00
|
|
|
export default {
|
2021-12-01 20:27:57 +01:00
|
|
|
title: 'Components/App/MetamaskTranslation',
|
2021-09-15 20:55:48 +02:00
|
|
|
id: __filename,
|
2021-12-07 23:29:12 +01:00
|
|
|
component: MetaMaskTranslation,
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
page: README,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
argTypes: {
|
|
|
|
translationKey: { options: keysWithoutSubstitution, control: 'select' },
|
|
|
|
variables: { control: 'array' },
|
|
|
|
},
|
2021-02-12 18:24:50 +01:00
|
|
|
};
|
|
|
|
|
2021-12-07 23:29:12 +01:00
|
|
|
export const DefaultStory = (args) => {
|
|
|
|
return <MetaMaskTranslation {...args} />;
|
|
|
|
};
|
2021-02-12 18:24:50 +01:00
|
|
|
|
2021-12-07 23:29:12 +01:00
|
|
|
DefaultStory.storyName = 'Default';
|
|
|
|
DefaultStory.args = {
|
|
|
|
translationKey: keysWithoutSubstitution[0],
|
|
|
|
};
|
2021-02-12 18:24:50 +01:00
|
|
|
|
2021-12-07 23:29:12 +01:00
|
|
|
export const WithTemplate = (args) => (
|
2021-02-12 18:24:50 +01:00
|
|
|
<MetaMaskTranslation
|
2021-12-07 23:29:12 +01:00
|
|
|
{...args}
|
|
|
|
variables={[<h1 key="link">{args.translationKey}</h1>]}
|
2021-02-12 18:24:50 +01:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2021-12-07 23:29:12 +01:00
|
|
|
WithTemplate.args = {
|
|
|
|
translationKey: keysWithoutSubstitution[0],
|
|
|
|
};
|