-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(TextArea): New TextArea Component
New bootstrap form-control TextArea component - leverages Paragon asInput Note* based on: https://github.com/edx/paragon/tree/master/src/InputText Ticket: EDUCATOR-1824
- Loading branch information
Farhanah Sheets
authored
Dec 4, 2017
1 parent
25fe397
commit 4bd0082
Showing
4 changed files
with
169 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
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,8 @@ | ||
# TextArea | ||
|
||
Provides an input component called TextArea that gives users a reusable textarea field. | ||
|
||
## API | ||
|
||
### `inputProps` (view asInput component for details) | ||
`inputProps` specifies all of the properties that are necessary from the included `asInput` component. Please see details for input requirements within that component. |
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,48 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
|
||
import TextArea from './index'; | ||
|
||
storiesOf('Textarea', module) | ||
.add('minimal usage', () => ( | ||
<TextArea | ||
name="name" | ||
label="First Name" | ||
value="Foo Bar" | ||
/> | ||
)) | ||
.add('scrollable', () => ( | ||
<TextArea | ||
name="name" | ||
label="Information" | ||
value="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor | ||
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud | ||
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure | ||
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | ||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt | ||
mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, | ||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | ||
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute | ||
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | ||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt | ||
mollit anim id est laborum." | ||
/> | ||
)) | ||
.add('validation', () => ( | ||
<TextArea | ||
name="username" | ||
label="Username" | ||
description="The unique name that identifies you throughout the site." | ||
validator={(value) => { | ||
let feedback = { isValid: true }; | ||
if (value.length < 3) { | ||
feedback = { | ||
isValid: false, | ||
validationMessage: 'Username must be at least 3 characters in length.', | ||
}; | ||
} | ||
return feedback; | ||
}} | ||
/> | ||
)); |
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,29 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import asInput, { inputProps } from '../asInput'; | ||
|
||
function Text(props) { | ||
return ( | ||
<textarea | ||
id={props.id} | ||
className={classNames(props.className)} | ||
type="text" | ||
name={props.name} | ||
value={props.value} | ||
placeholder={props.placeholder} | ||
aria-describedby={props.describedBy} | ||
onChange={props.onChange} | ||
onBlur={props.onBlur} | ||
aria-invalid={!props.isValid} | ||
disabled={props.disabled} | ||
required={props.required} | ||
/> | ||
); | ||
} | ||
|
||
Text.propTypes = inputProps; | ||
|
||
const TextArea = asInput(Text); | ||
|
||
export default TextArea; |