diff --git a/site/src/components/FormFooter/FormFooter.stories.tsx b/site/src/components/FormFooter/FormFooter.stories.tsx new file mode 100644 index 0000000000000..4590a263013d9 --- /dev/null +++ b/site/src/components/FormFooter/FormFooter.stories.tsx @@ -0,0 +1,29 @@ +import { ComponentMeta, Story } from "@storybook/react" +import React from "react" +import { FormFooter, FormFooterProps } from "./FormFooter" + +export default { + title: "components/FormFooter", + component: FormFooter, + argTypes: { + onCancel: { action: "cancel" }, + }, +} as ComponentMeta + +const Template: Story = (args) => + +export const Ready = Template.bind({}) +Ready.args = { + isLoading: false, +} + +export const Custom = Template.bind({}) +Custom.args = { + isLoading: false, + submitLabel: "Create", +} + +export const Loading = Template.bind({}) +Loading.args = { + isLoading: true, +} diff --git a/site/src/components/FormFooter/FormFooter.tsx b/site/src/components/FormFooter/FormFooter.tsx new file mode 100644 index 0000000000000..a7b5c48ba1717 --- /dev/null +++ b/site/src/components/FormFooter/FormFooter.tsx @@ -0,0 +1,46 @@ +import Button from "@material-ui/core/Button" +import { makeStyles } from "@material-ui/core/styles" +import React from "react" +import { LoadingButton } from "../LoadingButton/LoadingButton" + +const Language = { + cancelLabel: "Cancel", + defaultSubmitLabel: "Submit", +} + +export interface FormFooterProps { + onCancel: () => void + isLoading: boolean + submitLabel?: string +} + +const useStyles = makeStyles(() => ({ + footer: { + display: "flex", + flex: "0", + flexDirection: "row", + justifyContent: "center", + alignItems: "center", + }, + button: { + margin: "1em", + }, +})) + +export const FormFooter: React.FC = ({ + onCancel, + isLoading, + submitLabel = Language.defaultSubmitLabel, +}) => { + const styles = useStyles() + return ( +
+ + + {submitLabel} + +
+ ) +} diff --git a/site/src/components/FullPageForm/FullPageForm.stories.tsx b/site/src/components/FullPageForm/FullPageForm.stories.tsx new file mode 100644 index 0000000000000..3a92bc64cca1e --- /dev/null +++ b/site/src/components/FullPageForm/FullPageForm.stories.tsx @@ -0,0 +1,35 @@ +import TextField from "@material-ui/core/TextField" +import { action } from "@storybook/addon-actions" +import { ComponentMeta, Story } from "@storybook/react" +import React from "react" +import { FormFooter } from "../FormFooter/FormFooter" +import { Stack } from "../Stack/Stack" +import { FullPageForm, FullPageFormProps } from "./FullPageForm" + +export default { + title: "components/FullPageForm", + component: FullPageForm, +} as ComponentMeta + +const Template: Story = (args) => ( + +
{ + e.preventDefault() + }} + > + + + + + +
+
+) + +export const Example = Template.bind({}) +Example.args = { + title: "My Form", + detail: "Lorem ipsum dolor", + onCancel: action("cancel"), +} diff --git a/site/src/components/FullPageForm/FullPageForm.tsx b/site/src/components/FullPageForm/FullPageForm.tsx new file mode 100644 index 0000000000000..83f9c345da611 --- /dev/null +++ b/site/src/components/FullPageForm/FullPageForm.tsx @@ -0,0 +1,32 @@ +import { makeStyles } from "@material-ui/core/styles" +import React from "react" +import { FormCloseButton } from "../FormCloseButton/FormCloseButton" +import { FormTitle } from "../FormTitle/FormTitle" + +export interface FullPageFormProps { + title: string + detail?: React.ReactNode + onCancel: () => void +} + +const useStyles = makeStyles(() => ({ + root: { + maxWidth: "1380px", + width: "100%", + display: "flex", + flexDirection: "column", + alignItems: "center", + }, +})) + +export const FullPageForm: React.FC = ({ title, detail, onCancel, children }) => { + const styles = useStyles() + return ( +
+ + + + {children} +
+ ) +}