From 550760cf0e831e07ab62c1c18425e6b54a6681de Mon Sep 17 00:00:00 2001 From: Ian Jones <51156018+ianjon3s@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:06:20 +0100 Subject: [PATCH] feat: Full width map for list component (#3632) --- .../@planx/components/List/Public/index.tsx | 73 ++++++++------- .../Schema/InputFields/MapFieldInput.tsx | 90 ++++++++++--------- 2 files changed, 91 insertions(+), 72 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/List/Public/index.tsx b/editor.planx.uk/src/@planx/components/List/Public/index.tsx index 03a801c7c2..87dced62e0 100644 --- a/editor.planx.uk/src/@planx/components/List/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/List/Public/index.tsx @@ -15,6 +15,7 @@ import { PublicProps } from "@planx/components/ui"; import { useStore } from "pages/FlowEditor/lib/store"; import React, { useEffect, useRef } from "react"; import { FONT_WEIGHT_SEMI_BOLD } from "theme"; +import FullWidthWrapper from "ui/public/FullWidthWrapper"; import ErrorWrapper from "ui/shared/ErrorWrapper"; import Card from "../../shared/Preview/Card"; @@ -33,6 +34,9 @@ const ListCard = styled(Box)(({ theme }) => ({ flexDirection: "column", gap: theme.spacing(2), marginBottom: theme.spacing(2), + "& label, & table": { + maxWidth: theme.breakpoints.values.formWrap, + }, })); const CardButton = styled(Button)(({ theme }) => ({ @@ -201,6 +205,40 @@ const Root = () => { ); } + const listContent = ( + + <> + {formik.values.schemaData.map((_, i) => + i === activeIndex ? ( + + ) : ( + + ), + )} + {shouldShowAddAnotherButton && ( + + + + )} + + + ); + return ( { policyRef={policyRef} howMeasured={howMeasured} /> - - <> - {formik.values.schemaData.map((_, i) => - i === activeIndex ? ( - - ) : ( - - ), - )} - {shouldShowAddAnotherButton && ( - - - - )} - - + {hasMapField ? ( + {listContent} + ) : ( + listContent + )} ); }; diff --git a/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/MapFieldInput.tsx b/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/MapFieldInput.tsx index 203a1f6ab0..765ef75489 100644 --- a/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/MapFieldInput.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/MapFieldInput.tsx @@ -1,3 +1,4 @@ +import Box from "@mui/material/Box"; import { MapContainer } from "@planx/components/shared/Preview/MapContainer"; import type { MapField } from "@planx/components/shared/Schema/model"; import { Feature } from "geojson"; @@ -47,47 +48,52 @@ export const MapFieldInput: React.FC> = (props) => { }, [setFeatures]); return ( - - {description && } - - - {/* @ts-ignore */} - - - - + label": { maxWidth: "100% !important" } }}> + + {description && } + + + {/* @ts-ignore */} + + + + + ); };