Skip to content

Commit 534037a

Browse files
committed
Add atoms SubmitButton
1 parent 5b1dcd5 commit 534037a

4 files changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { SubmitButton } from "./submit-button";
2+
import { text } from "@storybook/addon-knobs";
3+
import React from "react";
4+
5+
export default {
6+
component: SubmitButton,
7+
title: "Atoms | Forms / Submit Button",
8+
};
9+
10+
export const submitButtonKnobs = () => (
11+
<SubmitButton buttonText={text("Button Text", "Submit")} />
12+
);
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("SubmitButton", () => {
4+
test.skip("TODO - https://github.com/AndcultureCode/AndcultureCode.JavaScript.React.Components/issues/8", () => {});
5+
});

src/atoms/forms/submit-button.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from "react";
2+
3+
// -----------------------------------------------------------------------------------------
4+
// #region Interfaces
5+
// -----------------------------------------------------------------------------------------
6+
7+
export interface SubmitButtonProps {
8+
buttonText?: string;
9+
cssClassName?: string;
10+
11+
/**
12+
* Typically you do not need this, but using it can allow you to
13+
* place the button outside of the form for styling purposes.
14+
*/
15+
formId?: string;
16+
}
17+
18+
// #endregion Interfaces
19+
20+
// -----------------------------------------------------------------------------------------
21+
// #region Component
22+
// -----------------------------------------------------------------------------------------
23+
24+
const SubmitButton: React.FC<SubmitButtonProps> = (
25+
props: SubmitButtonProps
26+
) => {
27+
return (
28+
<input
29+
className={props.cssClassName || "c-button"}
30+
form={props.formId}
31+
type="submit"
32+
value={props.buttonText || "Submit"}
33+
/>
34+
);
35+
};
36+
37+
// #endregion Component
38+
39+
// -----------------------------------------------------------------------------------------
40+
// #region Export
41+
// -----------------------------------------------------------------------------------------
42+
43+
export { SubmitButton };
44+
45+
// #endregion Export

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export { Button } from "./atoms/buttons/button";
1010
export { CheckboxButton } from "./atoms/forms/checkbox-button";
1111
export { CheckboxInput } from "./atoms/forms/checkbox-input";
1212
export { PasswordInput } from "./atoms/forms/password-input";
13+
export { SubmitButton } from "./atoms/forms/submit-button";
1314

1415
// Icons
1516
export { Icon } from "./atoms/icons/icon";

0 commit comments

Comments
 (0)