Skip to content

Commit c68fff2

Browse files
committed
Added atoms TextArea
1 parent d567b7b commit c68fff2

4 files changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from "react";
2+
import { text, boolean, number } from "@storybook/addon-knobs";
3+
import { TextArea } from "./text-area";
4+
import Faker from "faker";
5+
6+
export default {
7+
component: TextArea,
8+
title: "Atoms | Forms / Text Area",
9+
};
10+
11+
export const textAreaKnobs = () => (
12+
<TextArea
13+
disabled={boolean("Disabled", false)}
14+
id={Faker.random.uuid()}
15+
maxLength={number("Max Length", 30)}
16+
onChange={() => {}}
17+
placeholder={text("Placeholder", "Placeholder...")}
18+
rows={number("Rows", 5)}
19+
value={text("Value", "Input Value")}
20+
/>
21+
);

src/atoms/forms/text-area.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from "react";
2+
3+
describe("TextArea", () => {
4+
test.skip("TODO - https://github.com/AndcultureCode/AndcultureCode.JavaScript.React.Components/issues/10", () => {});
5+
});

src/atoms/forms/text-area.tsx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import React from "react";
2+
3+
// -----------------------------------------------------------------------------------------
4+
// #region Interfaces
5+
// -----------------------------------------------------------------------------------------
6+
7+
export interface TextAreaProps {
8+
disabled?: boolean;
9+
id: string;
10+
maxLength?: number;
11+
name?: string;
12+
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
13+
placeholder?: string;
14+
rows?: number;
15+
16+
/**
17+
* Unique identifier used select the underlying <textarea> for functional/e2e testing
18+
*/
19+
testId?: string;
20+
value?: string;
21+
}
22+
23+
// #endregion Interfaces
24+
25+
// -----------------------------------------------------------------------------------------
26+
// #region Component
27+
// -----------------------------------------------------------------------------------------
28+
29+
const TextArea: React.FC<TextAreaProps> = (props: TextAreaProps) => {
30+
const {
31+
disabled,
32+
id,
33+
maxLength,
34+
name,
35+
onChange,
36+
placeholder,
37+
rows,
38+
testId,
39+
value,
40+
} = props;
41+
42+
return (
43+
<textarea
44+
data-test-id={testId}
45+
disabled={disabled}
46+
id={id}
47+
maxLength={maxLength}
48+
name={name}
49+
onChange={onChange}
50+
placeholder={placeholder}
51+
rows={rows}
52+
value={value}
53+
/>
54+
);
55+
};
56+
57+
// #endregion Component
58+
59+
// -----------------------------------------------------------------------------------------
60+
// #region Exports
61+
// -----------------------------------------------------------------------------------------
62+
63+
export { TextArea };
64+
65+
// #endregion Exports

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export { CheckboxButton } from "./atoms/forms/checkbox-button";
1111
export { CheckboxInput } from "./atoms/forms/checkbox-input";
1212
export { PasswordInput } from "./atoms/forms/password-input";
1313
export { SubmitButton } from "./atoms/forms/submit-button";
14+
export { TextArea } from "./atoms/forms/text-area";
1415
export { TextInput } from "./atoms/forms/text-input";
1516
export { TextInputIcon } from "./atoms/forms/text-input-icon";
1617

0 commit comments

Comments
 (0)