Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
feat(Form): add a new all-in-one Form with single Input and Button
Browse files Browse the repository at this point in the history
A new component that provides a Form wrapped around a single
Form.InputGroup and appended Button
  • Loading branch information
jonthomp committed May 31, 2018
1 parent e024017 commit 564c7dd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/forms/FormWithSingleInputAndButton.react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// @flow

import * as React from "react";
import Form from "../components/Form/Form.react";
import Button from "../components/Button/Button.react";
import type { Props as FormProps } from "../components/Form/Form.react";
import type { Props as FormInputProps } from "../components/Form/FormInput.react";
import type { Props as ButtonProps } from "../components/Button/Button.react";

type Props = {|
formProps?: FormProps,
inputProps?: FormInputProps,
buttonProps?: ButtonProps,
|};

/**
* A form containing a single input field with an appended Button
*/
function FormWithSingleInputAndButton({
formProps,
inputProps,
buttonProps,
}: Props): React.Node {
const button = React.createElement(Button, buttonProps);
return (
<Form {...formProps}>
<Form.InputGroup inputProps={inputProps} append={button} />
</Form>
);
}

export default FormWithSingleInputAndButton;

0 comments on commit 564c7dd

Please sign in to comment.