From ed1cddb31e2d3896ecf031b3deca5fba64578e1a Mon Sep 17 00:00:00 2001 From: Ian Jones Date: Thu, 5 Sep 2024 16:41:14 +0100 Subject: [PATCH 1/2] feat: Full width map for list component --- .../@planx/components/List/Public/index.tsx | 64 +++++++------ .../Schema/InputFields/MapFieldInput.tsx | 90 ++++++++++--------- 2 files changed, 83 insertions(+), 71 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..c676c87b58 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 }) => ({ @@ -210,36 +214,38 @@ const Root = () => { policyRef={policyRef} howMeasured={howMeasured} /> - - <> - {formik.values.schemaData.map((_, i) => - i === activeIndex ? ( - - ) : ( - - ), - )} - {shouldShowAddAnotherButton && ( - - - - )} - - + + + )} + + + ); }; 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 */} + + + + + ); }; From 11de87bb284cff8d655bdbbce6c0932596369bc9 Mon Sep 17 00:00:00 2001 From: Ian Jones Date: Thu, 5 Sep 2024 16:54:44 +0100 Subject: [PATCH 2/2] full width only for list components with maps --- .../@planx/components/List/Public/index.tsx | 71 ++++++++++--------- 1 file changed, 39 insertions(+), 32 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 c676c87b58..87dced62e0 100644 --- a/editor.planx.uk/src/@planx/components/List/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/List/Public/index.tsx @@ -205,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 + )} ); };