mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
text-field (#12889)
This commit is contained in:
parent
5273aa334e
commit
51fa7734fd
51
ui/components/ui/text-field/README.mdx
Normal file
51
ui/components/ui/text-field/README.mdx
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
|
||||||
|
|
||||||
|
import TextField from '.';
|
||||||
|
|
||||||
|
# Text Field
|
||||||
|
|
||||||
|
Text fields allow users to enter text into a UI.
|
||||||
|
|
||||||
|
<Canvas>
|
||||||
|
<Story id="ui-components-ui-text-field-text-field-stories-js--default-story" />
|
||||||
|
</Canvas>
|
||||||
|
|
||||||
|
## Component API
|
||||||
|
|
||||||
|
<ArgsTable of={TextField} />
|
||||||
|
|
||||||
|
### Password Text Field
|
||||||
|
|
||||||
|
<Canvas>
|
||||||
|
<Story id="ui-components-ui-text-field-text-field-stories-js--password" />
|
||||||
|
</Canvas>
|
||||||
|
|
||||||
|
### With Error
|
||||||
|
|
||||||
|
<Canvas>
|
||||||
|
<Story id="ui-components-ui-text-field-text-field-stories-js--error" />
|
||||||
|
</Canvas>
|
||||||
|
|
||||||
|
### Mascara Text
|
||||||
|
|
||||||
|
<Canvas>
|
||||||
|
<Story id="ui-components-ui-text-field-text-field-stories-js--mascara-text" />
|
||||||
|
</Canvas>
|
||||||
|
|
||||||
|
### With Material Theme
|
||||||
|
|
||||||
|
<Canvas>
|
||||||
|
<Story id="ui-components-ui-text-field-text-field-stories-js--material-text" />
|
||||||
|
</Canvas>
|
||||||
|
|
||||||
|
### Password With Material Theme
|
||||||
|
|
||||||
|
<Canvas>
|
||||||
|
<Story id="ui-components-ui-text-field-text-field-stories-js--material-password" />
|
||||||
|
</Canvas>
|
||||||
|
|
||||||
|
### With Material Theme Error
|
||||||
|
|
||||||
|
<Canvas>
|
||||||
|
<Story id="ui-components-ui-text-field-text-field-stories-js--material-error" />
|
||||||
|
</Canvas>
|
@ -243,14 +243,35 @@ TextField.defaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TextField.propTypes = {
|
TextField.propTypes = {
|
||||||
|
/**
|
||||||
|
* Show error message
|
||||||
|
*/
|
||||||
error: PropTypes.string,
|
error: PropTypes.string,
|
||||||
|
/**
|
||||||
|
* Add custom CSS class
|
||||||
|
*/
|
||||||
classes: PropTypes.object,
|
classes: PropTypes.object,
|
||||||
dir: PropTypes.string,
|
dir: PropTypes.string,
|
||||||
|
/**
|
||||||
|
* Give theme to the text field
|
||||||
|
*/
|
||||||
theme: PropTypes.oneOf(['bordered', 'material', 'material-white-padded']),
|
theme: PropTypes.oneOf(['bordered', 'material', 'material-white-padded']),
|
||||||
startAdornment: PropTypes.element,
|
startAdornment: PropTypes.element,
|
||||||
|
/**
|
||||||
|
* Show large label
|
||||||
|
*/
|
||||||
largeLabel: PropTypes.bool,
|
largeLabel: PropTypes.bool,
|
||||||
|
/**
|
||||||
|
* Define min number input
|
||||||
|
*/
|
||||||
min: PropTypes.number,
|
min: PropTypes.number,
|
||||||
|
/**
|
||||||
|
* Define max number input
|
||||||
|
*/
|
||||||
max: PropTypes.number,
|
max: PropTypes.number,
|
||||||
|
/**
|
||||||
|
* Show auto complete text
|
||||||
|
*/
|
||||||
autoComplete: PropTypes.string,
|
autoComplete: PropTypes.string,
|
||||||
onPaste: PropTypes.func,
|
onPaste: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
@ -1,33 +1,75 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import README from './README.mdx';
|
||||||
import TextField from '.';
|
import TextField from '.';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Components/UI/TextField',
|
title: 'Components/UI/TextField',
|
||||||
id: __filename,
|
id: __filename,
|
||||||
|
component: TextField,
|
||||||
|
parameters: {
|
||||||
|
docs: {
|
||||||
|
page: README,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
argTypes: {
|
||||||
|
error: { control: 'text' },
|
||||||
|
classes: { control: 'object' },
|
||||||
|
dir: { control: 'text' },
|
||||||
|
theme: {
|
||||||
|
control: 'select',
|
||||||
|
options: ['bordered', 'material', 'material-white-padded'],
|
||||||
|
},
|
||||||
|
startAdornment: { control: 'element' },
|
||||||
|
largeLabel: { control: 'boolean' },
|
||||||
|
min: { control: 'number' },
|
||||||
|
max: { control: 'number' },
|
||||||
|
autoComplete: { control: 'text' },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DefaultStory = () => <TextField label="Text" type="text" />;
|
export const DefaultStory = (args) => <TextField {...args} />;
|
||||||
|
|
||||||
DefaultStory.storyName = 'Default';
|
DefaultStory.storyName = 'Default';
|
||||||
|
DefaultStory.args = {
|
||||||
|
label: 'Text',
|
||||||
|
type: 'text',
|
||||||
|
};
|
||||||
|
|
||||||
export const Password = () => <TextField label="Password" type="password" />;
|
export const Password = (args) => <TextField {...args} />;
|
||||||
|
Password.args = {
|
||||||
|
label: 'Password',
|
||||||
|
type: 'password',
|
||||||
|
};
|
||||||
|
export const Error = (args) => <TextField {...args} />;
|
||||||
|
Error.args = {
|
||||||
|
type: 'text',
|
||||||
|
label: 'Name',
|
||||||
|
error: 'Invalid Value',
|
||||||
|
};
|
||||||
|
export const MascaraText = (args) => <TextField {...args} />;
|
||||||
|
MascaraText.args = {
|
||||||
|
label: 'Text',
|
||||||
|
type: 'text',
|
||||||
|
largeLabel: true,
|
||||||
|
};
|
||||||
|
|
||||||
export const Error = () => (
|
export const MaterialText = (args) => <TextField {...args} />;
|
||||||
<TextField type="text" label="Name" error="Invalid value" />
|
MaterialText.args = {
|
||||||
);
|
label: 'Text',
|
||||||
|
type: 'text',
|
||||||
|
theme: 'material',
|
||||||
|
};
|
||||||
|
|
||||||
export const MascaraText = () => (
|
export const MaterialPassword = (args) => <TextField {...args} />;
|
||||||
<TextField label="Text" type="text" largeLabel />
|
MaterialPassword.args = {
|
||||||
);
|
label: 'Password',
|
||||||
|
type: 'password',
|
||||||
|
theme: 'material',
|
||||||
|
};
|
||||||
|
|
||||||
export const MaterialText = () => (
|
export const MaterialError = (args) => <TextField {...args} />;
|
||||||
<TextField label="Text" type="text" theme="material" />
|
MaterialError.args = {
|
||||||
);
|
type: 'text',
|
||||||
|
label: 'Name',
|
||||||
export const MaterialPassword = () => (
|
error: 'Invalid Value',
|
||||||
<TextField label="Password" type="password" theme="material" />
|
theme: 'material',
|
||||||
);
|
};
|
||||||
|
|
||||||
export const MaterialError = () => (
|
|
||||||
<TextField type="text" label="Name" error="Invalid value" theme="material" />
|
|
||||||
);
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user