1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

initial changes to support controls over knobs in storybook (#18502)

* initial changes to support controls over knobs in storybook

* fix linting issue
This commit is contained in:
dswilson4 2023-04-10 01:07:07 -07:00 committed by GitHub
parent f31596af24
commit 826ac55c32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,5 @@
import React from 'react'; import React from 'react';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { object } from '@storybook/addon-knobs';
import { panel, text, heading, divider, copyable } from '@metamask/snaps-ui'; import { panel, text, heading, divider, copyable } from '@metamask/snaps-ui';
import configureStore from '../../../../store/store'; import configureStore from '../../../../store/store';
import testData from '../../../../../.storybook/test-data'; import testData from '../../../../../.storybook/test-data';
@ -10,8 +9,13 @@ const store = configureStore(testData);
export default { export default {
title: 'Components/App/SnapUIRenderer', title: 'Components/App/SnapUIRenderer',
component: SnapUIRenderer,
decorators: [(story) => <Provider store={store}>{story()}</Provider>], decorators: [(story) => <Provider store={store}>{story()}</Provider>],
argTypes: {
data: {
control: 'object',
},
},
}; };
const DATA = panel([ const DATA = panel([
@ -22,13 +26,18 @@ const DATA = panel([
copyable('Text you can copy'), copyable('Text you can copy'),
]); ]);
export const DefaultStory = () => ( export const DefaultStory = (args) => (
<SnapUIRenderer <SnapUIRenderer snapId="local:http://localhost:8080/" data={args.data} />
snapId="local:http://localhost:8080/"
data={object('data', DATA)}
/>
); );
export const ErrorStory = () => ( DefaultStory.args = {
<SnapUIRenderer snapId="local:http://localhost:8080/" data="foo" /> data: DATA,
};
export const ErrorStory = (args) => (
<SnapUIRenderer snapId="local:http://localhost:8080/" data={args.data} />
); );
ErrorStory.args = {
data: 'foo',
};