1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/ui/components/app/metamask-translation
Maarten Zuidhoorn c341abaea6
Use Webpack 5 for Storybook (#16678)
* Fix storybook

* Update policies

* Bump all Storybook dependencies to the latest version

* Add Storybook dependencies to depcheck ignore list

* Update policy-override.json

* Fix SectionShape circular dependency

* Change policy override for eslint-scope

* Fix some Webpack build issues

* Add missing dependency

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2022-11-29 19:23:36 +01:00
..
index.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
metamask-translation.js Use Webpack 5 for Storybook (#16678) 2022-11-29 19:23:36 +01:00
metamask-translation.stories.js Fix metamask-translation component for new Storybook format (#12892) 2021-12-07 14:29:12 -08:00
README.mdx Updated all instances of "Component API" to "Props" in storybook documentation (#15324) 2022-07-27 00:22:40 +05:30

import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';

import MetaMaskTranslation from '.';

# MetaMask Translation

MetaMaskTranslation is a simple helper component for adding full translation
support to the template system. We do pass the translation function to the
template getValues function, but passing it React components as variables
would require React to be in scope, and breaks the object pattern paradigm.

This component gets around that by converting variables that are templates
themselves into tiny React trees. This component does additional validation
to make sure that the tree has a single root node, with maximum two leaves.
Each subnode can have a maximum of one child that must be a string.

This enforces a maximum recursion depth of 2, preventing translation strings
from being performance hogs. We could further limit this, and also attenuate
the safeComponentList for what kind of components we allow these special
trees to contain.

<Canvas>
  <Story id="ui-components-app-metamask-translation-metamask-translation-stories-js--default-story" />
</Canvas>

## Props

<!--
ArgsTable doesn't work with SectionShape
<ArgsTable of={MetaMaskTranslation} />
-->

| Name             | Description                                                                                             |
| ---------------- | ------------------------------------------------------------------------------------------------------- |
| `translationKey` | Translation object key `string`                                                                         |
| `variables`      | Array of variables for the MetaMaskTranslation. Can be an array of `string`, `number` or `SectionShape` |