Skip to content

Commit 4bd0082

Browse files
author
Farhanah Sheets
authored
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
1 parent 25fe397 commit 4bd0082

File tree

4 files changed

+169
-0
lines changed

4 files changed

+169
-0
lines changed

.storybook/__snapshots__/Storyshots.test.js.snap

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,3 +1961,87 @@ exports[`Storyshots Tabs basic usage 1`] = `
19611961
</div>
19621962
</div>
19631963
`;
1964+
1965+
exports[`Storyshots Textarea minimal usage 1`] = `
1966+
<div
1967+
className="form-group"
1968+
>
1969+
<label
1970+
htmlFor="asInput20"
1971+
>
1972+
First Name
1973+
</label>
1974+
<textarea
1975+
aria-describedby={undefined}
1976+
aria-invalid={false}
1977+
className="form-control"
1978+
disabled={false}
1979+
id="asInput20"
1980+
name="name"
1981+
onBlur={[Function]}
1982+
onChange={[Function]}
1983+
placeholder={undefined}
1984+
required={false}
1985+
type="text"
1986+
value="Foo Bar"
1987+
/>
1988+
</div>
1989+
`;
1990+
1991+
exports[`Storyshots Textarea scrollable 1`] = `
1992+
<div
1993+
className="form-group"
1994+
>
1995+
<label
1996+
htmlFor="asInput21"
1997+
>
1998+
Information
1999+
</label>
2000+
<textarea
2001+
aria-describedby={undefined}
2002+
aria-invalid={false}
2003+
className="form-control"
2004+
disabled={false}
2005+
id="asInput21"
2006+
name="name"
2007+
onBlur={[Function]}
2008+
onChange={[Function]}
2009+
placeholder={undefined}
2010+
required={false}
2011+
type="text"
2012+
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."
2013+
/>
2014+
</div>
2015+
`;
2016+
2017+
exports[`Storyshots Textarea validation 1`] = `
2018+
<div
2019+
className="form-group"
2020+
>
2021+
<label
2022+
htmlFor="asInput22"
2023+
>
2024+
Username
2025+
</label>
2026+
<textarea
2027+
aria-describedby="undefined description-asInput22"
2028+
aria-invalid={false}
2029+
className="form-control"
2030+
disabled={false}
2031+
id="asInput22"
2032+
name="username"
2033+
onBlur={[Function]}
2034+
onChange={[Function]}
2035+
placeholder={undefined}
2036+
required={false}
2037+
type="text"
2038+
value=""
2039+
/>
2040+
<small
2041+
className="form-text"
2042+
id="description-asInput22"
2043+
>
2044+
The unique name that identifies you throughout the site.
2045+
</small>
2046+
</div>
2047+
`;

src/TextArea/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# TextArea
2+
3+
Provides an input component called TextArea that gives users a reusable textarea field.
4+
5+
## API
6+
7+
### `inputProps` (view asInput component for details)
8+
`inputProps` specifies all of the properties that are necessary from the included `asInput` component. Please see details for input requirements within that component.

src/TextArea/TextArea.stories.jsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
import React from 'react';
3+
import { storiesOf } from '@storybook/react';
4+
5+
import TextArea from './index';
6+
7+
storiesOf('Textarea', module)
8+
.add('minimal usage', () => (
9+
<TextArea
10+
name="name"
11+
label="First Name"
12+
value="Foo Bar"
13+
/>
14+
))
15+
.add('scrollable', () => (
16+
<TextArea
17+
name="name"
18+
label="Information"
19+
value="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
20+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
21+
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
22+
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
23+
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
24+
mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit,
25+
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
26+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
27+
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
28+
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
29+
mollit anim id est laborum."
30+
/>
31+
))
32+
.add('validation', () => (
33+
<TextArea
34+
name="username"
35+
label="Username"
36+
description="The unique name that identifies you throughout the site."
37+
validator={(value) => {
38+
let feedback = { isValid: true };
39+
if (value.length < 3) {
40+
feedback = {
41+
isValid: false,
42+
validationMessage: 'Username must be at least 3 characters in length.',
43+
};
44+
}
45+
return feedback;
46+
}}
47+
/>
48+
));

src/TextArea/index.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
import classNames from 'classnames';
3+
4+
import asInput, { inputProps } from '../asInput';
5+
6+
function Text(props) {
7+
return (
8+
<textarea
9+
id={props.id}
10+
className={classNames(props.className)}
11+
type="text"
12+
name={props.name}
13+
value={props.value}
14+
placeholder={props.placeholder}
15+
aria-describedby={props.describedBy}
16+
onChange={props.onChange}
17+
onBlur={props.onBlur}
18+
aria-invalid={!props.isValid}
19+
disabled={props.disabled}
20+
required={props.required}
21+
/>
22+
);
23+
}
24+
25+
Text.propTypes = inputProps;
26+
27+
const TextArea = asInput(Text);
28+
29+
export default TextArea;

0 commit comments

Comments
 (0)