-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Federico Zivolo
committed
Jan 4, 2019
1 parent
5c6d6f6
commit f2eb2c6
Showing
4 changed files
with
53 additions
and
3 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
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,20 @@ | ||
The `TextArea` component acts exactly like a `textarea` HTML element, | ||
and shares all the features provided by the `InputText` component. | ||
|
||
```js | ||
<TextArea | ||
placeholder="This is a textarea, multiline text is supported" | ||
style={{ height: 100 }} | ||
/> | ||
``` | ||
|
||
Along with all the `InputText` features, there's the HTML form validation: | ||
|
||
```js | ||
<form onSubmit={e => e.preventDefault()}> | ||
<TextArea style={{ height: 100 }} required placeholder="This is required" /> | ||
<br /> | ||
<br /> | ||
<Button type="submit">Submit</Button> | ||
</form> | ||
``` |
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,13 @@ | ||
// @flow | ||
import * as React from 'react'; | ||
import styled from '@emotion/styled/macro'; | ||
import InputText, { Input, PADDING } from '../InputText'; | ||
|
||
const TextArea = styled(props => <InputText as="textarea" {...props} />)` | ||
${Input} { | ||
padding: ${props => PADDING[props.size || 'regular'] / 2.5}px | ||
${props => PADDING[props.size || 'regular']}px; | ||
} | ||
`; | ||
|
||
export default TextArea; |
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,16 @@ | ||
// @flow | ||
import * as React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import TextArea from '.'; | ||
|
||
it('renders a TextArea with all the supported sizes', () => { | ||
expect(mount(<TextArea />)).toHaveStyleRule('padding', '4px 10px'); | ||
expect(mount(<TextArea size="small" />)).toHaveStyleRule( | ||
'padding', | ||
'2px 5px' | ||
); | ||
expect(mount(<TextArea size="large" />)).toHaveStyleRule( | ||
'padding', | ||
'6px 15px' | ||
); | ||
}); |