diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/ButtonForm.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/ButtonForm.tsx index 763d5b815b..e4f4adc681 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/ButtonForm.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/ButtonForm.tsx @@ -11,7 +11,8 @@ import InputDescription from "ui/editor/InputDescription"; import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; -import { DesignPreview, FormProps, SettingsForm } from "."; +import { DesignPreview, FormProps } from "."; +import { SettingsForm } from "../shared/SettingsForm"; export const ButtonForm: React.FC = ({ formikConfig, @@ -33,7 +34,7 @@ export const ButtonForm: React.FC = ({ }); return ( - formik={formik} legend="Button colour" description={ diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/FaviconForm.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/FaviconForm.tsx index a037686bc3..3a7fa0f608 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/FaviconForm.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/FaviconForm.tsx @@ -10,7 +10,8 @@ import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; import InputRowLabel from "ui/shared/InputRowLabel"; -import { FormProps, SettingsForm } from "."; +import { FormProps } from "."; +import { SettingsForm } from "../shared/SettingsForm"; export const FaviconForm: React.FC = ({ formikConfig, @@ -36,7 +37,7 @@ export const FaviconForm: React.FC = ({ : formik.setFieldValue("favicon", null); return ( - formik={formik} legend="Favicon" description={ diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/TextLinkForm.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/TextLinkForm.tsx index a9891cff38..98c0fea0e6 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/TextLinkForm.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/TextLinkForm.tsx @@ -9,7 +9,8 @@ import InputDescription from "ui/editor/InputDescription"; import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; -import { DesignPreview, FormProps, SettingsForm } from "."; +import { DesignPreview, FormProps } from "."; +import { SettingsForm } from "../shared/SettingsForm"; export const TextLinkForm: React.FC = ({ formikConfig, @@ -43,7 +44,7 @@ export const TextLinkForm: React.FC = ({ }); return ( - formik={formik} legend="Text link colour" description={ diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/ThemeAndLogoForm.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/ThemeAndLogoForm.tsx index b87fe60999..afc872074f 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/ThemeAndLogoForm.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/ThemeAndLogoForm.tsx @@ -12,7 +12,8 @@ import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; import InputRowLabel from "ui/shared/InputRowLabel"; -import { DesignPreview, FormProps, SettingsForm } from "."; +import { DesignPreview, FormProps } from "."; +import { SettingsForm } from "../shared/SettingsForm"; export const ThemeAndLogoForm: React.FC = ({ formikConfig, @@ -54,7 +55,7 @@ export const ThemeAndLogoForm: React.FC = ({ : formik.setFieldValue("logo", null); return ( - formik={formik} legend="Theme colour & logo" description={ diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/index.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/index.tsx index 8c3bd88565..b791d4f2d3 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/index.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/DesignSettings/index.tsx @@ -1,17 +1,13 @@ import Alert from "@mui/material/Alert"; import Box from "@mui/material/Box"; -import Button from "@mui/material/Button"; import Snackbar from "@mui/material/Snackbar"; import { styled } from "@mui/material/styles"; import Typography from "@mui/material/Typography"; import { TeamTheme } from "@opensystemslab/planx-core/types"; -import { FormikConfig, FormikProps } from "formik"; +import { FormikConfig } from "formik"; import { useStore } from "pages/FlowEditor/lib/store"; import React, { useEffect, useState } from "react"; import EditorRow from "ui/editor/EditorRow"; -import InputGroup from "ui/editor/InputGroup"; -import InputLegend from "ui/editor/InputLegend"; -import ErrorWrapper from "ui/shared/ErrorWrapper"; import { ButtonForm } from "./ButtonForm"; import { FaviconForm } from "./FaviconForm"; @@ -28,67 +24,11 @@ export const DesignPreview = styled(Box)(({ theme }) => ({ export const EXAMPLE_COLOUR = "#007078"; -type SettingsFormProps = { - legend: string; - description: React.ReactElement; - input: React.ReactElement; - formik: FormikProps; - preview?: React.ReactElement; -}; - export interface FormProps { formikConfig: FormikConfig; onSuccess: () => void; } -export const SettingsForm: React.FC = ({ - formik, - legend, - description, - input, - preview, -}) => { - return ( - -
- - {legend} - {description} - {input} - - {preview && ( - - - Preview: - - {preview} - - )} - - - - - - -
-
- ); -}; - const DesignSettings: React.FC = () => { const [formikConfig, setFormikConfig] = useState< FormikConfig | undefined diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Settings/shared/SettingsForm.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Settings/shared/SettingsForm.tsx new file mode 100644 index 0000000000..99e001d097 --- /dev/null +++ b/editor.planx.uk/src/pages/FlowEditor/components/Settings/shared/SettingsForm.tsx @@ -0,0 +1,65 @@ +import Box from "@mui/material/Box"; +import Button from "@mui/material/Button"; +import Typography from "@mui/material/Typography"; +import { FormikProps } from "formik"; +import React from "react"; +import EditorRow from "ui/editor/EditorRow"; +import InputGroup from "ui/editor/InputGroup"; +import InputLegend from "ui/editor/InputLegend"; +import ErrorWrapper from "ui/shared/ErrorWrapper"; + +type SettingsFormProps = { + legend: string; + description: React.ReactElement; + input: React.ReactElement; + formik: FormikProps; + preview?: React.ReactElement; +}; + +export const SettingsForm = ({ + formik, + legend, + description, + input, + preview, +}: SettingsFormProps) => { + return ( + +
+ + {legend} + {description} + {input} + + {preview && ( + + + Preview: + + {preview} + + )} + + + + + + +
+
+ ); +}; \ No newline at end of file