-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(textArea): added textarea component
- Loading branch information
1 parent
d6277e5
commit 5e16d16
Showing
26 changed files
with
3,658 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ export const parameters = { | |
'Image', | ||
'Input', | ||
'Text', | ||
'TextArea', | ||
'Toast', | ||
'Switch', | ||
'Modal', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Meta } from '@storybook/addon-docs'; | ||
import TextAreaSizes from '../assets/textarea/TextAreaSizes.png'; | ||
import TextAreaTypes from '../assets/textarea/TextAreaTypes.png'; | ||
import TextAreaCases from '../assets/textarea/TextAreaCases.png'; | ||
|
||
<Meta | ||
title="Components/TextArea" | ||
parameters={{ | ||
viewMode: 'docs', | ||
previewTabs: { | ||
canvas: { | ||
hidden: true, | ||
}, | ||
}, | ||
}} | ||
/> | ||
|
||
# TextArea | ||
|
||
Text areas let users enter and edit text. | ||
|
||
<div | ||
style={{ | ||
display: 'flex', | ||
flexWrap: 'wrap', | ||
justifyContent: 'center', | ||
}}> | ||
<img src={TextAreaSizes} width="250" alt="TextAreaSizes" /> | ||
<img src={TextAreaTypes} width="250" alt="TextAreaTypes" /> | ||
<img src={TextAreaCases} width="250" alt="TextAreaCases" /> | ||
</div> | ||
|
||
<br/> | ||
<br/> | ||
|
||
## Usage | ||
|
||
```jsx | ||
<TextArea label="Lorem" placeHolder="Lorem" size="small" maxLength={200} /> | ||
``` | ||
|
||
## Props | ||
|
||
#### size | ||
|
||
The size of the button. | ||
`large`, | ||
`medium`, | ||
`small` | ||
|
||
#### label | ||
|
||
The text or component to use for the floating label. | ||
|
||
#### labelFixed | ||
|
||
Boolean value that checks if the label is fixed. | ||
|
||
#### placeholder | ||
|
||
The string that will be rendered before text has been entered. | ||
|
||
#### disabled | ||
|
||
If true, user won't be able to interact with the component. | ||
|
||
#### helpText | ||
|
||
Helper text providing information for the textArea. | ||
|
||
#### counterText | ||
|
||
Counts the length of the textArea. | ||
|
||
#### error | ||
|
||
Boolean value indicating the error status. | ||
|
||
#### errorText | ||
|
||
Helper text showing the error in the textArea. | ||
|
||
#### maxLength | ||
|
||
Max length of content. | ||
|
||
#### maxLengthErrorText | ||
|
||
Helper text showing the error if exceed maxLength. | ||
|
||
#### style | ||
|
||
Type: `StyleProp<TextAreaStyle>` | ||
|
||
<br /> | ||
TextArea implements: <> | ||
<a href="https://reactnative.dev/docs/textinput#props" title="title"> | ||
...TextInput props | ||
</a> | ||
</> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import React, { useState } from 'react'; | ||
import { ComponentStory, ComponentMeta } from '@storybook/react-native'; | ||
import Text from '../Text/Text'; | ||
import TextArea from './TextArea'; | ||
import Box from '../Box/Box'; | ||
import Button from '../Button/Button'; | ||
|
||
const sizeList = ['small', 'medium', 'large']; | ||
|
||
const TextAreaMeta: ComponentMeta<typeof TextArea> = { | ||
title: 'TextArea', | ||
component: TextArea, | ||
argTypes: { | ||
size: { | ||
options: sizeList, | ||
control: { type: 'radios' }, | ||
}, | ||
}, | ||
args: { | ||
size: 'medium', | ||
label: 'Label', | ||
placeholder: 'Type something...', | ||
labelFixed: false, | ||
helpText: 'Helper Text', | ||
error: false, | ||
disabled: false, | ||
errorText: 'Error Text', | ||
}, | ||
}; | ||
|
||
export default TextAreaMeta; | ||
|
||
type TextAreaStory = ComponentStory<typeof TextArea>; | ||
|
||
export const Basic: TextAreaStory = args => ( | ||
<Box> | ||
<Box px="2xs"> | ||
<Text py="2xs" variant="subtitle01Bold"> | ||
Text Area | ||
</Text> | ||
</Box> | ||
|
||
<TextArea {...args} /> | ||
</Box> | ||
); | ||
|
||
export const Cases: TextAreaStory = args => { | ||
const [state, setState] = useState(args); | ||
|
||
return ( | ||
<Box> | ||
<Box px="2xs"> | ||
<Text py="2xs" variant="subtitle01Bold"> | ||
Text Area Cases | ||
</Text> | ||
</Box> | ||
|
||
<TextArea {...args} disabled={true} /> | ||
|
||
<Box pt="2xl"> | ||
<TextArea {...state} /> | ||
|
||
<Box flexDirection="row" px="2xs" marginLeft="2xs" marginTop="xs"> | ||
<Button | ||
flex={1} | ||
kind="danger" | ||
variant="secondary" | ||
size="s" | ||
onPress={() => setState({ ...state, error: true, errorText: null })} | ||
label="Toggle Error" | ||
filled={true} | ||
mr="2xs" | ||
/> | ||
<Button | ||
flex={1} | ||
size="s" | ||
kind="danger" | ||
variant="secondary" | ||
onPress={() => | ||
setState({ | ||
...state, | ||
error: true, | ||
errorText: 'Error text', | ||
}) | ||
} | ||
label="Error with Text" | ||
filled={true} | ||
mr="2xs" | ||
/> | ||
</Box> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export const Sizes: TextAreaStory = () => ( | ||
<Box> | ||
<Box px="2xs"> | ||
<Text py="2xs" variant="subtitle01Bold"> | ||
Text Area Sizes | ||
</Text> | ||
</Box> | ||
|
||
<Box py="xs"> | ||
<TextArea | ||
size="large" | ||
label="Label" | ||
placeholder="Large" | ||
helpText="Help Text" | ||
/> | ||
</Box> | ||
|
||
<Box py="xs"> | ||
<TextArea | ||
size="medium" | ||
label="Label" | ||
placeholder="Medium" | ||
helpText="Help Text" | ||
/> | ||
</Box> | ||
|
||
<Box py="xs"> | ||
<TextArea | ||
size="small" | ||
label="Label" | ||
placeholder="Small" | ||
helpText="Help Text" | ||
/> | ||
</Box> | ||
</Box> | ||
); | ||
|
||
export const Types: TextAreaStory = args => { | ||
return ( | ||
<Box> | ||
<Box px="2xs"> | ||
<Text py="2xs" variant="subtitle01Bold"> | ||
Text Area Types | ||
</Text> | ||
</Box> | ||
|
||
<TextArea {...args} labelFixed={true} /> | ||
|
||
<TextArea {...args} /> | ||
|
||
<TextArea {...args} label={null} /> | ||
</Box> | ||
); | ||
}; |
Oops, something went wrong.