From 0a42334f771ef1ab742a452856f8ba40c3d91633 Mon Sep 17 00:00:00 2001 From: Jake Howell Date: Mon, 3 Aug 2026 19:08:30 +1000 Subject: [PATCH] refactor(site): demui `Form.stories.tsx` stories (#27762) Replace MUI `TextField` in the Form Storybook stories with `FormField`, wired through Formik and `getFormHelpers` so the examples match how real forms use the layout components. --- site/src/components/Form/Form.stories.tsx | 42 ++++++++++++----- .../FullPageForm/FullPageForm.stories.tsx | 47 +++++++++++-------- 2 files changed, 59 insertions(+), 30 deletions(-) diff --git a/site/src/components/Form/Form.stories.tsx b/site/src/components/Form/Form.stories.tsx index 7ba89fa440..527cfefc65 100644 --- a/site/src/components/Form/Form.stories.tsx +++ b/site/src/components/Form/Form.stories.tsx @@ -1,27 +1,47 @@ -import TextField from "@mui/material/TextField"; import type { Meta, StoryObj } from "@storybook/react-vite"; +import { useFormik } from "formik"; +import type { FC } from "react"; +import { FormField } from "#/components/FormField/FormField"; +import { getFormHelpers } from "#/utils/formUtils"; import { Form, FormFields, FormSection } from "./Form"; -const meta: Meta = { - title: "components/Form", - component: Form, - args: { - children: ( +const ExampleForm: FC<{ direction?: "horizontal" | "vertical" }> = ({ + direction, +}) => { + const form = useFormik({ + initialValues: { + workspaceName: "", + owner: "", + }, + onSubmit: () => {}, + }); + const getFieldHelpers = getFormHelpers(form); + + return ( +
- - + + - ), - }, +
+ ); +}; + +const meta: Meta = { + title: "components/Form", + component: ExampleForm, }; export default meta; -type Story = StoryObj; +type Story = StoryObj; export const Vertical: Story = { args: { diff --git a/site/src/components/FullPageForm/FullPageForm.stories.tsx b/site/src/components/FullPageForm/FullPageForm.stories.tsx index ac270a45ba..6815ab4880 100644 --- a/site/src/components/FullPageForm/FullPageForm.stories.tsx +++ b/site/src/components/FullPageForm/FullPageForm.stories.tsx @@ -1,28 +1,37 @@ -import TextField from "@mui/material/TextField"; import type { Meta, StoryObj } from "@storybook/react-vite"; +import { useFormik } from "formik"; import type { FC } from "react"; import { Button } from "#/components/Button/Button"; import { FormFooter } from "#/components/Form/Form"; +import { FormField } from "#/components/FormField/FormField"; +import { getFormHelpers } from "#/utils/formUtils"; import { FullPageForm, type FullPageFormProps } from "./FullPageForm"; -const Template: FC = (props) => ( - -
{ - e.preventDefault(); - }} - > -
- - - - - - -
-
-
-); +const Template: FC = (props) => { + const form = useFormik({ + initialValues: { + field1: "", + field2: "", + }, + onSubmit: () => {}, + }); + const getFieldHelpers = getFormHelpers(form); + + return ( + +
+
+ + + + + + +
+
+
+ ); +}; const meta: Meta = { title: "components/FullPageForm",