mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix radio-group component to for new Storybook format (#12900)
* radio-group * tweak proptype descs
This commit is contained in:
parent
311ea021f3
commit
d5b85c0e54
15
ui/components/ui/radio-group/README.mdx
Normal file
15
ui/components/ui/radio-group/README.mdx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
|
||||||
|
|
||||||
|
import RadioGroup from '.';
|
||||||
|
|
||||||
|
# Radio Group
|
||||||
|
|
||||||
|
A multiple-exclusion scope for a set of radio buttons.
|
||||||
|
|
||||||
|
<Canvas>
|
||||||
|
<Story id="ui-components-ui-radio-group-radio-group-stories-js--default-story" />
|
||||||
|
</Canvas>
|
||||||
|
|
||||||
|
## Component API
|
||||||
|
|
||||||
|
<ArgsTable of={RadioGroup} />
|
@ -85,9 +85,21 @@ export default function RadioGroup({ options, name, selectedValue, onChange }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RadioGroup.propTypes = {
|
RadioGroup.propTypes = {
|
||||||
|
/**
|
||||||
|
* Predefined options for radio group
|
||||||
|
*/
|
||||||
options: PropTypes.array,
|
options: PropTypes.array,
|
||||||
|
/**
|
||||||
|
* Show selected value
|
||||||
|
*/
|
||||||
selectedValue: PropTypes.string,
|
selectedValue: PropTypes.string,
|
||||||
|
/**
|
||||||
|
* Show name as label
|
||||||
|
*/
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
|
/**
|
||||||
|
* Handler for onChange
|
||||||
|
*/
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,30 +1,43 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { GAS_RECOMMENDATIONS } from '../../../../shared/constants/gas';
|
import { GAS_RECOMMENDATIONS } from '../../../../shared/constants/gas';
|
||||||
|
import README from './README.mdx';
|
||||||
import RadioGroup from '.';
|
import RadioGroup from '.';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Components/UI/RadioGroup',
|
title: 'Components/UI/RadioGroup',
|
||||||
id: __filename,
|
id: __filename,
|
||||||
|
component: RadioGroup,
|
||||||
|
parameters: {
|
||||||
|
docs: {
|
||||||
|
page: README,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
argTypes: {
|
||||||
|
options: { control: 'array' },
|
||||||
|
selectedValue: { control: 'text' },
|
||||||
|
name: { control: 'text' },
|
||||||
|
onChange: { action: 'onChange' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DefaultStory = () => {
|
export const DefaultStory = (args) => {
|
||||||
return (
|
return (
|
||||||
<div className="radio-group" style={{ minWidth: '600px' }}>
|
<div className="radio-group" style={{ minWidth: '600px' }}>
|
||||||
<RadioGroup
|
<RadioGroup {...args} />
|
||||||
name="gas-recommendation"
|
|
||||||
options={[
|
|
||||||
{ value: GAS_RECOMMENDATIONS.LOW, label: 'Low', recommended: false },
|
|
||||||
{
|
|
||||||
value: GAS_RECOMMENDATIONS.MEDIUM,
|
|
||||||
label: 'Medium',
|
|
||||||
recommended: false,
|
|
||||||
},
|
|
||||||
{ value: GAS_RECOMMENDATIONS.HIGH, label: 'High', recommended: true },
|
|
||||||
]}
|
|
||||||
selectedValue={GAS_RECOMMENDATIONS.HIGH}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
DefaultStory.storyName = 'Default';
|
DefaultStory.storyName = 'Default';
|
||||||
|
DefaultStory.args = {
|
||||||
|
name: 'gas-recommendation',
|
||||||
|
options: [
|
||||||
|
{ value: GAS_RECOMMENDATIONS.LOW, label: 'Low', recommended: false },
|
||||||
|
{
|
||||||
|
value: GAS_RECOMMENDATIONS.MEDIUM,
|
||||||
|
label: 'Medium',
|
||||||
|
recommended: false,
|
||||||
|
},
|
||||||
|
{ value: GAS_RECOMMENDATIONS.HIGH, label: 'High', recommended: true },
|
||||||
|
],
|
||||||
|
selectedValue: GAS_RECOMMENDATIONS.HIGH,
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user